/* Secret³.dev — teaser
   Monochrome, film-grain, high contrast — matches logo & motion mark. */

:root {
  --bg: #000000;
  --fg: #f4f4f4;
  --fg-muted: rgba(244, 244, 244, 0.62);
  --fg-faint: rgba(244, 244, 244, 0.28);
  --fg-ghost: rgba(244, 244, 244, 0.1);
  --line: rgba(255, 255, 255, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-serif: "Cormorant Garamond", "Times New Roman", Times, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --stage-pad: clamp(0.75rem, 3.5vw, 2.25rem);
  /* Video + banner scale with viewport; stay inside mobile chrome */
  --video-size: min(82vw, 52vh, 640px);
  --banner-max-w: min(92vw, calc(var(--video-size) * 1.08), 720px);
  --banner-max-h: clamp(4.5rem, 14vh, 12.5rem);
  --banner-aspect: 1157 / 379;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  /* Slight lift off pure black — closer to film stock in the video */
  background: #030303;
  color: var(--fg);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  font-family: var(--font-serif);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Atmosphere layer (behind stage) ─────────────────────────── */
.atmosphere {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #000;
}

/* Soft base texture under everything — not flat digital black */
.film-base {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 40%, #0a0a0a 0%, #000 70%),
    #000;
}

/* Spotlight pool behind the centered stack */
.stage-light {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(120vw, 1100px);
  height: min(110vh, 920px);
  transform: translate(-50%, -50%);
  background:
    radial-gradient(
      ellipse 48% 42% at 50% 48%,
      rgba(255, 255, 255, 0.07) 0%,
      rgba(255, 255, 255, 0.025) 38%,
      transparent 68%
    ),
    radial-gradient(
      ellipse 70% 55% at 50% 55%,
      rgba(255, 255, 255, 0.02) 0%,
      transparent 70%
    );
  animation: stage-light-breathe 7s ease-in-out infinite;
}

@keyframes stage-light-breathe {
  0%,
  100% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
  }
}

/* Depth watermark — barely-there; keep out of the way on small screens */
.depth-mark {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(72vw, 520px);
  transform: translate(-50%, -50%);
  opacity: 0.035;
  mix-blend-mode: screen;
  animation: depth-drift 18s ease-in-out infinite;
}

.depth-mark img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

@keyframes depth-drift {
  0%,
  100% {
    opacity: 0.03;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.048;
    transform: translate(-50%, -51.5%) scale(1.02);
  }
}

/* Full-viewport ambient signal field (JS-drawn) */
.ambient-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.45;
  mix-blend-mode: screen;
}

/* Film grain — matches teaser video grit */
.grain {
  position: absolute;
  inset: -25%;
  z-index: 2;
  background-image: url("/assets/film-grain.jpg?v=20260803e");
  background-repeat: repeat;
  pointer-events: none;
}

.grain--coarse {
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-size: 220px 220px;
  animation: grain-shift 0.7s steps(2) infinite;
}

.grain--fine {
  opacity: 0.16;
  mix-blend-mode: soft-light;
  background-size: 110px 110px;
  animation: grain-shift-alt 0.55s steps(3) infinite;
  /* SVG noise on top of photo grain for extra density */
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/%3E%3C/svg%3E"),
    url("/assets/film-grain.jpg?v=20260803e");
  background-size: 160px 160px, 95px 95px;
}

@keyframes grain-shift {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-1.2%, 0.9%);
  }
  50% {
    transform: translate(1.1%, -1.3%);
  }
  75% {
    transform: translate(-0.6%, -0.8%);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes grain-shift-alt {
  0% {
    transform: translate(0, 0);
  }
  33% {
    transform: translate(1.4%, -0.7%);
  }
  66% {
    transform: translate(-1.1%, 1.2%);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* Horizontal scanlines — same film language as the video */
.scanlines {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.07;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.045) 0,
    rgba(255, 255, 255, 0.045) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: radial-gradient(
    ellipse 75% 65% at 50% 46%,
    transparent 28%,
    rgba(0, 0, 0, 0.35) 68%,
    rgba(0, 0, 0, 0.72) 100%
  );
}

/* Full-screen film overlay — sits over video + UI so grain is continuous */
.film-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
}

.grain--overlay {
  inset: -30%;
  opacity: 0.14;
  mix-blend-mode: overlay;
  background-size: 180px 180px;
  animation: grain-shift 0.65s steps(2) infinite;
}

.scanlines--overlay {
  opacity: 0.045;
  z-index: 1;
}

/* ── Stage (content) ─────────────────────────────────────────── */
.stage {
  position: relative;
  z-index: 10;
  min-height: 100dvh;
  min-height: 100svh; /* mobile browser chrome */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.65rem, 2vh, 1.5rem);
  padding: var(--stage-pad);
  padding-top: max(var(--stage-pad), env(safe-area-inset-top));
  padding-bottom: max(var(--stage-pad), env(safe-area-inset-bottom));
  text-align: center;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  /* Prevent ghost watermark bleeding through gaps */
  background: transparent;
  animation: stage-in 1.4s var(--ease) both;
}

