/* ============================================================
   Seeing That Frees — shared stylesheet
   Family skeleton copied verbatim from categoryTheory/index.html;
   only the palette tokens are swapped (twilight indigo + warm gold)
   and the code/card theme is LIGHT throughout (no dark surfaces).
   ============================================================ */

/* === TOKENS === */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-sunken: #F4F3F9;
  --text: #1A1A2E;
  --text-muted: #5C5C7A;

  --accent:                 #4C5191;  /* twilight indigo — primary */
  --accent-dark:            #3A3E73;
  --accent-light:           #E4E5F0;
  --accent-secondary:       #C19B4A;  /* warm gold — secondary */
  --accent-secondary-light: #F3EAD6;

  --warn: #D97706;
  --warn-light: #FDF1E0;
  --ok: #2D7D46;
  --ok-light: #E8F5EC;
  --err: #DC2626;
  --err-light: #FEE8E8;

  --grid-line: rgba(76, 81, 145, 0.07);
  --border: #E5E3EC;
  --shadow: rgba(40, 30, 90, 0.07);
  --radius: 0.75rem;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;

  /* light code/card theme — the user finds dark code hard to read.
     EVERY card surface uses these; never dark. */
  --code-bg:       #EEF2F5;
  --code-bg-soft:  #E1E7EC;
  --code-border:   #D3DAE0;
  --code-fg:       #1F2533;
  --code-cm:       #7A8590;
  --code-kw:       #9C2D6E;
  --code-ty:       #2D6E78;
  --code-fn:       #2F5FA3;
  --code-op:       #B5552A;
  --code-st:       #3B7A4B;
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.container { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 1040px; }

/* === HEADER === */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}
header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px var(--shadow);
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 1040px;
}
.wordmark {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.wordmark:hover { text-decoration: none; }
.wordmark .mk {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem;
}
.wordmark span { opacity: 0.5; font-weight: 400; }
header nav { display: flex; gap: 1.2rem; }
header nav a {
  font-size: 0.85rem; color: var(--text-muted);
  transition: color 0.2s;
}
header nav a:hover { color: var(--accent); text-decoration: none; }
/* scroll progress */
.progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: var(--accent); width: 0%;
  transition: width 0.1s linear;
}

/* === CHAPTER STRIP === */
.ch-strip {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ch-strip::-webkit-scrollbar { display: none; }
.ch-strip .container {
  display: flex; align-items: center; gap: 0.4rem;
  padding-top: 0.55rem; padding-bottom: 0.55rem;
  max-width: 1040px;
}
.ch-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem; color: var(--text-muted);
  padding: 0.32rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: all 0.15s ease-out;
  text-decoration: none;
  white-space: nowrap;
}
.ch-pill:hover { color: var(--accent-dark); border-color: var(--accent); text-decoration: none; }
.ch-pill .ch-num {
  font-family: var(--mono); font-weight: 700; font-size: 0.7rem;
  color: var(--accent);
}
.ch-pill .ch-name { font-weight: 500; }
.ch-pill.current {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.ch-pill.current .ch-num { color: rgba(255,255,255,0.75); }
.ch-pill.current:hover { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }
.ch-divider {
  width: 12px; height: 1px; background: var(--border); flex-shrink: 0;
}
@media (max-width: 767px) {
  .ch-pill .ch-name { display: none; }
  .ch-pill { padding: 0.28rem 0.5rem; }
  .ch-divider { width: 6px; }
}

/* === HERO === */
.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
}
.hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  margin-bottom: 1.25rem;
  animation: fadeUp 0.6s ease-out both;
}
.hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3rem; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 0.85rem;
  animation: fadeUp 0.6s ease-out 0.08s both;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-subtitle {
  font-size: 1.15rem; color: var(--text-muted);
  max-width: 560px; margin: 0 auto 2rem;
  animation: fadeUp 0.6s ease-out 0.16s both;
}
.hero-arrows { animation: fadeUp 0.6s ease-out 0.28s both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === SECTIONS === */
section.lesson { padding: 1rem 0; }
.block { margin: 2.75rem 0; }
h2.sec {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  scroll-margin-top: 72px;
}
h2.sec .num {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
  color: var(--accent); margin-right: 0.5rem;
  vertical-align: 0.12em;
}
h3.sub { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p.lead { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 1rem; }
.prose p { margin-bottom: 0.9rem; }
.prose ul { margin: 0.4rem 0 1rem 1.3rem; }
.prose li { margin-bottom: 0.35rem; }

/* inline term/emphasis chips */
.m {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 0.08em 0.38em; border-radius: 4px;
  white-space: nowrap;
}
.m.obj { color: var(--accent-secondary); background: var(--accent-secondary-light); }
.m.mor { color: var(--accent-dark); background: var(--accent-light); }

/* === CALLOUT === */
.callout {
  display: flex; gap: 0.85rem;
  background: var(--accent-light);
  border: 1px solid #d2d4e6;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.callout .ic { font-size: 1.2rem; flex-shrink: 0; line-height: 1.5; }
.callout.warn { background: var(--warn-light); border-color: #f3dcb6; border-left-color: var(--warn); }
.callout strong { color: var(--accent-dark); }
.callout.warn strong { color: var(--warn); }

/* === FIGURE / WIDGET === */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px var(--shadow);
}
.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.widget-title {
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.45rem;
}
.widget-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hint { font-size: 0.8rem; color: var(--text-muted); }

svg.diagram { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }
.diagram-wrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }

/* === BUTTONS / CONTROLS === */
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; align-items: center; }
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.readout {
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--text-muted); margin-left: auto;
}
select.pick {
  font: inherit; font-family: var(--mono); font-size: 0.85rem;
  padding: 0.3rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer;
}

