/* Physics Atlas — shell layout: top bar, sidebar, pages. */
.skip-link { position: fixed; left: 8px; top: -60px; z-index: 1000; padding: 10px 14px; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 8px; font: 600 var(--fs-1) var(--font-ui); }
.skip-link:not(:focus) { clip-path: inset(50%); pointer-events: none; }
.skip-link:focus { top: 8px; }
@media (max-width: 640px) { .skip-link:focus { top: 0; left: 0; right: 0; border-radius: 0; text-align: center; } }   /* covers the top bar only, never the content */

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3) 0 var(--sp-2);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 28px; height: 28px; border-radius: 50%; flex: none; background:
  radial-gradient(circle at 50% 50%, transparent 5px, var(--accent) 5.5px, var(--accent) 7px, transparent 7.5px),
  conic-gradient(from 200deg, var(--unit-A), var(--unit-B), var(--unit-C), var(--unit-D), var(--unit-E), var(--unit-A)); box-shadow: inset 0 0 0 7px var(--bg); }
.brand-name { font: 700 1.05rem/1 var(--font-ui); letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font: 500 var(--fs-0)/1 var(--font-ui); color: var(--muted); white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar-slot { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-slot:empty { display: none; }

.level-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 999px; border: 1px solid var(--line); }
.level-switch button { font: 700 12px/1 var(--font-ui); letter-spacing: .04em; padding: 7px 11px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; min-height: 30px; }
.level-switch button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1); }

