/* Atlas skin for shell v2 (shared). Link after tokens.css and stage.css. Style guide: v2/ART.md.
   A white page; the picture sits directly on it. No italics, no capitals set by CSS.
   Chrome is set in ink and hairlines and steps back from the illustration. */

html, body { background-color: var(--bg); }
body {
  background-image: var(--grain);
  color: var(--ink);
  font: var(--fw-regular) var(--fs-3) / 1.4 var(--font-ui);
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga";
}
::selection { background: var(--wash); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-s); }

.stage-root {
  align-content: start;
  max-width: 1180px;
  padding: 26px 40px 22px;
  gap: 10px;
}

/* ---------- Header: a quiet running head and the reader's question ---------- */
.st-top { align-items: flex-end; padding-bottom: 2px; flex-wrap: nowrap; }
/* a long title wraps inside its column; the tools keep their place at the right */
.st-id { flex: 1 1 auto; min-width: 0; }
.st-top .st-tools { flex: none; }
.st-title {
  font: var(--fw-regular) var(--fs-6) / 1.1 var(--font-text);
  font-variation-settings: "opsz" 48;
  letter-spacing: -0.012em;
  color: var(--ink);
}
.st-tools { gap: 18px; }
.st-tool {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0;
  font: var(--fw-medium) var(--fs-2) / 1 var(--font-ui);
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.st-tool::before {
  content: ''; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.st-tool:hover { color: var(--ink); }
.st-tool[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
/* The look picker (shared/looks.js): "Aa" and the look's name over a transparent native select */
.st-look { position: relative; }
.st-look::before { content: 'Aa'; width: auto; height: auto; background: none; -webkit-mask: none; mask: none; font: 600 13.5px / 1 var(--font-text); }
.st-look select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font: inherit; border: 0; }
.st-look:focus-within { color: var(--ink); outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--radius-s); }
.st-renderers { gap: 2px; border-right: 1px solid var(--line); padding-right: 14px; }
.st-renderers .st-seg { font-size: var(--fs-1); letter-spacing: var(--track-caps); }

/* ---------- Segments (renderer switch, choice controls): text tabs, ink underline ---------- */
.st-seg {
  background: none; border: 0; border-radius: 0;
  padding: 6px 2px 5px; margin-right: 12px;
  font: var(--fw-medium) var(--fs-2) / 1 var(--font-ui);
  color: var(--ink-3);
  cursor: pointer;
  box-shadow: inset 0 -1px 0 transparent;
  transition: color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.st-seg:hover { color: var(--ink-2); box-shadow: inset 0 -1px 0 var(--line-2); }
.st-seg.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.st-choice { gap: 0; }

/* ---------- Stage: no frame. The page continues behind the picture. ---------- */
.st-stage-wrap { background: var(--stage-bg); border-radius: 0; }
.st-stage > svg { overflow: visible; }

/* Badges: scale notes set like a figure annotation, not chips */
.st-badges { left: 2px; bottom: 6px; gap: 18px; }
.st-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font: var(--fw-regular) 14.5px / 1.2 var(--font-text);
  color: var(--ink-2);
  background: none; border: 0; padding: 0;
}
.st-badge::before { content: ''; width: 18px; height: 1px; background: var(--ink-3); }

/* Explore chip: a quiet note in the corner with a way back */
.st-explore {
  right: 0; top: 2px; gap: 14px;
  font: var(--fw-semibold) var(--fs-1) / 1 var(--font-ui);
  letter-spacing: var(--track-caps);
  color: var(--you);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  padding: 7px 4px 7px 12px; border-radius: var(--radius-pill);
}
.st-explore > span { display: inline-flex; align-items: center; gap: 7px; }
.st-explore > span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--you); box-shadow: 0 0 0 3px var(--you-soft); }
.st-back {
  background: none; border: 0; padding: 2px 8px; cursor: pointer;
  font: var(--fw-regular) 16px / 1 var(--font-text);
  letter-spacing: 0;
  color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--line-2); text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.st-back::before { content: '\2190\00a0'; text-decoration: none; display: inline-block; }
.st-back:hover { text-decoration-color: var(--ink); }
/* Phone: the chip leaves the stage and sits above the controls (shell moves it into the dock). */
.st-dock > .st-explore { position: static; align-self: flex-start; padding-left: 0; margin-bottom: -4px; background: none; }

.st-toast {
  top: 10px;
  background: var(--ink); color: var(--bg);
  font: var(--fw-regular) 15.5px / 1.3 var(--font-text);
  padding: 9px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}