/* === CODE / LANGUAGE TOGGLE (LIGHT THEME) === */
.code-card { border: 1px solid var(--code-border); border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.code-tabs { display: flex; background: var(--code-bg-soft); border-bottom: 1px solid var(--code-border); }
.code-tab {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted); background: transparent; border: none;
  padding: 0.6rem 1.05rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.code-tab:hover { color: var(--text); }
.code-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.code-tab .lang-ic { opacity: 0.9; margin-right: 0.4rem; }
pre.code {
  margin: 0; padding: 1.1rem 1.2rem;
  background: var(--code-bg); color: var(--code-fg);
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.7;
  overflow-x: auto;
}
pre.code .cm { color: var(--code-cm); font-style: italic; } /* comment / plain-English annotation */
pre.code .kw { color: var(--code-kw); }                     /* the action / cue */
pre.code .ty { color: var(--code-ty); }                     /* named thing */
pre.code .fn { color: var(--code-fn); }                     /* named thing */
pre.code .op { color: var(--code-op); }                     /* operator */
pre.code .st { color: var(--code-st); }                     /* literal */
pre.code .hl { color: var(--accent-dark); font-weight: 600; } /* hand-marked highlight */
.code-pane { display: none; }
.code-pane.active { display: block; }

/* === QUIZ === */
.quiz-q { margin-bottom: 1.4rem; }
.quiz-q:last-child { margin-bottom: 0; }
.quiz-q .q { font-weight: 600; margin-bottom: 0.6rem; }
.quiz-q .q .qn {
  font-family: var(--mono); color: var(--accent); font-size: 0.85rem; margin-right: 0.4rem;
}
.opt {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 0.92rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.12s ease-out;
  display: flex; align-items: center; gap: 0.6rem;
}
.opt:hover:not(.locked) { border-color: var(--accent); background: var(--accent-light); }
.opt .mark { width: 18px; flex-shrink: 0; font-weight: 700; }
.opt.correct { border-color: var(--ok); background: var(--ok-light); color: #1b5e2e; }
.opt.wrong { border-color: var(--err); background: var(--err-light); color: #b91c1c; }
.opt.locked { cursor: default; }
.quiz-fb { font-size: 0.88rem; margin-top: 0.4rem; min-height: 1.2em; color: var(--text-muted); }
.quiz-fb.show.ok { color: var(--ok); }
.quiz-fb.show.no { color: var(--err); }

/* === NEXT / FOOTER === */
.next-card {
  display: flex; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light));
  border: 1px solid #d2d4e6; border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin: 2.5rem 0 1rem;
}
.next-card .big { font-size: 1.6rem; }
.next-card .t1 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.next-card .t2 { font-weight: 600; font-size: 1.05rem; }
.next-card .t3 { font-size: 0.88rem; color: var(--text-muted); }
.next-card .lock { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }
a.next-card { color: inherit; text-decoration: none; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; }
a.next-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); text-decoration: none; }
.next-card .arrow { margin-left: auto; font-size: 1.4rem; color: var(--accent-dark); transition: transform 0.2s ease-out; }
a.next-card:hover .arrow { transform: translateX(4px); }

