/* ---------- fonts ---------- */

@font-face {
  font-family: "Matisse Pro";
  src: url("assets/fonts/FOT-MatisseProEB.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("assets/fonts/SpaceMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #0b0b12;
  --text: #f2f0f7;
  --text-dim: #b3afc4;
  --accent: #b98cff;
  --accent-dim: #6b4fa0;
  --good: #6fd08c;
  --bad: #e0708a;
  --panel: rgba(12, 10, 20, 0.72);
  --panel-solid: rgba(18, 15, 28, 0.92);
  --border: rgba(185, 140, 255, 0.22);
  --radius: 14px;
  --font-title: "Matisse Pro", "Georgia", serif;
  --font-body: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.6;
}

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

.video-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg);
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}

.bg-video.is-active {
  opacity: 1;
}

/* Keeps text legible over any frame of the footage. */
.scrim {
  position: absolute;
  inset: 0;
  /* The footage is already dark and fades up from black, so this stays light —
     legibility over the bright frames comes mostly from text-shadow. */
  background:
    radial-gradient(125% 85% at 50% 45%, transparent 0%, rgba(6, 5, 12, 0.34) 100%),
    linear-gradient(180deg, rgba(6, 5, 12, 0.42) 0%, rgba(6, 5, 12, 0.12) 30%,
      rgba(6, 5, 12, 0.18) 65%, rgba(6, 5, 12, 0.55) 100%);
}

/* ---------- layout ---------- */

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 56px;
}

.scene {
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.boot-text {
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.04em;
}

/* ---------- intro crawl (typewriter) ---------- */

#scene-intro {
  min-height: calc(100vh - 96px);
  justify-content: center;
  position: relative;
}

.crawl-viewport {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 16px;
}

.crawl-viewport.is-retired {
  display: none;
}

.crawl {
  width: min(640px, 86vw);
  text-align: center;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9);
}

.crawl-line {
  margin: 0 0 1.15em;
  font-size: clamp(1rem, 2.6vw, 1.28rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
}

.crawl-gap {
  margin: 0 0 1.5em;
}

/* Blinking caret follows only the line currently being typed. */
.crawl-line.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 3px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caretBlink 0.9s steps(1) infinite;
}

@keyframes caretBlink {
  50% {
    opacity: 0;
  }
}

.skip-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 3;
  /* Opaque enough that crawl text passing behind is occluded, not blended. */
  background: rgba(9, 7, 14, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.skip-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- intro CTA ---------- */

.intro-cta {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: ctaIn 0.9s ease backwards;
}

.intro-mark {
  /* 30% smaller than the original clamp(120px, 26vw, 190px). */
  width: clamp(84px, 18.2vw, 133px);
  height: auto;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 4px 40px rgba(0, 0, 0, 0.85));
}

.intro-title {
  font-family: var(--font-title);
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.1;
  margin: 14px 0 0;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.85);
}

.intro-sub {
  font-family: var(--font-title);
  margin: 4px 0 30px;
  color: var(--accent);
  font-size: clamp(1.1rem, 3.4vw, 1.6rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.8);
}

.hint {
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

kbd {
  display: inline-block;
  min-width: 19px;
  padding: 1px 5px;
  margin: 0 1px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(10, 8, 16, 0.7);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.7rem;
  text-align: center;
}

@keyframes ctaIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-body);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  padding: 13px 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.1s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #17092b;
  border-color: var(--accent);
  font-weight: bold;
  box-shadow: 0 8px 34px rgba(185, 140, 255, 0.36);
}

.btn-primary:hover {
  background: #cba6ff;
  box-shadow: 0 10px 42px rgba(185, 140, 255, 0.5);
}

