/* Lesson expansion (partials/lesson-exploration.php, js/lesson/exploration.js): the second look at the idea after the film.
   The diagram stands on a night plate like the film's (always dark, in its subject hue) with the key idea beside it; under
   them the worked example, stepped one line at a time on a rail of numbered planets, and "Your turn", a question whose
   answer waits behind one button. Glass cards, tokens only; motion plays once and stops under reduced motion. */
.exploration { container-type: inline-size; margin-block: var(--sp-8) var(--sp-7); min-width: 0; max-width: 1120px; scroll-margin-top: 5rem; }
.ex-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.ex-head h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.9rem); text-wrap: balance; }
.ex-head__orb, .ex-ico {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--ico, var(--tint)), var(--lit-hi) 45%) 0, var(--ico, var(--tint)) 50%, color-mix(in srgb, var(--ico, var(--tint)), var(--bg) 55%) 100%);
  color: var(--on-hue);
  box-shadow: 0 0 16px -4px color-mix(in srgb, var(--ico, var(--tint)) 70%, transparent), inset 0 1px 0 color-mix(in srgb, var(--lit-hi) 45%, transparent);
}
.ex-head__orb { width: 40px; height: 40px; }
.ex-head__orb svg { width: 20px; height: 20px; }
.ex-ico { width: 28px; height: 28px; }
.ex-ico svg { width: 15px; height: 15px; }
.ex-ico--cyan { --ico: var(--cyan); }
.ex-ico--violet { --ico: var(--violet); }
.ex-ico--ok { --ico: var(--green); }
.ex-ico--quiet { --ico: var(--surface-3); color: var(--text-2); box-shadow: inset 0 1px 0 var(--glass-hi); }

.ex-panel { display: grid; gap: var(--sp-4); min-width: 0; }
.ex-panel__h { margin: 0; font-size: 1.2rem; }
.ex-board { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); min-width: 0; }
@container (min-width: 860px) { .ex-board { grid-template-columns: minmax(0, 1.7fr) minmax(250px, 1fr); align-items: stretch; } }

/* The plate: a night window lit from below in the subject hue, the diagram on it and its caption in a band at the foot. */
.ex-plate {
  margin: 0; min-width: 0; display: grid; grid-template-rows: 1fr auto; overflow: hidden; border-radius: var(--r-lg);
  color: var(--text);
  background-image: radial-gradient(110% 70% at 50% 118%, color-mix(in srgb, var(--tint) 24%, transparent), transparent 64%), var(--stardust), linear-gradient(180deg, color-mix(in srgb, var(--tint) 6%, var(--bg-raised)), var(--bg));
  background-size: auto, 180px 180px, auto; background-repeat: no-repeat, repeat, no-repeat;
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 color-mix(in srgb, var(--tint) 32%, transparent), var(--glass-shadow);
}
/* Margin, not padding: exploration.js draws at the board's clientWidth, which must be the width the SVG is shown at. */
.exploration__diagram { min-width: 0; min-height: 6rem; margin: clamp(var(--sp-3), 2.4cqw, var(--sp-5)); align-self: center; }
.exploration__diagram svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-ui); }
.exploration__fallback { margin: 0; padding: var(--sp-4); color: var(--text-2); font-size: .9rem; overflow-wrap: anywhere; }
.exploration__fallback[hidden] { display: none; }
.ex-plate__cap {
  margin: 0; padding: var(--sp-3) clamp(var(--sp-4), 2.4cqw, var(--sp-5)) var(--sp-4);
  font-family: var(--font-read); font-size: 1.02rem; line-height: 1.55; color: var(--text-2); text-wrap: pretty;
  background: color-mix(in srgb, var(--bg-raised) 72%, transparent); box-shadow: inset 0 1px 0 var(--glass-hi);
}
/* Diagram marks (exploration-diagrams.js): notation in the reading serif, numbers in mono, faint scaffolding, lit marks. */
.exploration__diagram .ex-m { font-family: var(--font-read); }
.exploration__diagram .ex-num { font-family: var(--font-mono); }
.exploration__diagram .ex-grid { stroke-opacity: .08; stroke-width: 1; }
.exploration__diagram .ex-curve { filter: drop-shadow(0 0 4px color-mix(in srgb, currentColor 70%, transparent)); }
.exploration__diagram .ex-bar { filter: drop-shadow(0 0 7px color-mix(in srgb, currentColor 50%, transparent)); }
.exploration__diagram .ex-lit { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--cyan) 60%, transparent)); }
.explore-halo { paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }

