/* =============================================================================
   lesson-shell.css — the step-through shell: a scene behind, a glass panel
   over it, progress dots in the top bar, Back and Next at the panel's foot.

   Chrome for kit/lesson-shell.js and nothing else. Ported from the tree
   prototype's stylesheet, which is the look user-generated apps take. Loaded
   after kodo.css; the tokens below are the shell's own and do not retheme
   the site sheet. `body.lshell-page` is set by the shell; `body.is-night` by
   a page whose scene has a night.
   ========================================================================== */
body.lshell-page {
  --bg: #f4f2ec;
  --ink: #17181a;
  --ink-2: #55585e;
  --ink-3: #9a9da3;
  --line: #e3e0d7;
  --panel: rgba(255, 255, 255, 0.86);
  /* THE SHELL'S OWN GREEN, AND IT IS NOT THE SITE ACCENT. kodo.css's #1f5f4f is
     a deep green for type and buttons on flat paper; this one is brighter
     because everything it marks sits over a lit 3D scene, where the deep green
     goes to a hole. Kept separate on purpose after the two were unified once
     and looked at side by side. Do not point it at --green-700. */
  --accent: #2d6a3e;
  --accent-soft: #eaf3ec;
  --air: #3b4252;
  --water: #2f6fb5;
  --o2: #6fb3d9;
  --soil: #b0702e;
  --sun: #e8b32b;
  --on-bg: var(--ink);
  /* The corner a callout takes in this room. annotate.css is shared with the
     site sheet, which flattens to 4px; here everything is rounded. */
  --annot-radius: 14px;
  --display: "Futura", "Futura PT", "Jost", system-ui, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  transition: background 1s ease;
  -webkit-font-smoothing: antialiased;
}
body.lshell-page.is-night { --bg: #232735; --on-bg: #f4f2ec; }

.lshell-stage { position: fixed; inset: 0; }
.lshell-stage canvas { display: block; touch-action: none; }

/* One box per component, stacked full-bleed, one shown at a time. Hidden with
   `visibility` so a component keeps its size and last frame and comes back
   without a resize; the shell stops it, which is what makes it free. */
.lshell-scene { position: absolute; inset: 0; }
.lshell-scene.is-off { visibility: hidden; pointer-events: none; }

/* Several at once, for a template with a layout: equal columns, and a hidden
   one leaves the row rather than holding an empty column. */
.lshell-stage.is-split { display: flex; }
.lshell-stage.is-split > .lshell-scene { position: relative; inset: auto; flex: 1 1 0; min-width: 0; }
.lshell-stage.is-split > .lshell-scene.is-off { display: none; }

/* ---------- top bar ---------- */
.lshell-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; pointer-events: none; z-index: 5; color: var(--on-bg);
  transition: color 1s ease;
}
.lshell-brand { font-family: var(--display); font-weight: 500; letter-spacing: 0.04em; font-size: 15px; }
.lshell-progress { display: flex; gap: 6px; pointer-events: auto; }
.lshell-progress button {
  width: 8px; height: 8px; border-radius: 4px; border: 0; padding: 0;
  background: currentColor; opacity: 0.25; cursor: pointer;
  transition: width 0.35s cubic-bezier(.2,.7,.2,1), opacity 0.3s, background 0.3s;
}
.lshell-progress button.is-done { opacity: 0.6; }
.lshell-progress button.is-current { width: 28px; opacity: 1; background: var(--accent); }
body.is-night .lshell-progress button.is-current { background: #9fd98a; }

/* ---------- panel ---------- */
.lshell-panel {
  position: fixed; left: 24px; top: 76px; bottom: 24px;
  width: min(430px, calc(100vw - 48px));
  display: flex; flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 24px;
  box-shadow: 0 30px 70px -40px rgba(20,30,20,0.45), 0 1px 0 rgba(0,0,0,0.03);
  z-index: 4;
}
.lshell-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 36px 36px 16px; scrollbar-width: none; -ms-overflow-style: none; }
.lshell-scroll::-webkit-scrollbar { width: 0; height: 0; }
.lshell-scroll.swap > * { animation: lshell-rise 0.55s cubic-bezier(.2,.7,.2,1) both; }
.lshell-scroll.swap > *:nth-child(2) { animation-delay: 0.05s; }
.lshell-scroll.swap > *:nth-child(3) { animation-delay: 0.10s; }
.lshell-scroll.swap > *:nth-child(4) { animation-delay: 0.16s; }
.lshell-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px 18px; border-top: 1px solid var(--line);
}
.lshell-count { font-family: var(--display); font-size: 12px; letter-spacing: 0.12em; color: var(--ink-3); }

