:root {
  --bg: #070b12;
  --bg-elevated: rgba(14, 19, 28, 0.92);
  --card-outer: rgba(14, 19, 28, 0.96);
  --card-inner: rgba(26, 36, 52, 0.98);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent-amber: #f59e0b;
  --accent-yellow: #facc15;
  --accent-cream: #fef08a;
  --accent-sky: #38bdf8;
  --accent-sky-soft: #7dd3fc;
  --accent-red: #ef4444;
  --border-subtle: rgba(148, 163, 184, 0.25);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 35% 40%, rgba(120, 78, 42, 0.22), transparent 55%),
    radial-gradient(circle at 75% 20%, rgba(30, 88, 165, 0.22), transparent 50%),
    var(--bg);
}

a {
  color: var(--accent-sky-soft);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
 * Top Header & Telemetry Bar
 * -------------------------------------------------------------------------- */
.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.65rem 1.25rem;
  background: linear-gradient(180deg, rgba(7, 11, 18, 0.94) 0%, rgba(7, 11, 18, 0.72) 100%);
  border-bottom: 1px solid rgba(250, 204, 21, 0.18);
  backdrop-filter: blur(8px);
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.subtitle code {
  padding: 0.05rem 0.35rem;
  border-radius: 0.35rem;
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-cream);
  font-family: var(--font-mono);
  font-weight: 700;
}

.telemetry-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.telemetry-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.telemetry-pill-amber {
  background: var(--accent-amber);
  border-color: var(--accent-cream);
  color: #0f141c;
}

/* --------------------------------------------------------------------------
 * Main Tornado Stage & Video Layer
 * -------------------------------------------------------------------------- */
.storm-main {
  flex: 1 1 auto;
  display: flex;
  position: relative;
  min-height: 0;
}

.storm-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  min-height: min(68dvh, 42rem);
}

.video-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #131c2c 0%, #070b12 85%);
  overflow: hidden;
  pointer-events: none;
}

.storm-video {
  width: 100%;
  height: 100%;
  /* Keep full 16:9 frame visible so "Here it Coooooooooooooomes!" and the tornado never clip */
  object-fit: contain;
  display: block;
  translate: 0px 0px;
  rotate: 0deg;
  scale: 1;
  transition: filter 0.65s ease, scale 0.85s ease;
}

body[data-phase="cycling"] .storm-video {
  filter: brightness(0.76) contrast(1.06) saturate(1.08);
}

.storm-video-loop {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out, filter 0.65s ease, scale 0.85s ease;
}

body[data-vortex-loop="true"] .storm-video-loop {
  opacity: 1;
}

@media (min-aspect-ratio: 11/10) {
  body[data-phase="cycling"] .storm-video {
    object-fit: cover;
  }
}

.storm-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(7, 11, 18, 0.22) 0%, rgba(7, 11, 18, 0.68) 100%);
  transition: opacity 0.65s ease;
}

body[data-phase="cycling"] .storm-vignette {
  opacity: 1;
}

.autoplay-fallback {
  position: relative;
  z-index: 15;
  display: grid;
  place-items: center;
  opacity: 1;
  transition:
    display,
    opacity 0.25s ease;
  transition-behavior: allow-discrete;
}

.autoplay-fallback[hidden] {
  display: none;
  opacity: 0;
}

@starting-style {
  .autoplay-fallback {
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
 * Live Card Stage & Quote Cards
 * -------------------------------------------------------------------------- */
.card-stage {
  position: relative;
  z-index: 10;
  width: min(44rem, 100%);
  min-height: 18rem;
  display: grid;
  place-items: center;
  perspective: 1200px;
}

.status-message {
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-amber);
  color: var(--accent-cream);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.status-message[hidden] {
  display: none;
}

.claim-card {
  grid-area: 1 / 1;
  width: 100%;
  background: var(--card-outer);
  border: 2.5px solid var(--accent-yellow);
  border-radius: 1.25rem;
  padding: clamp(0.95rem, 2.2vw, 1.35rem);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.78),
    0 0 36px rgba(245, 158, 11, 0.16);
  backdrop-filter: blur(12px);
  /* Base identity individual transform properties prevent stacking-context jumps */
  translate: 0px 0px;
  rotate: 0deg;
  scale: 1;
  opacity: 1;
  will-change: translate, rotate, scale, opacity;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    scale 0.2s ease;
}

.claim-card:hover,
.claim-card:focus-within {
  border-color: var(--accent-cream);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.85),
    0 0 46px rgba(245, 158, 11, 0.28);
}

