/* Habitat — the 8 flaw animations (storyboards: docs/habitat-animations.md).
   Every scene is a 5-second loop. All timing lives in keyframe percentages
   (1 s = 20%), so every element of a scene shares one clock.
   Reduced motion: every animation is frozen at 4.6 s (92%), the composed last frame.
   Scene canvas: 160 x 100 units; left% = x / 1.6, top% = y. 1em = 2.6% of the width. */

.stage {
  position: relative;
  aspect-ratio: 8 / 5;
  container-type: inline-size;
  overflow: hidden;
  background: var(--bg-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -0.01em;
  user-select: none;
}

.sc {
  position: absolute;
  inset: 3.5% 0 -3.5%; /* centred in the frame since the bottom corner label was removed */
  font-size: 12px;
  font-size: 2.6cqw;
  line-height: 1.2;
  animation: scene 5s infinite;
}
.sc > * { position: absolute; }

/* --- shared pieces --- */

.win {
  left: 4%;
  top: 4%;
  width: 92%;
  height: 85%;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 0.45em;
  background: rgb(255 255 255 / 0.015);
}
.bar {
  display: flex;
  align-items: center;
  gap: 0.9em;
  height: 2em;
  padding: 0 0.8em;
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
}
.dots3 {
  flex: 0 0 auto;
  width: 0.34em;
  height: 0.34em;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.25);
  box-shadow: 0.55em 0 0 rgb(255 255 255 / 0.25), 1.1em 0 0 rgb(255 255 255 / 0.25);
  margin-right: 1.1em;
}
.url {
  display: inline-flex;
  align-items: center;
  height: 1.3em;
  padding: 0 0.75em;
  border-radius: 0.65em;
  background: rgb(255 255 255 / 0.07);
  font: 500 0.66em/1 var(--mono);
  letter-spacing: 0;
  color: rgb(255 255 255 / 0.85);
  white-space: nowrap;
  min-width: 13em;
}
.url-t {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: calc(var(--n) * 1ch);
  animation: type-url 5s steps(var(--n), end) infinite;
}
.s01 .url-t { --n: 17; }
.s02 .url-t { --n: 17; }
.s04 .url-t { --n: 18; }
.s05 .url-t { --n: 17; }
.s06 .url-t { --n: 20; }
.s07 .url-t { --n: 19; }
.s08 .url-t { --n: 17; }

.ic {
  width: 1.6em;
  height: 1.6em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.t { font-size: 0.62em; font-weight: 500; line-height: 1.25; color: rgb(255 255 255 / 0.72); }

.field, .btnbar {
  display: block;
  height: 0.9em;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 0.2em;
}
.btnbar { background: rgb(255 255 255 / 0.22); border-color: transparent; }

.cap {
  --cx: 0%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.42em 0.75em 0.42em 0.6em;
  border-radius: 0.2em;
  background: var(--text);
  color: var(--ink);
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 0.4em 1.4em rgb(0 0 0 / 0.45);
  animation: cap 5s infinite;
}
.cap::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  background: var(--accent);
  border-radius: 0.08em;
}

.keypill {
  z-index: 3;
  padding: 0.3em 0.55em;
  border-radius: 0.2em;
  background: var(--accent);
  color: var(--ink);
  font: 600 0.56em/1 var(--mono);
  letter-spacing: 0;
  white-space: nowrap;
}

.laptop, .stranger {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  color: rgb(255 255 255 / 0.8);
}
.laptop .ic, .stranger .ic { width: 2.6em; height: 2.6em; stroke-width: 1.2; }

/* --- shared keyframes --- */