footer {
  padding: 2.5rem 0; text-align: center;
  font-size: 0.8rem; color: var(--text-muted);
  border-top: 1px solid var(--border); margin-top: 1rem;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
  .hero { padding: 3rem 0 2rem; }
  .hero-title { font-size: 2.1rem; }
  .hero-subtitle { font-size: 1rem; }
  h2.sec { font-size: 1.4rem; }
  header nav a:not(.nav-keep) { display: none; }
  .readout { margin-left: 0; width: 100%; }
}

/* ============================================================
   HUB MAP — the landing page's table of contents.
   A grid of chapter cards grouped into four "movements".
   All surfaces light; only the live Ch.1 card lifts on hover.
   ============================================================ */

/* --- movement / group heading --- */
.movement {
  display: flex; align-items: center; gap: 0.85rem;
  margin: 2.75rem 0 1.1rem;
}
.movement .mv-label {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-dark);
  white-space: nowrap;
}
.movement .mv-label .mv-roman {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 700;
  color: var(--accent); margin-right: 0.5rem;
  text-transform: none;
}
.movement .mv-rule {
  flex: 1; height: 1px; background: var(--border);
}

/* --- responsive card grid --- */
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}
@media (max-width: 600px) { .map-grid { grid-template-columns: 1fr; } }

/* --- a single chapter card --- */
.map-card {
  position: relative;
  display: flex; flex-direction: column; gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: 0 1px 3px var(--shadow);
  color: inherit;
}
.map-card .num {
  font-family: var(--mono); font-weight: 700; font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.map-card h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.18rem; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.2;
}
.map-card p {
  font-size: 0.9rem; color: var(--text-muted); line-height: 1.5;
  margin: 0;
}

/* --- the live Ch.1 card: accent edge + hover lift + "Start here" cue --- */
a.map-card {
  text-decoration: none;
  border-left: 3px solid var(--accent);
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}
a.map-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px var(--shadow);
  border-color: var(--accent);
  text-decoration: none;
}
a.map-card .num { color: var(--accent); }
.start-here {
  margin-top: 0.25rem;
  font-size: 0.82rem; font-weight: 600; color: var(--accent-dark);
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.start-here .arrow { transition: transform 0.2s ease-out; }
a.map-card:hover .start-here .arrow { transform: translateX(4px); }

/* --- "coming soon" cards: muted, dashed, no lift --- */
.map-card.soon {
  opacity: 0.72;
  border-style: dashed;
  background: var(--bg-sunken);
  box-shadow: none;
  cursor: default;
}
.badge-soon {
  align-self: flex-start;
  margin-top: 0.3rem;
  font-family: var(--mono); font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-secondary);
  background: var(--accent-secondary-light);
  border: 1px solid #e6d6ad;
  padding: 0.18rem 0.5rem; border-radius: 999px;
}

/* ============================================================
   THE FABRICATION DIAL — hub signature widget
   ============================================================ */
.fab-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.fab-sliderrow {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
}
.fab-sliderrow label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  white-space: nowrap;
}
.fab-range {
  flex: 1; min-width: 160px; accent-color: var(--accent);
  cursor: pointer;
}
.fab-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.fab-readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.fab-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.fab-stat .fab-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.fab-stat .fab-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700;
  color: var(--accent-dark);
}
.fab-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.fab-caption strong { color: var(--accent-dark); }

/* ===== ch01 widget rules (added by chapter agent) ===== */

/* --- Ch.1 next-card points back to the hub: flip the arrow left --- */
a.next-card:hover .arrow { transform: translateX(4px); }

/* --- Widget 2: the Fabrication Dial (applied to one worry) --- */
.fd2-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.fd2-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.fd2-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.fd2-range { flex: 1; min-width: 160px; accent-color: var(--accent); cursor: pointer; }
.fd2-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.fd2-readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.fd2-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.fd2-stat .fd2-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.fd2-stat .fd2-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
}
.fd2-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.fd2-caption strong { color: var(--accent-dark); }