/* ---------- typography ---------- */
.lshell-panel .eyebrow {
  font-family: var(--display); font-weight: 500; font-size: 12px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px;
}
.lshell-panel .title {
  font-family: var(--display); font-weight: 500;
  font-size: clamp(28px, 2.6vw, 38px); line-height: 1.08; letter-spacing: -0.012em;
  margin: 0 0 20px; text-wrap: balance;
}
.lshell-panel .body { font-family: var(--serif); font-size: 17px; line-height: 1.55; color: #2a2c30; font-optical-sizing: auto; }
.lshell-panel .body p { margin: 0 0 14px; }
/* 600, not 500: Literata is loaded at 400 and 600 only (kodo.css's @import),
   and a 500 renders identically to the body weight — every <strong> in a
   lesson's copy was reading as plain text. Jost has a 500 and the display
   type below uses it; the serif does not. */
.lshell-panel .body strong { font-weight: 600; }
/* THE ROLES A PARAGRAPH CAN TAKE, and the whole list of them: `lead` here,
   `callout` and `foot` below, plus strong and em inside a line. The panel has
   no size, weight or colour a page may set — a lesson says what a paragraph
   IS and the shell decides how that reads, which is what keeps a generated
   app and a hand-built one in one voice. Components.md hands the model the
   same four names, and the builder's text mode offers them on a selection. */
.lshell-panel .body .lead { font-size: 19px; line-height: 1.45; color: var(--ink); margin-bottom: 16px; }
.lshell-panel .body .callout { margin: 0 0 14px; }
.lshell-panel .body .foot { margin: 0 0 14px; }
.lshell-panel .controls { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- buttons ---------- */
.lshell-panel .btn {
  font-family: var(--display); font-weight: 500; font-size: 15px; letter-spacing: 0.02em;
  border-radius: 999px; padding: 11px 22px; border: 1px solid transparent; cursor: pointer;
  transition: transform 0.15s, background 0.2s, opacity 0.3s, border-color 0.2s;
}
.lshell-panel .btn.primary { background: var(--ink); color: #fff; }
.lshell-panel .btn.primary:hover { background: #000; transform: translateY(-1px); }
.lshell-panel .btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.lshell-panel .btn.ghost:hover { border-color: var(--ink-3); }
.lshell-panel .btn.secondary { background: var(--accent); color: #fff; align-self: flex-start; }
.lshell-panel .btn.secondary:hover { background: #245832; transform: translateY(-1px); }
.lshell-panel .btn:disabled { opacity: 0.3; cursor: default; transform: none !important; }

.lshell-panel .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lshell-panel .choice {
  font-family: var(--display); font-size: 17px; font-weight: 500; padding: 18px 14px;
  border-radius: 14px; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s;
}
.lshell-panel .choice:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.lshell-panel .choice.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.lshell-panel .callout {
  font-family: var(--serif); font-size: 15px; line-height: 1.5; padding: 14px 16px;
  border-left: 3px solid var(--accent); background: #f1f6f0; border-radius: 0 12px 12px 0; color: #2a2c30;
}
.lshell-panel .callout strong { font-weight: 600; }   /* the serif's real bold, as above */
.lshell-panel .callout.night { border-color: var(--air); background: #eef0f4; }

/* ---------- sliders & stats ---------- */
.lshell-panel .slider { display: flex; flex-direction: column; gap: 10px; }
.lshell-panel .slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.lshell-panel .label {
  font-family: var(--display); font-weight: 500; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2);
}
.lshell-panel .value { font-family: var(--display); font-weight: 500; font-size: 15px; font-variant-numeric: tabular-nums; }
.lshell-panel input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: none; margin: 4px 0; outline: none; cursor: pointer;
}
/* Track and thumb are drawn on the pseudo-elements, never on the input itself:
   Safari centres the thumb on the runnable track, so a track painted as the
   input's own background leaves the thumb sitting off the bar. */
.lshell-panel input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p, 0%) 100% no-repeat, var(--line);
}
.lshell-panel input[type=range]::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p, 0%) 100% no-repeat, var(--line);
}
.lshell-panel input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.18); cursor: grab;
  margin-top: -8px;   /* (track 4 - thumb 20) / 2 */
}
.lshell-panel input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; box-sizing: border-box;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.18); cursor: grab;
}
.lshell-panel input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; }
.lshell-panel input[type=range]:active::-moz-range-thumb { cursor: grabbing; }