/* Card Entrance & Exit Animations */
@media (prefers-reduced-motion: no-preference) {
  .claim-card.is-entering-left {
    animation: whip-in-left 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .claim-card.is-entering-right {
    animation: whip-in-right 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .claim-card.is-whipping-left {
    pointer-events: none;
    animation: whip-away-left 0.55s cubic-bezier(0.55, 0, 1, 0.45) forwards;
  }

  .claim-card.is-whipping-right {
    pointer-events: none;
    animation: whip-away-right 0.55s cubic-bezier(0.55, 0, 1, 0.45) forwards;
  }

  .claim-card.is-dwelling {
    animation: storm-hover 4.2s ease-in-out infinite;
  }

  .claim-card.is-dwelling:hover,
  .claim-card.is-dwelling:focus-within {
    animation-play-state: paused;
  }
}

@media (prefers-reduced-motion: reduce) {
  .claim-card {
    transition: opacity 0.25s ease;
    transition-behavior: allow-discrete;
  }

  @starting-style {
    .claim-card {
      opacity: 0;
    }
  }

  .claim-card[data-closing] {
    opacity: 0;
  }
}

@supports (translate: 0px) {
  @keyframes whip-in-left {
    0% {
      translate: -42vw -22vh;
      rotate: -34deg;
      scale: 0.16;
      opacity: 0;
      filter: blur(6px);
    }
    55% {
      opacity: 1;
      filter: blur(0px);
    }
    82% {
      translate: 1.5vw 0.8vh;
      rotate: 2.5deg;
      scale: 1.02;
    }
    100% {
      translate: 0px 0px;
      rotate: 0deg;
      scale: 1;
      opacity: 1;
    }
  }

  @keyframes whip-in-right {
    0% {
      translate: 42vw -18vh;
      rotate: 32deg;
      scale: 0.16;
      opacity: 0;
      filter: blur(6px);
    }
    55% {
      opacity: 1;
      filter: blur(0px);
    }
    82% {
      translate: -1.5vw 0.8vh;
      rotate: -2.2deg;
      scale: 1.02;
    }
    100% {
      translate: 0px 0px;
      rotate: 0deg;
      scale: 1;
      opacity: 1;
    }
  }

  @keyframes whip-away-left {
    0% {
      translate: 0px 0px;
      rotate: 0deg;
      scale: 1;
      opacity: 1;
    }
    25% {
      translate: 3vw 1.5vh;
      rotate: 5deg;
      scale: 1.03;
      opacity: 1;
    }
    100% {
      translate: -46vw -32vh;
      rotate: -52deg;
      scale: 0.1;
      opacity: 0;
      filter: blur(8px);
    }
  }

  @keyframes whip-away-right {
    0% {
      translate: 0px 0px;
      rotate: 0deg;
      scale: 1;
      opacity: 1;
    }
    25% {
      translate: -3vw 1.5vh;
      rotate: -5deg;
      scale: 1.03;
      opacity: 1;
    }
    100% {
      translate: 46vw -30vh;
      rotate: 52deg;
      scale: 0.1;
      opacity: 0;
      filter: blur(8px);
    }
  }

  @keyframes storm-hover {
    0%,
    100% {
      translate: 0px 0px;
      rotate: 0deg;
    }
    33% {
      translate: 4px -5px;
      rotate: 0.45deg;
    }
    66% {
      translate: -4px 4px;
      rotate: -0.45deg;
    }
  }
}

@supports not (translate: 0px) {
  @keyframes whip-in-left {
    0% {
      transform: translate(-42vw, -22vh) rotate(-34deg) scale(0.16);
      opacity: 0;
    }
    100% {
      transform: translate(0, 0) rotate(0deg) scale(1);
      opacity: 1;
    }
  }

  @keyframes whip-in-right {
    0% {
      transform: translate(42vw, -18vh) rotate(32deg) scale(0.16);
      opacity: 0;
    }
    100% {
      transform: translate(0, 0) rotate(0deg) scale(1);
      opacity: 1;
    }
  }

  @keyframes whip-away-left {
    0% {
      transform: translate(0, 0) rotate(0deg) scale(1);
      opacity: 1;
    }
    100% {
      transform: translate(-46vw, -32vh) rotate(-52deg) scale(0.1);
      opacity: 0;
    }
  }

  @keyframes whip-away-right {
    0% {
      transform: translate(0, 0) rotate(0deg) scale(1);
      opacity: 1;
    }
    100% {
      transform: translate(46vw, -30vh) rotate(52deg) scale(0.1);
      opacity: 0;
    }
  }

  @keyframes storm-hover {
    0%,
    100% {
      transform: translate(0, 0) rotate(0deg);
    }
    50% {
      transform: translate(0, -4px) rotate(0.4deg);
    }
  }
}

/* --------------------------------------------------------------------------
 * Card Internals (Outer Norvid Header + Inner Quoted Card)
 * -------------------------------------------------------------------------- */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.avatar-img,
.avatar-fallback {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.avatar-norvid {
  border: 2.5px solid var(--accent-red);
}

.avatar-quoted {
  width: 38px;
  height: 38px;
  border: 2px solid var(--accent-sky);
}

.avatar-fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  border: 2px solid var(--accent-sky);
}

.author-names {
  min-width: 0;
}

.display-name {
  display: block;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handle-line {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.claim-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border-radius: 0.75rem;
  background: var(--accent-amber);
  border: 2px solid var(--accent-cream);
  color: #0f141c;
  font-weight: 900;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

.claim-badge:hover {
  background: var(--accent-yellow);
}

.quoted-box {
  background: var(--card-inner);
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 0.95rem;
  padding: clamp(0.85rem, 2vw, 1.15rem);
}

.quoted-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.quoted-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.55rem;
  min-width: 0;
  flex: 1;
}

.quoted-display {
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--accent-sky-soft);
}

.quoted-handle {
  font-size: 0.84rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.quoted-body {
  margin: 0;
  font-size: clamp(1.06rem, 2.2vw, 1.32rem);
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
  overflow-wrap: anywhere;
  max-height: 44dvh;
  overflow-y: auto;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.85rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.card-stats {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* 5+ Second Dwell Progress Bar */
.dwell-track {
  margin-top: 0.7rem;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.dwell-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-sky), var(--accent-amber), var(--accent-yellow));
  transform-origin: left center;
  transform: scaleX(0);
}

/* --------------------------------------------------------------------------
 * Bottom Controls & Footer
 * -------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  z-index: 20;
  padding: 0.7rem 1.25rem 0.9rem;
  background: linear-gradient(0deg, rgba(7, 11, 18, 0.96) 0%, rgba(7, 11, 18, 0.75) 100%);
  border-top: 1px solid rgba(56, 189, 248, 0.16);
  backdrop-filter: blur(8px);
}

.storm-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.hud-btn {
  appearance: none;
  border: 1.5px solid var(--border-subtle);
  background: rgba(26, 36, 52, 0.92);
  color: var(--text);
  border-radius: 0.65rem;
  padding: 0.48rem 0.9rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  translate: 0px 0px;
  scale: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, scale 0.12s ease;
}

.hud-btn:hover:not(:disabled) {
  background: rgba(38, 52, 74, 0.98);
  border-color: var(--accent-sky);
}

.hud-btn:active:not(:disabled) {
  scale: 0.97;
}

.hud-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hud-btn-accent {
  border-color: rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-cream);
}

.hud-btn-primary {
  background: var(--accent-amber);
  border-color: var(--accent-cream);
  color: #0f141c;
}

.footer-note {
  margin: 0.45rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.noscript-box {
  position: relative;
  z-index: 25;
  max-width: 34rem;
  padding: 1.25rem;
  border-radius: 1rem;
  background: var(--card-outer);
  border: 2px solid var(--accent-amber);
}

/* Error 404 Page */
.error-page {
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.error-box {
  max-width: 32rem;
  padding: 2rem;
  border-radius: 1.25rem;
  background: var(--card-outer);
  border: 2px solid var(--accent-amber);
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-amber);
}

.error-copy {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

@media (max-width: 600px) {
  .site-header {
    padding: 0.55rem 0.85rem;
  }

  .card-header {
    align-items: flex-start;
  }

  .hud-btn {
    padding: 0.45rem 0.7rem;
    font-size: 0.82rem;
  }
}
