/* ==========================================================================
   Shared controls (chapters 02–04)
   ========================================================================== */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
}
.seg button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink-3);
  transition: color .25s var(--ease), background-color .25s var(--ease), box-shadow .25s var(--ease);
}
.seg button:hover { color: #fff; }
.seg button[aria-checked="true"] {
  color: #fff;
  background: rgba(var(--accent), .2);
  box-shadow: inset 0 0 0 1px rgba(var(--accent), .55);
}
.seg--lg button { height: 44px; font-size: 14.5px; }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --pct: 50%;
}
.range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgb(var(--accent)) var(--pct), rgba(255, 255, 255, .1) var(--pct));
  box-shadow: 0 0 14px -4px rgba(var(--accent), .8);
}
.range::-moz-range-track { height: 8px; border-radius: 8px; background: rgba(255, 255, 255, .1); }
.range::-moz-range-progress { height: 8px; border-radius: 8px; background: rgb(var(--accent)); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0 0 4px rgba(var(--accent), .35), 0 4px 12px rgba(0, 0, 0, .5);
  transition: transform .2s var(--ease-out);
}
.range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0 0 4px rgba(var(--accent), .35), 0 4px 12px rgba(0, 0, 0, .5);
}
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(var(--accent), .7), 0 4px 12px rgba(0, 0, 0, .5); }

@keyframes softIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes bump { 40% { transform: scale(1.12); } }

/* ==========================================================================
   02 — the stage: scrolling plays the home
   ========================================================================== */
.caps {
  --accent: 60, 196, 255;
  position: relative;
  padding-top: clamp(90px, 13vh, 150px);
  background: var(--bg);
}
.caps__head { position: relative; text-align: center; margin-bottom: clamp(24px, 5vh, 56px); }
.caps__title {
  margin: 0 0 18px;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 5vw, 76px);
  line-height: 1.02;
  letter-spacing: -.03em;
}
.caps__lead { margin: 0 auto; max-width: 34em; font-size: clamp(16px, 1.25vw, 18.5px); line-height: 1.65; color: var(--ink-2); }

.caps__pin { position: relative; height: calc(100vh + 5 * 115vh); height: calc(100svh + 5 * 115svh); }
.theatre {
  --enter: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--bg);
}

/* the scene melts into the page on every side */
.scene {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  opacity: calc(.25 + var(--enter) * .75);
  transform: translate3d(0, calc((1 - var(--enter)) * 9%), 0) scale(calc(.93 + var(--enter) * .07));
  transform-origin: 70% 60%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, rgba(0,0,0,.06) 5%, rgba(0,0,0,.2) 10%, rgba(0,0,0,.45) 16%, rgba(0,0,0,.72) 22%, rgba(0,0,0,.92) 27%, #000 30%), linear-gradient(0deg, transparent 0, rgba(0,0,0,.25) 7%, rgba(0,0,0,.7) 15%, #000 23%), linear-gradient(180deg, transparent, #000 9%);
  mask-image: linear-gradient(90deg, transparent 0, rgba(0,0,0,.06) 5%, rgba(0,0,0,.2) 10%, rgba(0,0,0,.45) 16%, rgba(0,0,0,.72) 22%, rgba(0,0,0,.92) 27%, #000 30%), linear-gradient(0deg, transparent 0, rgba(0,0,0,.25) 7%, rgba(0,0,0,.7) 15%, #000 23%), linear-gradient(180deg, transparent, #000 9%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.scene__in { position: absolute; inset: 0; transform: scale(1.035); will-change: transform; }
.scene__c {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
  will-change: transform, clip-path;
}
.scene__c.is-on { visibility: visible; }
.scene__seam {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--cyan-200) 30%, #fff 60%, var(--cyan-200));
  box-shadow: 0 0 24px 3px rgba(60, 196, 255, .75);
}

/* whatever the room glows with spills across the dark page */
.theatre__amb {
  --a1: 10, 20, 40;
  --a2: 10, 20, 40;
  --a3: 10, 20, 40;
  position: absolute;
  inset: 0;
  opacity: calc(var(--enter) * .5);
  background:
    radial-gradient(60% 55% at 58% 12%, rgba(var(--a1), .55), transparent 70%),
    radial-gradient(60% 55% at 52% 50%, rgba(var(--a2), .75), transparent 72%),
    radial-gradient(70% 60% at 56% 100%, rgba(var(--a3), .6), transparent 72%);
}

.theatre__ui {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr) auto;
  height: 100%;
  padding-top: var(--nav-h);
  padding-bottom: clamp(18px, 3.4vh, 34px);
  pointer-events: none;
}
.theatre__ui button { pointer-events: auto; }

