/* ============================================================
   Pikt - project scene
   Sticky stage with a project that goes up as the reader scrolls,
   labels and hotspot marks projected over it, and a phase rail.
   Everything takes its colour and type from tokens/*.css.
   ============================================================ */

.pscene { position: relative; background: var(--surface-page); }
.pscene__stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; z-index: 0; }
.pscene__canvas, .pscene__canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pscene__overlay { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* ---------- labels: a small tag on a leader stem, the home page pin-card in miniature ---------- */
.pscene__label { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .35s; }
.pscene__label.is-on { opacity: 1; }
.pscene__label-stem { position: absolute; left: 0; bottom: 0; width: 1px; height: 22px; background: var(--ink-900); opacity: .55; }
.pscene__label-tag {
  position: absolute; left: 0; bottom: 22px; transform: translateX(-4px);
  white-space: nowrap; background: var(--surface-ink); color: var(--text-on-ink);
  padding: 4px 7px; border-radius: var(--radius-xs);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; line-height: 1.2;
}

/* ---------- hotspot marks: a still ring in the accent, leader to the element ---------- */
.pscene__mark { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .2s; }
.pscene__mark.is-on { opacity: 1; }
.pscene__mark-stem { position: absolute; left: 0; bottom: 0; width: 1px; height: 30px; background: var(--accent); }
.pscene__mark-ring { position: absolute; left: 0; bottom: 30px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 1.5px solid var(--accent); background: rgba(247, 245, 241, .7); }
.pscene__mark-id { position: absolute; left: 10px; bottom: 34px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; color: var(--accent); font-weight: 600; }

/* ---------- hotspot buttons: still at rest, a touch larger on hover, never pulsing ---------- */
.pscene__hots { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pscene__mark--hot { pointer-events: none; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit; width: 0; height: 0; overflow: visible; }
.pscene__mark--hot.is-on { pointer-events: auto; }
.pscene__mark--hot .pscene__mark-ring { transition: transform var(--duration-base) var(--ease-standard), background var(--duration-base); }
.pscene__mark--hot:hover .pscene__mark-ring, .pscene__mark--hot:focus-visible .pscene__mark-ring { transform: scale(1.25); background: var(--accent-tint); }
.pscene__mark--hot:focus-visible { outline: none; }
.pscene__mark--hot:focus-visible .pscene__mark-ring { box-shadow: var(--shadow-focus); }
.pscene__mark--hot.is-open .pscene__mark-ring { background: var(--accent); }
.is-panel-open .pscene__mark--hot:not(.is-open) { opacity: 0; pointer-events: none; }

/* ---------- data flow: the only place the accent moves ---------- */
.pscene__flow { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .3s; }
.pscene__flow line { stroke: var(--accent); stroke-width: 1.25; }
.is-panel-open .pscene__flow { opacity: 1; }
.pscene__pikt { position: absolute; right: clamp(20px, 4vw, 48px); bottom: 54px; z-index: 3; color: var(--ink-900); opacity: 0; transition: opacity .3s; }
.pscene__pikt svg { display: block; }
.is-panel-open .pscene__pikt { opacity: 1; right: calc(min(440px, 100%) + clamp(20px, 4vw, 48px)); }

/* ---------- panel ---------- */
.pscene__panel {
  position: absolute; top: var(--pscene-inset, 0px); right: 0; bottom: 0; z-index: 4; width: min(440px, 100%);
  background: rgba(247, 245, 241, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--border-soft); display: flex; flex-direction: column; overflow: hidden;
}
.pscene__panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 24px 14px; border-bottom: 1px solid var(--border-soft); }
.pscene__panel-title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; margin: 0; text-wrap: balance; }
.pscene__panel-close { flex: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 10px; font: inherit; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.pscene__panel-close:hover { border-color: var(--ink-900); color: var(--text-primary); }
.pscene__panel-close:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.pscene__panel-body { overflow-y: auto; padding: 6px 24px 24px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.pscene__panel-body h3 { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 500; margin: 20px 0 6px; }
.pscene__panel-body p { margin: 0; }
.pscene__records, .pscene__refs { list-style: none; margin: 0; padding: 0; }
.pscene__records li { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border-soft); }
.pscene__records li:first-child { border-top: 0; padding-top: 0; }
.pscene__src { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-primary); padding-top: 2px; }
.pscene__refs li { padding: 8px 0; border-top: 1px solid var(--border-soft); }
.pscene__refs li:first-child { border-top: 0; padding-top: 0; }
.pscene__ref-point { color: var(--text-primary); }
.pscene__ref-cite { margin-top: 4px !important; font-size: 13px; }
.pscene__ref-cite a { color: var(--accent); text-decoration: none; }
.pscene__ref-cite a:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 2px; }
.pscene__ref-cite a:hover { color: var(--accent-hover); }
.pscene__ref-status { margin-top: 2px !important; font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); }
.pscene__panel-note { margin-top: 18px !important; color: var(--text-primary); font-weight: 500; }
.pscene__panel-link { margin-top: 14px !important; font-size: 13.5px; }
.pscene__panel-link a { color: var(--accent); text-decoration: none; }
.pscene__panel-closing { margin-top: 18px !important; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-tertiary); }

