/* ================================================================
   ANIMA TEST — Test Experience Styles V2
   ================================================================ */

/* ── Page background ──
   The body's default is --color-abyss (#0a0a0f) while the test container is
   --color-void (#050508). On Android the URL bar collapse makes the visual
   viewport taller than the 100svh container, exposing the abyss body below it
   — a two-tone background split. The page IS the container here, so paint
   everything void. */
html, body {
  background-color: var(--color-void);
}

/* ── Demo Banner Offset ── */
body.has-demo-banner {
  padding-top: 32px;
}

/* ── Test Container ── */
.test-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-void);
  position: relative;
  overflow: hidden;
}

/* ── Ambient background ── */
.test-container::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(123, 104, 238, 0.04) 0%,
    rgba(200, 168, 98, 0.02) 40%,
    transparent 70%
  );
  pointer-events: none;
  animation: breathe 8s ease-in-out infinite;
}


/* ── Instructions Screen ── */
.instructions {
  text-align: center;
  max-width: 520px;
  padding: var(--space-8);
  animation: fadeIn 0.8s var(--ease-out-expo);
}

.instructions__title {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  margin-bottom: var(--space-8);
  color: var(--color-text-primary);
}

.instructions__steps {
  list-style: none;
  margin-bottom: var(--space-10);
}

.instructions__steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  text-align: start;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-secondary);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
}

.instructions__steps li:last-child {
  border-bottom: none;
}

.instructions__steps li .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-gold-dark);
  color: var(--color-gold);
  font-size: var(--fs-caption);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.instructions__disclaimer {
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
  margin-top: var(--space-6);
  line-height: var(--lh-relaxed);
}


/* ── Word Display ── */
.word-display {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-8);
  gap: var(--space-6);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.word-display.active {
  display: flex;
}

.word-display__word {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: var(--fw-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-4);
  user-select: none;
  animation: wordAppear 0.6s var(--ease-out-expo) forwards;
  text-align: center;
  flex-shrink: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.word-display__word.exiting {
  animation: wordDisappear 0.3s var(--ease-in-out) forwards;
}

.word-display__input-wrapper {
  width: 100%;
  max-width: 400px;
  position: relative;
}

.word-display__input {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-primary);
  font-family: var(--font-serif);
  font-size: var(--fs-h3);
  text-align: center;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-in-out);
  caret-color: var(--color-gold);
}

.word-display__input:focus {
  border-color: var(--color-gold);
}

.word-display__input::placeholder {
  color: var(--color-text-tertiary);
  font-style: italic;
}

.word-display__hint {
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
  margin-top: var(--space-3);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.word-display__hint.visible {
  opacity: 1;
}

/* V2 — Next Button Wrapper (below input) */
.word-display__next-btn {
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
}


/* ── TTFK Indicator ── */
.ttfk-indicator {
  position: fixed;
  bottom: calc(var(--space-12) + env(safe-area-inset-bottom));
  right: var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
  opacity: 0.4;
}

.ttfk-indicator__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-gold);
  animation: pulse 1.5s ease-in-out infinite;
}

.ttfk-indicator.captured .ttfk-indicator__dot {
  background: var(--color-success);
  animation: none;
}


/* ── Fixed footer disclaimer ──
   A solid bar pinned to the very bottom. The progress counter and timer dot are
   positioned to sit ABOVE this bar so they never overlap it. */
.test-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  text-align: center;
  background: var(--color-void);
  z-index: 2;
}

.test-footer__text {
  opacity: 0.35;
  margin: 0;
}

/* ── Progress ── */
.test-progress {
  position: fixed;
  bottom: calc(var(--space-12) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
  font-family: var(--font-sans);
  letter-spacing: var(--tracking-wide);
  z-index: 1;
}


/* ── Completion Screen ── */
.completion {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8);
  animation: fadeIn 0.8s var(--ease-out-expo);
}

.completion.active {
  display: flex;
}

.completion__icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-gold-glow);
  border: 1px solid var(--color-gold-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: var(--space-8);
  animation: pulseGlow 2s ease-in-out infinite;
}

.completion__title {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  margin-bottom: var(--space-4);
}

