/* ============================================================
   THE CODEX — Mobile Styles (≤640px)
   Separado de styles.css para aislamiento total entre plataformas.
   Cargado con media="(max-width:640px)" en index.html.
   ARCANA C.A.D.E. © 2026 Sergio Emilio Arias
   ============================================================ */

@media (max-width: 640px) {

  /* ══════════════════════════════════════════════════════════
     HUD MOBILE — comprimido para dar espacio al hamburger
  ══════════════════════════════════════════════════════════ */
  .hud {
    padding: 10px 16px;
    flex-wrap: nowrap;
    gap: 10px;
  }
  .hud-sep   { display: none; }
  .hud-date  { display: none; }
  .hud-lvl   { min-width: 0; flex: 1; }
  .hud-streak { gap: 5px; }
  .streak-lbl { display: none; }

  /* Hamburger visible */
  .hud-menu-btn { display: flex; }

  /* ══════════════════════════════════════════════════════════
     SIDE DRAWER — left-panel convertido en drawer lateral
  ══════════════════════════════════════════════════════════ */
  .left-panel {
    position: fixed;
    top: 0; left: 0;
    width: min(88vw, 320px);
    height: 100vh; height: 100dvh;
    z-index: 4000;
    /* Oculto por defecto — desliza desde la izquierda */
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    /* Fondo sólido para el drawer */
    background: rgba(6,6,18,0.98);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-right: 1px solid var(--border);
    /* Scroll interno del drawer */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,232,255,0.18) transparent;
    /* Reset de límites del grid */
    max-height: none;
    padding: 0 0 60px;
    /* Posición tomada fuera del flujo del grid */
    position: fixed;
  }
  .left-panel.drawer-open {
    transform: translateX(0);
    box-shadow: 24px 0 80px rgba(0,0,0,0.85);
  }

  /* Overlay visible */
  .drawer-overlay { display: block; }

  /* ── Drawer header ──────────────────────────────────────── */
  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    background: rgba(6,6,18,0.98);
    backdrop-filter: blur(24px);
    z-index: 1;
    margin-bottom: 4px;
  }
  .drawer-logo {
    font-family: var(--fh);
    font-size: 14px; font-weight: 900;
    color: var(--cyan);
    letter-spacing: 4px;
    text-shadow: 0 0 18px var(--cyan-glow);
  }
  .drawer-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--t2); font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
  }
  .drawer-close:hover { border-color: var(--cyan); color: var(--cyan); }

  /* ── Drawer inventory button ────────────────────────────── */
  .drawer-inv-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 32px);
    margin: 14px 16px 6px;
    padding: 13px 16px;
    background: linear-gradient(135deg,
      rgba(0,232,255,0.08),
      rgba(123,97,255,0.06));
    border: 1px solid var(--border-h);
    border-radius: var(--r);
    color: var(--cyan);
    font-family: var(--fh);
    font-size: 11px; font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.25s;
    text-align: left;
  }
  .drawer-inv-btn:hover,
  .drawer-inv-btn:active {
    background: linear-gradient(135deg,
      rgba(0,232,255,0.14),
      rgba(123,97,255,0.10));
    border-color: var(--cyan);
    box-shadow: 0 0 18px rgba(0,232,255,0.18);
    transform: translateY(-1px);
  }
  .drawer-inv-icon { font-size: 18px; }
  .drawer-inv-arrow {
    margin-left: auto;
    font-size: 18px;
    color: var(--t3);
    font-family: var(--fb);
    font-weight: 300;
  }

  /* ── Secciones internas del drawer ─────────────────────── */
  /* Panel-label y secciones tienen padding en mobile */
  .left-panel > div {
    padding: 14px 20px 0;
  }

  /* RIGHT PANEL: oculto en mobile (task-form es el FAB + bottom sheet) */
  .right-panel { display: none !important; }

  /* Week board ocupa toda la pantalla disponible */
  .week-board { min-height: calc(100dvh - 56px); }

  /* ── Week board: scroll horizontal con snap por día ─────── */
  .days-grid {
    grid-template-columns: repeat(7, 84vw);
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-height: none;
    scrollbar-width: none;
  }
  .days-grid::-webkit-scrollbar { display: none; }

  .day-col {
    scroll-snap-align: start;
    min-height: calc(100vh - 260px);
    border-right: 1px solid var(--border);
  }

  /* ── Day header mobile ───────────────────────────────────── */
  .day-head {
    padding: 14px 12px 10px;
    position: relative; /* sin sticky en mobile — no necesaria */
    text-align: left;
  }
  .day-n       { display: none; }
  .day-initial { display: block; }
  .day-d       { font-size: 28px; }
  .day-month   { font-size: 9px; letter-spacing: 1px; }
  .day-count {
    font-size: 12px; font-family: var(--fm);
    color: var(--t2); margin-top: 8px;
    letter-spacing: 0.5px;
  }
  .day-count[data-n="0"]              { color: var(--t3); }
  .day-count[data-n]:not([data-n="0"]) { color: var(--cyan); font-weight: 700; }

  /* ── Right panel: overflow visible — fix crítico iOS ─────── */
  .right-panel { padding: 12px 16px; gap: 14px; overflow: visible; }
  .shortcuts   { display: none; }

  /* ── Form — bottom sheet fijo ────────────────────────────── */
  #task-form {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(10,10,22,0.98);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    padding: 12px 20px 44px;
    z-index: 3000;
    transform: translateY(calc(100% + 4px));
    transition: transform 0.4s var(--ease);
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 -20px 60px rgba(0,0,0,0.75);
    scrollbar-width: none;
  }
  #task-form::-webkit-scrollbar { display: none; }
  #task-form.open { transform: translateY(0); }

  /* ── Activar elementos sólo-mobile ──────────────────────── */
  .form-close-btn { display: flex !important; }
  .form-fab       { display: flex !important; }
  .form-overlay   { display: block !important; }
  .form-overlay.show { opacity: 1; pointer-events: all; }

} /* END @media max-width: 640px */
