/* Home — the overture "OPEN STRING" (js/home/overture.js).
   Frame 1 is CSS and inline SVG only: the painted sky and a vermilion string
   ringing across the exact middle as a long-exposure lens (23 traces of a
   plucked half-sine). The ring-down runs here too, so the opening is alive
   before any script arrives; the canvas takes over at 0.9 s. */

html[data-page="home"] .overture {
  position: fixed;
  inset: 0;
  right: auto;
  width: 100vw; /* also under a classic scrollbar's reserved gutter */
  z-index: 200;
  contain: strict;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Only if the module never runs: the overlay never traps the page. */
  animation: ov-failsafe 0s linear 10s forwards;
}

@keyframes ov-failsafe {
  to {
    visibility: hidden;
  }
}

html[data-page="home"] .overture.is-armed {
  animation: none;
}

html.no-js .overture,
html[data-site-intro="skip"] .overture,
.overture[hidden] {
  display: none;
}

html[data-page="home"] .overture__frame {
  position: absolute;
  inset: 0;
}

/* A breath of light while the string rings down. */
html[data-page="home"] .overture .sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: ov-brighten 900ms ease-out forwards;
}

@keyframes ov-brighten {
  to {
    opacity: 0.04;
  }
}

/* --- The lens ------------------------------------------------------------------- */
html[data-page="home"] .overture__lens {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* The ring-down scales the traces inside the SVG, so non-scaling strokes stay crisp. */
html[data-page="home"] .overture__traces {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation:
    ov-ring 900ms cubic-bezier(0.12, 0.62, 0.24, 1) forwards,
    ov-breathe 1.2s ease-in-out 900ms infinite alternate;
}

html[data-page="home"] .overture__lens path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

html[data-page="home"] .overture__lens .ov-t {
  --a: calc(0.55 - (var(--d) - 1) * 0.039);
  --keep: 0.45;
  stroke: #ff4f2b;
  stroke-width: 1px;
  opacity: var(--a);
  animation: ov-trace 900ms cubic-bezier(0.12, 0.62, 0.24, 1) forwards;
}

html[data-page="home"] .overture__lens .ov-t--edge,
html[data-page="home"] .overture__lens .ov-t--centre {
  --a: 1;
  --keep: 1;
  stroke-width: 2px;
}

html[data-page="home"] .overture__lens .ov-t--gold {
  --a: 0.75;
  --keep: 0.35;
  stroke: #e2bf4d;
}

@keyframes ov-ring {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(0.15);
  }
}

@keyframes ov-breathe {
  from {
    transform: scaleY(0.15);
  }
  to {
    transform: scaleY(0.17);
  }
}

@keyframes ov-trace {
  to {
    opacity: calc(var(--a) * var(--keep));
  }
}

/* --- The rule at the foot, with six ticks at k/7 (the seventh is coming) -------------- */
html[data-page="home"] .overture__rule {
  position: absolute;
  left: 0;
  right: 0;
  top: 93%;
  height: 1px;
  background: rgb(16 24 58 / 0.3);
}

html[data-page="home"] .overture__rule i {
  position: absolute;
  left: calc(var(--k) / 7 * 100%);
  top: -3px;
  width: 1px;
  height: 7px;
  background: rgb(16 24 58 / 0.55);
  transition: background-color 160ms, transform 300ms var(--ease-out);
}

html[data-page="home"] .overture__rule i.is-lit {
  background: #ff4f2b;
  transform: scaleY(1.6);
}

/* --- Canvas, glyphs and the mark -------------------------------------------------------- */
html[data-page="home"] .overture__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

html[data-page="home"] .overture__glyphs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  visibility: hidden;
}

html[data-page="home"] .overture__glyphs.is-on {
  visibility: visible;
}

html[data-page="home"] .overture__glyphs .wm {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ink);
}

html[data-page="home"] .overture__glyphs .wm__g {
  transform-origin: 50% 50%;
  will-change: transform, clip-path;
}

html[data-page="home"] .overture__glyphs .wm__b {
  clip-path: inset(0 100% 0 0);
}

html[data-page="home"] .overture__mark {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  clip-path: inset(0 100% 0 0);
}

html[data-page="home"] .overture__mark.is-on {
  visibility: visible;
}

html[data-page="home"] .overture__nodes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* --- Skip ---------------------------------------------------------------------------------- */
html[data-page="home"] .overture__skip {
  position: absolute;
  right: var(--gutter);
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgb(16 24 58 / 0.18);
  border-radius: 999px;
  background: rgb(238 244 241 / 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--d-1), border-color var(--d-1);
}

html[data-page="home"] .overture__skip:hover,
html[data-page="home"] .overture__skip:focus-visible {
  background: rgb(238 244 241 / 0.92);
  border-color: rgb(16 24 58 / 0.4);
}

html[data-page="home"] .overture__skip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #eef4f1, 0 0 0 4px #10183a, 0 0 0 6px #eef4f1, 0 0 0 8px #ff4f2b;
}

/* --- States written by overture.js ---------------------------------------------------------- */
html[data-page="home"] .overture.is-canvas .overture__lens {
  visibility: hidden;
}

html[data-page="home"] .overture.is-swapped :is(.sky, .overture__lens, .overture__canvas, .overture__rule, .overture__nodes) {
  visibility: hidden;
}

html[data-page="home"] .overture.is-leaving {
  pointer-events: none;
  cursor: auto;
}

html[data-page="home"] .overture.is-leaving .overture__skip {
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 0s linear 200ms;
}

/* Returning visitors: a fast ring-down. */
html[data-page="home"][data-intro-mode="short"] .overture__traces {
  animation-duration: 350ms, 1.2s;
  animation-delay: 0s, 350ms;
}

html[data-page="home"][data-intro-mode="short"] .overture__lens .ov-t {
  animation-duration: 350ms;
}

/* Reduced motion: frame 1 is a still picture, then a crossfade. */
html[data-page="home"][data-intro-mode="still"] .overture :is(.overture__traces, .overture__lens .ov-t, .sky::after, .sky__clouds) {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  html[data-page="home"] .overture :is(.overture__traces, .overture__lens .ov-t, .sky__clouds) {
    animation: none;
  }
  html[data-page="home"] .overture .sky::after {
    animation: none;
  }
}

/* Until the overture's own frame is parsed, the page underneath is already sky. */
html[data-page="home"][data-site-intro="play"] body {
  background: var(--sky) fixed;
}