/* --- Widget 3: the Path of Looking — focusable stops --- */
.pol-stop { outline: none; }
.pol-stop:focus-visible circle { stroke: var(--accent-secondary); stroke-width: 4; }
.pol-stop:hover circle { stroke: var(--accent-dark); }


/* ===== ch02 widget rules ===== */
/* ===== Ch.2 — "What Is Insight?" widget rules (added by chapter agent) ===== */
/* Prefix c02- to avoid collisions. The shared sheet already supplies
   .widget / .controls / .btn / .readout / .code-card / .quiz / .next-card.
   These rules only cover this chapter's three bespoke SVG widgets. */

/* --- Widget 1: the Insight Meter — no extra DOM beyond shared classes --- */
/* (toggle buttons reuse .btn / .btn.primary / .btn.active; nothing to add) */

/* --- Widget 2: the Repeat Loop — steppable cycle nodes --- */
.c02-loop .rl-node { transition: fill 0.18s ease-out, stroke 0.18s ease-out; }
#rl-marker { transition: cx 0.3s ease-out, cy 0.3s ease-out; }
#rl-meter { transition: width 0.3s ease-out, fill 0.3s ease-out; }

/* --- Widget 3: the Depth Ladder — focusable / clickable rungs --- */
.dl-rung { outline: none; }
.dl-rung rect { transition: fill 0.18s ease-out, stroke 0.18s ease-out; }
.dl-rung:hover rect { stroke: var(--accent-dark); }
.dl-rung:focus-visible rect { stroke: var(--accent-secondary); stroke-width: 4; }

/* --- Insight Meter bar: smooth the width/colour change --- */
#im-meter { transition: width 0.3s ease-out, fill 0.3s ease-out; }

/* --- Respect reduced motion: kill the widget transitions --- */
@media (prefers-reduced-motion: reduce) {
  .c02-loop .rl-node,
  #rl-marker, #rl-meter, #im-meter,
  .dl-rung rect {
    transition: none !important;
  }
}


/* ===== ch03 widget rules ===== */
/* ===== ch03 widget rules (added by chapter agent) ===== */

/* --- shared dial layout for all three Ch.3 widgets --- */
.c03-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.c03-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.c03-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.c03-range { flex: 1; min-width: 160px; accent-color: var(--accent); cursor: pointer; }
.c03-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.c03-readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.c03-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.c03-stat .c03-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.c03-stat .c03-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
}
.c03-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.c03-caption strong { color: var(--accent-dark); }


/* ===== ch04 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 4 widget styles
   "Samatha & Well-Being". Raw CSS, merged into the shared sheet
   later. Unique c04- prefix. Light surfaces only; reuses palette
   tokens from :root (never redefined here).
   ============================================================ */

/* --- Widget 1: Steeping in Pleasure — soak/fill slider --- */
.c04-soak { display: flex; flex-direction: column; gap: 0.6rem; }
.c04-soak-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.c04-soak-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.c04-range { flex: 1; min-width: 160px; accent-color: var(--accent-secondary); cursor: pointer; }
.c04-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.c04-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-secondary-light); border-radius: 8px;
  border-left: 3px solid var(--accent-secondary);
  font-size: 0.9rem; line-height: 1.5;
}
.c04-caption strong { color: var(--accent-dark); }

/* --- Widget 2: the Jhāna Ladder — focusable rungs --- */
.c04-rung { outline: none; }
.c04-rung:focus-visible circle { stroke: var(--accent-secondary); stroke-width: 4; }
.c04-rung:hover circle { stroke: var(--accent-dark); }
.c04-rung:hover line { stroke: var(--accent); }

/* --- gentle motion on the loop arc, disabled under reduced-motion --- */
#wl-arc { transition: opacity 0.25s ease-out; }
#wl-nodes circle { transition: fill 0.2s ease-out, stroke 0.2s ease-out; }
@media (prefers-reduced-motion: reduce) {
  #wl-arc, #wl-nodes circle { transition: none; }
}


/* ===== ch05 widget rules ===== */
/* ============================================================
   Chapter 5 — Mindfulness of Body & Energy
   Widget-specific styles. Prefix: c05-
   Reuses shared classes from style.css (.widget, .diagram,
   .controls, .btn, .readout, .code-card, .quiz-*, .next-card).
   Palette tokens only — no :root redefinition.
   ============================================================ */

