:root {
  --ink: #24303f;
  --ink-60: #6b7280;
  --teal: #0f9f9a;
  --teal-ink: #0b857f;
  --terra: #f59a34;
  --sun: #f5b73d;
  --sand: #f7f1ea;
  --paper: #fffdfb;
  /* House curve, mirrors --bz-ease-out in src/index.css / EASE_OUT in src/lib/motion.ts. */
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  /* Safe areas: the Android app (Capacitor SystemBars) writes --safe-area-inset-*; iOS and browsers give env(). */
  --sat: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --sar: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  --sab: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --sal: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --edge-t: max(16px, calc(var(--sat) + 8px));
  --edge-b: max(16px, calc(var(--sab) + 8px));
  --edge-l: calc(var(--sal) + 16px);
  --edge-r: calc(var(--sar) + 16px);
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; background: var(--sand); color: var(--ink); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }

.stage { position: relative; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; container-type: size; background: var(--sand) center / cover no-repeat; }
/* Recording formats: ?format=vertical (1080x1920) or ?format=landscape (1920x1080), centred, letterboxed. */
.stage.fixed { position: absolute; inset: 0; margin: auto; }
canvas#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.no-webgl canvas#scene { display: none; }

.top {
  position: absolute; top: var(--edge-t); left: var(--edge-l); right: calc(var(--sar) + 176px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.brand, .stories {
  border-radius: 999px; background: rgba(255, 253, 251, 0.86); box-shadow: 0 1px 2px rgba(36, 48, 63, 0.08);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 8px 14px; color: inherit; text-decoration: none;
  font-weight: 700; font-size: 0.875rem; letter-spacing: 0.01em;
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.stories {
  display: inline-flex; padding: 3px; gap: 2px; max-width: 100%;
  /* Large text: the tabs scroll inside the pill instead of spilling off the screen. */
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.stories::-webkit-scrollbar { display: none; }
.stories a {
  display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 12px; border-radius: 999px;
  color: var(--ink-60); font-size: 0.875rem; font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease;
}
.stories a[aria-current="page"] { background: var(--ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) { .stories a:not([aria-current]):hover { color: var(--ink); } }

.caption {
  position: absolute; left: var(--edge-l); right: var(--edge-r); bottom: max(84px, calc(var(--sab) + 72px));
  max-width: 560px; margin: 0 auto;
  padding: 18px 20px; border-radius: 20px;
  background: rgba(255, 253, 251, 0.92); box-shadow: 0 10px 30px rgba(36, 48, 63, 0.12);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.caption.swap { opacity: 0; transform: translateY(6px); }
.step-no { font-size: 0.875rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--teal-ink); }
.caption h1 { margin-top: 4px; font-size: clamp(1.375rem, 1rem + 1.2vw, 1.875rem); line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.step-body { margin-top: 6px; font-size: 1rem; line-height: 1.45; color: var(--ink-60); max-width: 62ch; }
.step-url { margin-top: 10px; font-weight: 800; color: var(--teal-ink); }
.step-app { margin-top: 2px; font-weight: 600; color: var(--ink-60); }
.cta {
  display: inline-flex; align-items: center; min-height: 44px; margin-top: 12px; padding: 0 18px;
  border-radius: 999px; background: var(--teal-ink); color: #fff; font-weight: 800; font-size: 1rem; text-decoration: none;
  transition: transform 160ms var(--ease), filter 160ms ease;
}
.cta:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .cta:hover { filter: brightness(1.08); } }
/* On the page the end card offers the button; the URL line is for videos. */
body:not(.recording) .step-url, body:not(.recording) .step-app { display: none; }
.recording .cta { display: none; }

.dots { position: absolute; left: var(--sal); right: var(--sar); bottom: max(40px, calc(var(--sab) + 28px)); display: flex; justify-content: center; gap: 4px; }
.dots button { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; }
.dots button::before {
  content: ""; width: 24px; height: 8px; border-radius: 999px; background: rgba(36, 48, 63, 0.25);
  transform: scaleX(0.333); transition: transform 220ms var(--ease), background-color 220ms ease;
}
.dots button[aria-current="step"]::before { transform: scaleX(1); background: var(--teal); }

.controls { position: absolute; top: var(--edge-t); right: var(--edge-r); display: flex; gap: 8px; }
.controls button {
  min-width: 44px; height: 44px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255, 253, 251, 0.86); color: var(--ink); font-size: 1rem; font-weight: 700;
  box-shadow: 0 1px 2px rgba(36, 48, 63, 0.08);
  transition: transform 120ms var(--ease);
}
.controls button:active { transform: scale(0.96); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Phones: the dots would not fit at a 44 px tap size, so the arrows step through instead (the caption shows
   "n / 6"). Controls move to the bottom right, under the caption. */
@media (max-width: 560px) {
  .top { right: var(--edge-r); }
  .controls { top: auto; bottom: var(--edge-b); }
  .dots { display: none; }
  .caption { bottom: calc(var(--edge-b) + 56px); padding: 16px 18px; }
}

/* The caption never grows past the header; long text (200% type) scrolls inside it. The engine measures the
   header into --hdr and moves the camera so the action sits in the space the caption leaves free. */
body:not(.recording) .caption {
  max-height: calc(100cqh - var(--hdr, 72px) - max(84px, calc(var(--sab) + 72px)) - 8px);
  overflow-y: auto; overscroll-behavior: contain;
}
@media (max-width: 560px) {
  body:not(.recording) .caption { max-height: calc(100cqh - var(--hdr, 120px) - var(--edge-b) - 64px); }
}

/* Landscape phones (and short windows): a 100dvh stage is only 320-430 px tall, so the caption moves to a
   side card on the left, the controls go bottom right and the scene gets the right-hand side. */
@media (orientation: landscape) and (max-height: 540px) {
  body:not(.recording) .top { right: var(--edge-r); flex-wrap: nowrap; }
  body:not(.recording) .brand { flex: none; white-space: nowrap; }
  body:not(.recording) .stories { flex: 0 1 auto; min-width: 0; }
  body:not(.recording) .stories a { padding: 0 10px; }
  body:not(.recording) .controls { top: auto; bottom: var(--edge-b); right: var(--edge-r); }
  body:not(.recording) .dots { display: none; }
  body:not(.recording) .caption {
    left: var(--edge-l); right: auto; bottom: var(--edge-b); margin: 0;
    width: min(23rem, 46%); max-width: none; padding: 14px 16px; border-radius: 16px;
    max-height: calc(100cqh - var(--hdr, 64px) - var(--edge-b) - 8px);
  }
  body:not(.recording) .caption h1 { font-size: 1.25rem; }
  body:not(.recording) .step-body { font-size: 0.9375rem; }
  body:not(.recording) .cta { margin-top: 10px; }
}

/* ?record=1 hides the chrome a viewer would not want in a video, keeps brand and captions. */
.recording .controls, .recording .dots, .recording .stories { display: none; }
.recording .top { right: 16px; }
.recording .caption { bottom: 48px; }
/* Sized to the stage, so a 1080 px wide capture gets type a phone can read. */
.recording .brand { font-size: max(14px, 2.2cqw); padding: 0.6em 1.1em; }
.recording.landscape .caption { left: 4cqw; right: auto; bottom: 6cqh; max-width: 46cqw; margin: 0; padding: 1.6cqw 2cqw; border-radius: 1.4cqw; }
.recording.landscape .step-no { font-size: 1cqw; }
.recording.landscape .caption h1 { font-size: 2.6cqw; }
.recording.landscape .step-body { font-size: 1.35cqw; }
.recording.landscape .step-url { font-size: 1.6cqw; }
.recording.landscape .step-app { font-size: 1.2cqw; }
/* Vertical (Reels, TikTok, Status): caption in the top third, 140 px clear on the right for the app's buttons. */
.recording.vertical .top { top: 4.5cqh; left: 4.4cqw; }
.recording.vertical .brand { font-size: 3.4cqw; }
.recording.vertical .caption {
  top: 12.5cqh; bottom: auto; left: 4.4cqw; right: 13cqw; max-width: none; margin: 0;
  padding: 3.4cqw 4cqw; border-radius: 3cqw;
}
.recording.vertical .step-no { font-size: 2.4cqw; }
.recording.vertical .caption h1 { font-size: 6.4cqw; }
.recording.vertical .step-body { font-size: 3.5cqw; }
.recording.vertical .step-url { font-size: 4cqw; }
.recording.vertical .step-app { font-size: 3cqw; }

.noscript { position: absolute; left: var(--edge-l); right: var(--edge-r); bottom: var(--edge-b); padding: 16px; background: var(--paper); border-radius: 12px; }

@media (prefers-reduced-motion: reduce) {
  .caption, .dots button::before, .cta, .controls button { transition: none; }
}