@keyframes scene {
  0% { opacity: 0; }
  4%, 95% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes type-url {
  0% { width: 0; }
  16%, 100% { width: calc(var(--n) * 1ch); }
}
@keyframes cap {
  0%, 79% { opacity: 0; transform: translate(var(--cx), 0.5em); }
  83%, 100% { opacity: 1; transform: translate(var(--cx), 0); }
}

/* ================= 01 — users table ================= */

.s01 .who {
  left: 5%;
  top: 60%;
  width: 14%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  color: rgb(255 255 255 / 0.85);
  animation: s01-who 5s infinite;
}
.s01 .who .ic { width: 2.2em; height: 2.2em; stroke-width: 1.3; }

.s01 .login {
  left: 19%;
  top: 28%;
  width: 20%;
  height: 52%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55em;
  padding: 0.8em 1em;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.3em;
  background: var(--bg-2);
  animation: s01-login 5s infinite;
}
.s01 .login .lock { align-self: center; width: 1.7em; height: 1.7em; stroke-width: 1.4; }
.s01 .login .t { align-self: center; margin-bottom: 0.15em; }

.s01 .arw {
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgb(255 255 255 / 0.62);
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.s01 .arw-l { stroke-dasharray: 100; animation: s01-arrow 5s infinite; }
.s01 .arw-h { animation: s01-head 5s infinite; }

.s01 .tbl {
  left: 45%;
  top: 21%;
  width: 49%;
  padding: 0.7em 0.8em 0.4em;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.3em;
  background: rgb(255 255 255 / 0.03);
  animation: s01-open 5s infinite;
}
.s01 .tbl-name {
  margin-bottom: 0.6em;
  font: 600 0.62em/1 var(--mono);
  letter-spacing: 0;
}
.s01 .tbl-rows { border-radius: 0.2em; animation: s01-glow 5s infinite; }
.s01 .tr {
  display: grid;
  grid-template-columns: 0.8fr 1.35fr 1fr;
  gap: 0.6em;
  padding: 0.62em 0.4em;
  border-top: 1px solid rgb(255 255 255 / 0.12);
  font: 500 0.5em/1.1 var(--mono);
  letter-spacing: 0;
  white-space: nowrap;
}
.s01 .tr span { overflow: hidden; text-overflow: clip; }
.s01 .r1 { animation: s01-r1 5s infinite; }
.s01 .r2 { animation: s01-r2 5s infinite; }
.s01 .r3 { animation: s01-r3 5s infinite; }
.s01 .r4 { animation: s01-r4 5s infinite; }

.s01 .cap { --cx: -50%; left: 69.5%; top: 76%; }

@keyframes s01-who { 0%, 8% { opacity: 0; transform: translateY(0.4em); } 16%, 100% { opacity: 1; transform: none; } }
@keyframes s01-login { 0%, 10% { opacity: 0; transform: scale(0.96); } 19%, 100% { opacity: 1; transform: none; } }
@keyframes s01-arrow { 0%, 20% { stroke-dashoffset: 100; } 39%, 100% { stroke-dashoffset: 0; } }
@keyframes s01-head { 0%, 37% { opacity: 0; } 40%, 100% { opacity: 1; } }
@keyframes s01-open {
  0%, 40% { opacity: 0; clip-path: inset(0 0 100% 0); }
  41% { opacity: 1; clip-path: inset(0 0 100% 0); }
  48%, 100% { opacity: 1; clip-path: inset(0 0 0 0); }
}
@keyframes s01-r1 { 0%, 48% { opacity: 0; transform: translateX(-0.6em); } 52%, 100% { opacity: 1; transform: none; } }
@keyframes s01-r2 { 0%, 56% { opacity: 0; transform: translateX(-0.6em); } 60%, 100% { opacity: 1; transform: none; } }
@keyframes s01-r3 { 0%, 64% { opacity: 0; transform: translateX(-0.6em); } 68%, 100% { opacity: 1; transform: none; } }
@keyframes s01-r4 { 0%, 72% { opacity: 0; transform: translateX(-0.6em); } 76%, 100% { opacity: 1; transform: none; } }
@keyframes s01-glow {
  0%, 79% { color: rgb(255 255 255 / 0.85); background: transparent; box-shadow: none; }
  83%, 100% {
    color: var(--accent);
    background: color-mix(in oklab, var(--accent) 14%, transparent);
    box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 70%, transparent), 0 0 2.2em color-mix(in oklab, var(--accent) 28%, transparent);
  }
}

/* ================= 02 — login check works backwards ================= */

.s02 .door {
  left: 41%;
  top: 27%;
  width: 12%;
  height: 59%;
  border: 1px solid rgb(255 255 255 / 0.34);
  border-bottom: 0;
  border-radius: 0.2em 0.2em 0 0;
  background: rgb(255 255 255 / 0.04);
}
.s02 .door .knob {
  position: absolute;
  right: 0.7em;
  top: 52%;
  width: 0.36em;
  height: 0.36em;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.55);
}

.s02 .fig {
  top: 32%;
  width: 15%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35em;
  text-align: center;
  color: rgb(255 255 255 / 0.85);
}
.s02 .fig-a { left: 6%; }
.s02 .fig-b { left: 22.5%; animation: s02-walk 5s infinite; }
.s02 .fig .body { width: 2.4em; height: 2.4em; stroke-width: 1.3; }
.s02 .fig .t { font-size: 0.56em; }

.s02 .mark {
  display: grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
}
.s02 .mark .ic { width: 1em; height: 1em; stroke-width: 2.4; }
.s02 .mark-x { background: var(--accent); color: var(--ink); animation: s02-x 5s infinite; }
.s02 .mark-ok { background: var(--ok); color: var(--ink); animation: s02-ok 5s infinite; }
.s02 .deny {
  position: absolute;
  top: -1.2em;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.56em;
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent);
  animation: s02-x 5s infinite;
}