/* The dial of a plot with a parameter: on the plate, between the diagram and its caption. */
.ex-dial { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--sp-2) var(--sp-3); align-items: center; padding: 0 clamp(var(--sp-4), 2.4cqw, var(--sp-5)) var(--sp-4); }
.ex-dial label { font-weight: 600; color: var(--text); }
.ex-dial output { font-size: .95rem; color: var(--tint); }
.ex-dial input { grid-column: 1 / -1; width: 100%; height: 2rem; accent-color: var(--cyan); }
.ex-dial input:focus-visible { outline: 2px solid var(--bone); outline-offset: 4px; }
.ex-dial button { grid-row: 1; grid-column: 3; }

/* Cards: the key idea, the worked example, your turn. */
.ex-idea, .ex-card { min-width: 0; padding: clamp(var(--sp-4), 3cqw, var(--sp-5)); display: grid; gap: var(--sp-3); align-content: start; }
.ex-card__h { display: flex; align-items: center; gap: var(--sp-3); margin: 0; font-family: var(--font-ui); font-size: 1rem; font-weight: 650; color: var(--text); }
.ex-idea__text { margin: 0; font-family: var(--font-read); font-size: 1.12rem; line-height: 1.62; color: var(--text); text-wrap: pretty; overflow-wrap: anywhere; }
.ex-idea { grid-template-rows: auto 1fr auto; }

.ex-work { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); min-width: 0; }
@container (min-width: 760px) { .ex-work { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; } }

.exploration summary { cursor: pointer; list-style: none; }
.exploration summary::-webkit-details-marker { display: none; }
.exploration summary:focus-visible { outline: 2px solid var(--bone); outline-offset: 4px; border-radius: var(--r-sm); }
.ex-example > summary { cursor: default; }
.ex-example__problem { margin: 0; font-family: var(--font-read); font-size: 1.08rem; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }

/* The rail of steps: a planet per step joined by a thin line in the subject hue; the result is a green planet with a tick. */
.ex-steps { list-style: none; margin: var(--sp-1) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.ex-step { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: var(--sp-3); align-items: start; padding-block: var(--sp-1); }
.ex-step:not(:last-child)::before { content: ""; position: absolute; left: 14px; top: 34px; bottom: calc(-1 * var(--sp-2) - 2px); width: 2px; background: linear-gradient(180deg, color-mix(in srgb, var(--tint) 55%, transparent), color-mix(in srgb, var(--tint) 18%, transparent)); }
.ex-step__n {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: .82rem; font-weight: 700; color: var(--on-hue);
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--tint), var(--lit-hi) 45%) 0, var(--tint) 52%, color-mix(in srgb, var(--tint), var(--bg) 50%) 100%);
  box-shadow: 0 0 12px -4px color-mix(in srgb, var(--tint) 75%, transparent), inset 0 1px 0 color-mix(in srgb, var(--lit-hi) 40%, transparent);
}
.ex-step__t { padding-top: 3px; font-family: var(--font-read); font-size: 1.04rem; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.ex-step--result .ex-step__n { --tint: var(--green); }
.ex-step--result .ex-step__t { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); color: var(--text); font-weight: 600; background: color-mix(in srgb, var(--green) 14%, var(--surface)); }
/* Steps still to come wait as dim lines of the right length; the next button lights them one by one. */
.ex-step[data-ghost] .ex-step__n { filter: saturate(0) brightness(.55); box-shadow: none; }
.ex-step[data-ghost] .ex-step__t { visibility: hidden; position: relative; }
.ex-step[data-ghost]::after { content: ""; position: absolute; left: 42px; top: calc(var(--sp-1) + 10px); height: 10px; width: min(62%, 22rem); border-radius: var(--r-sm); background: var(--surface-3); opacity: .55; }
.ex-step[data-ghost]:not(:last-child)::before { opacity: .3; }
.ex-step--result[data-ghost] .ex-step__t { background: none; }
.ex-steps__bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding-top: var(--sp-3); box-shadow: inset 0 1px 0 var(--line); }
.ex-steps__count { margin-right: auto; color: var(--text-3); font-size: .875rem; font-variant-numeric: tabular-nums; }
.ex-example[data-done] .ex-steps__count { color: var(--green); font-weight: 600; }

