/* ═══════════════════════════════════════════════
   DESKTOP LAYOUT — Sidebar + Multi-Column Grid
   Only active at min-width: 1024px.
   Below 1024px everything is unchanged (mobile).
   ═══════════════════════════════════════════════ */

/* ── Sidebar Brand & Bottom — hidden on mobile ── */
.sidebar-brand,
.sidebar-bottom { display: none; }

/* ── Sub-menu & chevron — hidden on mobile ── */
.sidebar-sub { display: none; }
.sidebar-chevron { display: none; }

/* ── Nav FABs — hidden on mobile ── */
.nav-fabs { display: none; }

@media (min-width: 1024px) {

  /* ── 1. Tab Bar → Left Sidebar ── */
  .tab-bar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: 220px;
    flex-direction: column;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--bdr);
    padding: 0;
    gap: 0;
    z-index: 50;
  }

  /* Sidebar brand header */
  .sidebar-brand {
    display: block;
    padding: 24px 20px 20px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    color: var(--wh);
    letter-spacing: -0.03em;
  }

  /* Tab items become horizontal rows */
  .tab-bar-item {
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  .tab-bar-item:hover {
    background: rgba(142,142,147,0.08);
  }
  .tab-bar-item:hover svg {
    filter: none;
  }
  .tab-bar-item.active:hover svg {
    filter: none;
  }
  .tab-bar-item.active {
    color: var(--acc);
    background: rgba(10,132,255,0.08);
    border-left-color: var(--acc);
  }
  .tab-bar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Badge repositioned for horizontal layout */
  .tab-badge {
    position: static;
    margin-left: -4px;
  }

  /* Sidebar bottom section (settings) */
  .sidebar-bottom {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    border-top: 1px solid var(--bdr);
    padding: 8px 0;
  }

  /* Settings toggle chevron rotation */
  #settings-toggle .sidebar-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
  }
  #settings-toggle.expanded .sidebar-chevron {
    transform: rotate(180deg);
  }

  /* Expandable sub-menu */
  .sidebar-sub {
    display: none;
    flex-direction: column;
    overflow: hidden;
  }
  .sidebar-sub.open {
    display: flex;
  }
  .sidebar-sub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 36px;
    font-size: 13px;
    font-weight: 500;
    color: var(--dim);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: left;
    font-family: inherit;
  }
  .sidebar-sub-item:hover {
    background: rgba(142,142,147,0.08);
    color: var(--wh);
  }
  .sidebar-sub-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  /* ── 2. Content Area — Push Right ── */
  .view {
    margin-left: 220px;
    padding-bottom: 24px;
  }

  /* Login view should NOT be pushed right */
  #view-login {
    margin-left: 0;
  }

  /* ── 3. Dashboard — Single Column Centered ── */
  #home-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 32px 40px;
    display: block;
  }

  /* ── 4. Study View — Wider Grids ── */
  #view-study {
    padding-left: 16px;
    padding-right: 16px;
  }
  #study-hub-grid {
    max-width: 900px;
    margin: 0 auto;
  }
  .sh-grid-3 {
    grid-template-columns: repeat(4, 1fr);
  }
  .sh-grid-2 {
    grid-template-columns: repeat(3, 1fr);
  }
  #study-content {
    max-width: 800px;
    margin: 0 auto;
  }

  /* ── 4b. Exam Cards — Horizontal on Desktop ── */
  .exam-columns {
    grid-template-columns: 1fr;
    max-width: 1000px;
    margin: 0 auto;
  }
  .exam-practice-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  /* ── 5. Insights View — Centered ── */
  #insights-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 32px;
  }

  /* ── 5b. Community View — Centered ── */
  #community-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 32px;
  }

  /* ── 6. Settings — Nav Docks into Sidebar Column ── */
  #view-settings {
    margin-left: 0;
  }
  .stg-layout {
    height: 100vh;
  }
  .stg-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    z-index: 51;
    border-right: 1px solid var(--bdr);
    background: var(--bg);
  }
  .stg-detail {
    margin-left: 220px;
    max-width: 800px;
  }

  /* ── 7. Hub / Launcher — Wider ── */
  .hub-container,
  .launcher-container {
    max-width: 800px;
  }

  /* ── 8. Zoom Panel — Repositioned ── */
  .zoom-panel {
    left: 232px;
  }

  /* ── 9. Quiz Arrows — Account for Sidebar ── */
  .quiz-nav-arrows {
    left: 220px;
    padding: 0 16px;
  }

  /* ── 10. Nav FABs — Bottom Left ── */
  .nav-fabs {
    display: flex;
    gap: 8px;
    position: fixed;
    bottom: 28px;
    left: 248px;
    z-index: 60;
  }
  .nav-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--sf);
    border: 1px solid var(--bdr);
    color: var(--tx);
    cursor: pointer;
    box-shadow: var(--elev-2);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }
  .nav-fab svg {
    color: var(--tx);
  }
  .nav-fab:hover {
    transform: scale(1.08);
    box-shadow: var(--elev-3);
    background: var(--cd2);
  }
  .nav-fab:active {
    transform: scale(0.95);
  }

  /* ═══════════════════════════════════════════════
     11. QUIZ FOCUS MODE — Desktop Simulation
     Activated by .quiz-focus on <body> when a
     practice quiz is started on desktop (1024px+).
     ═══════════════════════════════════════════════ */

  /* ── Hide study chrome smoothly ── */
  body.quiz-focus #study-tab-header,
  body.quiz-focus #study-mode-pills,
  body.quiz-focus #study-hub-grid,
  body.quiz-focus #quiz-stats,
  body.quiz-focus #quiz-filters {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* ── Hide main sidebar in focus mode ── */
  body.quiz-focus .tab-bar {
    transform: translateX(-100%);
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* ── Push content to left edge when sidebar hidden ── */
  body.quiz-focus #view-study {
    margin-left: 0;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* ── Quiz content fade-in (initial entry) ── */
  body.quiz-focus #quiz-main {
    animation: qf-fadein 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  @keyframes qf-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Content swap transition (switching filters in sidebar) ── */
  body.quiz-focus #quiz-main.qf-switching {
    opacity: 0;
    transform: translateY(6px);
  }

  /* ── Center quiz content wider in focus mode ── */
  body.quiz-focus #study-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 32px;
  }

  /* ── Hide nav FABs in focus mode (sidebar handles nav) ── */
  body.quiz-focus .nav-fabs {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  /* ── Quiz Sidebar Overlay ── */
  #quiz-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 55;
    background: var(--bg);
    border-right: 1px solid var(--bdr);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
  }

  #quiz-sidebar.collapsed {
    transform: translateX(-100%);
  }

  /* ── Sidebar section labels ── */
  .qsb-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    padding: 16px 20px 6px;
  }

  /* ── Sidebar items ── */
  .qsb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tx);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  .qsb-item:hover {
    background: rgba(142,142,147,0.08);
  }
  .qsb-item.active {
    color: var(--acc);
    background: rgba(10,132,255,0.08);
    border-left-color: var(--acc);
  }
  .qsb-item-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--dim);
    font-weight: 400;
  }

  /* ── Back button inside sidebar ── */
  .qsb-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dim);
    cursor: pointer;
    transition: color 0.15s ease;
    border-bottom: 1px solid var(--bdr);
    margin-bottom: 4px;
  }
  .qsb-back:hover {
    color: var(--wh);
  }

  /* ── Hover trigger strip ── */
  .quiz-sidebar-trigger {
    display: none;
  }
  body.quiz-focus .quiz-sidebar-trigger {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 24px;
    z-index: 54;
    cursor: pointer;
  }
  body.quiz-focus .quiz-sidebar-trigger::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 6px;
    transform: translateY(-50%);
    width: 4px;
    height: 40px;
    border-radius: 2px;
    background: var(--dim);
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  body.quiz-focus .quiz-sidebar-trigger:hover::after {
    opacity: 0.5;
  }

  /* ── Move quiz nav arrows in focus mode ── */
  body.quiz-focus .quiz-nav-arrows {
    left: 0;
  }

  /* ── Smooth default transition for sidebar ── */
  .tab-bar {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #view-study {
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
}
