/* Math Essentials for ML & DL: self-contained.
   Inherit the site's "Sage Biophilic" root tokens, define the rest.
   Accent identity: muted heather-plum (distinct on the hub map, kept
   desaturated so it stays calm and earthy with the sage system). */
@import url("../styles.css");

:root {
  --accent: #6e5a7e;        /* heather-plum */
  --accent-2: #574168;      /* darker, hover / gradients */
  --accent-soft: #efeaf3;   /* light tint for soft fills */
  --accent-line: #ddd2e4;   /* accent-tinted border */
  --accent-deep: #3f2e50;   /* darkest, for contrast text */
}
.mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 7px; color: #fff; background: linear-gradient(135deg, #2f8a5e, #6e5a7e); }
button { cursor: pointer; font: inherit; }
.hl { color: var(--accent); }
.nowrap, .nw { white-space: nowrap; }
.eyebrow { margin: 0 0 12px; color: var(--clay); font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(24px, 5vw, 56px); align-items: center; padding: clamp(44px, 7vw, 84px) clamp(18px, 4vw, 56px); min-height: 540px; background: radial-gradient(900px 460px at 88% -10%, #e4dcec, transparent 60%), var(--paper); }
.hero h1 { margin: 0; font-size: clamp(2rem, 4.4vw, 3.6rem); line-height: 1.06; }
.lead { color: var(--muted); line-height: 1.7; font-size: clamp(1rem, 1.55vw, 1.14rem); max-width: 66ch; text-wrap: pretty; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.hero-badges span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff; font-weight: 800; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 850; transition: transform .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.hero-stage { border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #efeaf3, #e8eede); box-shadow: var(--shadow); overflow: hidden; }
.hero-stage canvas { display: block; width: 100%; height: auto; }

/* bands */
.howto, .band, .next { padding: clamp(36px, 6vw, 76px) clamp(18px, 4vw, 56px); border-top: 1px solid var(--line); }
.band { background: #e7eddc; } .band.alt { background: #e9e5ee; }
.section-title { max-width: 860px; margin: 0 auto 24px; text-align: center; }
.section-title h2 { margin: 6px 0 10px; font-size: clamp(1.6rem, 3.2vw, 2.6rem); text-wrap: balance; }
.section-title .lead { margin-inline: auto; }
.howto { background: #fff; }
.howlist { max-width: 940px; margin: 0 auto; color: var(--ink); line-height: 1.7; padding-left: 20px; }
.howlist li { margin-bottom: 6px; } .howlist strong { color: var(--accent); }

/* ============================================================
   QLab: the "visualize the math" interactive widget
   ============================================================ */
.lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.qlab { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 18px; background: var(--panel); margin: 0 0 16px; box-shadow: var(--shadow); }
.lab-title { margin: 0 0 4px; font-weight: 900; color: var(--ink); font-size: 1.05rem; }
.lab-blurb { margin: 0 0 10px; color: var(--muted); line-height: 1.55; font-size: .92rem; }
.qlab-stage { margin: 0 0 4px; }
.qlab canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; }
.lab-ctrls { display: grid; gap: 8px; margin: 12px 0 4px; }
.lab-row { display: grid; grid-template-columns: minmax(120px, 42%) 1fr auto; align-items: center; gap: 10px; }
.lab-name { font-weight: 700; color: var(--ink); font-size: .9rem; }
.lab-slider { width: 100%; min-height: 28px; accent-color: var(--accent); }
.lab-val { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent); min-width: 3.6em; text-align: right; }
.lab-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.lab-btn { min-height: 38px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 800; color: var(--ink); }
.lab-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.lab-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(31,42,34,.10); }
.qlab-mathbox { margin: 12px 0 0; padding: 10px 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; background: linear-gradient(180deg, var(--accent-soft), #fbfcff); }
.qlab-mathlbl { margin: 0 0 4px; font-size: .72rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.qlab-mathrows { display: grid; gap: 2px; }
.qlab-mathrow { overflow-x: auto; overflow-y: hidden; }
.qlab-mathrow .katex-display { margin: 6px 0; }
.qlab-why { display: flex; gap: 9px; align-items: flex-start; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: #fbfcf5; border: 1px dashed var(--line); color: var(--ink); line-height: 1.65; font-size: .92rem; }
.qlab-why-i { flex: none; font-size: 1.05rem; line-height: 1.4; }
.qlab-why b { color: var(--accent); }
.statechips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.statechip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 800; font-size: .84rem; color: var(--muted); }
.statechip.on { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ============================================================
   PSET: the solve-by-hand problem bank (type an answer, check, reveal)
   ============================================================ */
.pset-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; max-width: 1180px; margin: 0 auto; }
.pset-bank { border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); padding: 16px 18px 18px; }
.pset-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 6px; }
.pset-head h3 { margin: 0; font-size: 1.16rem; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.pset-head .pset-emoji { font-size: 1.3rem; }
.pset-score { font-weight: 900; font-size: .82rem; color: var(--accent-deep); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 999px; padding: 5px 12px; font-variant-numeric: tabular-nums; }
.pset-sub { margin: 6px 0 12px; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.pset-q { border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 13px 15px; margin: 0 0 12px; }
.pset-q.solved { border-color: #7fcdb0; background: linear-gradient(180deg, #f0f8f3, #fff); }
.pset-qtop { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.pset-qn { font-weight: 900; color: var(--accent); font-size: .92rem; }
.pset-tag { font-size: .68rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: #fbfcf5; }
.pset-tag.warmup { color: #2f7d5b; border-color: #bfe0cf; background: #eef7f1; }
.pset-tag.core { color: #466f96; border-color: #c8d6e4; background: #eef3f8; }
.pset-tag.challenge { color: var(--accent-deep); border-color: var(--accent-line); background: var(--accent-soft); }
.pset-prompt { line-height: 1.6; color: var(--ink); margin: 0 0 4px; }
.pset-prompt .katex-display { margin: 8px 0; overflow-x: auto; overflow-y: hidden; }
.pset-ask { margin: 4px 0 0; font-weight: 700; color: var(--ink); }
.pset-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
.pset-input { font: inherit; min-height: 40px; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); width: clamp(120px, 40%, 220px); font-variant-numeric: tabular-nums; }
.pset-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pset-unit { color: var(--muted); font-size: .9rem; font-weight: 700; }
.pset-check { min-height: 40px; padding: 7px 16px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: #fff; font-weight: 850; }
.pset-check:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(63,46,80,.22); }
.pset-fb { margin: 9px 0 0; padding: 8px 12px; border-radius: 9px; font-size: .92rem; line-height: 1.55; font-weight: 700; display: none; }
.pset-fb.show { display: block; }
.pset-fb.ok { background: #dcf3ec; border: 1px solid #7fcdb0; color: #14523a; }
.pset-fb.no { background: #f6ddd3; border: 1px solid #e3a98f; color: #7a3a26; }
.pset-fb.near { background: #fdf3da; border: 1px solid #e6cf94; color: #6f5512; }
.pset-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.pset-tool { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font-weight: 800; font-size: .85rem; color: var(--ink); }
.pset-tool:hover { border-color: var(--accent); }
.pset-hint { margin: 8px 0 0; padding: 9px 12px; background: #fbfcf5; border: 1px dashed var(--line); border-radius: 9px; color: var(--ink); line-height: 1.55; font-size: .9rem; display: none; }
.pset-hint.show { display: block; }
.pset-sol { margin: 8px 0 0; display: none; }
.pset-sol.show { display: block; }
.pset-sstep { margin: 8px 0; padding: 9px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.pset-sstep .pset-swhy { margin: 4px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.pset-sstep .katex-display { margin: 4px 0; overflow-x: auto; overflow-y: hidden; }
.pset-sresult { margin: 8px 0 0; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 9px; background: #fff; line-height: 1.6; font-size: .93rem; }

/* references / next */
.ref-list { max-width: 1000px; margin: 0 auto; color: var(--ink); line-height: 1.7; padding-left: 22px; }
.ref-list li { margin-bottom: 8px; } .ref-list a { color: var(--accent); font-weight: 800; }
.next { text-align: center; background: linear-gradient(180deg, #e2ebdb, var(--paper)); } .next .actions { justify-content: center; }

/* ✦ beautiful-idea callouts (the four pillars) */
.beauty-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; max-width: 1180px; margin: 4px auto 26px; }
.beauty-note { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 14px 16px 16px; background: linear-gradient(180deg, var(--panel), #fff); box-shadow: var(--shadow); }
.bn-lbl { margin: 0 0 6px; font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.bn-name { margin: 0 0 8px; font-size: 1.04rem; line-height: 1.3; color: var(--ink); font-weight: 900; }
.bn-eq { margin: 4px 0 10px; overflow-x: auto; overflow-y: hidden; }
.bn-eq .katex-display { margin: 0; }
.bn-why { margin: 0; color: var(--ink); line-height: 1.7; font-size: .92rem; }
.bn-why em { font-style: normal; font-weight: 800; color: var(--accent); }

/* reveal */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 920px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
}
@media (max-width: 760px) { .lab-grid, .pset-wrap { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .actions .button { flex: 1 1 100%; justify-content: center; }
  .lab-row { grid-template-columns: 1fr auto; } .lab-name { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } html { scroll-behavior: auto; } .lab-btn:hover, .pset-check:hover { transform: none; } }

/* focus rings */
.button:focus-visible, .lab-btn:focus-visible, .lab-slider:focus-visible, .pset-check:focus-visible, .pset-tool:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, #fff); outline-offset: 2px; border-radius: 6px; }
.ref-list a:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, #fff); outline-offset: 3px; border-radius: 4px; }

/* ============================================================
   In-module navigation: sticky bar, smooth scroll, pillar map
   ============================================================ */
html { scroll-behavior: smooth; }
.topbar { position: sticky; top: 0; z-index: 60; background: rgba(230, 237, 218, .92); backdrop-filter: saturate(1.1) blur(8px); -webkit-backdrop-filter: saturate(1.1) blur(8px); }
main section[id] { scroll-margin-top: 78px; }

.math-map { margin: 6px 0 18px; }
.math-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.math-filter-lbl { font-weight: 800; color: var(--muted); font-size: .86rem; margin-right: 2px; }
.math-fbtn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-weight: 800; font-size: .85rem; color: var(--ink); display: inline-flex; align-items: center; gap: 7px; transition: transform .12s ease, border-color .12s ease; }
.math-fbtn:hover { transform: translateY(-1px); border-color: var(--p, var(--accent)); }
.math-fbtn.on { background: var(--p, var(--accent)); border-color: var(--p, var(--accent)); color: #fff; }
.math-fcount { font-size: .72rem; font-weight: 900; background: rgba(31, 42, 34, .08); border-radius: 999px; padding: 1px 7px; }
.math-fbtn.on .math-fcount { background: rgba(255, 255, 255, .28); }
.math-road-wrap { border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, var(--accent-soft), var(--panel)); box-shadow: var(--shadow); padding: 12px 14px; }
.math-road-head { margin: 0 0 6px; color: var(--ink); font-weight: 700; line-height: 1.5; font-size: .9rem; }
#mathRoadmap { display: block; width: 100%; height: auto; cursor: pointer; }

/* ============================================================
   Practice progress bar (across all four banks)
   ============================================================ */
.pset-progress { max-width: 1180px; margin: 0 auto 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); padding: 12px 16px; }
.pset-progress:empty { display: none; }
.pset-prog-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 8px; font-size: .95rem; }
.pset-prog-num { font-weight: 900; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.pset-prog-track { height: 12px; border-radius: 999px; background: #e7e1ee; overflow: hidden; }
.pset-prog-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s ease; }
.pset-prog-done { margin: 8px 0 0; color: #14523a; font-weight: 800; font-size: .92rem; }

/* progressive solution reveal */
.pset-solctrls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.pset-solcount { color: var(--muted); font-weight: 700; font-size: .82rem; }
.pset-tool:disabled { opacity: .45; cursor: not-allowed; }
.pset-sstep { display: none; }
.pset-sstep.show { display: block; }
.pset-sresult { display: none; }
.pset-sresult.show { display: block; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .math-fbtn:hover { transform: none; } }
@media (max-width: 560px) { .math-filter-lbl { width: 100%; } }