.s02 .list {
  left: 60%;
  top: 17%;
  width: 34%;
  height: 68%;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.3em;
  background: rgb(255 255 255 / 0.03);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%);
  animation: s02-list 5s infinite;
}
.s02 .list-in { padding: 0.4em 0.8em; animation: s02-scroll 5s infinite; }
.s02 .list-in p {
  padding: 0.75em 0;
  border-bottom: 1px solid rgb(255 255 255 / 0.12);
  font: 500 0.52em/1 var(--mono);
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--accent);
}

.s02 .cap { --cx: -50%; left: 24%; top: 76%; }

@keyframes s02-x { 0%, 30% { opacity: 0; transform: translate(var(--tx, 0), 0.3em) scale(0.6); } 34%, 100% { opacity: 1; transform: translate(var(--tx, 0), 0) scale(1); } }
.s02 .deny { --tx: -50%; }
@keyframes s02-ok { 0%, 50% { opacity: 0; transform: scale(0.6); } 54%, 100% { opacity: 1; transform: none; } }
@keyframes s02-walk { 0%, 55% { transform: none; } 66%, 100% { transform: translateX(1.5em); } }
@keyframes s02-list { 0%, 52% { opacity: 0; } 57%, 100% { opacity: 1; } }
@keyframes s02-scroll { 0%, 55% { transform: translateY(0); } 80%, 100% { transform: translateY(-38%); } }

/* ================= 03 — change one number ================= */

.s03 .url { min-width: 0; }
.s03 .num { display: inline-grid; }
.s03 .num > span { grid-area: 1 / 1; overflow: hidden; white-space: nowrap; }
.s03 .n-old { animation: s03-old 5s infinite; }
.s03 .n-new { width: 4ch; color: var(--accent); animation: s03-new 5s steps(4, end) infinite; }

.s03 .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin-left: auto;
  padding: 0.25em 0.6em 0.25em 0.4em;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 1em;
  font-size: 0.56em;
  font-weight: 500;
  white-space: nowrap;
  color: rgb(255 255 255 / 0.85);
}
.s03 .badge .ic { width: 1.3em; height: 1.3em; stroke-width: 1.6; }

.s03 .order {
  left: 24%;
  top: 27%;
  width: 52%;
  height: 46%;
  perspective: 40em;
}
.s03 .order-in {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: s03-flip 5s infinite;
}
.s03 .face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.55em;
  padding: 0 1.4em;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.3em;
  background: var(--bg-2);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.s03 .face-b {
  transform: rotateY(180deg);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 2.4em color-mix(in oklab, var(--accent) 25%, transparent);
}
.s03 .o-id { font: 500 0.56em/1 var(--mono); letter-spacing: 0; color: rgb(255 255 255 / 0.55); }
.s03 .o-main { font-size: 0.9em; font-weight: 600; white-space: nowrap; }
.s03 .face-b .o-main { color: var(--accent); font-size: 0.78em; }
.s03 .o-line { display: block; height: 0.42em; width: 70%; border-radius: 0.2em; background: rgb(255 255 255 / 0.12); }
.s03 .o-line.short { width: 42%; }

.s03 .cursor {
  left: 48.5%;
  top: 9.5%;
  width: 1.5em;
  height: 1.5em;
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 1.2;
  stroke-linejoin: round;
  animation: s03-cursor 5s infinite;
}

.s03 .cap { --cx: -50%; left: 50%; top: 78%; }

@keyframes s03-old {
  0%, 29% { opacity: 1; background: transparent; }
  31%, 41% { opacity: 1; background: rgb(255 255 255 / 0.85); color: var(--ink); }
  42%, 100% { opacity: 0; }
}
@keyframes s03-new { 0%, 42% { width: 0; } 50%, 100% { width: 4ch; } }
@keyframes s03-flip { 0%, 52% { transform: rotateY(0); } 62%, 100% { transform: rotateY(180deg); } }
@keyframes s03-cursor {
  0%, 12% { opacity: 0; transform: translate(6em, 9em); }
  16% { opacity: 1; transform: translate(6em, 9em); }
  29%, 44% { opacity: 1; transform: translate(0, 0); }
  52%, 100% { opacity: 0; transform: translate(0.4em, 0.6em); }
}

/* ================= 04 — paid features open without paying ================= */

.s04 .side {
  left: 6.5%;
  top: 18%;
  width: 15%;
  display: grid;
  gap: 0.6em;
}
.s04 .side span { display: block; height: 0.45em; border-radius: 0.2em; background: rgb(255 255 255 / 0.12); }
.s04 .side span:first-child { width: 70%; background: rgb(255 255 255 / 0.3); }

