/* Cinema utility — brand + live frame + one CTA */

@layer reset, tokens, base, stage, board, motion, a11y;

@layer tokens {
  :root {
    --bg: #07090d;
    --panel: #10151d;
    --ink: #f4f6f8;
    --mute: rgba(244, 246, 248, 0.58);
    --line: rgba(244, 246, 248, 0.1);
    --ember: #ff5a45;
    --mint: #3dffb8;
    --cta: #c0392b;
    --cta-ink: #fff8f6;
    --font-d: "Outfit", "Avenir Next", sans-serif;
    --font-t: "Source Sans 3", "Avenir Next", sans-serif;
    --pad: clamp(1rem, 4.4vw, 1.4rem);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --max: 27rem;
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; }
  a { color: inherit; text-decoration: none; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
  p, h1 { margin: 0; }
  img { display: block; max-width: 100%; height: auto; }
}

@layer base {
  body {
    font-family: var(--font-t);
    color: var(--ink);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }

  .skip { position: absolute; left: -999px; }
  .skip:focus {
    left: 12px; top: 12px; z-index: 30;
    background: var(--ink); color: var(--bg);
    padding: 0.5rem 0.7rem;
  }
}

@layer stage {
  .stage {
    position: relative;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    width: min(100%, calc(var(--max) + 2 * var(--pad)));
    margin-inline: auto;
    padding:
      calc(0.85rem + env(safe-area-inset-top))
      var(--pad)
      calc(0.8rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(0.55rem, 1.8vh, 0.9rem);
  }

  .stage__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background:
      radial-gradient(120% 70% at 50% -10%, #151c28 0%, transparent 55%),
      linear-gradient(180deg, #0b0f15 0%, #07090d 55%, #05070a 100%);
  }

  .stage__grain {
    position: absolute;
    inset: 0;
    opacity: 0.07;
    mix-blend-mode: overlay;
    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.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  .stage__glow {
    position: absolute;
    width: 18rem;
    height: 18rem;
    left: 50%;
    top: 28%;
    transform: translate(-50%, -40%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192, 57, 43, 0.18), transparent 70%);
    filter: blur(8px);
  }

  .top,
  .board,
  .foot { position: relative; z-index: 1; }

  .brand-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .brand {
    font-family: var(--font-d);
    font-weight: 800;
    font-size: clamp(1.85rem, 7.2vw, 2.35rem);
    letter-spacing: -0.06em;
    line-height: 0.92;
  }

  .brand-logo {
    width: clamp(1.7rem, 6.5vw, 2.05rem);
    height: clamp(1.7rem, 6.5vw, 2.05rem);
    border-radius: 0.5rem;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  }

  .top h1 {
    margin-top: 0.55rem;
    font-family: var(--font-d);
    font-weight: 750;
    font-size: clamp(1.55rem, 6.2vw, 2rem);
    letter-spacing: -0.045em;
    line-height: 1.05;
  }

  .lead {
    margin-top: 0.35rem;
    color: var(--mute);
    font-size: clamp(0.92rem, 3.1vw, 1.02rem);
    line-height: 1.35;
    font-weight: 500;
    max-width: 34ch;
  }

  .foot { display: grid; }

  .cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 20rem;
    margin-inline: auto;
    min-height: 3.25rem;
    padding: 0 1.25rem;
    border-radius: 999px;
    background: var(--cta);
    color: var(--cta-ink);
    font-family: var(--font-d);
    font-weight: 700;
    font-size: 1.08rem;
    letter-spacing: -0.02em;
    border: 1.5px solid rgba(255, 210, 200, 0.32);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.14) inset,
      0 12px 28px rgba(0, 0, 0, 0.42);
    transition: transform 160ms var(--ease), filter 160ms var(--ease), opacity 0.2s ease;
  }
  .cta:hover { filter: brightness(1.05); }
  .cta:active { transform: scale(0.988); }
  .cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
  .cta.is-busy { opacity: 0.72; pointer-events: none; }
}

@layer board {
  .board {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.65rem;
  }

  .frame {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    border-radius: 1.15rem;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.03) inset,
      0 24px 48px rgba(0, 0, 0, 0.45);
  }

  .frame__shot {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #080c12;
  }

  .shot-still,
  .shot-live,
  .shot-live img,
  .shot-scan,
  .frame__veil {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .shot-still,
  .shot-live img {
    object-fit: cover;
    object-position: center 22%;
  }

  .shot-still {
    filter: grayscale(1) contrast(1.06) brightness(0.88);
    transition: opacity 0.75s var(--ease);
    z-index: 1;
  }

  .shot-live {
    z-index: 2;
    opacity: 0;
    transform-origin: 50% 28%;
  }

  .shot-live img {
    opacity: 0;
    transition: opacity 0.38s ease;
  }
  .shot-live img.is-on { opacity: 1; }

  .shot-scan {
    z-index: 3;
    height: 26%;
    top: -30%;
    background: linear-gradient(180deg, transparent, rgba(61, 255, 184, 0.22), transparent);
    opacity: 0;
    pointer-events: none;
  }

  .frame__veil {
    z-index: 4;
    background: linear-gradient(180deg, transparent 55%, rgba(7, 9, 13, 0.55) 100%);
    pointer-events: none;
  }

  .frame.is-alive .shot-still { opacity: 0; }
  .frame.is-alive .shot-live { opacity: 1; }

  .frame__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    min-height: 2.35rem;
    padding: 0.55rem 0.85rem 0.7rem;
    background: #0c1118;
    border-top: 1px solid var(--line);
  }

  .bar-prompt {
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .bar-prompt span {
    color: var(--mint);
    font-family: var(--font-d);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-right: 0.35rem;
  }

  .bar-state {
    flex: none;
    color: var(--mute);
    font-family: var(--font-d);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .frame.is-alive .bar-state { color: var(--mint); }

  .modes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
  }

  .mode {
    min-height: 2.35rem;
    padding: 0.45rem 0.2rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.035);
    font-family: var(--font-d);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: -0.02em;
    color: var(--mute);
    -webkit-tap-highlight-color: transparent;
    transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
  }

  .mode.is-on,
  .mode:active {
    color: var(--ink);
    border-color: rgba(255, 90, 69, 0.45);
    background: rgba(255, 90, 69, 0.12);
  }

  .mode:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
  }
}

