/* Redesign, guided walkthrough workstream — hand-off v2 (guided-walk-through-v2).
   Tokens, the layout system and the type atoms live in redesign.css; this file is the
   only stylesheet this page owns. See docs/redesign-workstreams.md.

   v2 is a re-composition, not a restyle. The photograph no longer fills the screen: it
   is a window at the top of the content area with the copy on a flat #3A2C24 field
   underneath it, which is why the words read cleanly. Everything that changes state
   lives in quick_steps_controller.js — the picture cross-fade, the copy fade, the clock,
   the ring, the schedule and the closing countdown. Nothing here decides when anything
   happens.

   Sizes are the package's points on a 390 x 844 screen. The window is a proportion of
   the content area (not the package's fixed 452) so a 568 pt phone keeps room for the
   copy, and the type is clamped against the viewport height for the same reason: on a
   844 pt phone every size below is the render's, and below that it shrinks instead of
   overflowing. */

.gw {
  /* --gw-offset is the height of the banner above this page, measured by the controller
     so that the stage fills the screen on web (a 52px banner) and in the iOS app (none). */
  --gw-edge: 24px;
  --gw-field: #3a2c24;
  --gw-warm: #f6d2b8;

  /* The picture window is the package's own frame, 390 x 452 — its aspect is what decides how
     hard a photograph is cropped, so a taller window makes every subject look zoomed in. It
     never eats the copy's 296 pt: on a short stage the frame gives way, not the words. */
  --gw-window-h: max(232px, min(452px, calc(100% - 296px)));

  --gw-bar: 2px;
  --gw-phase-size: clamp(11.5px, 1.6dvh, 13.5px);
  --gw-count-size: clamp(30px, 4.74dvh, 40px);
  --gw-clock-size: clamp(50px, 9dvh, 76px);
  /* The drawings are drawn at the window's own size, so they are placed at 1:1 and nudged
     down to open air under the clock; the nudge crops the drawing's empty bottom edge, which
     carries nothing (the lowest caption in the ten drawings sits at y = 392 of 452). */
  --gw-art-shift: min(40px, calc(var(--gw-window-h) * 0.09));
  --gw-ring: clamp(48px, 8.8dvh, 74px);
  --gw-label-size: clamp(11.5px, 1.66dvh, 14px);
  --gw-before-size: clamp(14px, 2dvh, 17px);
  --gw-instruction-size: clamp(29px, 5.45dvh, 46px);
  --gw-instruction-spoken: clamp(25px, 4.74dvh, 40px);
  --gw-instruction-long: clamp(23px, 4.27dvh, 36px);
  --gw-note-size: clamp(16px, 2.43dvh, 20.5px);
  --gw-button-h: clamp(48px, 6.6dvh, 56px);

  position: relative;
  height: calc(100dvh - var(--gw-offset, 0px));
  overflow: hidden;
  background: var(--gw-field);
  color: #fff;
  font-family: var(--rd-sans);
  font-weight: 300;
}

.gw *,
.gw *::before,
.gw *::after {
  box-sizing: border-box;
}

.gw :where(p, h1, h2) {
  margin: 0;
}

/* ---------- the picture window ---------- */

.gw-window {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--gw-window-h);
  overflow: hidden;
  background: var(--gw-field);
}

/* the intro puts the photograph behind the whole content area */
.gw.is-intro .gw-window {
  height: 100%;
}

.gw-window__photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.1s ease;
}

.gw-window__photo.is-on {
  opacity: 1;
}

/* The drawings' own tint used to sit inside each SVG, at its own bounds — fine while the
   art filled the window, a visible rectangle the moment it was contained. The shade lives
   here now, over the whole window, and only when a drawing is showing. */
.gw-window__art {
  position: absolute;
  inset: 0;
}

/* .is-art is set by the controller when a drawing is showing; :has(img) is the same idea
   for the first paint, before the controller has run. */
.gw-window__art:has(img),
.gw.is-art .gw-window__art {
  background: rgba(52, 36, 27, 0.32);
}

/* The drawings are the package's animated SVGs, played as they are — at the window's own
   390 x 452, which is the size the package draws them at. */
.gw-window__art img {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: 50% 0;
  transform: translateY(var(--gw-art-shift));
  animation: gw-art-in 0.45s ease both;
}

@keyframes gw-art-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* The package's gradient: a thin shade behind the progress line, clear over the
   photograph, then a fade into the field by the bottom of the window. */
.gw-window__scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(30, 19, 13, 0.42) 0%,
    rgba(30, 19, 13, 0) 20%,
    rgba(30, 19, 13, 0) 82%,
    var(--gw-field) 100%
  );
}