/* ---------- Narrative: the caption is the sentence the picture illustrates ---------- */
.st-narrative { grid-template-columns: minmax(0, 1fr) 290px; gap: 56px; padding-top: 6px; border-top: 1px solid var(--line); }
/* Reserve three caption lines as the story changes. */
.st-text { min-height: calc(var(--fs-5) * var(--lh-text) * 3); padding-top: 10px; }
.st-caption {
  font: var(--fw-regular) var(--fs-5) / var(--lh-text) var(--font-text);
  font-variation-settings: "opsz" 24;
  color: var(--ink);
  max-width: 50ch;
  text-wrap: balance;
  hanging-punctuation: first;
}
.st-caption strong {
  font-weight: var(--fw-semibold);
  background: linear-gradient(transparent 58%, var(--wash) 58%, var(--wash) 90%, transparent 90%);
  padding: 0 1px;
  white-space: nowrap;
}

/* ---------- Controls: a ruler, a value set like a figure ---------- */
.st-dock { padding-top: 12px; gap: var(--space-5); }
.st-control { font-size: var(--fs-2); }
.st-control-head { align-items: baseline; margin-bottom: 6px; }
.st-control-head label {
  font: var(--fw-semibold) var(--fs-2) / 1 var(--font-ui);
  letter-spacing: var(--track-caps);
  color: var(--ink-2);
}
.st-control-val {
  font: var(--fw-regular) 24px / 1 var(--font-text);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
}
.st-control input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 30px; margin: 0; background: none; cursor: pointer;
}
.st-control input[type=range]::-webkit-slider-runnable-track {
  height: 30px;
  background:
    linear-gradient(var(--ink-3), var(--ink-3)) 0 50% / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, var(--line-2) 0 1px, transparent 1px 10%) 0 9px / calc(100% - 1px) 5px no-repeat,
    linear-gradient(90deg, var(--ink-3) 0 1px, transparent 1px calc(100% - 1px), var(--ink-3) calc(100% - 1px)) 0 7px / 100% 16px no-repeat;
}
.st-control input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: 6px; border-radius: 50%;
  background: radial-gradient(circle, var(--ink) 0 3px, var(--paper-light) 3.5px);
  border: 1.5px solid var(--ink);
  box-shadow: 0 1px 3px rgba(74, 52, 30, 0.28);
  transition: transform var(--dur-fast) var(--ease-out);
}
.st-control input[type=range]:hover::-webkit-slider-thumb,
.st-control input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }
.st-control input[type=range]::-moz-range-track { height: 1px; background: var(--ink-3); }
.st-control input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--paper-light); border: 1.5px solid var(--ink); }
.st-control-toggle input { accent-color: var(--ink); width: 18px; height: 18px; }
.st-hint { font: var(--fw-regular) 15px / 1.35 var(--font-text); color: var(--ink-3); margin-top: 6px; }