.completion__subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-10);
}

/* ── Loading animation ── */
.loading-dots {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-gold);
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }


/* ── Processing State (completion screen) ── */
.completion__status {
  font-size: var(--fs-body-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-6);
  letter-spacing: var(--tracking-wide);
  transition: opacity var(--duration-normal) var(--ease-in-out);
}

.completion__results-btn {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
  pointer-events: none;
}

.completion__results-btn.revealed {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.completion__results-btn:disabled {
  cursor: not-allowed;
}


/* ── Consent Text (below Start button) ── */
.consent-text {
  font-size: var(--fs-caption);
  color: var(--color-text-tertiary);
  text-align: center;
  line-height: var(--lh-relaxed);
  max-width: 480px;
  margin: var(--space-4) auto 0;
  opacity: 0.7;
}

.consent-text a {
  color: var(--color-text-secondary);
  text-decoration: underline;
}


/* ================================================================
   V2 — MOBILE RESPONSIVE (PWA-first)
   ================================================================ */

@media (max-width: 768px) {
  .test-container {
    padding: var(--space-4);
    min-height: 100svh;
    min-height: 100dvh; /* tracks the Android URL-bar collapse/expand */
  }

  .instructions {
    padding: var(--space-6) var(--space-4);
    max-width: 100%;
  }

  .instructions__title {
    font-size: var(--fs-h3);
    margin-bottom: var(--space-6);
  }

  .instructions__steps {
    margin-bottom: var(--space-8);
  }

  .instructions__steps li {
    font-size: var(--fs-body-sm);
    padding: var(--space-3) 0;
  }

  .instructions .btn {
    width: 100%;
    min-height: 52px;
  }

  /* Word display — prevent overlap with keyboard */
  .word-display {
    gap: var(--space-4);
    padding: var(--space-4) var(--space-2);
    justify-content: flex-start;
    padding-top: 15vh;
  }

  .word-display__word {
    font-size: clamp(2rem, 10vw, 3.5rem);
    margin-bottom: var(--space-2);
  }

  .word-display__input-wrapper {
    max-width: 100%;
    padding: 0 var(--space-2);
  }

  .word-display__input {
    font-size: var(--fs-h4);
    padding: var(--space-3) var(--space-4);
  }

  /* V2 Next button — full width on mobile */
  .word-display__next-btn {
    width: 100%;
    padding: 0 var(--space-2);
  }

  .word-display__next-btn .btn--next {
    width: 100%;
    min-height: 52px;
    max-width: 100%;
  }

  .completion__icon {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
    margin-bottom: var(--space-6);
  }

  .completion__title {
    font-size: var(--fs-h3);
  }

  .completion .btn {
    width: 100%;
    min-height: 52px;
  }

  /* Progress and indicators — lifted clear of the fixed footer bar */
  .test-progress {
    bottom: var(--space-16);
    font-size: 0.65rem;
  }

  .ttfk-indicator {
    bottom: var(--space-16);
    right: var(--space-4);
    font-size: 0.65rem;
  }
}


/* ── Keyboard open (short viewport) ──
   With interactive-widget=resizes-content the layout viewport shrinks to the
   space above the keyboard (~350-450px). Compact the word display so the
   stimulus, input AND the Next button all fit without scrolling. */
@media (max-height: 520px) {
  .word-display {
    padding-top: var(--space-4);
    gap: var(--space-3);
  }

  .word-display__word {
    font-size: clamp(1.6rem, 6vh, 2.5rem);
    margin-bottom: 0;
  }

  .word-display__next-btn .btn--next {
    min-height: 44px;
    margin-top: 0;
  }

  /* Fixed chrome would eat the little space left — hide it while typing */
  .test-footer,
  .ttfk-indicator {
    display: none;
  }

  .test-progress {
    bottom: var(--space-2);
  }
}

/* ── Small phones ── */
@media (max-width: 380px) {
  .word-display__word {
    font-size: 2rem;
  }

  .instructions__title {
    font-size: var(--fs-h4);
  }
}


/* ── PWA Safe Areas ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .test-container {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ttfk-indicator {
    bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
  }

  .test-progress {
    bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
  }
}
