/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE LAYER — cargado AL FINAL de la cascada (gana por orden a igual
   especificidad). Concentra la bottom tab bar y los overrides mobile-only.
   Breakpoints canónicos: 600px (móvil) · 380px (mini). Desktop no se toca.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── A. INPUTS ≥16px (anti-zoom automático de iOS) ─────────────────────────────
   Regla única de elemento: las clases (.form-input .92rem, .ctrl-input, .club-input,
   .friends-search-input, .news-input, selects de filtros…) ganan por especificidad
   sin importar el orden, así que el !important es necesario y queda acotado al media. */
@media (max-width: 600px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]),
  select, textarea { font-size: 16px !important; }
}

/* ── A. TOUCH TARGETS ≥44px en punteros gruesos ───────────────────────────────── */
@media (pointer: coarse) {
  .btn-add, .btn-sub { min-height: 44px; width: 44px; }
  .btn-ach { width: 44px; min-height: 44px; }
  .log-revert-btn { padding: 9px 12px; }
  .friend-btn { min-height: 40px; padding: 8px 14px; }
  .club-act-del { width: 44px; height: 44px; }
  .modal-close { width: 38px; height: 38px; }
  .club-modal-close { padding: 10px 14px; }
  .notif-item-del { width: 32px; height: 32px; }
  .user-chip-logout { width: 32px; height: 32px; }
}

/* ── A. AFFORDANCES hover-only → visibles en táctil ───────────────────────────── */
@media (hover: none) {
  /* Flechas del carousel de destacados (shop.css las oculta hasta :hover) */
  .shop-feat-nav { opacity: .85; }
  /* Lápiz de editar avatar: chip de esquina en vez de overlay que solo aparece con hover */
  .profile-avatar-wrap.is-editable .avatar-edit-hint {
    opacity: 1; inset: auto -2px -2px auto; width: 26px; height: 26px;
    border-radius: 50%; font-size: .8rem;
    background: var(--surface-3); border: 1px solid var(--border-hi);
  }
  /* El hover bg de filas de tabla no aporta en táctil y tapa las sombras de scroll */
  .log-table tr:hover td { background: none; }
}

/* ── B. BOTTOM TAB BAR (móvil <600px) ─────────────────────────────────────────── */
.bottom-nav { display: none; }

@media (max-width: 600px) {
  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 180; /* bajo modales (200+) */
    padding: 6px max(6px, env(safe-area-inset-right))
             calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface-1) 90%, transparent);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid var(--border);
  }
  .bnav-item {
    flex: 1; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 2px; min-height: 52px;
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: .6rem; font-weight: 700; letter-spacing: .02em;
    font-family: 'Inter', system-ui, sans-serif;
  }
  .bnav-item:active { transform: scale(.94); transition: transform .08s; }
  .bnav-ico {
    display: grid; place-items: center; width: 44px; height: 26px; border-radius: 999px;
    transition: background .2s, box-shadow .25s var(--ease-out), color .2s;
  }
  .bnav-ico svg { width: 19px; height: 19px; }
  .bnav-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bnav-item.active { color: var(--text-1); }
  .bnav-item.active .bnav-ico {
    background: var(--grad-red); color: #fff;
    box-shadow: 0 4px 14px var(--red-glow), inset 0 1px 0 rgba(255,255,255,.18);
  }
  .bnav-dot {
    position: absolute; top: 4px; right: calc(50% - 16px);
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--red); box-shadow: 0 0 6px var(--red-glow);
  }
  .bnav-dot[hidden] { display: none; }

  /* La nav superior se reemplaza por la bottom bar. !important: 07-boot.js
     setea appNav.style.display = "flex" inline al bootear. */
  .app-nav { display: none !important; }

  /* Aire inferior para que la barra fija no tape el final del contenido. */
  main, .teacher-view-inner, .profile-view-inner, .yearbook-inner, .hof-inner {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }

  /* El footer quedaría tapado por la bottom bar: fuera en móvil. */
  footer { display: none; }

  /* Red de seguridad: ningún desborde puntual debe generar scroll horizontal
     de página (descoloca la bottom bar fija respecto al contenido). */
  body { overflow-x: clip; }

  /* Header del perfil: botones compactos y título que puede partir línea,
     para que "Compartir" no empuje el layout fuera de la pantalla. */
  .profile-view-header { flex-wrap: wrap; }
  .profile-back-btn, .profile-share-btn { padding: 8px 12px; min-height: 40px; }
  .profile-view-title { white-space: normal; min-width: 0; }

  /* Panel docente — fila de estudiante: los puntos (input + subir/bajar) son lo
     esencial y quedan en su propia línea; el resto de acciones vive en el sheet
     que abre el botón ⋯ (openStudentActions). */
  .student-row-extra { display: none; }
  .student-more-btn { display: flex; }
  .student-row-controls { flex-basis: 100%; justify-content: flex-end; }
  /* Sin scroll interno: la página scrollea y el padding inferior del view
     garantiza que el último estudiante libre la bottom bar. */
  .student-list { max-height: none; overflow-y: visible; }
}

/* Fondo de perfil equipado en modo columna (<440px): la máscara horizontal de
   escritorio dejaba la imagen justo detrás del texto centrado. Pasa a "foto de
   portada": visible arriba (tras el avatar) y desvanecida antes del texto. */
@media (max-width: 440px) {
  .profile-identity-bg {
    background-position: center top;
    -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.45) 42%, transparent 75%);
            mask-image: linear-gradient(180deg, rgba(0,0,0,.9), rgba(0,0,0,.45) 42%, transparent 75%);
  }
}

/* ── B. SHEETS (filas grandes dentro del modal-box canónico) ──────────────────── */
.more-sheet .modal-body { padding: 18px 16px 28px; display: flex; flex-direction: column; gap: 8px; }
.sheet-title { font-size: .95rem; font-weight: 800; color: var(--text-1); padding: 2px 4px 6px; }
.sheet-item-ico { display: inline-flex; width: 20px; justify-content: center; flex-shrink: 0; }
.more-sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px;
  padding: 12px 16px; text-align: left; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-1); font-size: .95rem; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.more-sheet-item:active { background: var(--surface-3); }
.more-sheet-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-2); }
.more-sheet-item .nav-badge { margin-left: auto; }

/* ── C. NOTIF PANEL como sheet full-width bajo la campana ─────────────────────── */
@media (max-width: 600px) {
  /* !important: 12-notifications.js setea right inline al posicionarlo bajo el bell. */
  .notif-panel { left: 10px !important; right: 10px !important; width: auto; }
  .notif-list { max-height: min(60dvh, 440px); }
}

/* ── D. CHROME NO-STICKY EN MÓVIL ──────────────────────────────────────────────
   La bottom bar ya da navegación persistente; liberar el chrome apilado
   (topbar + banners + header + nav) recupera hasta ~250px de viewport. */
@media (max-width: 600px) {
  .sticky-chrome { position: static; }
  .sim-banner { padding-top: 6px; padding-bottom: 6px; }
  .poll-banner { padding-top: 10px; padding-bottom: 10px; }
}
