/* responsive.css — Vital responsive layer
   Layers ON TOP of styles.css. Mobile is the default (no media queries).

   Breakpoints:
     0–767      mobile    | bottom tab bar, single column
     768–1023   tablet    | icon rail sidebar (88px)
     1024–1439  laptop    | full sidebar (240px) + 2-col content where useful
     ≥1440      desktop   | extra breathing room + wider grids
*/

/* ─────────────────────────────────────────────────────────────────────────
   Mobile base — keep existing behavior; default-hide the sidebar.
   ───────────────────────────────────────────────────────────────────────── */
.sidenav { display: none; }
.app-main { display: contents; }                /* flatten on mobile */
.topbar   { display: none; }
.detail-cols > * { contents: unset; }           /* fallback */

/* On mobile, body/stage occupy full viewport (already true), but ensure
   horizontal scrolling never happens. */
body { overflow-x: hidden; }

/* ─────────────────────────────────────────────────────────────────────────
   ≥ 768 — tablet and up: icon-rail sidebar, hide bottom tab bar.
   ───────────────────────────────────────────────────────────────────────── */
@media (min-width: 768px) {

  /* The host stage no longer needs to be a fixed-viewport iOS-style frame.
     Switch to a flex-row dashboard shell. */
  html, body { height: 100%; }
  .stage    { width: 100vw; height: 100vh; overflow: hidden; }

  .app {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
  }

  /* Reveal sidebar */
  .sidenav {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 88px;
    height: 100%;
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    padding: 22px 12px 18px;
    gap: 6px;
    align-items: stretch;
    position: relative;
    z-index: 20;
  }

  /* Hide the mobile bottom tab bar */
  .tab-bar { display: none !important; }

  /* The content column flows below sidebar */
  .app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    position: relative;
  }

  /* Inner scroll fills the column; centered max-width below */
  .scroll {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Page-level desktop topbar (slim, optional) */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 28px;
    flex-shrink: 0;
    border-bottom: 0.5px solid var(--border);
    background: color-mix(in oklch, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    gap: 12px;
  }

  /* Per-screen headers used to start at 56px top padding to clear the
     phone status bar — that's no longer needed on desktop. */
  .top { padding-top: 22px; }

  /* Sheets become centered modals */
  .sheet-backdrop {
    position: fixed;
    z-index: 200;
  }
  .sheet {
    position: fixed;
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: 560px;
    max-width: calc(100vw - 64px);
    max-height: 80vh;
    border-radius: 22px;
    box-shadow: 0 28px 64px -16px rgba(20, 20, 14, 0.30), 0 12px 28px -10px rgba(20, 20, 14, 0.18);
    animation: vital-pop .22s cubic-bezier(.18, .7, .2, 1) both;
    z-index: 201;
  }
  .sheet-handle { display: none; }

  @keyframes vital-pop {
    from { transform: translate(-50%, -50%) scale(0.96); }
    to   { transform: translate(-50%, -50%) scale(1); }
  }

  /* Course detail CTA bar stays at the bottom of its app column */
  .cta-bar         { bottom: 0; }
  .cta-bar.detail  { bottom: 0; }

  /* Auth shell — center the form rather than stretch */
  .auth-shell {
    align-items: stretch;
    padding: 0;
  }
  .auth-top, .auth-foot {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
  .auth-body {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    padding-top: 48px;
  }

  /* Discover responsive grid — replaces the inline 2-col grid */
  .discover-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   ≥ 1024 — laptop: full sidebar, content max-width, 2-col detail.
   ───────────────────────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .sidenav {
    width: 240px;
    padding: 26px 16px 20px;
  }
  .sidenav .sn-rail-label { display: inline; }
  .sidenav .sn-item        { justify-content: flex-start; padding: 10px 12px; }
  .sidenav .sn-item span.sn-label { display: inline; }

  /* Center page contents in a max-width column. .scroll-x rows escape the
     padding via negative margins, which we restore here for new metrics. */
  .scroll > .top,
  .scroll > .desktop-container,
  .scroll > section,
  .scroll > div:not(.scroll-x) {
    /* This is too broad — instead use a specific wrapper class. */
  }
  .scroll {
    padding-left: max(28px, calc((100% - 1100px) / 2));
    padding-right: max(28px, calc((100% - 1100px) / 2));
  }
  .scroll > .scroll-x {
    /* The horizontal scrolling pill row's negative margins of -20px no
       longer reach the edge, but that's fine — it just scrolls within
       the centered column. */
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Header padding tightens — no top "status bar" area needed */
  .top { padding-top: 28px; padding-left: 0; padding-right: 0; }

  /* The CTA bar should align with the centered content too */
  .cta-bar {
    padding-left: max(28px, calc((100vw - 240px - 1100px) / 2));
    padding-right: max(28px, calc((100vw - 240px - 1100px) / 2));
  }

  /* Course detail — full-bleed hero stays, the rest splits 2 cols */
  .detail-hero-full { margin-left: -28px; margin-right: -28px; }

  .detail-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
  }
  .detail-cols .detail-facts { margin: 0; }

  /* Discover grid widens to 3 cols */
  .discover-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
  }

  /* Wallet hero gets a touch more breathing room */
  .wallet { padding: 28px; }

  /* Auth body wider on laptop */
  .auth-shell {
    background:
      radial-gradient(900px 600px at 12% 8%, var(--primary-soft-2), transparent 60%),
      radial-gradient(700px 500px at 92% 92%, var(--accent-soft), transparent 70%),
      var(--bg);
  }
  .auth-body {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: 22px;
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    margin-top: 24px;
  }

  /* Profile cards: 2-col list of preference sections */
  .profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   ≥ 1280 — wider laptop: Discover grid pushes to 4 cols.
   ───────────────────────────────────────────────────────────────────────── */
@media (min-width: 1280px) {
  .discover-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─────────────────────────────────────────────────────────────────────────
   ≥ 1440 — desktop: a touch more max-width.
   ───────────────────────────────────────────────────────────────────────── */
@media (min-width: 1440px) {
  .scroll {
    padding-left: max(40px, calc((100% - 1240px) / 2));
    padding-right: max(40px, calc((100% - 1240px) / 2));
  }
  .cta-bar {
    padding-left: max(40px, calc((100vw - 240px - 1240px) / 2));
    padding-right: max(40px, calc((100vw - 240px - 1240px) / 2));
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   SideNav structure (used at ≥768)
   ───────────────────────────────────────────────────────────────────────── */
.sn-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 0 18px;
  margin-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
}
@media (min-width: 1024px) {
  .sn-brand {
    justify-content: flex-start;
    padding: 4px 8px 18px;
  }
}
.sn-brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sn-brand-text { display: none; min-width: 0; }
@media (min-width: 1024px) {
  .sn-brand-text { display: block; }
}
.sn-brand-name {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--fg);
  display: none;       /* shown via .sn-rail-label@1024 */
}
.sn-brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 3px;
  display: none;
}
@media (min-width: 1024px) {
  .sn-brand-name, .sn-brand-sub { display: block; }
}

.sn-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
}
.sn-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font: 500 13.5px var(--font-sans);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  position: relative;
}
.sn-item:hover { background: var(--surface-2); color: var(--fg); }
.sn-item.on    {
  background: var(--primary-soft);
  color: var(--primary);
}
.sn-item.on::before { display: none; }
.sn-item .sn-label { display: none; flex: 1; }
.sn-item.on .sn-label { color: var(--primary); font-weight: 500; }

