/* Stacking section — the original timeline (css/stacking-timeline.css, all its visuals) with the words cut
   to a big title and one short line per step. Loaded after stacking-timeline.css + sep-b.css.
   Markup: stacking/section.html · scripts: stacking/js/stacking.js (the word), stacking/js/stacking-steps.js (the steps). */

.stx {
  --stx-display: "SF Pro Display", "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Opener: the word, focus-stacked ---------- */

/* The sheet's own top space is enough: the title no longer needs room around it (2026-11-13). */
.sb-slot > .stk.stx { padding-top: clamp(48px, 5vw, 80px); }

.stx-open { margin: 0 auto clamp(72px, 9vw, 136px); text-align: center; font-family: var(--stx-display); }

.stx-word {
  --breath: 0.075;                          /* size step between two frames, as focus breathing in a bracket */
  position: relative;
  width: fit-content;
  margin: 0 auto;
  font-size: clamp(60px, 12.4vw, 196px);    /* section titles: Stacking, Editing, Retouching share it */
  font-weight: 700;
  letter-spacing: -0.04em;                  /* 2026-11-17: was -0.055em */
  line-height: 1;
  white-space: nowrap;
}
/* The real heading text: sized and read aloud, drawn by the planes. */
.stx-word__text { display: block; padding: 0 0.04em 0.1em; color: transparent; }

/* The styles below are the end state (stacked, sharp); the scroll motion at the end of this block starts from the
   fanned, soft state. */
.stx-plane { position: absolute; inset: 0; will-change: transform; }
.stx-plane__soft, .stx-plane__sharp { position: absolute; inset: 0; padding: 0 0.04em 0.1em; }
/* A frame out of focus: the word as a haze. Its blur is drawn once; only its opacity moves. */
.stx-plane__soft {
  color: transparent;
  text-shadow: 0 0 0.07em rgba(241, 244, 242, 0.55);
  opacity: 0;
  will-change: opacity;
}
/* Its one plane in focus: a fifth of the word, left to right. Each fifth reaches 1 px into its neighbours: cut edges
   meeting on a fractional pixel are half transparent in both planes and left a faint line through the letters. */
.stx-plane__sharp {
  color: var(--text);
  -webkit-mask-image: linear-gradient(90deg, transparent calc(var(--i) * 20% - 1px), #000 calc(var(--i) * 20% - 1px), #000 calc((var(--i) + 1) * 20% + 1px), transparent calc((var(--i) + 1) * 20% + 1px));
          mask-image: linear-gradient(90deg, transparent calc(var(--i) * 20% - 1px), #000 calc(var(--i) * 20% - 1px), #000 calc((var(--i) + 1) * 20% + 1px), transparent calc((var(--i) + 1) * 20% + 1px));
}

/* Scroll motion (2026-11-16, phone perf pass): only transform and opacity move, so the browser never repaints the
   word while it animates. The five frames fan apart while the word is low on the screen and stack into one sharp
   word as it rises: from once the whole word is on screen (its bottom at 90 % of the screen) until its top is a
   quarter of the way down, eased (cubic-bezier(1/3, 0, 2/3, 1) = smoothstep).
   Where the browser has scroll timelines (Safari 26, Chrome 115+) the scroll drives it directly, in step with the
   finger; elsewhere stacking.js holds the same animations paused and sets their time on scroll. */
@keyframes stx-plane { from { transform: scale(calc(1 + (var(--i) - 2) * var(--breath))); } to { transform: none; } }
@keyframes stx-soft { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .stx-plane { animation: stx-plane 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  .stx-plane__soft { animation: stx-soft 1s cubic-bezier(0.3333, 0, 0.6667, 1) both; }
  @supports (animation-timeline: view()) {
    .stx-word { view-timeline: --stx-word block; }
    .stx-plane, .stx-plane__soft {
      animation-duration: auto;
      animation-timeline: --stx-word;
      animation-range-start: entry calc(100% + 10dvh);
      animation-range-end: cover 75dvh;
    }
  }
}

.stx-lede {
  margin-top: clamp(20px, 2.4vw, 36px);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--muted);
}
.stx-lede span { color: var(--text); }

/* ---------- Steps: big title, one short line ---------- */

.stk .tl-chapter h3.stx-title,
.stk .finale h3.stx-title {
  margin: 0;
  font-family: var(--stx-display);
  font-size: clamp(40px, 4.8vw, 72px);       /* same size as the Edit step titles (2026-11-17, was 6vw / 88px) */
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.96;
}
.stk .tl-chapter__head p.stx-line,
.stk .finale__head p.stx-line {
  margin-top: clamp(10px, 1.2vw, 16px);
  font-family: var(--stx-display);
  font-size: clamp(18px, 1.55vw, 22px);
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.3;
  color: var(--muted);
}
/* The app's step names (StackInspectorView), small above each title; the number is in the rail's circle. */
.stk.stx .step-label { display: block; margin-bottom: clamp(10px, 1.2vw, 16px); font-size: 12px; color: var(--muted); }
/* The words start on the photo's top edge; the title's own leading would push it below. */
.stk.stx .tl-chapter__head { margin-top: -0.06em; }
.stk.stx .tl-chapter__ctrl { margin-top: clamp(24px, 2.6vw, 36px); }
.stk.stx .finale__head { margin-top: 20px; }

/* Steps pulled closer: the original gaps (96–168 px between steps, 32–48 px above the run card) were sized
   for long paragraphs; with one line per step they read as empty. */
.stx-open { margin-bottom: clamp(48px, 6vw, 88px); }
.stk.stx .tl-chapter + .tl-chapter,
.stk.stx .tl-chapter + .finale { margin-top: clamp(40px, 5vw, 72px); }
.stk.stx .finale__card { margin-top: clamp(24px, 2.6vw, 36px); }
.stk.stx .stk__foot { margin-top: clamp(24px, 3vw, 36px); }
/* The algorithm line under the picker: one line, the voice of the step lines. */
.stk.stx .algo-panels h4 { margin: 0; font-size: 17px; font-weight: 500; letter-spacing: -0.01em; color: var(--muted); }
/* The race no longer stretches to the photo's height: bars sit under their title. */
.stk.stx .bars { flex: 0 0 auto; margin: 20px 0 8px; }
.stk.stx .race__note { margin-top: auto; padding-top: 10px; }

/* ---------- Step 1: the app's RAW groups as pills (option A of raw-groups-proposals.html) ---------- */

.stx-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.stx-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px; border: 1px solid #ffffff1a; background: #ffffff0a;
  font-size: 13px; color: var(--text); white-space: nowrap;
  transition: opacity .3s;
}
/* The app's group symbols: tinted rounded square, symbol in the group's colour (RAWGroupIconView). */
.stx-gi { --c: #fff; flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--c); }
.stx-gi svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.stx-gi--look   { --c: #6ac4dc; }
.stx-gi--color  { --c: #ff9f0a; }
.stx-gi--lens   { --c: #0a84ff; }
.stx-gi--noise  { --c: #bf5af2; }
.stx-gi--detail { --c: #ff453a; }
.stx-pills[data-mode="linear"] .stx-pill--look { opacity: .32; }

/* ---------- Final card (option A): focus map → stacked photo + divider, beside the race ---------- */

.stk.stx .stx-run {
  width: 100%;
  margin-top: clamp(24px, 2.6vw, 36px);
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 10px;
  font-family: var(--stx-display);
}
.stx-run__shot {
  --pos: 50%;
  position: relative; margin: 0;
  aspect-ratio: 3 / 2; overflow: hidden;
  border-radius: 19px; background: #1d2412;
  user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.stx-run__shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
.stx-run__before { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.stx-run__map { position: absolute; inset: 0; transition: opacity .6s ease-in-out; }
.stx-run__map img { opacity: 0; }
.stx-run__map img.is-on { opacity: 1; }
.stx-run__handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos);
  width: 2px; margin-left: -1px;
  background: #ffffffe6; box-shadow: 0 0 12px #00000059;
  pointer-events: none;
}
.stx-run__knob {
  position: absolute; left: 50%; top: 50%;
  display: grid; place-items: center;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: #14161573; border: 1px solid #ffffff8c;
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  color: #fff; box-shadow: 0 6px 20px #00000059;
  transition: transform .2s cubic-bezier(.2,.7,.2,1);
}
.stx-run__shot.is-dragging .stx-run__knob { transform: scale(1.08); }
.stx-run__range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.stx-run__shot:has(.stx-run__range:focus-visible) .stx-run__knob { outline: 2px solid var(--accent); outline-offset: 3px; }
.stk .stx-run__chip--before { left: 14px; top: 14px; opacity: clamp(0, (var(--pos-n, 50) - 17) / 6, 1); }
.stk .stx-run__chip--after { right: 14px; top: 14px; opacity: clamp(0, (78 - var(--pos-n, 50)) / 6, 1); }

/* Map phase: only the map; the divider and its chips come in with the result. */
.stx-run__handle, .stx-run__chip, .stx-run__before { transition: opacity .4s ease; }
.stx-run__shot[data-phase="map"] :is(.stx-run__handle, .stx-run__chip, .stx-run__before) { opacity: 0 !important; }
.stx-run__shot[data-phase="compare"] { cursor: ew-resize; }
.stx-run__shot[data-phase="compare"] .stx-run__map { opacity: 0; }

.stx-run__side { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: clamp(20px, 2.6vw, 36px); }
/* Bottom row, its own line across the card: the test behind the times + Replay. */
.stx-run__foot {
  grid-column: 1 / -1;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 8px 4px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.stx-run__foot p { min-width: 0; font-size: 15px; color: var(--muted); }
.stx-run__replay {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 11px;
  border: 1px solid #ffffff26; border-radius: 999px;
  background: #ffffff0d;
  color: var(--text); font: 500 12px var(--stx-display);
  cursor: pointer;
  transition: background .15s;
}
.stx-run__replay:hover { background: #ffffff1a; }
.stx-race { display: grid; gap: clamp(22px, 2.6vw, 32px); }
.stx-race__top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stx-race__name { font-size: clamp(15px, 1.3vw, 18px); font-weight: 500; color: var(--muted); }
.stx-race__time { font-size: clamp(24px, 2.6vw, 36px); font-weight: 700; letter-spacing: -0.03em; color: rgba(241, 244, 242, 0.34); font-variant-numeric: tabular-nums; }
.stx-race__track { position: relative; height: 12px; margin-top: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.stx-race__fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--w, 0) * 100%); border-radius: inherit; background: rgba(241, 244, 242, 0.34); }
.stx-race__row--us .stx-race__name { color: var(--text); font-weight: 600; }
.stx-race__row--us .stx-race__fill { background: var(--text); }
.stx-race__row--us .stx-race__time { color: var(--text); }

@media (max-width: 960px) {
  .stk .tl-chapter h3.stx-title, .stk .finale h3.stx-title { font-size: clamp(40px, 10vw, 64px); }
  .stk.stx .finale__head { margin-top: 0; }
  .stk.stx .stx-run { grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr); }
  .stx-run__side { padding: 22px 14px 18px; }
  .stk.stx .tl-chapter + .tl-chapter,
  .stk.stx .tl-chapter + .finale { margin-top: clamp(40px, 9vw, 56px); }
}

@media (prefers-reduced-motion: reduce) {
  .stx-run *, .stx-run *::before { transition: none !important; }
}
