/*
 * site.css — styling for the semantic topic/hub pages ONLY. It does not touch
 * lesson.css / intro.css (the frozen interactive lesson keeps its own styles).
 * Minimal on purpose; a full visual pass is deferred.
 */

:root {
  --ink: #16241f;
  --muted: #4a625a;
  --bg: #f6faf7;
  --card: #ffffff;
  --line: #d8e6de;
  --accent: #0f7a5a;
  --accent-ink: #0c2b22;
  --focus: #0a6cff;
  --lede: #24352e;
  --maxw: 46rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.62 var(--font-family, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent-ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
.btn-start:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Minimal — the immersive lesson is the product; this webpage chrome around
   it stays quiet and never inherits into the full-screen lesson overlay. */
.site-header {
  border-bottom: 1px solid var(--line);
}
.site-name {
  display: inline-block;
  padding: 10px 20px;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent-ink);
}

.breadcrumb {
  max-width: var(--maxw);
  margin: 14px auto 0;
  padding: 0 20px;
  font-size: 0.86rem;
  color: var(--muted);
}
.breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--line); }

#main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 20px 64px;
}

h1 { font-size: 1.72rem; line-height: 1.25; margin: 18px 0 8px; color: var(--accent-ink); }
h2 { font-size: 1.24rem; margin: 34px 0 10px; color: var(--accent-ink); }
h3 { font-size: 1.03rem; margin: 20px 0 6px; }

.lede { font-size: 1.08rem; color: var(--lede); }

ul, ol { padding-left: 1.25rem; }
li { margin: 4px 0; }

.lesson-doc table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.95rem;
}
.lesson-doc th, .lesson-doc td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.lesson-doc thead th { background: var(--card); }
.lesson-doc tbody th[scope="row"] { font-weight: 700; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef4f0;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.95em;
}

.formula { font-size: 1.05rem; }
.formula-block { margin: 14px 0; }
.sign-rule { color: var(--muted); font-size: 0.92rem; }

dl { margin: 12px 0; }
.term { padding: 10px 0; border-top: 1px solid var(--line); }
.term:last-child { border-bottom: 1px solid var(--line); }
.term dt { font-weight: 700; }
.term dd { margin: 4px 0 0; }

.activity {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 14px 0;
}
.activity h3 { margin-top: 0; }

.lesson-launch { margin: 20px 0 8px; }
.btn-start {
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 13px 20px;
  cursor: pointer;
}
.btn-start:hover { background: #0c6b4f; }
.lesson-noscript { color: var(--muted); font-size: 0.92rem; }

.topic-list { list-style: none; padding: 0; }
.topic-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0;
}
.topic-card h3 { margin: 0 0 4px; }
.topic-card p { margin: 0; color: var(--muted); }

.topic-nav {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.topic-nav ul { list-style: none; padding: 0; }
.topic-nav .nav-label {
  display: inline-block;
  min-width: 6.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer p { max-width: var(--maxw); margin: 0 auto; padding: 16px 20px; }

/* ---- full-screen interactive lesson overlay ----
   Always the dark stage look, regardless of the article's own light/dark
   theme — it must never inherit a conventional website header/navbar, and it
   must never flip light in dark mode (a fixed token, not a theme-aware one). */
html.lesson-open { overflow: hidden; }
.lesson-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--stage-2, #0d3226);
}
.lesson-overlay[hidden] { display: none; }
/* Wraps bodyEl (+ the quiet desktop header below) so the Chapter Map
   rail's own row-flex layout (chapter-map.css) is completely unaffected —
   this wrapper simply takes over bodyEl's old spot as the rail's sibling. */
.lesson-overlay-mainarea {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lesson-overlay-body {
  position: relative;   /* native lessons mount an inset:0 root here */
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.lesson-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: var(--stage-2, #0c2b22);
}

/* Quiet lesson header (screen-by-screen redesign, reflection-of-light) —
   product-brand chrome, so it uses the canonical TextbookLive palette
   (not the lesson stage's own aqua/amber). Desktop only: below 900px the
   existing mobile topbar (chapter-map.css) already carries the Chapter
   Map trigger, and this stays out of its way rather than adding a second
   bar. NOTE: this cannot include Skip or the progress indicator — both
   are rendered INSIDE the frozen per-lesson iframe (intro.html/intro.css),
   which this parent document has no access to restyle or relocate. */
.lesson-overlay-header { display: none; }
@media (min-width: 901px) {
  .lesson-overlay-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-height: 48px;
    padding: 0 64px 0 20px; /* right space clears the floating Close chip */
    box-sizing: border-box;
    background: var(--bg-deep, #0A3B31);
    border-bottom: 1px solid rgba(197, 216, 209, 0.14);
  }
}
.lesson-overlay-brand {
  display: flex;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #A9E8CF;
}
.lesson-overlay-brand svg { width: 100%; height: 100%; }
.lesson-overlay-title {
  font: 600 0.88rem 'Manrope', var(--font-family, inherit);
  color: var(--text, #F7FAF8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* quiet floating chip — never a header bar/empty strip on its own; on
   desktop it visually sits inside .lesson-overlay-header's row purely by
   matching vertical position, not by being one of its DOM children (so
   its behaviour/position on mobile, where no header exists, is untouched). */
.lesson-overlay-close {
  position: absolute;
  top: 10px;
  right: max(10px, env(safe-area-inset-right));
  z-index: 20;
  font: 500 0.85rem 'Manrope', var(--font-family, inherit);
  color: var(--text-secondary, #C5D8D1);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-button, 10px);
  padding: 7px 11px;
  min-height: 36px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.lesson-overlay-close:hover {
  background: rgba(169, 232, 207, 0.08);
  border-color: rgba(169, 232, 207, 0.18);
  color: var(--text, #F7FAF8);
}
/* the additive Activity-9.3-style label drawn over a frozen iframe lesson */
.lesson-overlay-activity-tag { z-index: 15; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7f0ea;
    --muted: #9db8ac;
    --bg: #0f1a16;
    --card: #16241d;
    --line: #294137;
    --accent: #4bd0a4;
    --accent-ink: #d7f2e7;
    --lede: #c7d8ce;
  }
  code { background: #1d2f27; }
  .formula code { color: var(--ink); }
}