/* ---------- Navigation: three glyph buttons and a table of contents ---------- */
.st-nav { gap: 6px; padding-top: 4px; }
.st-navbtn {
  width: 34px; height: 34px; flex: none; padding: 0;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: none;
  font: 400 24px / 1 var(--font-text); color: var(--ink-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.st-navbtn:hover { background: var(--surface-2); color: var(--ink); }
.st-play {
  width: 38px; height: 38px; margin: 0 2px;
  background: var(--ink); color: var(--bg);
  font: 400 12px / 1 var(--font-ui); letter-spacing: -0.06em;
  box-shadow: var(--shadow-1);
}
.st-play svg { display: block; }
.st-play:hover { background: var(--ink-2); color: var(--bg); }
.st-progress { gap: 10px; margin-left: 14px; align-self: stretch; }
.st-seg-step { height: 50px; }
.st-seg-step::before { top: 7px; height: 2px; border-radius: 1px; background: var(--track); }
.st-fill { top: 7px; height: 2px; border-radius: 1px; background: var(--track-fill); }
.st-seg-label {
  position: absolute; left: 0; right: 0; top: 17px;
  font: var(--fw-medium) var(--fs-1) / 1.2 var(--font-ui);
  color: var(--ink-3); text-align: left;
  white-space: normal; overflow-wrap: break-word; hyphens: auto; text-wrap: balance;
  transition: color var(--dur-fast) var(--ease);
}
.st-seg-step:hover .st-seg-label { color: var(--ink-2); }
.st-seg-step.on .st-seg-label { color: var(--ink); font-weight: var(--fw-semibold); }

/* ---------- Hot spots: hover, focus or tap feedback, and the tooltip ---------- */
/* Faded-out elements (opacity 0 to 0.09, as the kit writes it) never catch the pointer, so an invisible mark
   can't block a visible hot spot beneath it. */
[opacity="0"], [opacity^="0.0"] { pointer-events: none; }
/* Only the hover filter animates. Renderers set opacity every frame, so a transition on it would lag the story. */
[data-tip] { transition: filter var(--dur-fast) var(--ease); }
[data-tip].is-hot { filter: brightness(1.06) saturate(1.12) drop-shadow(0 0 0.8px color-mix(in oklab, var(--ink) 55%, transparent)) drop-shadow(0 3px 8px rgba(43, 36, 30, 0.14)); }
.k-label[data-tip].is-hot, [data-tip].is-hot .k-label { fill: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.st-tip {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 8px 11px 9px;
  font: var(--fw-regular) 14px / 1.35 var(--font-ui);
}
.st-tip-title { font: var(--fw-semibold) 14px / 1.3 var(--font-ui); margin-bottom: 2px; }
.st-count {
  font: var(--fw-regular) 15px / 1 var(--font-text);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink-3); min-width: 3.2em; margin-left: 8px;
}

/* ---------- SVG text roles used by kit.js ---------- */
.k-text { font: var(--type-label); fill: var(--ink); }
.k-halo { paint-order: stroke fill; stroke: var(--halo); stroke-width: 4.5px; stroke-linejoin: round; stroke-linecap: round; }
.k-label { font: var(--type-label); fill: var(--ink); letter-spacing: 0.005em; }
.k-label.em { font: var(--type-label-em); }
.k-label.you { fill: var(--you); }
.k-sub { font: var(--type-sub); fill: var(--ink-2); }
.k-tick { font: var(--type-tick); fill: var(--ink-3); font-variant-numeric: lining-nums tabular-nums; }
.k-axis { font: var(--type-axis); fill: var(--ink-2); }
.k-status { font: var(--type-status); letter-spacing: var(--track-caps); }
.k-hero { font: var(--type-hero); fill: var(--ink); font-variant-numeric: lining-nums; font-variation-settings: "opsz" 72; letter-spacing: -0.02em; }
.k-unit { font: var(--type-unit); fill: var(--ink-2); }
.k-node { font: var(--type-node); fill: var(--ink); }
.k-you { font: 700 14px var(--font-ui); fill: var(--you); letter-spacing: 0.02em; }
.k-leader { stroke: var(--ink-2); stroke-width: var(--leader); fill: none; stroke-linecap: round; }
.k-pin { fill: var(--ink); stroke: var(--halo); stroke-width: 1.5px; }
.k-pin.you { fill: var(--you); }
.k-bracket { fill: none; stroke: var(--ink-3); stroke-width: 1.1px; stroke-linecap: round; stroke-linejoin: round; }
.k-note { font: 400 13.5px var(--font-text); fill: var(--ink-3); }

/* Performance: while a big zoom or transform is in motion (kit setMotion) or on slow
   devices (installDefs quality 'fast'), drop the rim-shading and cast-shadow filters.
   The CSS property wins over the filter attribute, so nothing is re-rendered. */
.k-moving .k-form, .k-fast .k-form, .k-moving .k-cast, .k-fast .k-cast, .k-moving .k-soft-light, .k-fast .k-soft-light { filter: none !important; }

/* ---------- Phone: designed, not shrunk ---------- */
@media (max-width: 760px) {
  .stage-root { padding: 18px 16px 18px; gap: 8px; position: relative; }
  .st-title { font-size: 23px; padding-right: 0; }
  .st-tools { gap: 12px; position: absolute; top: 14px; right: 16px; }
  .st-look { display: none; } /* phone: pick a look from the gallery; the choice carries over */
  /* Only pages with a 2D/3D switch reserve space beside the title. */
  .st-renderers { padding-right: 10px; }
  .st-renderers .st-seg { margin-right: 8px; }
  .stage-root:has(.st-renderers:not([hidden])) .st-title { padding-right: 112px; }
  .st-narrative { grid-template-columns: 1fr; gap: 12px; }
  .st-progress { align-self: center; }
  .st-seg-step::before, .st-seg-step .st-fill { top: 11px; }
  .st-text { padding-top: 8px; }
  .st-caption { font-size: 19.5px; }
  .st-caption strong { white-space: normal; }
  .st-dock { padding-top: 0; }
  .st-progress { gap: 6px; margin-left: 8px; }
  .st-seg-step { height: 24px; }
  .st-seg-label { display: none; }
  .st-badge { font-size: 14px; }
}

/* Keep lesson controls visible at every scroll position and above phone safe areas. */
.stage-root { padding-bottom: calc(var(--st-nav-height, 84px) + 24px); }
.stage-root > .st-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 10px 40px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg); border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
  .stage-root > .st-nav {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}