@layer motion {
  .frame.is-alive .shot-live {
    animation: breath 5.2s var(--ease) infinite;
  }

  .frame.is-waking .shot-scan {
    animation: scan 1.05s var(--ease) forwards;
  }

  @keyframes breath {
    0%, 100% { transform: scale(1.01); }
    50% { transform: scale(1.035) translateY(-1%); }
  }

  @keyframes scan {
    0% { top: -30%; opacity: 0; }
    20% { opacity: 1; }
    100% { top: 105%; opacity: 0; }
  }
}

@layer a11y {
  @media (prefers-reduced-motion: reduce) {
    .shot-live,
    .shot-scan,
    .cta { animation: none !important; transition: none !important; }
    .frame.is-alive .shot-still { opacity: 0; }
    .frame.is-alive .shot-live { opacity: 1; transform: none; }
  }

  @media (min-width: 720px) {
    .stage { max-width: 30rem; }
  }

  @media (max-height: 720px) {
    .lead { display: none; }
    .mode { min-height: 2.1rem; font-size: 0.72rem; }
  }

  @media (max-height: 620px) {
    .top h1 { font-size: 1.35rem; margin-top: 0.35rem; }
    .modes { display: none; }
    .cta { min-height: 3rem; }
  }
}

.dl {
  overflow: auto;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-t);
}

.dl-card {
  width: min(100%, 24rem);
  display: grid;
  gap: 0.7rem;
}

.dl-card .brand { font-size: 1.2rem; }

.dl-card h1 {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.dl-card p { color: var(--mute); line-height: 1.45; }

.back {
  color: var(--mute);
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
