/**
 * CCW Prep — responsive.css  (v2 — full rewrite)
 * Desktop (> 1024px): NO changes. Everything below only fires on mobile/tablet.
 */

/* ═══════════════════════════════════════════════════
   MOBILE HEADER — hidden by default, shown ≤ 1024px
════════════════════════════════════════════════════ */
#mobileHeader { display: none; }

/* ═══════════════════════════════════════════════════
   TABLET + MOBILE  (≤ 1024px)
════════════════════════════════════════════════════ */
@media (max-width: 1024px) {

  /* ── Show mobile header ── */
  #mobileHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 52px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    flex-shrink: 0;
  }
  #mobileMenuBtn {
    background: none;
    border: none;
    color: var(--t1);
    font-size: 1.3rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
  }
  #mobileMenuBtn:hover, #themeToggleBtnMobile:hover { background: var(--glass); }
  #mobileHeaderLogo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  #mobileHeaderLogo img { height: 24px; width: auto; }
  #mobileHeaderRight { width: 36px; }

  /* ── Sidebar: fully off-screen by default ── */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    /* Keep sidebar scrollable so Profile/Settings always reachable */
    overflow-y: auto;
    padding-top: 1.5rem;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 6px 0 32px rgba(0,0,0,0.6); }

  /* ── Overlay backdrop ── */
  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 350;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
  #sidebarOverlay.open { display: block; }

  /* ── App layout: column, push below header ── */
  #app {
    flex-direction: column !important;
    padding-top: 52px; /* height of mobile header */
  }

  /* ── Main content: no sidebar margin ── */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    min-height: calc(100vh - 52px);
    padding: 1.25rem 1rem;
    overflow-x: hidden;
  }

  /* ── Dashboard stats: 2×2 grid ── */
  .dash-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Subjects: 3 columns ── */
  .dash-subjects { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ═══════════════════════════════════════════════════
   LARGE MOBILE  (≤ 768px)
════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Dashboard header: stack title and buttons ── */
  .dash-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
  }
  .dash-header > div:last-child {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }
  .dash-header > div:last-child .btn {
    flex: 1;
    font-size: 0.82rem;
    padding: 0.6rem 0.75rem;
    justify-content: center;
  }
  .dash-greeting { font-size: 1.4rem !important; }

  /* ── Stats padding ── */
  .stat-card { padding: 0.875rem 1rem; }
  .stat-value { font-size: 1.6rem !important; }
  .streak-num { font-size: 2rem !important; }

  /* ── Subjects: 2 columns on mobile ── */
  .dash-subjects { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Quick Practice + Recent Tests: stack ── */
  #dashboard > div[style*="grid-template-columns:1fr 1fr"],
  #dashboard > div[style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.25rem;
  }

  /* ── Accuracy chart + countdown: stack ── */
  #dashboard > div[style*="grid-template-columns:2fr 1fr"],
  #dashboard > div[style*="grid-template-columns: 2fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem;
  }

  /* ── Quick actions: 1 column ── */
  .quick-actions { grid-template-columns: 1fr !important; }

  /* ── Cards ── */
  .card-p  { padding: 1rem; }
  .card-p2 { padding: 1.25rem; }

  /* ── Mock / PYQ cards: wrap action buttons ── */
  .card-p2 > div[style*="display:flex;gap:.75rem"],
  .card-p2 > div[style*="display:flex;gap: .75rem"] {
    flex-wrap: wrap;
  }
  .card-p2 button { flex: 1; min-width: 130px; }

  /* ── Practice modes: 1 column ── */
  #practiceModesGrid { grid-template-columns: 1fr !important; }

  /* ── Subject practice grid: 2 columns ── */
  #subjectPracticeGrid { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Flashcard subject buttons ── */
  #flashcards > div > div[style*="grid-template-columns:repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  /* ── Profile view ── */
  #profile-view > div[style*="grid-template-columns:1fr 1fr"],
  #profile-view > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #profile-view h2 { font-size: 1.35rem !important; }

  /* ── Settings ── */
  #settings > h1 { font-size: 1.35rem !important; }

  /* ── Bookmarks / PYQ / Mock headings ── */
  h1[style*="font-size:1.75rem"] { font-size: 1.35rem !important; }

  /* ── Toast ── */
  .toast-container { left: 0.75rem; right: 0.75rem; bottom: 0.75rem; }
  .toast { max-width: 100%; }

  /* ── Modal ── */
  .modal { padding: 1.5rem 1rem; margin: 0.75rem; }

  /* ── OMR Sheet ── */
  .omr-sheet { padding: 0.875rem; font-size: 0.85rem; }
  .omr-bubbles { gap: 0.45rem; }
  .omr-bubble { width: 22px; height: 22px; font-size: 0.62rem; }
  #omr-view > div[style*="display:flex"] { flex-direction: column; gap: 0.75rem; }
  #omr-view button { width: 100%; }

  /* ═══ EXAM PAGE ═══ */
  /* Stack left panel above right panel */
  #examWrap {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh;
  }
  body:has(#examWrap) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  /* Left panel: compact strip — move to BOTTOM on mobile */
  #leftPanel {
    width: 100% !important;
    max-width: 100% !important;
    border-right: none !important;
    border-top: 1px solid var(--border);
    border-bottom: none !important;
    flex-shrink: 0;
    overflow: visible;
    order: 2; /* show AFTER the question */
  }

  /* Right panel (question): show FIRST on mobile */
  #rightPanel {
    order: 1;
    flex: 1;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
  }

  /* Timer: inline row */
  .timer-section {
    padding: 0.625rem 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .timer-section .timer-label { margin-bottom: 0 !important; }
  #timerDisplay { font-size: 1.6rem !important; }

  /* Question palette: more columns, fully visible */
  .palette-section { padding: 0.75rem 1rem !important; overflow: visible !important; }
  #qPalette {
    grid-template-columns: repeat(10, 1fr) !important;
    gap: 0.3rem !important;
  }
  .qb { height: 30px !important; font-size: 0.7rem !important; border-radius: 5px !important; }

  /* Legend row: tighter */
  .legend { padding: 0.625rem 1rem !important; }
  .legend-row { gap: 0.75rem !important; }
  .legend-item { font-size: 0.65rem !important; }

  /* Submit button */
  .submit-section { padding: 0.625rem 1rem !important; }

  #questionBody {
    padding: 1.25rem 1rem !important;
    overflow: visible !important;
    flex: 1;
  }
  .q-text { font-size: 0.975rem !important; }

  /* Bottom bar */
  #bottomBar {
    padding: 0.75rem 1rem !important;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .nav-btns { gap: 0.5rem !important; }
  .action-btns { gap: 0.5rem !important; flex-wrap: wrap; }
  #bottomBar .btn, #bottomBar #markBtn, #bottomBar #bookmarkBtn {
    padding: 0.55rem 0.875rem !important;
    font-size: 0.82rem !important;
  }

  /* Top bar in exam */
  .q-topbar { padding: 0.625rem 1rem !important; }

  /* ═══ RESULTS PAGE ═══ */
  .results-wrap { padding: 1rem 0.875rem !important; }
  .score-hero   { padding: 2rem 1rem !important; }
  .score-big    { font-size: 3.5rem !important; }
  .score-denom  { font-size: 1.75rem !important; }
  .stats-row    { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem; }
  .analysis-grid { grid-template-columns: 1fr !important; }

  /* Results top bar */
  .results-wrap > div:first-child {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .results-wrap > div:first-child .btn { flex: 1; min-width: 100px; font-size: 0.8rem; }

  /* Strong/Weak areas */
  .results-wrap > div[style*="grid-template-columns:1fr 1fr"],
  .results-wrap > div[style*="display:grid"] {
    grid-template-columns: 1fr !important;
  }

  /* Action row */
  .action-row { flex-direction: column; gap: 0.625rem; }
  .action-row .btn { width: 100% !important; justify-content: center; }

  /* Bug FAB — keep above bottom bar on exam page */
  #bugReportFab {
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
    bottom: 4.5rem !important;
    right: 0.75rem !important;
  }
}