.lshell-panel .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lshell-panel .stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.lshell-panel .stat-label { font-family: var(--display); font-weight: 500; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.lshell-panel .stat-value { font-family: var(--display); font-size: 22px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lshell-panel .stat-sub { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lshell-panel .stat.accent { border-color: var(--accent); background: var(--accent-soft); }
.lshell-panel .stat.accent .stat-value { color: var(--accent); }

/* ---------- toggles ---------- */
.lshell-panel .row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lshell-panel .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lshell-panel .chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; font-family: var(--display); font-size: 14px;
  font-weight: 500; cursor: pointer; color: var(--ink-2); transition: border-color 0.2s, color 0.2s;
}
.lshell-panel .chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: 0.3; transition: opacity 0.2s; }
.lshell-panel .chip.is-on { border-color: var(--ink); color: var(--ink); }
.lshell-panel .chip.is-on i { opacity: 1; }
/* ---------- .segmented ----------
   ONE CONTROL, N ANSWERS. Chips are the wrong control for that — a chip is a thing
   you turn on and off beside other things you can also turn on, and a row of
   them cannot say "these three are the same question".

   PILLS IN A TRAY, NOT SLICES OF A BAR. The wrapper is the group; the chosen
   answer is a pill floating inside it, the same capsule shape as .chip and
   .btn, so a panel has one button vocabulary instead of two.
*/
.lshell-panel .segmented {
  display: inline-flex; align-self: flex-start; gap: 2px; padding: 4px;
  /* 32 + 8 padding + 2 border = 42, the height of .btn beside it. */
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.lshell-panel .segmented > * {
  border: 0; padding: 7px 16px; border-radius: 999px; background: transparent; color: var(--ink-2);
  font-family: var(--display); font-size: 14px; font-weight: 500; line-height: 18px;
  /* STATED, NOT INHERITED: kodo.css loads first and its own .segmented shouts
     in uppercase with wide tracking. Its `.segmented > *` matches these
     elements too, so anything this rule does not say, that one still says. */
  text-transform: none; letter-spacing: 0.02em;
  white-space: nowrap; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.lshell-panel .segmented > *:hover:not([disabled]):not(.is-on):not([aria-pressed="true"]) { background: var(--paper); color: var(--ink); }
.lshell-panel .segmented > *.is-on,
.lshell-panel .segmented > *[aria-pressed="true"] { background: var(--accent); color: #fff; }
/* Inside, because an outline on a pill in a tray draws over the tray's edge. */
.lshell-panel .segmented > *:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px var(--ink); }
.lshell-panel .segmented > *[disabled] { opacity: 0.35; cursor: default; }
/* THE CHOSEN ONE IS NOT DIMMED. A control that disables the current answer to
   stop it being re-pressed would otherwise draw the fill at 35% and read as
   the segment least available rather than the one in force. */
.lshell-panel .segmented > *.is-on[disabled],
.lshell-panel .segmented > *[aria-pressed="true"][disabled] { opacity: 1; }

/* NO SCRIPT NEEDED WHEN THE CONTROL IS THE ANSWER. A radio per segment and a
   label for each, and the browser owns which one is chosen — arrow keys, the
   name group, the form value, all of it, for free:

     <div class="segmented">
       <input type="radio" name="view" id="v-a" checked><label for="v-a">Atoms</label>
       <input type="radio" name="view" id="v-b"><label for="v-b">Ribbon</label>
     </div>

   Use buttons and `.is-on` instead when the control is a VIEW of something
   that can move underneath it — a value a tween or another control also
   writes, or one that can sit between the named answers, where the honest
   drawing is no segment lit at all. A radio cannot say none-of-these. */
.lshell-panel .segmented > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.lshell-panel .segmented > input[type="radio"]:checked + label { background: var(--accent); color: #fff; }
.lshell-panel .segmented > input[type="radio"]:focus-visible + label { box-shadow: inset 0 0 0 2px var(--ink); }

.lshell-panel .switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-family: var(--display); font-weight: 500; font-size: 14px; position: relative; }
.lshell-panel .switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.lshell-panel .track { width: 44px; height: 26px; border-radius: 13px; background: #cfd2d8; position: relative; transition: background 0.25s; flex: none; }
.lshell-panel .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.25s cubic-bezier(.2,.7,.2,1);
}
.lshell-panel .switch input:checked + .track { background: var(--sun); }
.lshell-panel .switch input:checked + .track::after { transform: translateX(18px); }
.lshell-panel .switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.lshell-panel .equation { padding: 16px 18px; border-radius: 14px; background: var(--ink); color: #fff; }
.lshell-panel .eq-line { font-family: var(--display); font-size: 18px; font-weight: 500; letter-spacing: 0.02em; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.lshell-panel .eq-line .arrow { opacity: 0.6; }
.lshell-panel .t-air { color: #c3cbda; } .lshell-panel .t-water { color: #8fbdf2; } .lshell-panel .t-sugar { color: #9fd98a; } .lshell-panel .t-o2 { color: #ffffff; }
.lshell-panel .eq-caption { font-family: var(--serif); font-size: 13px; opacity: 0.7; margin-top: 8px; }
.lshell-panel .hint-text { font-size: 13px; color: var(--ink-2); margin: 0; }

.lshell-panel .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: #fff; align-self: flex-start; }
.lshell-panel .seg button {
  border: 0; background: transparent; font-family: var(--display); font-weight: 500; font-size: 13px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-2); transition: background 0.2s, color 0.2s;
}
.lshell-panel .seg button.is-on { background: var(--ink); color: #fff; }

.lshell-panel .legend { display: flex; flex-direction: column; gap: 10px; }
.lshell-panel .legend-row { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.lshell-panel .legend-name { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 500; }
.lshell-panel .legend-name i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.lshell-panel .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.lshell-panel .bar i { display: block; height: 100%; background: var(--c); width: var(--w); transition: width 0.9s cubic-bezier(.2,.7,.2,1); }
.lshell-panel .legend-pct { font-family: var(--display); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.lshell-panel .foot { font-size: 12px; color: var(--ink-3); line-height: 1.45; margin: 0; }

.lshell-panel .is-hidden { display: none !important; }
.lshell-panel .rise { animation: lshell-rise 0.5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes lshell-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- labels a scene pins to a 3D point ---------- */
.lshell-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lshell-labels > * { position: absolute; transform: translate(-50%, -50%); }
.pile-label { text-align: center; color: var(--on-bg); transition: color 1s; animation: lshell-fadein 0.8s both; white-space: nowrap; }
@keyframes lshell-fadein { from { opacity: 0; } to { opacity: 1; } }
.pile-pct { display: block; font-family: var(--display); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; line-height: 1; }
.pile-name { display: block; font-family: var(--display); font-weight: 500; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px; }
.pile-sub { display: block; font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.lshell-hint {
  position: fixed; right: 28px; bottom: 24px; font-size: 11px; color: var(--on-bg); opacity: 0.55;
  font-family: var(--display); letter-spacing: 0.14em; text-transform: uppercase; transition: opacity 1s, color 1s; pointer-events: none;
}
.lshell-hint.is-faded { opacity: 0; }

@media (max-width: 760px) {
  .lshell-panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 54vh; border-radius: 22px 22px 0 0; }
  .lshell-scroll { padding: 24px 22px 12px; }
  .lshell-panel .title { font-size: 26px; }
  .lshell-panel .body { font-size: 16px; }
  .lshell-hint { display: none; }
  .lshell-topbar { padding: 0 18px; }
}

/* A shell with nowhere to go: no Back/Next, no dots, and the panel's scroll
   takes the room they leave. kit/sandbox-shell.js asks for this. */
.lshell.lshell-bare .lshell-nav,
.lshell.lshell-bare .lshell-progress { display: none; }