/* ---------- exposure curve: a compact panel in the corner, neutral line, current position in accent, no units ---------- */
.pscene__curve { position: relative; box-sizing: border-box; z-index: 3; pointer-events: none; background: rgba(247, 245, 241, .88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border-soft); border-radius: var(--radius-md); padding: 14px 14px 12px; }
.pscene__curve-svg { display: block; width: 100%; height: 150px; overflow: visible; }
.pscene__curve-hot { fill: rgba(247, 245, 241, .8); }
.pscene__curve-a { fill: none; stroke: var(--ink-900); stroke-width: 1.25; opacity: .85; }
.pscene__curve-b { fill: none; stroke: var(--ink-900); stroke-width: 1.25; opacity: .3; }
.pscene__curve-dot { fill: var(--accent); }
.pscene__curve-hot { stroke: var(--accent); stroke-width: 1.5; opacity: 0; transition: opacity .3s; }
.pscene__curve-hot.is-on { opacity: 1; }
.pscene__curve-survey { opacity: 0; transition: opacity .35s; }
.is-survey .pscene__curve-survey { opacity: 1; }
.pscene__curve-band { fill: var(--accent-tint); }
.pscene__curve-tick { stroke: var(--border-strong); stroke-width: 1; }
.pscene__curve-bandlab, .pscene__curve-ticklab { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; fill: var(--text-tertiary); }
.pscene__curve-bandlab { fill: var(--red-600); }
.pscene__curve-axis { display: flex; justify-content: space-between; font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); margin-top: 6px; }
.pscene__curve-caps { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 11px; line-height: 1.35; color: var(--text-tertiary); }
.pscene__curve-bandlab, .pscene__curve-ticklab { display: none; }
.pscene__curve-togglecap, .pscene__curve-legend { display: none; }
.is-survey .pscene__curve-togglecap, .is-survey .pscene__curve-legend { display: block; }
.pscene__curve-legend { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); }
.pscene__curve-legend i { display: inline-block; vertical-align: middle; margin: 0 6px 0 0; }
.pscene__curve-legend-band { width: 14px; height: 6px; background: var(--accent-tint); border-radius: 1px; }
.pscene__curve-legend-tick { width: 1px; height: 10px; background: var(--border-strong); margin-left: 12px !important; }
.pscene__pikt { bottom: 24px; }
.is-panel-open .pscene__pikt { right: calc(min(440px, 100%) + clamp(20px, 4vw, 48px)); bottom: 24px; }