/* ═══════════════════════════════════════════════════
   SMALL MOBILE  (≤ 480px)
════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  .main-content { padding: 1rem 0.75rem; }

  /* Stats: 2×2 still, smaller */
  .dash-grid { gap: 0.625rem !important; }
  .stat-card { padding: 0.75rem 0.875rem; }
  .stat-value { font-size: 1.4rem !important; }
  .stat-label { font-size: 0.68rem; }
  .streak-num { font-size: 1.75rem !important; }
  .streak-fire { font-size: 1.5rem; }

  /* Greeting */
  .dash-greeting { font-size: 1.25rem !important; }
  .dash-subtitle { font-size: 0.82rem; }

  /* Subjects: 2 col, smaller padding */
  .dash-subjects { gap: 0.625rem !important; }
  .subject-prog-card { padding: 0.875rem 0.75rem !important; }
  .spcard-icon { font-size: 1.2rem !important; }
  .spcard-name { font-size: 0.75rem !important; }
  .spcard-count { font-size: 0.65rem !important; }

  /* Buttons */
  .btn { font-size: 0.875rem; padding: 0.6rem 1rem; }
  .btn-sm { font-size: 0.78rem; padding: 0.45rem 0.8rem; }

  /* Cards */
  .card-p  { padding: 0.875rem; }
  .card-p2 { padding: 1rem; }

  /* Splash */
  .splash-logo { font-size: 2.25rem; }
  .splash-sub  { font-size: 0.75rem; letter-spacing: 0.08em; }
  .splash-loader { width: 160px; }

  /* Landing */
  #landing > div {
    padding: 2rem 1rem !important;
  }
  #landing h1 { font-size: 1.8rem !important; }

  /* Exam page palette: tighter */
  #qPalette {
    grid-template-columns: repeat(8, 1fr) !important;
    gap: 0.25rem !important;
  }
  .qb { height: 28px !important; font-size: 0.65rem !important; }

  /* Bottom bar: full stack */
  #bottomBar { flex-direction: column; align-items: stretch; }
  .nav-btns { justify-content: space-between; width: 100%; }
  .action-btns { justify-content: flex-end; width: 100%; }

  /* Modal */
  .modal { padding: 1.25rem 0.875rem; border-radius: var(--r); }

  /* Countdown */
  .countdown-unit-num { font-size: 1rem; }
  .countdown-units { gap: 0.5rem; }

  /* Flashcard buttons: 2 col */
  #flashcards > div > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  /* Bug FAB — push higher on small screens where bottom bar can wrap */
  #bugReportFab {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.9rem !important;
    bottom: 5.5rem !important;
    right: 0.5rem !important;
  }

  /* Results */
  .score-big   { font-size: 2.75rem !important; }
  .score-denom { font-size: 1.5rem !important; }
  .review-item { padding: 0.875rem 0.75rem; }
  .review-item-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