/* Energy-body field: soft transition on the SVG nodes/halo so a
   manual render() looks smooth; the JS rAF tween still drives the
   real motion, this just polishes attribute snaps. */
#eb-svg #eb-field circle,
#eb-svg #eb-halo,
#eb-svg #eb-tense,
#eb-svg #eb-ease {
  transition: fill 0.4s ease, fill-opacity 0.4s ease;
}

/* Whole-body breath: gentle easing on the breathing field when
   stepping by hand (the continuous rAF loop overrides per-frame). */
#wb-svg #wb-breath {
  transition: rx 0.6s ease-in-out, ry 0.6s ease-in-out, opacity 0.6s ease-in-out;
}
#wb-svg #wb-phase {
  transition: opacity 0.3s ease;
}

/* Where clinging grips: zones ease between gripped/relaxed states. */
#cg-svg #cg-zones circle {
  transition: r 0.45s ease, fill 0.45s ease, fill-opacity 0.45s ease,
              stroke 0.45s ease, stroke-width 0.45s ease;
}
#cg-svg #cg-tag {
  transition: opacity 0.3s ease;
}

/* The hero's nested field rings — a barely-there breathing pulse,
   purely decorative and motion-gated below. */
.hero .c05-pulse {
  transform-origin: center;
  animation: c05-breathe 7s ease-in-out infinite;
}
@keyframes c05-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* ============================================================
   Reduced motion — kill every transition/animation introduced here.
   The widget JS already branches on prefers-reduced-motion to stop
   continuous loops; this guarantees the CSS layer is calm too.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  #eb-svg #eb-field circle,
  #eb-svg #eb-halo,
  #eb-svg #eb-tense,
  #eb-svg #eb-ease,
  #wb-svg #wb-breath,
  #wb-svg #wb-phase,
  #cg-svg #cg-zones circle,
  #cg-svg #cg-tag {
    transition: none !important;
  }
  .hero .c05-pulse {
    animation: none !important;
  }
}


/* ===== ch06 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 6 widget styles
   "Working with Craving & Aversion"
   Raw CSS, merged into style.css later. UNIQUE prefix: c06-
   Reuses shared palette tokens (:root in style.css); never
   redefines them. All surfaces light.
   ============================================================ */

/* --- Widget 1: the two engines — twin dials feeding one output --- */
.c06-te-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
}
.c06-te-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.c06-te-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 12.5em;
}
.c06-range {
  flex: 1;
  min-width: 150px;
  accent-color: var(--accent);
  cursor: pointer;
}
.c06-pct {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-dark);
  min-width: 3.2em;
  text-align: right;
}

/* --- shared caption block for the interactive widgets --- */
.c06-caption {
  margin-top: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--accent-light);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  line-height: 1.5;
}
.c06-caption strong { color: var(--accent-dark); }

/* --- ring-gauge arcs animate smoothly unless reduced motion --- */
#te-want-arc, #te-av-arc {
  transition: stroke-dashoffset 0.25s ease-out;
}
#te-out {
  transition: r 0.25s ease-out, fill-opacity 0.25s ease-out;
}

/* --- Widget 2: the second arrow — toggled resistance fades --- */
#sa-arrow2 {
  transition: opacity 0.3s ease-out;
}
#sa-meter, #te-meter, #mu-meter {
  transition: width 0.3s ease-out, fill 0.3s ease-out;
}

/* --- Widget 3: meeting the urge — grip opening / urge fading --- */
#mu-urge {
  transition: r 0.3s ease-out, fill-opacity 0.3s ease-out;
}
#mu-halo {
  transition: opacity 0.3s ease-out;
}

/* --- responsive: stack the engine labels above their sliders --- */
@media (max-width: 600px) {
  .c06-te-row label { min-width: 100%; }
}

/* === REDUCED MOTION — every widget honours the preference === */
@media (prefers-reduced-motion: reduce) {
  #te-want-arc, #te-av-arc, #te-out,
  #sa-arrow2, #sa-meter, #te-meter, #mu-meter,
  #mu-urge, #mu-halo {
    transition: none !important;
  }
}


/* ===== ch07 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 7 widget styles
   Impermanence (anicca). Raw CSS, merged into style.css later.
   Unique prefix: c07-  ·  all surfaces light, palette tokens
   reused, reduced-motion honoured.
   ============================================================ */