.theme-icon, .menu-icon { display: block; width: 20px; height: 20px; }
.theme-icon { border-radius: 50%; border: 2px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
[data-mode="light"] .theme-icon { background: transparent; box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px currentColor; width: 14px; height: 14px; margin: 3px; }
[data-mode="dark"] .theme-icon { background: currentColor; -webkit-mask: radial-gradient(circle at 70% 30%, transparent 6px, #000 6.5px); mask: radial-gradient(circle at 70% 30%, transparent 6px, #000 6.5px); border: 0; }
.menu-icon { background: linear-gradient(currentColor 0 0) 0 4px/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 9px/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 14px/70% 2px no-repeat; }
.menu-btn { display: none; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.main { min-width: 0; padding: var(--sp-6) clamp(16px, 4vw, 56px) var(--sp-8); outline: none; }
.scrim { display: none; }

/* ---- sidebar ---- */
.sidebar {
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--sp-4) var(--sp-3) var(--sp-7); border-right: 1px solid var(--line); background: var(--bg);
  font: 500 var(--fs-1)/1.35 var(--font-ui); scrollbar-width: thin;
}
.nav-home { display: block; padding: 8px 10px; margin-bottom: var(--sp-2); border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.nav-home:hover, .nav-home[aria-current] { background: var(--sunken); color: var(--ink); }
.nav-unit { margin-bottom: var(--sp-2); }
.nav-unit > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; font: 700 12px/1.3 var(--font-ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.nav-unit > summary::-webkit-details-marker { display: none; }
.nav-unit > summary:hover { color: var(--ink); }
.unit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unit); flex: none; }
.nav-unit-letter { color: var(--unit); }
.nav-chapters, .nav-sections { list-style: none; margin: 0; padding: 0; }
.nav-chlink { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.nav-chlink:hover { background: var(--sunken); color: var(--ink); }
.nav-chlink[aria-current] { background: var(--unit-soft); color: var(--ink); }
.nav-chnum { font: 600 12px/1 var(--font-ui); color: var(--muted); width: 1.6em; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.nav-chtitle { flex: 1; min-width: 0; }
.nav-ring { display: inline-flex; flex: none; }
.nav-chapter[data-ch] { --unit: inherit; }
.nav-chapter.is-soon > .nav-chlink { color: var(--muted); }
.nav-sections { display: none; margin: 2px 0 6px 26px; border-left: 1px solid var(--line); }
.nav-chapter.is-open .nav-sections { display: block; }
.nav-sections a { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; font-size: var(--fs-0); line-height: 1.35; }
.nav-sections a:hover { color: var(--ink); background: var(--sunken); }
.nav-sections a[aria-current] { color: var(--ink); border-left-color: var(--unit); background: var(--unit-soft); font-weight: 600; }
.nav-sections a.is-soon { color: var(--muted); }
.nav-secnum { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.nav-sectitle { flex: 1; }
.nav-check { width: 14px; height: 14px; flex: none; align-self: center; border-radius: 50%; }
.is-visited > a .nav-check { border: 2px solid var(--line-strong); }
.is-complete > a .nav-check { border: 0; background: var(--good); -webkit-mask: none; box-shadow: inset 0 0 0 3px var(--bg); }
.sidebar.is-sl .is-hl { display: none; }
.nav-unit[data-unit="A"] { --unit: var(--unit-A); --unit-soft: var(--unit-A-soft); }
.nav-unit[data-unit="B"] { --unit: var(--unit-B); --unit-soft: var(--unit-B-soft); }
.nav-unit[data-unit="C"] { --unit: var(--unit-C); --unit-soft: var(--unit-C-soft); }
.nav-unit[data-unit="D"] { --unit: var(--unit-D); --unit-soft: var(--unit-D-soft); }
.nav-unit[data-unit="E"] { --unit: var(--unit-E); --unit-soft: var(--unit-E-soft); }
.nav-tools { --unit: var(--accent); }
.nav-foot { margin-top: var(--sp-6); padding: 0 10px; color: var(--muted); font-size: var(--fs-0); line-height: 1.5; }

/* ---- pages ---- */
.page { max-width: var(--wide); margin: 0 auto; }
.page.narrow { max-width: var(--measure); }
.eyebrow { font: 700 12px/1.3 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--unit, var(--accent)); margin: 0 0 var(--sp-2); }
.eyebrow a { color: inherit; text-decoration: none; }

/* home */
.home-hero { padding: var(--sp-6) 0 var(--sp-5); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.home-hero h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); margin-bottom: var(--sp-3); }
.lede { font: 400 1.2rem/1.55 var(--font-prose); color: var(--ink-2); max-width: 38rem; margin: 0 0 var(--sp-5); }
.hero-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.resume-card { display: inline-flex; flex-direction: column; gap: 2px; padding: 10px 16px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); text-decoration: none; box-shadow: var(--shadow-2); }
.resume-card:hover { color: var(--on-accent); background: var(--accent-2); }
.resume-card small { font: 600 11px/1.2 var(--font-ui); text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.resume-card span { font-weight: 650; }
.unit-block { margin: var(--sp-6) 0; }
.unit-title { display: flex; align-items: center; gap: 12px; font-size: var(--fs-3); margin: 0 0 var(--sp-3); }
.unit-letter { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--unit); color: var(--bg); font-weight: 800; }
.chapter-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--sp-3); }
.chapter-card, .section-card {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-1); transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
  border-left: 4px solid var(--unit);
}
.chapter-card:hover, .section-card:hover { color: var(--ink); border-color: var(--unit); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.chapter-card.is-soon, .section-card.is-soon { border-left-style: dashed; }
.chapter-card.is-soon .card-title, .section-card.is-soon .card-title { color: var(--ink-2); }
.card-num { font: 700 1.15rem/1 var(--font-ui); color: var(--unit); min-width: 2.2ch; font-variant-numeric: tabular-nums; }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-title { font-weight: 650; line-height: 1.3; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-sub { font-size: var(--fs-0); color: var(--muted); }

/* chapter overview */
.chapter-head { padding: var(--sp-5) 0 var(--sp-4); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.chapter-intro { margin-bottom: var(--sp-5); }
.section-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-3); }
.secnum { color: var(--unit, var(--accent)); font-variant-numeric: tabular-nums; }
.link-list { list-style: none; padding: 0; display: grid; gap: var(--sp-2); }
.link-list li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.link-list a { font-weight: 650; text-decoration: none; color: var(--unit); }
.link-reason { color: var(--ink-2); }

/* section page */
.section-page { max-width: var(--wide); margin: 0 auto; }
.section-head { margin-bottom: var(--sp-4); }
.crumbs { font: 600 var(--fs-0)/1.4 var(--font-ui); color: var(--muted); margin-bottom: var(--sp-2); }
.crumbs a { color: var(--unit); text-decoration: none; }
.section-head h1 { font-size: clamp(1.7rem, 3.6vw, 2.3rem); }
.section-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.section-ring { display: inline-flex; align-items: center; gap: 6px; }
.hl-notice { display: none; }
:root[data-level="sl"] .hl-notice { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; border: 1px solid var(--unit-E); background: var(--unit-E-soft); border-radius: var(--radius); }
.hl-notice p { margin: 0; }

.loop-strip {
  position: sticky; top: var(--topbar); z-index: 20; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * clamp(16px, 4vw, 56px)) var(--sp-5); padding: 8px clamp(16px, 4vw, 56px);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.loop-strip::-webkit-scrollbar { display: none; }
.loop-strip button { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 5px 10px 5px 5px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 600 12px/1 var(--font-ui); cursor: pointer; }
.loop-strip button:hover { border-color: var(--unit); color: var(--ink); }
.loop-strip button[aria-current] { background: var(--unit); color: var(--bg); border-color: var(--unit); }
.loop-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--sunken); color: var(--ink-2); font-size: 11px; }
.loop-strip button[aria-current] .loop-n { background: color-mix(in srgb, var(--bg) 25%, transparent); color: var(--bg); }