@keyframes stage-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Living banner — fixed aspect so WebViews don't collapse/stretch it */
.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: var(--banner-max-w);
  line-height: 0;
  flex-shrink: 0;
  z-index: 2;
}

.banner-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  /* Reserve space from aspect ratio, not a tall min-height that leaves ghosts */
  aspect-ratio: var(--banner-aspect);
  max-height: var(--banner-max-h);
  height: auto;
  margin-inline: auto;
}

.banner-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  /* drop-shadow filters glitch in some in-app WebViews */
  filter: none;
  user-select: none;
  pointer-events: none;
}

.banner-fallback {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  pointer-events: none;
}

.banner-wrap.is-live .banner-fallback {
  display: none;
}

.banner-wrap.is-static .banner-canvas {
  display: none;
}

.banner-wrap.is-static .banner-fallback {
  display: block;
  position: relative;
  inset: auto;
  max-height: var(--banner-max-h);
  height: auto;
}

/* Brand = square box. Feature = wider 16:9, but always inside the stage. */
.hero {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
}

.video-shell {
  position: relative;
  width: var(--video-size);
  max-width: 100%;
  /* room for soft floor glow without clipping */
  padding-bottom: 1.75rem;
  transition:
    width 0.4s var(--ease),
    max-width 0.4s var(--ease);
}

/* Wider than square, never full-viewport blowout */
.hero.is-cinematic .video-shell {
  /* Fit 16:9 under banner + status: cap height first, derive width */
  width: min(92vw, 720px, calc((52vh) * 16 / 9));
  max-width: 100%;
  padding-bottom: 1rem;
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border: none;
  outline: none;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
  overflow: hidden;
}

.hero.is-cinematic .video-frame {
  aspect-ratio: 16 / 9;
  /* Hard cap so it never eats the whole page */
  max-height: min(52vh, 420px);
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

/* Soft floor reflection under the frame */
.video-shell::after {
  content: "";
  pointer-events: none;
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 0;
  height: 1.75rem;
  background: radial-gradient(
    ellipse 70% 100% at 50% 0%,
    rgba(255, 255, 255, 0.09),
    transparent 72%
  );
  filter: blur(6px);
  opacity: 0.65;
}

.hero.is-cinematic .video-shell::after {
  opacity: 0.4;
  height: 1rem;
}

.teaser {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  border: none;
  outline: none;
  opacity: 0;
  pointer-events: none;
}

.teaser.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Fill the 16:9 box — full width of the box, no letterbox grey bars */
.teaser--feature {
  object-fit: cover;
}

.teaser--brand {
  object-fit: cover;
}


/* Manual play for feature clip — must sit ABOVE .film-overlay (z-index 40).
   Stage is z-index 10, so a nested button cannot paint over the grain layer
   unless we escape that stacking context (fixed + high z-index). */
.feature-play {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: min(92vw, 720px);
  max-width: calc(100vw - 1.5rem);
  /* Match cinematic frame height caps */
  height: min(52vh, 420px, calc((100vw - 1.5rem) * 9 / 16));
  max-height: min(52vh, 420px);
  margin: 0;
  padding: 1rem;
  border: 0;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  transform: translate(-50%, -50%);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* Prefer class over [hidden] — mobile WebViews are flaky with [hidden] + display */
.feature-play.is-visible {
  display: flex !important;
}

.feature-play[hidden] {
  display: none !important;
}

.feature-play__icon {
  display: grid;
  place-items: center;
  width: clamp(4rem, 18vw, 5.25rem);
  height: clamp(4rem, 18vw, 5.25rem);
  color: #fff;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.65));
  transition: transform 0.2s var(--ease);
}

.feature-play__icon svg {
  width: 100%;
  height: 100%;
}

.feature-play:hover .feature-play__icon,
.feature-play:focus-visible .feature-play__icon,
.feature-play:active .feature-play__icon {
  transform: scale(1.06);
}

.feature-play:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 4px;
}

.feature-play__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.9;
}

@media (max-height: 700px) {
  .feature-play {
    height: min(40vh, 320px);
    max-height: min(40vh, 320px);
    width: min(92vw, 640px);
  }
}

/* Unmute control */
.audio-toggle {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    background 0.25s var(--ease),
    transform 0.25s var(--ease),
    opacity 0.25s var(--ease);
  opacity: 0.72;
}