.s04 .sheet {
  left: 26%;
  top: 18%;
  width: 38%;
  display: grid;
  gap: 0.65em;
  padding-left: 1.4em;
  border-left: 1px solid rgb(255 255 255 / 0.12);
}
.s04 .sheet span { display: block; height: 0.42em; border-radius: 0.2em; background: rgb(255 255 255 / 0.12); }
.s04 .sheet .sheet-h { height: 0.75em; width: 60%; background: rgb(255 255 255 / 0.32); margin-bottom: 0.3em; }
.s04 .sheet .short { width: 55%; }

.s04 .export {
  left: 68.5%;
  top: 17%;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.35em 0.75em 0.35em 0.5em;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: 0.25em;
  font-size: 0.7em;
  font-weight: 600;
  white-space: nowrap;
  color: rgb(255 255 255 / 0.5);
  animation: s04-export 5s infinite;
}
.s04 .padlock { width: 1.5em; height: 1.5em; stroke-width: 1.6; }
.s04 .shackle { transform-box: view-box; transform-origin: 16px 10.5px; animation: s04-shackle 5s infinite; }

.s04 .pro {
  left: 69%;
  top: 27.5%;
  padding: 0.2em 0.5em;
  border-radius: 0.2em;
  background: rgb(255 255 255 / 0.1);
  font-size: 0.52em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgb(255 255 255 / 0.7);
  animation: s04-pro 5s infinite;
}

.s04 .pdf {
  left: 74%;
  top: 31%;
  display: grid;
  place-items: center;
  color: var(--accent);
  animation: s04-pdf 5s infinite;
}
.s04 .pdf .ic { width: 3em; height: 3em; stroke-width: 1.2; }
.s04 .pdf span {
  position: absolute;
  top: 58%;
  font-size: 0.5em;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.s04 .tools {
  left: 4%;
  top: 58%;
  width: 92%;
  height: 31%;
  border-top: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0 0 0.45em 0.45em;
  background: rgb(8 8 8);
  animation: s04-tools 5s infinite;
}
.s04 .tools-tabs {
  display: flex;
  gap: 1.4em;
  padding: 0.55em 1em;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  font-size: 0.5em;
  font-weight: 500;
  color: rgb(255 255 255 / 0.5);
}
.s04 .tools-tabs .on { color: var(--text); }
.s04 .tools-line {
  padding: 0.7em 1em;
  font: 500 0.66em/1 var(--mono);
  letter-spacing: 0;
  color: rgb(255 255 255 / 0.85);
  white-space: nowrap;
}
.s04 .pr { color: rgb(255 255 255 / 0.4); }
.s04 .val { display: inline-grid; }
.s04 .val > span { grid-area: 1 / 1; overflow: hidden; white-space: nowrap; }
.s04 .v-f { width: 5ch; animation: s04-false 5s steps(5, end) infinite; }
.s04 .v-t { width: 4ch; color: var(--accent); animation: s04-true 5s steps(4, end) infinite; }

.s04 .cap { left: 26%; top: 44%; }

@keyframes s04-tools { 0%, 20% { transform: translateY(170%); } 30%, 100% { transform: none; } }
@keyframes s04-false { 0%, 50% { width: 5ch; } 57%, 100% { width: 0; } }
@keyframes s04-true { 0%, 58% { width: 0; } 66%, 100% { width: 4ch; } }
@keyframes s04-shackle { 0%, 70% { transform: none; } 74%, 100% { transform: translateY(-2.5px) rotate(28deg); } }
@keyframes s04-export {
  0%, 70% { color: rgb(255 255 255 / 0.5); border-color: rgb(255 255 255 / 0.3); }
  74%, 100% { color: var(--accent); border-color: var(--accent); }
}
@keyframes s04-pro { 0%, 70% { opacity: 1; } 74%, 100% { opacity: 0.25; text-decoration: line-through; } }
@keyframes s04-pdf {
  0%, 71% { opacity: 0; transform: translateY(-2.4em) scale(0.4); }
  74% { opacity: 1; transform: translateY(-2em) scale(0.6); }
  82%, 100% { opacity: 1; transform: none; }
}

/* ================= 05 — login switches off on error ================= */

.s05 .dash {
  left: 6.5%;
  top: 16%;
  width: 87%;
  height: 70%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr 1.6fr;
  gap: 0.8em;
  animation: s05-blur 5s infinite;
}
.s05 .tile { border: 1px solid rgb(255 255 255 / 0.16); border-radius: 0.3em; background: rgb(255 255 255 / 0.03); }
.s05 .tile::before {
  content: "";
  display: block;
  width: 45%;
  height: 0.5em;
  margin: 0.8em 0 0 0.8em;
  border-radius: 0.2em;
  background: rgb(255 255 255 / 0.25);
}
.s05 .chart {
  grid-column: 1 / 3;
  display: flex;
  align-items: flex-end;
  gap: 0.6em;
  padding: 0.8em;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 0.3em;
}
.s05 .chart i { flex: 1; border-radius: 0.15em 0.15em 0 0; background: rgb(255 255 255 / 0.22); }
.s05 .chart i:nth-child(1) { height: 30%; }
.s05 .chart i:nth-child(2) { height: 55%; }
.s05 .chart i:nth-child(3) { height: 40%; }
.s05 .chart i:nth-child(4) { height: 75%; }
.s05 .chart i:nth-child(5) { height: 60%; }
.s05 .chart i:nth-child(6) { height: 88%; }
.s05 .chart i:nth-child(7) { height: 70%; }
.s05 .keyf {
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 0.3em;
  font: 600 0.62em/1 var(--mono);
  letter-spacing: 0;
  white-space: nowrap;
  animation: s05-key 5s infinite;
}

.s05 .signin {
  left: 35%;
  top: 22%;
  width: 30%;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  padding: 1em 1.2em 1.1em;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 0.35em;
  background: var(--bg-2);
  box-shadow: 0 1em 3em rgb(0 0 0 / 0.55);
  animation: s05-signin 5s infinite;
}
.s05 .signin > .t { font-size: 0.75em; font-weight: 600; color: var(--text); margin-bottom: 0.2em; }
.s05 .err {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.6em;
  font-weight: 600;
  color: var(--accent);
  animation: s05-err 5s infinite;
}
.s05 .err .ic { width: 1.4em; height: 1.4em; stroke-width: 1.8; }

.s05 .tag {
  right: 6%;
  top: 5.3%;
  padding: 0.25em 0.6em;
  border-radius: 1em;
  background: var(--text);
  color: var(--ink);
  font-size: 0.55em;
  font-weight: 600;
  white-space: nowrap;
  animation: s05-tag 5s infinite;
}

.s05 .cap { --cx: -50%; left: 50%; top: 77%; }

@keyframes s05-blur { 0%, 50% { filter: blur(0.3em); opacity: 0.75; } 60%, 100% { filter: blur(0); opacity: 1; } }
@keyframes s05-err { 0%, 30% { opacity: 0; } 34%, 100% { opacity: 1; } }
@keyframes s05-signin {
  0%, 8% { opacity: 0; transform: translateY(0.5em); }
  14%, 50% { opacity: 1; transform: none; }
  58%, 100% { opacity: 0; transform: translateY(-0.4em) scale(0.97); }
}
@keyframes s05-key {
  0%, 60% { color: rgb(255 255 255 / 0.8); border-color: rgb(255 255 255 / 0.16); background: transparent; }
  66%, 100% { color: var(--accent); border-color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); }
}
@keyframes s05-tag { 0%, 56% { opacity: 0; transform: translateY(-0.4em); } 62%, 100% { opacity: 1; transform: none; } }