/* the intro's own gradient: clear at the top, into the field by 58 % down */
.gw.is-intro .gw-window__scrim {
  background: linear-gradient(
    180deg,
    rgba(30, 19, 13, 0.18) 0%,
    rgba(30, 19, 13, 0) 22%,
    rgba(58, 44, 36, 0.55) 42%,
    var(--gw-field) 58%,
    var(--gw-field) 100%
  );
}

/* ---------- nest labels (opening step 1) ---------- */

.gw-window__tags {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.gw-window__tags.is-on {
  opacity: 1;
}

.gw-window__leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  stroke: #fff;
  stroke-width: 1;
  opacity: 0.85;
}

.gw-tag__dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 6px rgba(20, 12, 8, 0.6);
}

.gw-tag__dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
}

.gw-tag {
  position: absolute;
  transform: translateY(-50%);
  padding: 5px 10px 4px;
  border-radius: 20px;
  background: rgba(251, 246, 238, 0.94);
  color: var(--gw-field);
  font-family: var(--rd-sans);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 10px -2px rgba(30, 18, 10, 0.35);
}

.gw-tag--end {
  transform: translate(-100%, -50%);
}

/* ---------- the time left and the ring ---------- */

.gw-timer-head {
  position: absolute;
  z-index: 2;
  top: max(18px, env(safe-area-inset-top));
  left: var(--gw-edge);
  right: var(--gw-edge);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.gw.is-running .gw-timer-head {
  display: flex;
}

.gw-clock {
  font-family: var(--rd-sans);
  font-weight: 300;
  font-size: var(--gw-clock-size);
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: lining-nums tabular-nums;
  color: #fff;
  text-shadow: 0 1px 14px rgba(20, 12, 8, 0.55);
}

/* the last two minutes, as in screen 24: the clock takes the label's warmth */
.gw.is-final .gw-clock {
  color: var(--gw-warm);
}

.gw.is-paused .gw-clock {
  opacity: 0.5;
}

/* A drop shadow behind the hairline, so the ring and its dot keep their edge on a bright
   photograph (they washed out over the almond-light of the drawings). */
.gw-orbit {
  flex: none;
  width: var(--gw-ring);
  height: var(--gw-ring);
  overflow: visible;
  filter: drop-shadow(0 1px 6px rgba(20, 12, 8, 0.55));
}

.gw-orbit__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.68);
  stroke-width: 1.5;
}

.gw-orbit__arc,
.gw-orbit__dot {
  fill: #fff;
}

.gw-orbit__arc {
  fill: none;
}

/* ---------- the state itself ---------- */

.gw-panel {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}

.gw-panel.is-current {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0s;
}

.gw-panel__head {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: var(--gw-edge);
  right: var(--gw-edge);
}

.gw-bars {
  display: flex;
  gap: 4px;
}

.gw-bar {
  flex: 1 1 0;
  height: var(--gw-bar);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.38);
}

.gw-bar.is-lit {
  background: #fff;
}

.gw-panel__where {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  text-shadow: 0 1px 10px rgba(20, 12, 8, 0.55);
}

.gw-phase {
  font-size: var(--gw-phase-size);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #fff;
}

.gw-count {
  font-family: var(--rd-sans);
  font-weight: 300;
  font-size: var(--gw-count-size);
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: lining-nums tabular-nums;
  color: #fff;
}

/* ---------- the copy, on the flat field ---------- */

.gw-panel__foot {
  position: absolute;
  left: var(--gw-edge);
  right: var(--gw-edge);
  bottom: calc(28px + env(safe-area-inset-bottom));
  text-shadow: 0 1px 14px rgba(20, 12, 8, 0.55);
}

/* the timer's states sit above the shared Pause/End pills */
.gw-panel--timer .gw-panel__foot {
  bottom: calc(28px + 20px + var(--gw-button-h) + env(safe-area-inset-bottom));
}

.gw-step-label {
  display: block;
  font-size: var(--gw-label-size);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gw-warm);
}

.gw-before {
  margin-top: 10px;
  font-size: var(--gw-before-size);
  font-weight: 400;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.88);
}

.gw-instruction {
  margin-top: 8px;
  font-family: var(--rd-serif);
  font-weight: 500;
  font-size: var(--gw-instruction-size);
  line-height: 1.02;
  letter-spacing: 0;
  color: #fff;
  text-wrap: balance;
}

.gw-instruction--spoken {
  font-style: italic;
  font-size: var(--gw-instruction-spoken);
  line-height: 1.06;
}

.gw-instruction--long {
  font-size: var(--gw-instruction-long);
  line-height: 1.08;
}

.gw-note {
  margin-top: 12px;
  font-size: var(--gw-note-size);
  font-weight: 400;
  line-height: 1.36;
  color: #fff;
  text-wrap: pretty;
}

.gw-suggested {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0.9;
}