/* --- Ch.7 next-card points FORWARD: arrow slides right --- */
a.next-card:hover .arrow { transform: translateX(4px); }

/* --- Widget 2: the Grain Slider --- */
.c07-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.c07-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.c07-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.c07-row .c07-rlabel { text-align: right; }
.c07-range { flex: 1; min-width: 160px; accent-color: var(--accent); cursor: pointer; }
.c07-readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.c07-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.c07-stat .c07-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.c07-stat .c07-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
}
.c07-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.c07-caption strong { color: var(--accent-dark); }

/* --- Reduced motion: freeze widget transitions --- */
@media (prefers-reduced-motion: reduce) {
  .c07-range,
  a.next-card:hover .arrow { transition: none !important; }
}


/* ===== ch08 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 8 widget styles
   Dukkha & the Roots of Clinging. Raw CSS, merged into the
   shared sheet later. All surfaces LIGHT; palette tokens reused;
   unique c08- prefixes; no :root redefinition.
   ============================================================ */

/* --- Widget 1: Find the clinging — layer toggles + dukkha meter --- */
.c08-layers { display: flex; flex-direction: column; gap: 0.6rem; }
.c08-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.c08-layer-btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.c08-layer-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.c08-layer-btn .c08-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.12);
}
.c08-layer-btn[aria-pressed="true"] {
  background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark);
}
.c08-layer-btn[aria-pressed="false"] { opacity: 0.7; }
.c08-caption {
  margin-top: 0.4rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.c08-caption strong { color: var(--accent-dark); }

/* --- Widget 2: the clinging → dukkha link — dial + readout --- */
.c08-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.c08-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.c08-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.c08-range { flex: 1; min-width: 160px; accent-color: var(--accent); cursor: pointer; }
.c08-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.c08-readgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.c08-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.c08-stat .c08-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.c08-stat .c08-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
}

/* --- Widget 3: three flavours explorer — tabs + example panel --- */
.c08-flav-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.c08-flav-tab {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.c08-flav-tab:hover { border-color: var(--accent); color: var(--accent-dark); }
.c08-flav-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.c08-flav-tab.active:hover { background: var(--accent-dark); color: #fff; }
.c08-flav-panel {
  margin-top: 0.4rem; padding: 0.85rem 1rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.92rem; line-height: 1.55;
}
.c08-flav-panel .c08-flav-name {
  font-weight: 700; color: var(--accent-dark);
  display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.3rem;
}
.c08-flav-panel .c08-flav-pali {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500;
  color: var(--text-muted); font-style: italic;
}
.c08-flav-panel .c08-flav-eg {
  margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.88rem;
}
.c08-flav-panel .c08-flav-eg strong { color: var(--accent-dark); }


/* ===== ch09 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 9 (Not-Self) widget styles.
   Raw CSS, merged into style.css later. Unique prefix: c09-.
   All surfaces light; palette tokens reused from :root (NOT
   redefined here). prefers-reduced-motion handled per widget.
   ============================================================ */

/* --- Widget 3: object selector row --- */
.c09-pickrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.c09-pickrow label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  white-space: nowrap;
}

/* the released-ownership SVG elements ease gently between states */
#ap-tether, #ap-object, #ap-owner, #ap-halo {
  transition: opacity 0.4s ease-out, fill 0.4s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  #ap-tether, #ap-object, #ap-owner, #ap-halo { transition: none; }
}


/* ===== ch10 widget rules ===== */
/* ============================================================
   Seeing That Frees — Ch.10 "Dependent Arising" widget styles.
   Raw CSS, prefix c10-, to be merged into shared style.css later.
   Light surfaces only; palette tokens reused; no :root redefinition.
   ============================================================ */

/* --- Ch.10 next-card points forward: keep the arrow nudging right
   (overrides ch01's leftward override; this rule must follow it) --- */
a.next-card:hover .arrow { transform: translateX(4px); }

/* --- shared readout caption used under widgets --- */
.c10-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.c10-caption strong { color: var(--accent-dark); }