/* ================= 06 — Stripe secret key in the code ================= */

.s06 .book {
  left: 6.5%;
  top: 17%;
  width: 44%;
  height: 68%;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
  animation: s06-book 5s infinite;
}
.s06 .book-h { display: block; width: 55%; height: 0.75em; border-radius: 0.2em; background: rgb(255 255 255 / 0.3); }
.s06 .cal { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.45em; }
.s06 .cal i { aspect-ratio: 1.3; border: 1px solid rgb(255 255 255 / 0.16); border-radius: 0.2em; }
.s06 .cal i.on { background: rgb(255 255 255 / 0.5); border-color: transparent; }
.s06 .book .btnbar { width: 40%; height: 1.2em; }

.s06 .code6 {
  left: 53%;
  top: 14.5%;
  width: 41.5%;
  height: 72%;
  overflow: hidden;
  border-left: 1px solid rgb(255 255 255 / 0.16);
  background: rgb(8 8 8);
  animation: s06-panel 5s infinite;
}
.s06 .code6-in { padding: 0.8em 0 0 0.9em; animation: s06-scroll 5s infinite; }
.s06 .code6-in p {
  font: 500 0.56em/1.75 var(--mono);
  letter-spacing: 0;
  white-space: pre;
  color: rgb(255 255 255 / 0.55);
}
.s06 .code6-in p.kl {
  margin-left: -0.9em;
  padding-left: 0.9em;
  animation: s06-key 5s infinite;
}

.s06 .stranger {
  left: 21%;
  top: 63%;
  animation: s06-stranger 5s infinite;
}
.s06 .keypill {
  left: 30.5%;
  top: 68.5%;
  animation: s06-pill 5s infinite;
}

.s06 .cap { --cx: -50%; left: 73.5%; top: 78%; }

