/* ============================================================
   Course Student — Shared responsive layer (mobile + tablet)
   Loaded LAST on every page. Desktop ≥1101px is untouched.
   Works with assets/js/mobile-nav.js (.mnav-* elements).
   ============================================================ */

/* ===== Generic hygiene (all widths) ===== */
[id] { scroll-margin-top: 84px; }
a, button { touch-action: manipulation; }
.table-wrap { -webkit-overflow-scrolling: touch; }

/* ===== Hamburger button (injected by mobile-nav.js) ===== */
.mnav-burger {
  display: none;
  width: 44px; height: 44px; flex-shrink: 0;
  align-items: center; justify-content: center;
  border-radius: 12px; font-size: 17px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; transition: border-color .2s;
}
.mnav-burger:hover { border-color: var(--gold); }

/* ===== Backdrop + scroll lock ===== */
html.mnav-lock { overflow: hidden; }
.mnav-backdrop {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(13, 3, 5, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
}
body.mnav-open .mnav-backdrop,
body.mnav-sidebar-open .mnav-backdrop { opacity: 1; visibility: visible; }

/* ===== Slide-in drawer (public navbar pages) ===== */
.mnav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 140;
  width: min(320px, 86vw); height: 100dvh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(105%); visibility: hidden;
  transition: transform .3s ease, visibility .3s;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
body.mnav-open .mnav-drawer {
  transform: none; visibility: visible;
  box-shadow: -24px 0 60px rgba(0, 0, 0, .45);
}

.mnav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.mnav-head strong { font-size: 16px; font-weight: 800; color: var(--text); }
.mnav-close {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); display: grid; place-items: center; font-size: 15px;
}
.mnav-close:hover { color: var(--text); border-color: var(--gold); }

