/* How We Unlock Doors — presentation styles
   Tokens: the page background is the renders' own black, so the 16:9 frame has no visible edge.
   Gold is reserved for the shear line: the progress line, the shear-line label, the sweep, active steps. */
:root {
  --bg: #010101;
  --ink: #f2ede3;
  --text: #c9c3b6;
  --steel: #8b8f96;
  --gold: #c9a227;
  --gold-hi: #e5c35a;
  --hair: rgba(139, 143, 150, 0.34);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --chrome-h: 76px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font-family: var(--serif);
  overflow: hidden;
  caret-color: transparent; /* nothing on these slides is editable */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- slides */
.deck { position: fixed; inset: 0; }
.slide {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.9s var(--ease), visibility 0s linear 0.9s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.slide.is-active {
  opacity: 1; visibility: visible;
  transition: opacity 0.9s var(--ease), visibility 0s;
}

/* the 16:9 frame: everything inside scales with it (cqw units) */
.frame {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  width: min(100vw, calc(100svh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}
.stage { position: absolute; inset: 0; }
.plate {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%;
  /* feather the frame edges into the page black */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 7%, #000 80%, transparent 100%),
                      linear-gradient(to right, transparent 0%, #000 4%, #000 96%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent 0%, #000 7%, #000 80%, transparent 100%),
              linear-gradient(to right, transparent 0%, #000 4%, #000 96%, transparent 100%);
  mask-composite: intersect;
}
.plate img, video.plate {
  display: block; width: 100%; height: 100%; object-fit: cover;
}
.plate img { transform: scale(1.03); transition: transform 2.6s var(--ease); }
.slide.is-active .plate img { transform: none; }

/* ---------------------------------------------------------------- type */
.copy {
  position: absolute; z-index: 3;
  left: 5.5%; top: 9%; width: 35%;
  cursor: auto;
  text-shadow: 0 1px 22px rgba(0, 0, 0, 0.65);
}
.copy h1, .copy h2 {
  font-family: var(--display);
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
.copy h1 {
  font-stretch: 125%;
  font-weight: 300;
  font-size: 4.7cqw;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin-bottom: 1.6cqw;
}
.copy h2 {
  font-stretch: 116%;
  font-weight: 400;
  font-size: 2.4cqw;
  line-height: 1.12;
  letter-spacing: -0.012em;
  margin-bottom: 1.5cqw;
}
.copy p {
  font-size: max(15px, 1.2cqw);
  line-height: 1.55;
  margin: 0 0 0.9em;
  max-width: 33em;
  text-wrap: pretty;
}
.copy--title { top: 13%; width: 44%; }
.copy--title p {
  font-size: max(17px, 1.55cqw);
  font-style: italic;
  font-weight: 300;
  color: var(--text);
}
.copy--door { top: 24%; left: 6%; width: 36%; }
.copy--compare { width: 38%; top: 8%; }
.copy--video { width: 17%; } /* two short lines: stays clear of the housing as the camera orbits */
.copy--close { width: 34%; top: 7%; }
.copy--close p { max-width: 26em; }

/* text enters a beat after its image */
.copy > *, .steps, .labels li, .toggle {
  transition: opacity 0.8s var(--ease) var(--delay, 0.25s);
}
.slide:not(.is-active) .copy > *,
.slide:not(.is-active) .steps { opacity: 0; transition-delay: 0s; }
.copy > :nth-child(2) { --delay: 0.4s; }
.copy > :nth-child(3) { --delay: 0.55s; }

.copy .hint {
  margin-top: 2.2cqw;
  font-family: var(--display); font-stretch: 100%; font-weight: 400; font-style: normal;
  font-size: max(12px, 0.85cqw); color: var(--steel);
  --delay: 1.2s;
}
body.has-moved .copy .hint { opacity: 0; }

/* ---------------------------------------------------------------- labels + leaders */
.leaders {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2; overflow: visible;
}
.leaders path {
  fill: none; stroke: rgba(242, 237, 227, 0.6); stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.leaders circle {
  fill: var(--bg); stroke: var(--ink); stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}
.leaders .is-gold path { stroke: var(--gold-hi); }
.leaders .is-gold circle { stroke: var(--gold-hi); fill: var(--gold); }
.leaders g { opacity: 0; transition: opacity 0.6s var(--ease) var(--delay, 0.5s); }
.slide.is-active .leaders g { opacity: 1; }
.leaders .marks { display: none; }

.labels { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; z-index: 2; }
.labels li {
  position: absolute;
  transform: translate(0, -50%);
  font-family: var(--display); font-stretch: 100%; font-weight: 500;
  font-size: max(12px, 0.98cqw);
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 1px 10px #000, 0 0 2px #000;
  opacity: 0;
}
.labels li[data-side="l"] { transform: translate(-100%, -50%); text-align: right; }
.labels li.is-gold { color: var(--gold-hi); }
.slide.is-active .labels li { opacity: 1; }
.labels .n { display: none; }

/* ---------------------------------------------------------------- compare (slide 3) */
.plate--b { opacity: 0; transition: opacity 1.1s var(--ease); }
[data-state="aligned"] .plate--b { opacity: 1; }
[data-compare] .labels li.is-gold,
[data-compare] .leaders .is-gold { transition: opacity 0.6s var(--ease); }
[data-compare][data-state="locked"] .labels li.is-gold { opacity: 0.45; }

.sweep {
  position: absolute; z-index: 2; height: 2px;
  left: calc(var(--x0, 0.47) * 100%);
  top: calc(var(--y0, 0.45) * 100%);
  width: var(--len, 34%);
  transform-origin: 0 50%;
  transform: translateY(-50%) rotate(var(--rot, 0deg)) scaleX(0);
  background: linear-gradient(90deg, rgba(229, 195, 90, 0), var(--gold-hi) 5%, var(--gold-hi) 95%, rgba(229, 195, 90, 0));
  box-shadow: 0 0 10px 1px rgba(229, 195, 90, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
[data-state="aligned"] .sweep {
  opacity: 1;
  transform: translateY(-50%) rotate(var(--rot, 0deg)) scaleX(1);
  transition: transform 1.25s var(--ease) 0.45s, opacity 0.4s var(--ease) 0.45s;
}

.toggle {
  display: inline-flex; gap: 0.4cqw; margin-top: 0.6cqw;
  --delay: 0.6s;
}
.slide:not(.is-active) .toggle { opacity: 0; }
.toggle button {
  background: none; border: 0; padding: 0.55em 0.1em 0.5em; margin-right: 1.4em;
  font-family: var(--display); font-stretch: 100%; font-weight: 500;
  font-size: max(13px, 0.98cqw); letter-spacing: 0.01em;
  color: var(--steel);
  cursor: pointer;
  border-bottom: 1px solid var(--hair);
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.toggle button:hover { color: var(--ink); }
.toggle button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--gold); box-shadow: 0 1px 0 var(--gold); }

/* ---------------------------------------------------------------- video steps (slide 4) */
.stage--video::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: linear-gradient(to top, rgba(1, 1, 1, 0.9) 0%, rgba(1, 1, 1, 0.55) 45%, rgba(1, 1, 1, 0) 100%);
  pointer-events: none;
}
.steps {
  position: absolute; z-index: 3;
  left: 5.5%; right: 5.5%; bottom: 12.5%;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2.2cqw;
  margin: 0; padding: 0; list-style: none;
  cursor: auto;
  --delay: 0.5s;
}
.steps li {
  position: relative;
  padding-top: 0.9cqw;
  font-family: var(--display); font-stretch: 100%; font-weight: 500;
  font-size: max(12px, 0.98cqw); line-height: 1.35;
  color: var(--steel);
  text-shadow: 0 1px 12px #000, 0 0 2px #000;
  transition: color 0.4s var(--ease);
}
.steps li::before, .steps li::after {
  content: ""; position: absolute; left: 0; top: 0; height: 1px;
}
.steps li::before { right: 0; background: var(--hair); }
.steps li::after {
  width: 100%; background: var(--gold); box-shadow: 0 0 6px rgba(201, 162, 39, 0.7);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
}
.steps li.is-on, .steps li.is-done { color: var(--ink); }
.steps-n {
  display: inline-block; min-width: 1.6em;
  font-variant-numeric: tabular-nums; color: var(--gold-hi);
}
.steps li:not(.is-on):not(.is-done) .steps-n { color: var(--steel); }

.vid-toggle {
  position: absolute; z-index: 3; right: 5.5%; top: 9%;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(1, 1, 1, 0.35); border: 1px solid var(--hair);
  cursor: pointer; transition: border-color 0.3s, color 0.3s;
  color: var(--ink);
}
.vid-toggle:hover { border-color: var(--gold); color: var(--gold-hi); }
.vid-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.vid-toggle .i-play { display: none; fill: currentColor; stroke: none; }
.vid-toggle[data-playing="false"] .i-play { display: block; }
.vid-toggle[data-playing="false"] .i-pause { display: none; }

/* ---------------------------------------------------------------- close (slide 7) */
.restart {
  margin-top: 0.8cqw;
  background: none; border: 0; padding: 0.5em 0;
  font-family: var(--display); font-stretch: 100%; font-weight: 500;
  font-size: max(13px, 1cqw); letter-spacing: 0.01em;
  color: var(--ink);
  border-bottom: 1px solid var(--gold);
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.restart:hover { color: var(--gold-hi); }

/* ---------------------------------------------------------------- chrome: the progress bar is a shear line */
.chrome {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--chrome-h) + env(safe-area-inset-bottom));
  padding: 0 max(28px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(28px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 28px;
  background: linear-gradient(to top, rgba(1, 1, 1, 0.92) 0%, rgba(1, 1, 1, 0.75) 45%, rgba(1, 1, 1, 0) 100%);
  font-family: var(--display); font-stretch: 100%;
}
.count {
  margin: 0; min-width: 3.2em;
  font-size: 13px; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--steel);
}
.count b { color: var(--ink); font-weight: 500; }
.shear { position: relative; flex: 1; height: 48px; margin: 0 14px; }
.shear-track { position: absolute; left: 0; right: 0; top: 14px; height: 1px; background: var(--hair); }
.shear-fill {
  position: absolute; left: 0; top: 0; height: 1px; width: 0;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(201, 162, 39, 0.75);
  transition: width 0.8s var(--ease);
}
.pin {
  position: absolute; top: 0;
  width: 30px; height: 48px; margin-left: -15px;
  padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 4px;
}
.pin span {
  position: absolute; left: 50%; top: 15px;
  width: 6px; height: var(--h, 18px); margin-left: -3px;
  border-radius: 3px;
  background: #4a4d54;
  transform: translateY(var(--o, 8px));
  transition: transform 0.75s var(--ease), background-color 0.5s var(--ease), box-shadow 0.5s var(--ease);
}
.pin:hover span { background: #6a6e76; }
.pin.is-set span { transform: translateY(0); background: var(--gold); }
.pin.is-current span { background: var(--gold-hi); box-shadow: 0 0 10px rgba(229, 195, 90, 0.6); }
.chrome.is-open .shear-fill { box-shadow: 0 0 10px rgba(229, 195, 90, 0.9); background: var(--gold-hi); }

.ctrl { display: flex; gap: 8px; }
.ctrl button {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--hair);
  color: var(--ink); cursor: pointer;
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease), opacity 0.3s;
}
.ctrl button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-hi); }
.ctrl button:disabled { opacity: 0.28; cursor: default; }
.ctrl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 1px solid var(--gold-hi); outline-offset: 3px; }
.pin:focus-visible { outline-offset: 0; }

/* ---------------------------------------------------------------- portrait / phones: image on top, words below */
@media (max-aspect-ratio: 1/1) {
  :root { --chrome-h: 68px; }
  .slide {
    display: block;
    overflow-y: auto; overscroll-behavior: contain;
    padding: max(18px, env(safe-area-inset-top)) 0 calc(var(--chrome-h) + 24px);
  }
  .frame { width: 100vw; aspect-ratio: auto; display: flex; flex-direction: column; }
  .stage { position: relative; inset: auto; width: 100%; aspect-ratio: 16 / 9; }
  .copy, .copy--title, .copy--door, .copy--video, .copy--close {
    position: static; width: auto; padding: 22px 20px 0; text-shadow: none;
  }
  .copy h1 { font-size: clamp(34px, 10.5vw, 58px); margin-bottom: 14px; }
  .copy h2 { font-size: clamp(23px, 6.6vw, 34px); margin-bottom: 14px; }
  .copy p { font-size: 17px; }
  .copy--title p { font-size: 19px; }
  .copy .hint { font-size: 13px; }
  .steps { position: static; grid-template-columns: 1fr; gap: 14px; padding: 18px 20px 0; }
  .steps li { font-size: 15px; padding-top: 10px; }
  .vid-toggle { top: 12px; right: 12px; }
  /* labels become numbered marks with a key below the copy */
  .labels { position: static; padding: 6px 20px 0; display: grid; gap: 8px; }
  .labels li { position: static !important; transform: none !important; font-size: 15px; white-space: normal; text-shadow: none; }
  .labels li[data-side="l"] { text-align: left; }
  .labels .n {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; margin-right: 10px; border-radius: 50%;
    border: 1px solid currentColor; font-size: 12px; font-variant-numeric: tabular-nums;
  }
  .stage .labels { order: 3; }
  .leaders .lines { display: none; }
  .leaders .marks { display: inline; }
  .leaders .marks circle { fill: rgba(1, 1, 1, 0.75); stroke: var(--ink); stroke-width: 1.2; }
  .leaders .marks text { fill: var(--ink); font-family: var(--display); font-size: 46px; text-anchor: middle; dominant-baseline: central; }
  .leaders .marks .is-gold circle { stroke: var(--gold-hi); }
  .leaders .marks .is-gold text { fill: var(--gold-hi); }
  .chrome { gap: 14px; padding-left: 16px; padding-right: 16px; }
  .ctrl .btn-fs { display: none; }
  .shear { margin: 0 6px; }
  .pin { width: 26px; margin-left: -13px; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .slide.is-active { transition: opacity 0.25s linear, visibility 0s; }
  .plate img, .slide.is-active .plate img { transform: none; transition: none; }
  .sweep, [data-state="aligned"] .sweep { transition: opacity 0.2s linear; }
  .pin span, .shear-fill { transition-duration: 0.2s; }
}