.audio-toggle:hover,
.audio-toggle:focus-visible {
  opacity: 1;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.62);
  outline: none;
}

.audio-toggle:active {
  transform: scale(0.96);
}

.audio-toggle__icon {
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
}

.audio-toggle .icon {
  width: 1.05rem;
  height: 1.05rem;
  grid-area: 1 / 1;
}

.audio-toggle .icon--unmuted {
  display: none;
}

.audio-toggle[aria-pressed="true"] .icon--muted {
  display: none;
}

.audio-toggle[aria-pressed="true"] .icon--unmuted {
  display: block;
}

/* Broadcast-style status + typewriter line */
.status-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.15rem;
  width: 100%;
  max-width: min(94vw, 40rem);
  padding-inline: 0.5rem;
  box-sizing: border-box;
  flex-shrink: 0;
}

.status-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-ghost);
  user-select: none;
}

.status-meta__label {
  opacity: 0.85;
}

.status-meta__ticks {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.7rem;
  min-width: 4.5rem;
  justify-content: center;
}

.status-meta__ticks i {
  display: block;
  width: 1px;
  background: rgba(255, 255, 255, 0.35);
  transform-origin: bottom center;
}

.status {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  /* Reserve 2 lines so longer quotes don't jump the layout */
  min-height: calc(1.45em * 2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-inline: 0.25rem;
  font-size: clamp(0.92rem, 2.6vw, 1.28rem);
  font-weight: 400;
  /* Tighter tracking so long lines fit on phones */
  letter-spacing: 0.12em;
  line-height: 1.45;
  text-transform: lowercase;
  text-align: center;
  color: var(--fg-muted);
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: manual;
}

.status__text {
  display: inline;
  max-width: 100%;
  /* Optical balance with letter-spacing; no fixed text-indent (breaks wrap) */
  margin-inline: 0.06em;
}

/* Cursor sits as a block underline after the last glyph */
.status__cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.5px;
  margin-left: 0.12em;
  margin-bottom: 0.12em;
  vertical-align: baseline;
  background: var(--fg-faint);
  flex-shrink: 0;
  animation: cursor-blink 1.15s steps(1) infinite;
}

.status.is-holding .status__text {
  animation: status-hold-glow 3.2s ease-in-out infinite;
}

.status.is-deleting .status__cursor,
.status.is-typing .status__cursor {
  opacity: 1;
  animation: cursor-blink 0.7s steps(1) infinite;
}

@keyframes status-hold-glow {
  0%,
  100% {
    opacity: 0.78;
  }
  50% {
    opacity: 1;
  }
}

@keyframes cursor-blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.12;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .grain,
  .grain--coarse,
  .grain--fine,
  .grain--overlay,
  .stage,
  .status__text,
  .status__cursor,
  .status.is-holding .status__text,
  .stage-light,
  .depth-mark {
    animation: none;
  }

  .stage {
    opacity: 1;
    transform: none;
  }

  .stage-light {
    opacity: 0.85;
  }

  /* Keep watermark ghost-quiet even with reduced motion */
  .depth-mark {
    opacity: 0.04;
    animation: none;
  }
}

/* Short / phone viewports */
@media (max-height: 700px) {
  :root {
    --video-size: min(78vw, 46vh, 480px);
    --banner-max-h: clamp(3.75rem, 11vh, 7rem);
    --banner-max-w: min(90vw, calc(var(--video-size) * 1.05), 520px);
  }

  .stage {
    gap: 0.55rem;
  }

  .depth-mark {
    width: min(50vw, 280px);
    opacity: 0.02;
  }

  .hero.is-cinematic .video-shell {
    width: min(92vw, 640px, calc(40vh * 16 / 9));
  }

  .hero.is-cinematic .video-frame {
    max-height: min(40vh, 320px);
  }
}

@media (max-width: 480px) {
  :root {
    --video-size: min(86vw, 44vh, 400px);
    --banner-max-h: clamp(3.5rem, 10vh, 6rem);
  }

  .status-meta {
    gap: 0.5rem;
    letter-spacing: 0.16em;
    font-size: 0.55rem;
  }

  .status-meta__ticks {
    min-width: 3.2rem;
  }

  .status {
    font-size: clamp(0.88rem, 3.6vw, 1.1rem);
    letter-spacing: 0.08em;
    min-height: calc(1.5em * 2.15);
  }

  .status-block {
    max-width: 96vw;
    padding-inline: 0.35rem;
  }

  .depth-mark {
    display: none; /* avoid ghost mark over content on small phones */
  }

  .audio-toggle {
    width: 2.5rem;
    height: 2.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
  }
}