@keyframes s06-book { 0%, 12% { opacity: 0; } 18%, 100% { opacity: 1; } }
@keyframes s06-panel { 0%, 20% { transform: translateX(105%); } 30%, 100% { transform: none; } }
@keyframes s06-scroll { 0%, 30% { transform: translateY(0); } 50%, 100% { transform: translateY(-9em); } }
@keyframes s06-key {
  0%, 50% { color: rgb(255 255 255 / 0.55); background: transparent; box-shadow: none; }
  55%, 100% { color: var(--accent); background: color-mix(in oklab, var(--accent) 16%, transparent); box-shadow: inset 0.15em 0 0 var(--accent); }
}
@keyframes s06-stranger { 0%, 64% { opacity: 0; transform: translateY(0.5em); } 69%, 100% { opacity: 1; transform: none; } }
@keyframes s06-pill {
  0%, 68% { opacity: 0; transform: translate(28.4em, -9.8em); }
  71% { opacity: 1; transform: translate(28.4em, -9.8em); }
  84%, 100% { opacity: 1; transform: translate(0, 0); }
}

/* ================= 07 — fake "payment received" message ================= */

.s07 .win { width: 66%; }

.s07 .course {
  left: 7.5%;
  top: 17%;
  width: 36%;
  height: 66%;
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}
.s07 .welcome {
  padding: 0.5em 0.7em;
  border-radius: 0.25em;
  background: var(--text);
  color: var(--ink);
  font-size: 0.7em;
  font-weight: 600;
  white-space: nowrap;
  animation: s07-welcome 5s infinite;
}
.s07 .c-title { font-size: 0.95em; font-weight: 600; white-space: nowrap; }
.s07 .c-line { display: block; height: 0.42em; width: 90%; border-radius: 0.2em; background: rgb(255 255 255 / 0.12); }
.s07 .c-line.short { width: 60%; }
.s07 .paybtn {
  align-self: flex-start;
  margin-top: 0.3em;
  padding: 0.45em 1.4em;
  border: 1px solid rgb(255 255 255 / 0.4);
  border-radius: 0.25em;
  font-size: 0.65em;
  font-weight: 600;
  color: rgb(255 255 255 / 0.8);
}

.s07 .inbox {
  left: 48%;
  top: 46%;
  width: 15%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25em;
  color: rgb(255 255 255 / 0.85);
}
.s07 .inbox > .ic { width: 2.6em; height: 2.6em; stroke-width: 1.2; }
.s07 .inbox .ok {
  position: absolute;
  z-index: 4;
  top: -0.2em;
  right: -0.2em;
  display: grid;
  place-items: center;
  width: 1.3em;
  height: 1.3em;
  border-radius: 50%;
  background: var(--ok);
  color: var(--ink);
  animation: s07-ok 5s infinite;
}
.s07 .inbox .ok .ic { width: 0.9em; height: 0.9em; stroke-width: 2.6; }

.s07 .laptop { left: 76%; top: 50%; }

.s07 .env {
  z-index: 2;
  left: 71%;
  top: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  padding: 0.5em 0.7em 0.45em;
  border: 1px solid rgb(255 255 255 / 0.4);
  border-radius: 0.25em;
  background: var(--bg-2);
  animation: s07-env 5s infinite;
}
.s07 .env > .ic { width: 1.8em; height: 1.8em; stroke-width: 1.3; }
.s07 .stamp {
  padding: 0.2em 0.45em;
  border: 1px solid var(--accent);
  border-radius: 0.15em;
  color: var(--accent);
  font-size: 0.5em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-4deg);
}
.s07 .signed {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.48em;
  color: rgb(255 255 255 / 0.55);
}
.s07 .signed i { width: 0.9em; height: 0.9em; border: 1px dashed rgb(255 255 255 / 0.55); border-radius: 0.1em; }

.s07 .cap { --cx: -50%; left: 50%; top: 80%; }

@keyframes s07-env {
  0%, 18% { opacity: 0; transform: translate(0.6em, 3.6em) scale(0.6); }
  22% { opacity: 1; transform: translate(0, 2.6em) scale(0.9); }
  44%, 100% { opacity: 1; transform: translate(-9.2em, 4.2em) scale(0.86); }
}
@keyframes s07-ok { 0%, 52% { opacity: 0; transform: scale(0.4); } 57%, 100% { opacity: 1; transform: none; } }
@keyframes s07-welcome { 0%, 70% { opacity: 0; transform: translateY(-0.4em); } 76%, 100% { opacity: 1; transform: none; } }

/* ================= 08 — OpenAI key in the code ================= */

.s08 .win { width: 62.5%; }