/* the copy */
.theatre__copy { display: grid; align-items: center; grid-column: 1; grid-row: 1; }
.fp { grid-area: 1 / 1; visibility: hidden; transition: visibility 0s .4s; }
.fp.is-active { visibility: visible; transition-delay: 0s; }
.fp__title {
  display: flex;
  margin: 0 0 18px;
  padding-block: .1em .14em;
  overflow: hidden;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(48px, 6.6vw, 100px);
  line-height: 1;
  letter-spacing: -.035em;
  color: #fff;
}
.fp__title .ch {
  display: inline-block;
  transform: translate3d(0, -115%, 0);
  transition: transform .4s var(--ease);
}
.fp.is-active .fp__title .ch {
  transform: translate3d(0, 0, 0);
  transition: transform .9s var(--ease-out) calc(.08s + var(--i) * .028s);
}
/* not yet reached: letters wait below and rise up */
.fp.is-active ~ .fp .fp__title .ch { transform: translate3d(0, 115%, 0); }
.fp__text {
  max-width: 25em;
  margin: 0 0 clamp(22px, 4vh, 38px);
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.55;
  color: var(--ink-2);
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.fp.is-active .fp__text {
  opacity: 1;
  transform: none;
  transition: opacity .8s var(--ease) .28s, transform .9s var(--ease-out) .28s;
}

/* the spoken command */
.voice {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: min(100%, 410px);
  padding: 12px 22px 12px 12px;
  border-radius: 20px;
  text-align: left;
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  background: rgba(10, 20, 40, .46);
  border: 1px solid rgba(214, 228, 244, .12);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: opacity .3s var(--ease), transform .3s var(--ease), border-color .3s var(--ease), background-color .3s var(--ease);
}
.fp.is-active .voice {
  opacity: 1;
  transform: none;
  transition: opacity .8s var(--ease) .4s, transform .9s var(--ease-out) .4s, border-color .3s var(--ease), background-color .3s var(--ease);
}
.fp.is-active .voice:hover { border-color: rgba(127, 220, 255, .55); background: rgba(16, 36, 68, .6); }
.fp.is-active .voice:active { transform: scale(.985); transition-duration: .15s; transition-delay: 0s; }
.voice__mic {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  color: #fff;
  background: var(--btn-grad);
  box-shadow: 0 10px 26px -10px rgba(37, 182, 255, .9), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.voice__mic svg { width: 22px; height: 22px; }
.voice__mic::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid var(--cyan-300);
  opacity: 0;
}
.voice.is-listening .voice__mic::after { animation: micPing 1.5s var(--ease-out) infinite; }
@keyframes micPing { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.45); } }
.voice__body { display: grid; gap: 3px; min-width: 0; }
.voice__body small {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.voice__ask { min-height: 1.35em; font-size: clamp(16px, 1.35vw, 19px); font-weight: 500; line-height: 1.35; color: #fff; }
.voice__ask:empty::before { content: "…"; color: var(--ink-3); }
.voice__wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.voice__wave i {
  width: 2.5px;
  height: 100%;
  border-radius: 2px;
  background: var(--cyan-300);
  transform: scaleY(.14);
  transition: transform .4s var(--ease);
}
.voice.is-listening .voice__wave i { animation: waveBar 1s ease-in-out infinite; }
.voice__wave i:nth-child(2) { animation-delay: -.72s !important; }
.voice__wave i:nth-child(3) { animation-delay: -.28s !important; }
.voice__wave i:nth-child(4) { animation-delay: -.9s !important; }
.voice__wave i:nth-child(5) { animation-delay: -.45s !important; }
@keyframes waveBar { 0%, 100% { transform: scaleY(.22); } 50% { transform: scaleY(1); } }
.fp__reply {
  min-height: 1.5em;
  margin: 14px 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
  color: rgb(var(--warm));
  opacity: 0;
  transform: translate3d(-6px, 0, 0);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.fp.is-done .fp__reply { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .7s var(--ease-out); }

/* live value, in the room */
.readout {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: end;
  width: clamp(190px, 18vw, 270px);
  margin-bottom: clamp(16px, 3vh, 30px);
  position: relative;
  isolation: isolate;
  text-align: right;
  opacity: var(--enter);
  text-shadow: 0 2px 24px rgba(0, 0, 0, .55);
}
.readout::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -40% -30% -35% -45%;
  background: radial-gradient(closest-side, rgba(4, 9, 20, .8), rgba(4, 9, 20, .5) 55%, rgba(4, 9, 20, 0));
  pointer-events: none;
}
.readout__label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .78);
}
.readout__value {
  display: block;
  margin: 4px 0 12px;
  font-weight: 300;
  font-size: clamp(46px, 5.2vw, 82px);
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #fff;
}
.readout__bar { display: block; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.readout__bar i {
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: right;
  background: rgb(var(--warm));
  box-shadow: 0 0 10px rgba(var(--warm), .8);
}

/* the whole section reads like a timeline */
.tl {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 18px);
  opacity: var(--enter);
}
.tl__seg { display: block; padding: 12px 0 4px; text-align: left; }
.tl__track {
  position: relative;
  display: block;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(214, 228, 244, .18);
  transition: transform .25s var(--ease-out);
  transform-origin: bottom;
}
.tl__seg:hover .tl__track { transform: scaleY(2); }
.tl__track b {
  position: absolute;
  inset: 0;
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  background: linear-gradient(90deg, var(--cyan-500), var(--cyan-200));
}
.tl__seg span {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-top: 11px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(214, 228, 244, .5);
  transition: color .3s var(--ease);
}
.tl__seg em { font-family: var(--mono); font-size: 11px; font-style: normal; font-weight: 400; color: rgba(214, 228, 244, .38); transition: color .3s var(--ease); }
.tl__seg:hover span,
.tl__seg.is-active span { color: #fff; }
.tl__seg.is-active em { color: rgb(var(--warm)); }
.tl__seg.is-active .tl__track b { background: linear-gradient(90deg, #f5854a, #ffc08a); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px), (max-aspect-ratio: 5/4) {
  .caps__head { text-align: left; }
  .caps__title { padding-right: 84px; }
  .caps__lead { margin: 0; }
  .theatre { --scene-h: min(100vw, 50svh); }
  .scene {
    left: 0;
    right: 0;
    height: var(--scene-h);
    aspect-ratio: auto;
    transform-origin: 50% 50%;
    -webkit-mask-image: linear-gradient(0deg, transparent, #000 24%);
    mask-image: linear-gradient(0deg, transparent, #000 24%);
    -webkit-mask-composite: source-over;
    mask-composite: add;
  }
  .theatre__ui { grid-template-columns: minmax(0, 1fr); padding-top: calc(var(--scene-h) - 8px); }
  .theatre__copy { align-items: start; }
  .fp__title { margin-bottom: 8px; font-size: clamp(38px, 11vw, 64px); }
  .fp__text { margin-bottom: 16px; font-size: 15px; }
  .voice { width: 100%; padding: 8px 16px 8px 8px; gap: 12px; }
  .voice__mic { width: 44px; height: 44px; border-radius: 13px; }
  .voice__ask { font-size: 15.5px; }
  .fp__reply { margin: 10px 0 0 8px; font-size: 14px; }
  .readout {
    position: absolute;
    grid-area: auto;
    top: calc(var(--scene-h) - 96px);
    right: var(--gutter);
    width: 150px;
    margin: 0;
  }
  .readout__value { font-size: 42px; margin-bottom: 8px; }
  .readout__label { font-size: 10px; }
  .tl { grid-column: 1; }
  .tl__seg span { justify-content: flex-start; margin-top: 7px; font-size: 11.5px; }
  .tl__seg span { display: none; }
  .tl__seg.is-active { position: relative; }
  .eli__say { display: none; }
}
@media (max-width: 900px) and (max-height: 720px) {
  .fp__text { display: none; }
}
/* tablets in portrait keep the same stack with larger type */
@media (min-width: 901px) and (max-aspect-ratio: 5/4) {
  .fp__title { font-size: 72px; }
  .tl__seg span { display: flex; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .eli { display: none; }
  .fp__title .ch,
  .fp__text,
  .voice,
  .fp__reply { transition: none !important; }
  .voice.is-listening .voice__mic::after,
  .voice.is-listening .voice__wave i { animation: none; }
}