/* --- Widget 1: the web of conditions — focusable nodes --- */
.c10-node { cursor: pointer; outline: none; }
.c10-node circle { transition: opacity 0.35s ease-out, fill 0.2s ease-out; }
.c10-node:focus-visible circle { stroke: var(--accent-secondary); stroke-width: 4; }
.c10-node:hover circle { stroke: var(--accent-dark); }
.c10-edge { transition: opacity 0.35s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .c10-node circle, .c10-edge { transition: none; }
}

/* --- Widget 2: the chain — focusable links --- */
.c10-link { cursor: pointer; outline: none; }
.c10-link rect { transition: fill 0.2s ease-out, stroke 0.2s ease-out; }
.c10-link:focus-visible rect { stroke: var(--accent-secondary); stroke-width: 3; }
.c10-link:hover rect { stroke: var(--accent-dark); }
@media (prefers-reduced-motion: reduce) {
  .c10-link rect { transition: none; }
}

/* --- Widget 3: this because that — co-arising toggle --- */
.c10-coarise g { transition: opacity 0.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .c10-coarise g { transition: none; }
}


/* ===== ch11 widget rules ===== */
/* ============================================================
   Seeing That Frees — Chapter 11 (Emptiness) widget styles.
   Raw widget CSS only; merged into style.css later. All surfaces
   light; palette tokens reused from :root (defined in style.css).
   Unique prefix: c11-
   ============================================================ */

/* --- Ch.11 hero arrows: gentle fade so the rainbow doesn't shout --- */
.hero-arrows svg { opacity: 0.9; }

/* --- Widget 2: Doorways — caption + door styling --- */
.c11-dw-caption {
  margin-top: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--accent-light);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
.c11-dw-caption strong { color: var(--accent-dark); }

/* doors are SVG rects; nudge a soft transition (instant under reduced-motion) */
.c11-dw-door {
  transition: fill 0.18s ease-out, stroke 0.18s ease-out, stroke-width 0.18s ease-out;
}
#dw-beam {
  transition: opacity 0.25s ease-out;
}

/* --- Widget 1 & 3: soft transitions on the toggled SVG bits --- */
#ea-meter, #ea-scene {
  transition: width 0.3s ease-out;
}
#ee-orb, #ee-halo, #ee-pedestal, #ee-label {
  transition: fill 0.3s ease-out, fill-opacity 0.3s ease-out,
              opacity 0.3s ease-out, stroke-opacity 0.3s ease-out;
}

/* --- Reduced motion: kill all widget transitions in this chapter --- */
@media (prefers-reduced-motion: reduce) {
  .c11-dw-door,
  #dw-beam,
  #ea-meter,
  #ea-scene,
  #ee-orb,
  #ee-halo,
  #ee-pedestal,
  #ee-label {
    transition: none !important;
  }
  .hero-arrows svg { opacity: 0.9; }
}


/* ===== ch12 widget rules ===== */
/* ============================================================
   Seeing That Frees — Ch.12 widget styles
   Merged LATER into the shared sheet. Raw CSS only.
   All surfaces LIGHT; reuse palette tokens; prefix c12-.
   Do NOT redefine :root.
   ============================================================ */

/* --- Widget 2: Release the Looking — the watcher dial --- */
.c12-dial { display: flex; flex-direction: column; gap: 0.6rem; }
.c12-row { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.c12-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.c12-range { flex: 1; min-width: 160px; accent-color: var(--accent); cursor: pointer; }
.c12-pct {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: var(--accent-dark); min-width: 3.2em; text-align: right;
}
.c12-readout {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.55rem; margin-top: 0.6rem;
}
.c12-stat {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-sunken); padding: 0.55rem 0.7rem;
}
.c12-stat .c12-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.12rem;
}
.c12-stat .c12-v {
  font-family: var(--mono); font-size: 0.9rem; font-weight: 700; color: var(--accent-dark);
}
.c12-caption {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--accent-light); border-radius: 8px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem; line-height: 1.5;
}
.c12-caption strong { color: var(--accent-dark); }

/* --- Reduced motion: no transitions on any ch12 surface --- */
@media (prefers-reduced-motion: reduce) {
  .c12-range, .c12-stat, .c12-caption { transition: none !important; }
  #op-rings { transform: none !important; }
}

/* ============================================================
   FINALE next-card — the series is complete.
   ============================================================ */
.next-card.finale { background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light)); }
.next-card.finale .big { font-size: 2.2rem; }
.next-card.finale .t2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.35rem; }