/* the loop sections inside a fragment */
.section-body > section[data-loop] { margin: 0 0 var(--sp-7); }
.section-body > section[data-loop] > h2 { margin-top: 0; padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.section-body > section[data-loop]:first-child > h2 { border-top: 0; padding-top: 0; }
.section-body > section[data-loop] > h2::before { display: block; font: 700 11px/1.3 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--unit); margin-bottom: 6px; }
section[data-loop="hook"] > h2::before { content: "1 · Hook"; }
section[data-loop="predict"] > h2::before { content: "2 · Predict"; }
section[data-loop="play"] > h2::before { content: "3 · Play"; }
section[data-loop="explain"] > h2::before { content: "4 · Explain"; }
section[data-loop="example"] > h2::before { content: "5 · Worked example"; }
section[data-loop="check"] > h2::before { content: "6 · Check"; }
section[data-loop="reflect"] > h2::before { content: "7 · Reflect"; }
section[data-loop="extra"] > h2::before { content: "Going further"; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 3px; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--unit); color: var(--ink); }
.pager small { font: 700 11px/1 var(--font-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pager-next { text-align: right; }

.coming-soon { text-align: center; padding: var(--sp-7) var(--sp-4); max-width: 34rem; margin: 0 auto; }
.coming-soon h2 { margin-top: var(--sp-4); }
.soon-art { width: 120px; height: 60px; margin: 0 auto; border-radius: 60px 60px 0 0; border: 3px dashed var(--unit); border-bottom: 0; opacity: .6; }

.error-page code { display: block; margin-top: var(--sp-3); white-space: pre-wrap; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: var(--topbar); bottom: 0; height: auto; width: min(86vw, var(--sidebar));
    transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-2); visibility: hidden;
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .nav-open .scrim { display: block; position: fixed; inset: var(--topbar) 0 0 0; z-index: 55; background: rgba(10, 12, 15, .35); }
}
@media (max-width: 640px) {
  :root { --fs-2: 1.03rem; --fs-5: 1.8rem; --fs-4: 1.4rem; }
  .brand-sub { display: none; }
  .main { padding-top: var(--sp-4); }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
}