.mnav-links { display: flex; flex-direction: column; gap: 4px; }
.mnav-links > a, .mnav-acc-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 46px; padding: 10px 12px; border-radius: 12px;
  background: transparent; border: 0; text-align: right;
  color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .2s, color .2s;
}
.mnav-links > a:hover, .mnav-acc-btn:hover { background: var(--card); }
.mnav-links > a.active { color: var(--gold-light); background: var(--card); }
.mnav-acc-btn i { font-size: 11px; color: var(--muted); transition: transform .25s; }
.mnav-acc.is-open .mnav-acc-btn i { transform: rotate(180deg); }
.mnav-acc-panel { max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.mnav-acc-panel a {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 9px 22px 9px 12px; border-radius: 10px;
  color: var(--muted); font-size: 14px; transition: color .2s, background .2s;
}
.mnav-acc-panel a:hover { color: var(--text); background: var(--card); }
.mnav-acc-panel .pill-ic { width: 22px; height: 22px; display: inline-flex; align-items: center; }

.mnav-tools {
  margin-top: auto; display: flex; flex-direction: column; gap: 12px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.mnav-lang { display: flex; gap: 8px; }
.mnav-lang button {
  flex: 1; min-height: 44px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer;
}
.mnav-lang button.is-active { color: var(--gold-light); border-color: var(--gold); }
.mnav-theme {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
}
.mnav-theme:hover { border-color: var(--gold); }
.mnav-login { width: 100%; justify-content: center; min-height: 48px; }

/* ===== Tablet ≤1100: show burger; off-canvas app sidebar ===== */
@media (max-width: 1100px) {
  .mnav-burger { display: inline-flex; }

  /* Dashboards (dashboard/teacher/admin): sidebar becomes a drawer */
  .app > .sidebar {
    display: flex; position: fixed; top: 0; right: 0; bottom: 0; z-index: 140;
    width: min(300px, 85vw); height: 100dvh;
    background: var(--surface); border-left: 1px solid var(--line);
    transform: translateX(105%); visibility: hidden;
    transition: transform .3s ease, visibility .3s;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  body.mnav-sidebar-open .app > .sidebar {
    transform: none; visibility: visible;
    box-shadow: -24px 0 60px rgba(0, 0, 0, .5);
  }

  /* Footer: 4 cols → 2 (was 1 before) */
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 40px; }

  /* Hero stacks here: copy (academy name + headline + CTAs) leads,
     testimonial stack follows — overrides the page's order:-1 */
  :root .hero-grid .hero-logo-visual { order: 1; }
}

/* Hero headline scales on tablet only (768 rules keep their own clamp) */
@media (min-width: 769px) and (max-width: 1100px) {
  .hero h1 { font-size: clamp(30px, 4.6vw, 52px); }
}

/* ===== Mobile ≤768 ===== */
@media (max-width: 768px) {
  /* Public navbar: tools + login live inside the drawer.
     `:root` prefix matches the specificity of the light-theme
     `:root[data-theme="light"] .nav-tools{display:flex}` rule. */
  :root .nav .nav-tools,
  :root .nav .nav-inner > .btn { display: none; }

  /* iOS: prevent input zoom */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="search"], input[type="tel"], select, textarea { font-size: 16px; }

  /* Modals never overflow the viewport (welcome + auth share .welcome-dialog) */
  .welcome-dialog { max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .crm-modal-dialog { max-height: 90dvh; margin-top: 5vh; }

  /* Curriculum browser: grade tabs become a swipe row */
  .crm-grades {
    flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 2px 2px 10px; scrollbar-width: thin;
  }

  /* Dashboards: topbar wraps instead of squeezing the search */
  .app .topbar { flex-wrap: wrap; gap: 10px; }
  .app .topbar .search { flex: 1 1 200px; min-width: 0; }
  .pkg-grid { grid-template-columns: 1fr; }

  /* Library top nav: drop the breadcrumb + user text, keep actions */
  .topnav .breadcrumb { display: none; }
  .topnav .user strong, .topnav .user small { display: none; }
  .topnav-inner { gap: 14px; }

  /* Bottom nav (student dashboard only — body[data-bottom-nav]) */
  body[data-bottom-nav] .mnav-bottombar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
    display: flex; justify-content: space-around; gap: 2px;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  body[data-bottom-nav] .mnav-bottombar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; min-width: 56px; min-height: 48px; padding: 4px 6px;
    border-radius: 10px; color: var(--muted); font-size: 10.5px; font-weight: 600;
  }
  body[data-bottom-nav] .mnav-bottombar a span {
    max-width: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body[data-bottom-nav] .mnav-bottombar a i { font-size: 16px; }
  body[data-bottom-nav] .mnav-bottombar a.active { color: var(--gold-light); }
  body[data-bottom-nav] .main { padding-bottom: 96px; }
}
.mnav-bottombar { display: none; }
@media (max-width: 768px) {
  body[data-bottom-nav] .mnav-bottombar { display: flex; }
}

/* ===== Small mobile ≤480 ===== */
@media (max-width: 480px) {
  /* Hero CTAs: full-width, stacked */
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; justify-content: center; }

  /* Footer: one column + tighter padding on mobile */
  footer { padding: 44px 0 28px; margin-top: 40px; }
  .foot-grid { grid-template-columns: 1fr; gap: 28px; margin-bottom: 32px; }

  /* Dashboards: stat/KPI cards stack; user chip shrinks to its avatar */
  .app .stats, .app .kpis { grid-template-columns: 1fr; }
  .app .topbar .user-info { display: none; }

  /* Dashboard package card: 2-col → 1-col so content isn't crushed */
  .pkg-grid { grid-template-columns: 1fr; gap: 18px; }

  /* Library: one book per row; brand text gives room to actions */
  .books-grid { grid-template-columns: 1fr; }
  .topnav .brand-word { display: none; }

  /* Live session player: tighter chrome (brand text only lives in its topbar) */
  .app > .topbar { gap: 10px; }
  .app > .topbar .brand-word { display: none; }

  /* Chat FAB clears the bottom bar */
  body[data-bottom-nav] .chat-fab { bottom: calc(78px + env(safe-area-inset-bottom)); }

  /* Curriculum browser on homepage: 2-col → 1-col, tighter chips */
  .crm-grid { grid-template-columns: 1fr; gap: 12px; }
  .crm-stage { padding: 10px 14px; font-size: 13px; gap: 8px; }
  .crm-card { padding: 14px; gap: 10px; }
  .crm-card-ic { width: 38px; height: 38px; }
  .crm-card-ic i { font-size: 17px; }
  .crm-card h3 { font-size: 14px; }
  .crm-card p { font-size: 12px; }

  /* Study-path title: 30px → 26px so it doesn't hit the edges */
  .study-path .section-head h2 { font-size: 26px; }

  /* Trusted FB stat: its whole text lives in the .stat-num span — size that */
  .trusted-stat .stat-num { font-size: 20px; }

  /* Video card badges: smaller on tiny cards */
  .tv-views { font-size: 16px; padding: 6px 11px; }
  .tv-featured .tv-views { font-size: 18px; padding: 6px 12px; }

  /* Video card meta: more compact, title slightly smaller */
  .tv-meta { padding: 12px 14px; }
  .tv-meta h3 { font-size: 14px; }
  .tv-cta { font-size: 12px; }

  /* Main hero stats: 30px → 26px so they don't feel oversized in 1-col layout */
  .stats-inner .stat-num { font-size: 26px; }
  .stats-inner .stat-icon { width: 44px; height: 44px; }

  /* Study-path chips: larger touch target, smaller text */
  .sp-chip { padding: 7px 12px; font-size: 13px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .mnav-drawer, .app > .sidebar, .mnav-backdrop, .mnav-acc-panel, .mnav-acc-btn i {
    transition: none;
  }
}