/* ---------- survey toggle, at the end of the phase rail ---------- */
.pscene__toggle { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 0; background: none; border: 0; font: inherit; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.pscene__toggle-track { position: relative; width: 26px; height: 14px; border-radius: 999px; background: var(--border); transition: background var(--duration-base); flex: none; }
.pscene__toggle-knob { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper-0); transition: transform var(--duration-base) var(--ease-standard); }
.pscene__toggle[aria-checked="true"] .pscene__toggle-track { background: var(--accent); }
.pscene__toggle[aria-checked="true"] .pscene__toggle-knob { transform: translateX(12px); }
.pscene__toggle:focus-visible { outline: none; }
.pscene__toggle:focus-visible .pscene__toggle-track { box-shadow: var(--shadow-focus); }

/* ---------- reduced motion: the stage is a plain block and the rail steps between frames ---------- */
.pscene.is-stepper { height: auto !important; }
.pscene.is-stepper .pscene__stage { position: relative; }
.pscene.is-stepper .pscene__canvas { transition: opacity .16s; }
.pscene.is-stepper.is-fading .pscene__canvas { opacity: 0; }
.pscene.is-stepper .pscene__rail-item { cursor: pointer; }

/* ---------- text alternative ---------- */
.pscene__alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pscene.is-static .pscene__alt { position: static; width: auto; height: auto; clip: auto; white-space: normal; max-width: 64ch; padding: 40px 0; }

/* ---------- phase rail ---------- */
.pscene__side { position: absolute; left: clamp(20px, 4vw, 48px); bottom: 24px; width: 300px; z-index: 3; display: flex; flex-direction: column; gap: 12px; }
.pscene__rail { display: flex; flex-direction: column; gap: 9px; box-sizing: border-box; padding: 14px 16px; background: rgba(247, 245, 241, .88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
.pscene__rail-item { display: flex; align-items: baseline; gap: 10px; color: var(--text-tertiary); font-size: 12px; line-height: 1.2; text-decoration: none; }
.pscene__rail-n { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; width: 14px; font-variant-numeric: tabular-nums; }
.pscene__rail-item.is-current { color: var(--text-primary); }
.pscene__rail-item.is-current .pscene__rail-n { color: var(--accent); }
.pscene__rail-item:hover { color: var(--text-primary); }

@media (prefers-reduced-motion: reduce) {
  .pscene__label, .pscene__mark { transition: none; }
}

@media (max-width: 900px) {
  .pscene__side { display: contents; }
  .pscene__rail { position: absolute; left: 12px; right: 12px; top: calc(var(--pscene-inset, 0px) + 10px); z-index: 3; flex-direction: row; flex-wrap: wrap; gap: 6px 12px; padding: 8px 10px; }
  .pscene__rail-t { display: none; }
  .pscene__rail-item.is-current .pscene__rail-t { display: inline; }
  .pscene__label-tag { font-size: 9.5px; }
  .pscene__panel { top: auto; left: 0; right: 0; width: auto; max-height: 78%; border-left: 0; border-top: 1px solid var(--border-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .pscene__pikt, .is-panel-open .pscene__pikt { bottom: auto; top: 14px; right: 14px; }
  .pscene__records li { grid-template-columns: 96px 1fr; }
  .pscene__curve { position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 3; padding: 10px 12px 8px; }
  .pscene__curve-svg { height: 72px; }
  .pscene__curve-cap { display: none; }
  .pscene__pikt, .is-panel-open .pscene__pikt { bottom: auto; top: 14px; right: 14px; }
  .pscene__toggle { margin: 0 0 0 auto; }
}

/* ---------- neutral dimming overlay (driven by progress, never coloured) and the one non-hotspot accent mark ---------- */
.pscene__dim { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: var(--ink-900); opacity: 0; }
.pscene__accent { position: absolute; left: 0; top: 0; opacity: 0; transition: opacity .25s; }
.pscene__accent.is-on { opacity: 1; }
.pscene__accent-dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(247, 245, 241, .55); }
.pscene__records-note { margin-top: 10px !important; font-size: 13px; color: var(--text-primary); }
@media (prefers-reduced-motion: reduce) { .pscene__accent { transition: none; } }
