/* ==========================================================================
   MAANG.io — /curriculum hub ("console" layout)
   Two panes: a persistent track rail and the selected track's levels.

   Progressive enhancement: the server renders EVERY track pane and the rail
   links are real in-page anchors, so with JavaScript off the page is one long
   readable document. curriculum-hub.js adds `.hub-js` to <html> and turns the
   same markup into a tabbed console.

   Depends on tokens.css + editorial.css. All colour comes from tokens so the
   dark theme works with no overrides here.
   ========================================================================== */

/* ---- page width ---------------------------------------------------------
   Match the per-level curriculum pages, which widen the shared container and
   use a 320px rail (see CurriculumRenderer's .page-curriculum block). Without
   this the hub sits at the 1120px marketing width while the level page you land
   on is 1720px, so the layout jumps on every click through.

   Scoped to .page-curriculum-hub on <body> rather than overriding .ed-container
   bare: same reasoning as the level pages — keep the widening opt-in to this
   page so nothing else inherits a 1720px container. */
.page-curriculum-hub .ed-container { width: min(100% - 48px, 1720px); }

.hub-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 1200px) {
  .hub-shell { grid-template-columns: 300px minmax(0, 1fr); }
}

/* ---- breadcrumbs -------------------------------------------------------- */
.hub-crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-faint); margin-bottom: 18px; }
.hub-crumbs a { color: var(--text-faint); }
.hub-crumbs a:hover { color: var(--brand); }
.hub-crumbs i { font-size: .6rem; opacity: .7; }
.hub-crumbs [aria-current] { color: var(--text-muted); font-weight: 600; }

/* ---- rail --------------------------------------------------------------- */
.hub-rail {
  position: sticky; top: 70px; max-height: calc(100vh - 70px); overflow-y: auto;
  padding: 24px 20px 32px 0; border-right: 1px solid var(--border);
}
.hub-rail-k { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 12px; padding-left: 12px; }
.hub-rail-k + * { margin-top: 0; }
.hub-rail-k.is-later { margin-top: 28px; }
.hub-rail-total { margin: -6px 0 12px; padding-left: 12px; font-family: var(--font-mono); font-size: .7rem; color: var(--text-faint); }

.hub-you { padding: 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); margin-bottom: 26px; }
.hub-you .top { display: flex; align-items: center; gap: 12px; }
.hub-you .n { font-family: var(--font-display); font-size: 1.28rem; font-weight: 600; line-height: 1; }
.hub-you .l { font-size: var(--fs-xs); color: var(--text-faint); margin-top: 4px; }
.hub-you .stat { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-xs); color: var(--text-muted); }
.hub-you .stat b { color: var(--text); }

/* progress ring — conic-gradient, no SVG */
.hub-ring {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  border-radius: 50%; position: relative;
  background: conic-gradient(var(--brand) calc(var(--p, 0) * 1%), color-mix(in srgb, var(--brand) 16%, transparent) 0);
}
.hub-ring::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.hub-ring b { position: relative; z-index: 1; font-size: .7rem; font-weight: 700; color: var(--brand); }

.hub-nav { display: grid; gap: 2px; }
.hub-nav-item {
  display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm); color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.hub-nav-item:hover { background: var(--surface-2); color: var(--text); }
.hub-nav-item[aria-current="true"] { background: var(--brand-soft); color: var(--brand); }
.hub-nav-item[aria-current="true"] .nm { font-weight: 700; }
.hub-nav-item .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: .84rem; background: var(--surface-2); color: var(--text-faint); }
.hub-nav-item[aria-current="true"] .ico { background: var(--brand); color: var(--text-on-brand); }
.hub-nav-item .nm { font-size: var(--fs-sm); font-weight: 600; display: block; line-height: 1.25; }
.hub-nav-item .sub { font-size: .7rem; color: var(--text-faint); display: block; margin-top: 2px; font-family: var(--font-mono); }
.hub-nav-item[aria-current="true"] .sub { color: color-mix(in srgb, var(--brand) 72%, var(--text-muted)); }
.hub-nav-item .hub-bar { grid-column: 2; margin-top: 6px; }
.hub-nav-item.is-soon { opacity: .62; }

.hub-links { display: grid; gap: 1px; }
.hub-links a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-muted); }
.hub-links a:hover { background: var(--surface-2); color: var(--text); }
.hub-links a i { width: 16px; text-align: center; color: var(--text-faint); font-size: .82rem; }

/* ---- shared bar --------------------------------------------------------- */
.hub-bar { height: 4px; border-radius: 99px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.hub-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.hub-bar.is-done > i { background: var(--good); }

/* ---- pane --------------------------------------------------------------- */
.hub-main { padding: 24px 0 var(--sp-8) clamp(22px, 3vw, 44px); min-width: 0; }
/* The container is wide (matching the level pages) but the reading column is not:
   cap it at the same 1080px the level pages cap their prose at, so cards don't
   stretch to ~1350px and the two pages line up. */
.hub-main > * { max-width: 1080px; }

/* Inactive panes carry the `hidden` attribute (native display:none). The
   <noscript> block in the view reveals them and restores inter-pane spacing. */
.hub-pane { scroll-margin-top: 86px; }

.hub-head { padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.hub-head .row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.hub-head .ico { width: 46px; height: 46px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem; background: var(--brand-soft); color: var(--brand); }
.hub-head h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.1; }
.hub-head p { margin: 0; font-size: 1.02rem; color: var(--text-muted); line-height: 1.6; max-width: 68ch; }
.hub-figs { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; }
.hub-figs div { font-size: var(--fs-sm); color: var(--text-faint); }
.hub-figs b { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--text); margin-right: 5px; }