.btn-secondary {
  background: rgba(10, 8, 16, 0.62);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* Brand signature at the close of the result screen. */
.result-mark {
  width: 56px;
  height: auto;
  margin: 30px auto 0;
  display: block;
  opacity: 0.7;
  animation: revealUp 0.5s ease backwards;
  animation-delay: 640ms;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- panel (quiz + result) ---------- */

.panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 28px;
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.panel.fade-out {
  opacity: 0;
  transform: translateY(6px);
}

.back-btn {
  align-self: flex-start;
  margin: -6px 0 -10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  padding: 6px 2px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.back-btn:hover {
  color: var(--accent);
}

.scene {
  transition: opacity 0.2s ease;
}

.scene.fade-out {
  opacity: 0;
}

/* ---------- progress ---------- */

.progress-wrap {
  width: 100%;
}

.progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  width: 0%;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.progress {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.steps {
  display: flex;
  gap: 7px;
}

.step {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.step.done {
  background: var(--accent);
}

.step.current {
  background: var(--accent);
  transform: scale(1.45);
  box-shadow: 0 0 0 3px rgba(185, 140, 255, 0.2);
}

/* ---------- question ---------- */

.category {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.prompt {
  font-family: var(--font-title);
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  line-height: 1.35;
  font-weight: 800;
  margin: 0 0 24px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 14px 44px 14px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.87rem;
  line-height: 1.55;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease,
    opacity 0.3s ease, box-shadow 0.2s ease;
  /* `backwards`, not `both`: a forwards-filling animation would pin opacity
     at 1 and override .dimmed once an answer is picked. */
  animation: optionIn 0.34s ease backwards;
  animation-delay: calc(var(--i) * 55ms);
}

.option:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(185, 140, 255, 0.1);
  transform: translateX(3px);
}

.option:hover:not(:disabled):not(.selected) .option-key {
  background: rgba(185, 140, 255, 0.16);
}

.option:active:not(:disabled) {
  transform: translateX(3px) scale(0.99);
}

.option:disabled {
  cursor: default;
}

.option.selected {
  border-color: var(--accent);
  background: rgba(185, 140, 255, 0.14);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 30px rgba(185, 140, 255, 0.26);
}

.option.dimmed {
  opacity: 0.28;
}

.option-key {
  flex-shrink: 0;
  width: 27px;
  height: 27px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: bold;
  /* color transitions with the fill so the letter never sits dark-on-dark */
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.option.selected .option-key {
  background: var(--accent);
  color: #17092b;
  border-color: var(--accent);
}

.option-text {
  line-height: 1.55;
}

.option-check {
  position: absolute;
  right: 16px;
  top: 50%;
  color: var(--accent);
  font-size: 1.05rem;
  opacity: 0;
  transform: translateY(-50%) scale(0.5);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.option.selected .option-check {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ---------- loading beat ---------- */

#scene-loading {
  min-height: calc(100vh - 96px);
  justify-content: center;
}

.loading-line {
  margin: 0;
  min-height: 1.6em;
  text-align: center;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  letter-spacing: 0.08em;
  color: var(--text);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9);
  transition: opacity 0.2s ease;
}

.loading-line.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 3px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caretBlink 0.9s steps(1) infinite;
}

.loading-line.is-clearing {
  opacity: 0;
}

/* ---------- result ---------- */

.reveal {
  animation: revealUp 0.5s ease backwards;
  animation-delay: calc(var(--i) * 90ms);
}

.result-id {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  margin-bottom: 8px;
  font-family: var(--font-body);
}

.result-name {
  font-family: var(--font-title);
  font-weight: 800;
  margin: 0 0 4px;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 1.1;
}

.result-title {
  font-family: var(--font-title);
  margin: 0 0 26px;
  color: var(--text-dim);
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.result-section {
  margin-bottom: 20px;
}

.result-section h3 {
  margin: 0 0 7px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 400;
}

.result-section p {
  margin: 0;
  line-height: 1.6;
  font-size: 0.88rem;
}

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.76rem;
}

.chip-good {
  border-color: rgba(111, 208, 140, 0.55);
  color: var(--good);
}

.chip-bad {
  border-color: rgba(224, 112, 138, 0.55);
  color: var(--bad);
}

.compat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- motion ---------- */

@keyframes optionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes revealUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ultraGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 207, 107, 0.2); }
  50% { box-shadow: 0 0 26px rgba(255, 207, 107, 0.45); }
}

@media (max-width: 480px) {
  .panel {
    padding: 24px 18px;
  }

  .compat-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .option:hover:not(:disabled) {
    transform: none;
  }
}