/* ---------- controls ---------- */

.gw-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  /* 62 pt of clearance at the right, as the package asks */
  padding-right: 62px;
}

.gw-control {
  flex: none;
  height: var(--gw-button-h);
  gap: 10px;
  padding: 0 32px;
  font-family: var(--rd-sans);
  font-size: clamp(13px, 1.78dvh, 15px);
  font-weight: 500;
  letter-spacing: 0.2em;
  white-space: nowrap;
}

.gw-control--primary {
  margin-left: auto;
}

/* The complete screen offers two ways out and they do not fit side by side at 390 — two
   pills plus the 62 pt launcher clearance come to about 440. They stack, left-aligned.
   The clearance goes with them: the launcher is hidden on the walkthrough, and the pill
   row is the last thing on the page. */
.gw-controls--complete {
  flex-direction: column;
  align-items: flex-start;
  padding-right: 0;
  gap: 10px;
}

.gw-control__icon {
  margin-right: -2px;
  opacity: 0.9;
}

.gw-resume-icon {
  display: none;
}

.gw.is-paused .gw-resume-icon {
  display: inline-flex;
}

.gw.is-paused .gw-pause-icon {
  display: none;
}

/* the timer's own pills, over the bottom of the field */
.gw-timer-controls {
  position: absolute;
  z-index: 2;
  left: var(--gw-edge);
  right: var(--gw-edge);
  bottom: calc(28px + env(safe-area-inset-bottom));
  display: none;
  align-items: center;
  gap: 12px;
}

.gw.is-running .gw-timer-controls {
  display: flex;
  /* the launcher is hidden on this page, so the pills keep the 62 pt reserve too */
  padding-right: 62px;
}

/* icon-only: the restart glyph, square so Restart + Pause (+ End) still fit the row */
.gw-control--icon {
  flex: none;
  width: var(--gw-button-h);
  padding: 0;
}

.gw-control--end {
  display: none;
}

.gw.is-paused .gw-control--end {
  display: inline-flex;
}

/* ---------- the intro ---------- */

.gw-panel--intro .gw-panel__foot {
  text-align: center;
  bottom: calc(28px + env(safe-area-inset-bottom));
}

.gw-panel--intro .gw-instruction {
  font-size: clamp(32px, 5.87dvh, 44px);
  line-height: 1.05;
  margin-top: 10px;
}

.gw-panel--intro .gw-note {
  margin-top: 12px;
  font-size: clamp(16px, 2.47dvh, 18.5px);
  line-height: 1.34;
  color: rgba(255, 255, 255, 0.92);
  text-wrap: balance;
}

.gw-parts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.gw-parts div {
  padding: 12px 4px 11px;
}

.gw-parts div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.gw-parts b {
  display: block;
  font-size: clamp(10.5px, 1.42dvh, 12px);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gw-warm);
}

.gw-parts span {
  display: block;
  margin-top: 4px;
  font-family: var(--rd-serif);
  font-size: clamp(18px, 2.5dvh, 21px);
  line-height: 1.2;
}

.gw-panel--intro .gw-controls {
  justify-content: center;
  padding-right: 0;
}

/* ---------- the error line (the session could not be created at Begin) ---------- */

.gw-error {
  position: absolute;
  z-index: 5;
  left: var(--gw-edge);
  right: var(--gw-edge);
  top: calc(var(--gw-window-h) + 12px);
  display: none;
  border-radius: 18px;
  background: var(--rd-sheet);
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--rd-ink);
  text-shadow: none;
}

.gw-error.is-visible {
  display: block;
}

/* ---------- small screens ---------- */

/* a 320-wide phone cannot hold Back, Next and the launcher's clearance at once */
@media (max-width: 360px) {
  .gw {
    --gw-edge: 20px;
  }

  .gw-controls,
  .gw.is-running .gw-timer-controls {
    padding-right: 0;
  }

  .gw-control {
    padding: 0 22px;
  }

  .gw-tag {
    font-size: 9.5px;
    padding: 4px 8px 3px;
  }
}

/* short screens: the copy tightens before the picture gives up its height */
@media (max-height: 620px) {
  .gw {
    --gw-window-h: clamp(190px, 50%, 452px);
    --gw-instruction-size: 27px;
    --gw-instruction-spoken: 24px;
    --gw-instruction-long: 22px;
  }

  .gw-panel__foot {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .gw-panel--timer .gw-panel__foot {
    bottom: calc(20px + 16px + var(--gw-button-h) + env(safe-area-inset-bottom));
  }

  .gw-controls {
    margin-top: 14px;
  }

  .gw-note {
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gw-window__photo,
  .gw-panel,
  .gw-window__tags,
  .gw-window__art img {
    transition: none;
    animation: none;
  }
}