/* ---- resume ------------------------------------------------------------- */
.hub-resume {
  display: flex; align-items: center; gap: 16px; margin-top: 22px; padding: 15px 18px;
  border: 1px solid var(--brand); border-radius: var(--r); flex-wrap: wrap;
  background: color-mix(in srgb, var(--brand-soft) 50%, var(--surface));
}
.hub-resume .k { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--brand); }
.hub-resume .t { font-family: var(--font-display); font-size: 1.06rem; font-weight: 600; margin: 3px 0 2px; color: var(--text); }
.hub-resume .s { font-size: var(--fs-sm); color: var(--text-muted); }
.hub-resume .txt { flex: 1; min-width: 200px; }

/* ---- level cards -------------------------------------------------------- */
.hub-levels { display: grid; gap: 14px; margin-top: 26px; }

.hub-lv { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); transition: border-color var(--t), box-shadow var(--t); }
.hub-lv:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.hub-lv.is-current { border-color: var(--brand); box-shadow: var(--shadow-2); }
.hub-lv.is-soon { border-style: dashed; background: transparent; }

.hub-lv-in { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: start; gap: 16px; padding: 20px 22px; }
.hub-lv-num { font-family: var(--font-display); font-size: 2rem; font-weight: 600; color: var(--brand); line-height: .9; letter-spacing: -.03em; }
.hub-lv.is-soon .hub-lv-num { color: var(--text-faint); }
.hub-lv-num small { display: block; font-family: var(--font-body); font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-top: 7px; }

.hub-lv-body { min-width: 0; }
.hub-lv-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.hub-lv-title h3 { margin: 0; font-size: 1.12rem; }
.hub-lv-body p { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.55; max-width: 62ch; }
.hub-lv-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); margin-bottom: 11px; }

.hub-lv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; min-width: 132px; }
.hub-lv-side .pct { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 700; color: var(--brand); }
.hub-lv-side .hub-bar { width: 92px; }
.hub-lv-side .ed-btn { white-space: nowrap; }
.hub-lv-side .soon { font-size: var(--fs-xs); color: var(--text-faint); display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* Topic chips plus a native "+N more" disclosure — a <details>, so it expands
   with JavaScript off. Deliberately NOT `display: contents`: browsers stop
   hiding a closed <details>'s children when its box is removed. */
.hub-topics { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hub-topics span { font-size: .75rem; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

.hub-more { flex: 0 0 auto; }
.hub-more[open] { flex: 1 0 100%; }
.hub-more > summary {
  display: inline-block; list-style: none; cursor: pointer;
  font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px dashed var(--border-strong); color: var(--brand);
}
.hub-more > summary::-webkit-details-marker { display: none; }
.hub-more > summary::marker { content: ""; }
.hub-more > summary:hover { background: var(--brand-soft); }
.hub-more > summary:focus-visible { outline: none; box-shadow: var(--ring); }
.hub-more > .hub-topics { margin-top: 8px; }

/* ---- chips -------------------------------------------------------------- */
.hub-tag { display: inline-flex; align-items: center; gap: 5px; font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 4px 8px; border-radius: var(--r-pill); line-height: 1; white-space: nowrap; }
.hub-tag--free { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.hub-tag--mixed { color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
/* No 'premium' tag: nothing is paid yet — the only gate is sign-in. */
.hub-tag--authenticated { color: var(--brand); background: var(--brand-soft); }
.hub-tag--soon { color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border); }
.hub-tag--done { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }

/* ---- notes / empty ------------------------------------------------------ */
.hub-note { margin-top: 26px; padding: 20px 22px; border: 1px dashed var(--border-strong); border-radius: var(--r); display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hub-note > i { font-size: 1.2rem; color: var(--text-faint); }
.hub-note .txt { flex: 1; min-width: 220px; }
.hub-note h4 { margin: 0 0 4px; font-size: 1rem; }
.hub-note p { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

.hub-empty { text-align: center; padding: 64px 24px; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.hub-empty i { font-size: 1.8rem; color: var(--text-faint); display: block; margin-bottom: 14px; }
.hub-empty h2 { margin: 0 0 8px; font-size: 1.3rem; }
.hub-empty p { margin: 0 auto; max-width: 46ch; color: var(--text-muted); font-size: var(--fs-sm); }

/* ---- mobile track picker ----------------------------------------------- */
.hub-mob { display: none; margin-bottom: 20px; }
.hub-mob select { width: 100%; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; }

.hub-skip { position: absolute; left: -9999px; }
.hub-skip:focus { left: 12px; top: 12px; z-index: 300; padding: 10px 16px; background: var(--brand); color: var(--text-on-brand); border-radius: var(--r-sm); }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 900px) {
  .hub-shell { grid-template-columns: 1fr; }
  .hub-rail { display: none; }
  .hub-main { padding-left: 0; padding-top: 18px; }
  /* The <select> only steers panes when JS is driving them. */
  .hub-js .hub-mob { display: block; }
}
@media (max-width: 620px) {
  .hub-lv-in { grid-template-columns: 46px minmax(0, 1fr); gap: 12px; padding: 17px 16px; }
  .hub-lv-num { font-size: 1.6rem; }
  /* The 46px column can't fit the "FOUNDATIONS" mini-label and it overlaps the
     body text; the card title carries the same name, so drop it on phones. */
  .hub-lv-num small { display: none; }
  .hub-lv-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .hub-lv-side .ed-btn { flex: 1; justify-content: center; }
  .hub-resume .ed-btn { width: 100%; justify-content: center; }
}
