/* clockdivider.us — design-first prototype
   Black stage, fullscreen crossfading show fragments, translucent card.
   Three overlay variants switched via <body data-variant="...">:
     frost   — blurred dark glass, soft edges
     signal  — near-solid black panel, red signal accent (matches ad-cut grade)
     phantom — borderline-invisible card: thin rule + darkened backdrop only
*/

:root {
  --red: #e5362e;            /* red mids from the ad-cut grade */
  --ink: #f2efe9;
  --ink-dim: rgba(242, 239, 233, 0.72);
  --fade-in: 2.4s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: #000;
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  overflow: hidden;
}

/* ---------- background video layer ---------- */

.bg {
  position: fixed;
  inset: 0;
  background: #000;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 3s ease; /* FADE_MS in main.js — keep in sync */
  /* fragments are 480p sources; a gentle grade hides the upscale and
     keeps them reading as glimpses, not hero footage */
  filter: contrast(1.06) saturate(0.92) brightness(0.82);
}

.bg-video.live { opacity: 1; }

/* fine scanline/grain veil — unifies disparate fragments, masks softness */
.bg-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.14) 0px,
      rgba(0, 0, 0, 0.14) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: multiply;
}

/* ---------- page fade-in ---------- */

.stage {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 6vmin;
  opacity: 0;
  animation: pagein var(--fade-in) ease 0.3s forwards;
}

@keyframes pagein { to { opacity: 1; } }

/* ---------- overlay card (shared bones) ---------- */

.card {
  width: min(34rem, 92vw);
  padding: clamp(1.75rem, 4vmin, 3rem) clamp(1.5rem, 4vmin, 2.75rem);
  text-align: center;
  /* slightly above optical center */
  transform: translateY(-4vmin);
}

.brand {
  font-size: clamp(1.9rem, 6vw, 3.1rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.1;
}

.line { letter-spacing: 0.18em; }

.show {
  margin-top: 0.9rem;
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
}

.sub {
  margin-top: 0.45rem;
  font-size: clamp(0.72rem, 2vw, 0.85rem);
  color: var(--ink-dim);
  letter-spacing: 0.12em;
}

.cta {
  margin-top: 2rem;
  font-size: clamp(0.95rem, 2.8vw, 1.2rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* ---------- form ---------- */

.signup {
  margin-top: 1.4rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

.signup[hidden] { display: none; }

.signup input {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.85rem 1rem;
  font: inherit;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(242, 239, 233, 0.35);
  border-radius: 2px;
  outline: none;
}

.signup input::placeholder { color: rgba(242, 239, 233, 0.45); }
.signup input:focus { border-color: var(--ink); }

.signup button {
  padding: 0.85rem 1.3rem;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #000;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.signup button:hover { background: var(--red); border-color: var(--red); color: var(--ink); }

.form-note {
  margin-top: 0.9rem;
  min-height: 1.2em;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}

/* ---------- sound toggle ---------- */

.sound-toggle {
  margin-top: 1.1rem;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid rgba(242, 239, 233, 0.3);
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sound-toggle:hover { color: var(--ink); border-color: var(--ink); }

.sound-toggle[aria-pressed="true"] {
  color: var(--red);
  border-color: var(--red);
}

/* ---------- variant A: frost ---------- */

body[data-variant="frost"] .card {
  background: rgba(8, 8, 10, 0.42);
  backdrop-filter: blur(18px) saturate(0.85) brightness(0.85);
  -webkit-backdrop-filter: blur(18px) saturate(0.85) brightness(0.85);
  border: 1px solid rgba(242, 239, 233, 0.14);
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

/* ---------- variant B: signal ---------- */

body[data-variant="signal"] .card {
  background: rgba(3, 3, 4, 0.88);
  border: 1px solid rgba(242, 239, 233, 0.1);
  border-top: 3px solid var(--red);
  border-radius: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

body[data-variant="signal"] .brand { color: var(--ink); }
body[data-variant="signal"] .show { color: var(--red); }

/* ---------- variant C: phantom ---------- */

body[data-variant="phantom"] .card {
  background: transparent;
  backdrop-filter: brightness(0.38) contrast(1.05) blur(2px);
  -webkit-backdrop-filter: brightness(0.38) contrast(1.05) blur(2px);
  border: 1px solid rgba(242, 239, 233, 0.28);
  border-radius: 0;
}

body[data-variant="phantom"] .cta { text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8); }

/* fallback: if backdrop-filter is unsupported, phantom/frost get a solid scrim */
@supports not (backdrop-filter: blur(1px)) {
  body[data-variant="frost"] .card,
  body[data-variant="phantom"] .card {
    background: rgba(5, 5, 6, 0.82);
  }
}

/* ---------- a11y / misc ---------- */

/* A short, deterministic signal dropout: offset horizontal bands, a brief
   red/cyan split, then progressively less of the card survives. */
.card.dissolving {
  pointer-events: none;
  animation: signal-out 720ms steps(1, end) forwards;
}

@keyframes signal-out {
  0% { opacity: 1; }
  12% {
    transform: translate(7px, -4vmin);
    clip-path: polygon(0 0, 100% 0, 100% 25%, 0 25%, 0 31%, 100% 31%, 100% 67%, 0 67%, 0 73%, 100% 73%, 100% 100%, 0 100%);
    text-shadow: -3px 0 #e5362e, 3px 0 #55dce6;
    opacity: 0.9;
  }
  25% {
    transform: translate(-10px, -4vmin);
    clip-path: inset(15% 0 32%);
    text-shadow: 3px 0 #e5362e, -3px 0 #55dce6;
    opacity: 0.75;
  }
  36% {
    transform: translateY(-4vmin);
    clip-path: inset(0);
    text-shadow: none;
    opacity: 0.65;
  }
  52% {
    transform: translate(14px, -4vmin);
    clip-path: polygon(0 12%, 100% 12%, 100% 20%, 0 20%, 0 46%, 100% 46%, 100% 62%, 0 62%, 0 87%, 100% 87%, 100% 92%, 0 92%);
    text-shadow: -4px 0 #e5362e, 4px 0 #55dce6;
    opacity: 0.45;
  }
  70% {
    transform: translate(-18px, -4vmin);
    clip-path: inset(54% 0 38%);
    text-shadow: none;
    opacity: 0.25;
  }
  86% {
    transform: translate(22px, -4vmin);
    clip-path: inset(22% 0 76%);
    opacity: 0.1;
  }
  100% { opacity: 0; }
}

@keyframes card-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .stage { animation-duration: 0.01s; }
  .bg-video { transition: none; }
  .card.dissolving { animation: card-fade-out 720ms ease-out forwards; }
}