/* Notification dot — visible on tablet/rail when the count would be hidden */
.sn-dot {
  position: absolute;
  top: 8px;
  right: 22px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}
@media (min-width: 1024px) {
  .sn-dot { display: none; }                /* count badge takes over */
}
.sn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  min-width: 18px;
  padding: 0 6px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font: 500 10px var(--font-mono);
  letter-spacing: 0.04em;
}

.sn-log-btn {
  appearance: none;
  border: 0;
  background: var(--fg);
  color: var(--bg);
  font: 500 13.5px var(--font-sans);
  border-radius: 999px;
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity 120ms, transform 120ms;
  margin: 10px auto 0;
}
.sn-log-btn:hover { opacity: 0.92; }
.sn-log-btn:active { transform: scale(0.99); }
.sn-log-btn .sn-label { display: none; }
@media (min-width: 1024px) {
  .sn-log-btn {
    width: auto;
    height: auto;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 10px 0 0;
    justify-content: center;
  }
  .sn-log-btn .sn-label { display: inline; }
}

.sn-footer {
  border-top: 0.5px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sn-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  min-width: 0;
}
.sn-user .avatar {
  width: 32px; height: 32px; font-size: 11px;
  flex-shrink: 0;
}
.sn-user-meta { display: none; min-width: 0; }
@media (min-width: 1024px) {
  .sn-user-meta { display: block; }
}
.sn-user-name {
  font-size: 13px; font-weight: 500; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sn-user-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Detail screen — full-bleed hero on tablet/desktop */
@media (min-width: 768px) {
  .detail-hero {
    /* on the centered .scroll, full-bleed within its column is fine */
    padding-left: 0; padding-right: 0;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   Detail shell — replaces inner .app wrapper inside CourseDetailScreen
   ───────────────────────────────────────────────────────────────────────── */
.detail-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

/* Detail two-column at ≥1024 */
.detail-cols { display: block; }
.detail-side { padding: 18px 20px 0; }

@media (min-width: 1024px) {
  .detail-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 28px;
    align-items: start;
    padding: 0 0 32px;
  }
  .detail-cols .detail-body { padding-top: 4px; }
  .detail-cols .detail-side { padding: 0; position: sticky; top: 18px; }
  .detail-cols .detail-facts { margin: 0; }
}

/* Sticky CTA bar adjustments: on desktop it sits naturally at the bottom
   of the detail-shell column, no longer absolute-anchored. */
@media (min-width: 768px) {
  .detail-shell .cta-bar,
  .detail-shell .cta-bar.detail {
    position: static;
    flex-shrink: 0;
    margin-top: 0;
  }
}