.s08 .bill {
  left: 7.5%;
  top: 16%;
  width: 55%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.8em;
  animation: s08-bill 5s infinite;
}
.s08 .bill .t { color: var(--text); font-weight: 600; white-space: nowrap; }
.s08 .track { display: block; height: 0.7em; border-radius: 0.35em; background: rgb(255 255 255 / 0.1); overflow: hidden; }
.s08 .fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: 0 50%;
  animation: s08-fill 5s infinite;
}

.s08 .bubble {
  right: 41%;
  top: 29%;
  padding: 0.35em 0.8em;
  border-radius: 0.8em 0.8em 0.2em 0.8em;
  background: rgb(255 255 255 / 0.85);
  color: var(--ink);
  font-size: 0.7em;
  font-weight: 600;
  animation: s08-bubble 5s infinite;
}

.s08 .net {
  left: 7.5%;
  top: 41%;
  width: 55%;
  display: grid;
  gap: 0.6em;
  padding: 0.7em 0.9em;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 0.3em;
  background: rgb(8 8 8);
  font: 500 0.58em/1 var(--mono);
  letter-spacing: 0;
  white-space: nowrap;
  animation: s08-net 5s infinite;
}
.s08 .net-to { color: rgb(255 255 255 / 0.55); }
.s08 .net-key { justify-self: start; padding: 0.25em 0.4em; margin-left: -0.4em; border-radius: 0.2em; animation: s08-key 5s infinite; }

.s08 .chatin {
  left: 7.5%;
  top: 73%;
  width: 55%;
  height: 9%;
  display: flex;
  align-items: center;
  padding: 0 0.8em;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 0.3em;
}
.s08 .typed {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: 2ch;
  font: 500 0.66em/1 var(--mono);
  letter-spacing: 0;
  border-right: 1px solid rgb(255 255 255 / 0.7);
  animation: s08-type 5s steps(2, end) infinite;
}

.s08 .ai {
  left: 73%;
  top: 15%;
  width: 22%;
  height: 15%;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.4);
  border-radius: 0.3em;
  font-size: 0.62em;
  font-weight: 600;
  white-space: nowrap;
}
.s08 .links {
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgb(255 255 255 / 0.4);
  stroke-width: 0.5;
  stroke-dasharray: 1.2 1.2;
  overflow: visible;
  animation: s08-net 5s infinite;
}

.s08 .laptop { left: 74.5%; top: 62%; animation: s08-laptop 5s infinite; }

.s08 .stream {
  left: 83.5%;
  top: 31%;
  width: 0.3em;
  height: 22%;
  border-radius: 0.15em;
  background: repeating-linear-gradient(to top, var(--accent) 0 0.35em, transparent 0.35em 1.1em);
  animation: s08-stream 5s linear infinite;
}

.s08 .keypill { left: 71.5%; top: 55%; animation: s08-pill 5s infinite; }

.s08 .cap { left: 7.5%; top: 26.5%; }

@keyframes s08-type {
  0%, 3% { width: 0; }
  12%, 15% { width: 2ch; }
  16%, 100% { width: 0; border-color: transparent; }
}
@keyframes s08-bubble { 0%, 15% { opacity: 0; transform: translateY(0.4em); } 19%, 100% { opacity: 1; transform: none; } }
@keyframes s08-net { 0%, 21% { opacity: 0; } 27%, 100% { opacity: 1; } }
@keyframes s08-key {
  0%, 30% { color: rgb(255 255 255 / 0.85); background: transparent; }
  36%, 100% { color: var(--ink); background: var(--accent); box-shadow: 0 0 1.6em color-mix(in oklab, var(--accent) 45%, transparent); }
}
@keyframes s08-laptop { 0%, 44% { opacity: 0; transform: translateY(0.5em); } 49%, 100% { opacity: 1; transform: none; } }
@keyframes s08-pill {
  0%, 48% { opacity: 0; transform: translate(-42.9em, -3.6em); }
  50% { opacity: 1; transform: translate(-42.9em, -3.6em); }
  58%, 100% { opacity: 1; transform: none; }
}
@keyframes s08-stream {
  0% { opacity: 0; background-position: 0 0; }
  58% { opacity: 0; }
  61%, 92% { opacity: 1; }
  96% { opacity: 0; }
  100% { opacity: 0; background-position: 0 -22em; }
}
@keyframes s08-bill { 0%, 74% { opacity: 0; } 78%, 100% { opacity: 1; } }
@keyframes s08-fill { 0%, 77% { transform: scaleX(0.04); } 92%, 100% { transform: scaleX(0.92); } }

/* ================= small stages: phones, and 2 columns on narrow laptops =================
   The scene keeps its layout, but its words get a floor: captions 12px, labels and key
   pills 9px, mock-screen text 7.5–8px. Pieces that would then collide move a little.
   Moves use cqw (1% of the stage width), so they don't change when a font size does. */