/* Your turn: violet glass; the answer waits behind one button and rises in when asked for. */
.ex-try { background-image: var(--stardust), linear-gradient(180deg, color-mix(in srgb, var(--violet) 14%, var(--glass-top)), color-mix(in srgb, var(--violet) 6%, var(--glass-bottom))); }
.ex-try__q { margin: 0; font-family: var(--font-read); font-size: 1.12rem; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.ex-reveal { display: grid; gap: var(--sp-3); }
.ex-reveal > summary { justify-self: start; }
.ex-reveal > summary .ex-ico { width: 24px; height: 24px; margin-left: calc(-1 * var(--sp-1)); }
.ex-reveal[open] > summary { opacity: .7; }
.ex-reveal__a { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--sp-3); align-items: start; margin: 0; padding: var(--sp-3); border-radius: var(--r-md); background: color-mix(in srgb, var(--green) 13%, var(--surface)); font-family: var(--font-read); font-size: 1.04rem; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.ex-reveal__a > span:last-child { padding-top: 2px; }

/* The diagram's values as a table: a quiet disclosure at the foot of the key idea. */
.ex-values { margin-top: var(--sp-2); font-size: .9rem; }
.ex-values > summary { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text-2); font-weight: 600; }
.ex-values > summary .ex-ico { width: 24px; height: 24px; }
.ex-values > summary:hover { color: var(--text); }
.ex-values table { width: 100%; margin-top: var(--sp-3); border-collapse: collapse; font-size: .875rem; }
.ex-values th, .ex-values td { padding: var(--sp-1) var(--sp-2); text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.ex-values td { font-family: var(--font-mono); }
.ex-values ul, .ex-values ol, .ex-values p { margin: var(--sp-2) 0 0; padding-left: var(--sp-4); line-height: 1.5; overflow-wrap: anywhere; }

.exploration__formula { max-width: 100%; overflow-x: auto; padding: var(--sp-2); }
.exploration__sources { margin-top: var(--sp-5); font-size: .9rem; }
.exploration__sources > summary { color: var(--text-2); font-weight: 600; }
.exploration__sources a { overflow-wrap: anywhere; }

/* Motion, once: the plate's marks rise in their order when it is first seen (data-seen), curves are wiped in from the left,
   bars grow from zero; a new step and the answer rise in. Nothing moves after that, and nothing under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .ex-plate[data-anim]:not([data-played]) .ex-in { animation: ex-in .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 150ms + 60ms); }
  .ex-plate[data-anim]:not([data-played]) .ex-wipe { animation: ex-wipe 1.5s var(--ease) both .25s; }
  .ex-plate[data-anim]:not([data-played]) .ex-grow, .ex-plate[data-anim]:not([data-played]) .ex-grow-r { transform-box: fill-box; animation: ex-grow .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 150ms + 160ms); }
  .ex-plate[data-anim]:not([data-played]) .ex-grow { transform-origin: left center; }
  .ex-plate[data-anim]:not([data-played]) .ex-grow-r { transform-origin: right center; }
  .ex-plate[data-anim]:not([data-seen]) :is(.ex-in, .ex-wipe, .ex-grow, .ex-grow-r) { animation-play-state: paused; }
  .ex-step[data-fresh] { animation: ex-rise .5s var(--ease) both; }
  .ex-step[data-fresh] .ex-step__n { animation: ex-flare .9s var(--ease) both; }
  .ex-reveal[open] .ex-reveal__a { animation: ex-rise .45s var(--ease) both; }
}
@keyframes ex-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ex-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes ex-grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes ex-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ex-flare { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tint) 0%, transparent); } 40% { box-shadow: 0 0 22px 2px color-mix(in srgb, var(--tint) 70%, transparent); } 100% { box-shadow: 0 0 12px -4px color-mix(in srgb, var(--tint) 75%, transparent); } }
@media (prefers-reduced-motion: reduce) { .exploration *, .exploration *::before, .exploration *::after { animation: none !important; transition: none !important; } }