@container (max-width: 600px) {
  .t { font-size: max(0.62em, 9px); }
  .cap { font-size: max(0.95em, 12px); }
  .keypill { font-size: max(0.56em, 9px); }
  .url { font-size: max(0.66em, 7.5px); min-width: 0; }

  /* 01 */
  .s01 .who { left: 4%; width: 16%; }
  .s01 .login { left: 21.5%; }
  .s01 .tbl-name { font-size: max(0.62em, 9px); }
  .s01 .tr { grid-template-columns: 0.75fr 1.5fr; gap: 0.5em; font-size: max(0.5em, 8px); padding: 0.45em 0.3em; }
  .s01 .tr span:nth-child(3) { display: none; }

  /* 02 */
  .s02 .fig .t { font-size: max(0.56em, 9px); }
  .s02 .deny { font-size: max(0.56em, 9px); top: -1.6em; }
  .s02 .fig-a { left: 3%; }
  .s02 .fig-b { left: 21%; }
  .s02 .list-in p { font-size: max(0.52em, 7.5px); }
  .s02 .cap { --cx: 0%; left: 3.5%; top: 77%; }

  /* 03 */
  .s03 .badge { font-size: max(0.56em, 9px); }
  .s03 .o-id { font-size: max(0.56em, 8px); }
  .s03 .o-main { font-size: max(0.9em, 10px); }
  .s03 .face-b .o-main { font-size: max(0.78em, 9px); white-space: normal; line-height: 1.25; }
  .s03 .order { left: 18%; width: 64%; }

  /* 04 */
  .s04 .export { left: 66%; font-size: max(0.7em, 9px); }
  .s04 .pro { left: 66.5%; top: 29%; font-size: max(0.52em, 8px); }
  .s04 .pdf { top: 36%; }
  .s04 .pdf span { font-size: max(0.5em, 7px); }
  .s04 .tools-tabs { font-size: max(0.5em, 8px); }
  .s04 .tools-line { font-size: max(0.66em, 9px); }

  /* 05 */
  .s05 .keyf { font-size: max(0.62em, 8.5px); }
  .s05 .signin > .t { font-size: max(0.75em, 10px); }
  .s05 .err { font-size: max(0.6em, 9px); }
  .s05 .tag { font-size: max(0.55em, 9px); }

  /* 06 */
  .s06 .stranger { left: 6%; }
  .s06 .keypill { left: 19%; animation-name: s06-pill-sm; }

  /* 07 */
  .s07 .welcome { font-size: max(0.7em, 9px); }
  .s07 .c-title { font-size: max(0.95em, 10px); }
  .s07 .paybtn { font-size: max(0.65em, 9px); }
  .s07 .stamp { font-size: max(0.5em, 8.5px); letter-spacing: 0.02em; }
  .s07 .signed { font-size: max(0.48em, 8px); }
  .s07 .inbox { left: 53.5%; }
  .s07 .env { left: 66%; animation-name: s07-env-sm; }

  /* 08 */
  .s08 .bubble { right: 35%; font-size: max(0.7em, 9px); }
  .s08 .net { font-size: max(0.58em, 8.5px); }
  .s08 .typed { font-size: max(0.66em, 8px); }
  .s08 .ai { font-size: max(0.62em, 9px); }
  .s08 .keypill { left: 67%; animation-name: s08-pill-sm; }
}

/* The key pills' flights for small stages: each starts on the key in the code and ends
   where the pill sits above. Measured at 375px wide. */
@keyframes s06-pill-sm {
  0%, 68% { opacity: 0; transform: translate(52.85cqw, -14.27cqw); }
  71% { opacity: 1; transform: translate(52.85cqw, -14.27cqw); }
  84%, 100% { opacity: 1; transform: translate(0, 0); }
}
/* The bigger envelope starts further left, and lands above the inbox so "Inbox" stays readable. */
@keyframes s07-env-sm {
  0%, 18% { opacity: 0; transform: translate(1.56cqw, 9.36cqw) scale(0.6); }
  22% { opacity: 1; transform: translate(0, 6.76cqw) scale(0.9); }
  44%, 100% { opacity: 1; transform: translate(-21.8cqw, 0.5cqw); }
}
@keyframes s08-pill-sm {
  0%, 48% { opacity: 0; transform: translate(-58.8cqw, -2.9cqw); }
  50% { opacity: 1; transform: translate(-58.8cqw, -2.9cqw); }
  58%, 100% { opacity: 1; transform: none; }
}

/* ================= performance and reduced motion ================= */

/* main.js marks scenes that are off screen; they stop drawing */
.stage.is-off *, .stage.is-off *::before, .stage.is-off *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::before, .stage *::after {
    animation-duration: 5s !important;
    animation-delay: -4.6s !important;
    animation-play-state: paused !important;
  }
}
