:root {
  --bg: #101418;
  --card: #171c22;
  --text: #eef1f4;
  --text-dim: #9aa5b1;
  --accent: #e4572e;
  /* Same colour as --accent in channel form, so tints can be built with rgba()
     without depending on color-mix support. Keep the two in step. */
  --accent-rgb: 228, 87, 46;
  --border: #262d35;
  --border-hover: #3a434e;
  --focus: #8ab4f8;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

/* One visible focus treatment for every control. Without this the 60-question
   form is effectively unusable by keyboard. */
:where(button, input, a, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* Language switch — pinned top right, above the sticky progress bar. */
.lang-switch {
  position: fixed;
  top: 0.75rem;
  right: 0.9rem;
  z-index: 20;
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lang-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
}

.lang-btn:hover {
  color: var(--text);
  opacity: 1;
}

.lang-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #101418;
}

/* Keeps the first heading clear of the switcher on narrow screens. */
@media (max-width: 560px) {
  main {
    padding-top: 3.75rem;
  }
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 1.9rem;
  margin-bottom: 0.4rem;
}

h2 {
  font-size: 1.4rem;
  margin: 2rem 0 0.75rem;
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  /* Dark ink rather than white: white on this orange measures 3.7:1 and fails
     AA at this size, while near-black clears 5:1. */
  color: #101418;
  font-weight: 700;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

button:hover {
  opacity: 0.88;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

button.secondary:hover {
  border-color: var(--border-hover);
  opacity: 1;
}

/* Intro — element preview */

.element-strip {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  padding: 0;
  margin: 0 0 1.5rem;
}

.element-chip {
  padding: 0.8rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--el);
  border-radius: 10px;
}

.element-chip-name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.element-chip-tag {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-dim);
}

/* Intro — test mode choice */

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.mode-note {
  margin: 1.1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dim);
}

/* Results — generated test result marker */

.debug-note {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.95rem;
  border: 1px dashed var(--border-hover);
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-dim);
}

/* Results — quick-test caveat */

.quick-warning {
  margin: 0 0 1.5rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid #4a3f2a;
  border-left: 4px solid #c9922e;
  border-radius: 8px;
  background: rgba(201, 146, 46, 0.08);
  font-size: 0.87rem;
  line-height: 1.55;
}

.quick-warning strong {
  color: #e6b354;
}

.link-btn {
  padding: 0;
  margin-left: 0.35rem;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Progress bar */

#progress {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.75rem 0 1rem;
  z-index: 10;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

#step-text {
  font-size: 0.85rem;
  font-weight: 600;
}

#progress-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Steps */

.step:focus {
  outline: none;
}

.step-nav {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.5rem;
}

.step-nav #next-btn,
.step-nav #submit-btn {
  margin-left: auto;
}

.step-error {
  margin: 0 0 0.9rem;
  min-height: 1.2em;
  font-size: 0.87rem;
  color: #e6b354;
}

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* Questions */

fieldset.question {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0 0 1.5rem;
  margin: 0 0 1.5rem;
}

fieldset.question legend {
  padding: 0;
  margin-bottom: 0.9rem;
  font-weight: 500;
  white-space: normal;
}

.scale {
  --scale-points: 5;
  display: grid;
  grid-template-columns: repeat(var(--scale-points), 1fr);
  gap: 0.5rem;
}

/* The most-used control in the app — clicked once per question — so selection
   needs to read at a glance, not as a 1px border shift. */
.scale-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  padding: 0.7rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1.25;
  text-align: center;
  color: var(--text-dim);
  background: transparent;
  transition: border-color 0.15s ease, color 0.15s ease,
    background-color 0.15s ease, transform 0.12s ease;
}

.scale-option:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.scale-option:active {
  transform: scale(0.97);
}

.scale-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--text);
  font-weight: 600;
}

/* The native radio keeps keyboard behaviour; the ring goes on the whole tile
   so the focused option is obvious at a glance. */
.scale-option:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.scale-option input {
  margin: 0;
  accent-color: var(--accent);
}

/* Full labels on wide screens, abbreviations on narrow ones. Previously the
   labels were simply hidden below 480px, which left five unlabelled radios. */
.label-short {
  display: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.scale-legend {
  display: none;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  color: var(--text-dim);
}

@media (max-width: 560px) {
  .label-full {
    /* Kept in the accessibility tree, just not painted. */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .label-short {
    display: block;
    font-size: 0.8rem;
  }

  .scale-legend {
    display: flex;
  }

  .scale-option {
    /* Comfortable thumb target across 60 questions. */
    min-height: 52px;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.5rem 0.2rem;
  }

  .scale {
    gap: 0.35rem;
  }
}

/* Results — title card */

.headline-card {
  --dominant: var(--accent);
  background: var(--card);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dominant) 20%, var(--card)),
    var(--card) 65%
  );
  border: 1px solid var(--border);
  border-left: 4px solid var(--dominant);
  border-radius: var(--radius);
  padding: 2.25rem 1.75rem;
  margin-bottom: 1.75rem;
}

/* Element icons — inline SVG that inherits its element's colour, so it can't
   drift the way a vendor-coloured emoji does. */
.element-icon {
  flex: 0 0 auto;
  vertical-align: -0.15em;
  margin-right: 0.42em;
}

.headline-emoji {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1;
  margin-bottom: 0.85rem;
}

/* The headline row spaces its icons with a gap instead. */
.headline-emoji .element-icon {
  margin-right: 0;
}

.element-chip-name,
.desc-heading,
.noise-label {
  display: flex;
  align-items: center;
}

.headline-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#headline {
  font-size: clamp(2rem, 7vw, 3.1rem);
  line-height: 1.1;
  margin: 0 0 0.6rem;
  letter-spacing: -0.015em;
}

.element-word {
  font-weight: 800;
}

.headline-tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 1.02rem;
}

/* Results — descriptions */

.desc-block {
  border-left: 3px solid var(--border);
  padding-left: 1.1rem;
  margin-bottom: 1.6rem;
}

.desc-heading {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.desc-block p {
  margin: 0 0 0.85rem;
}

.desc-block p:last-child {
  margin-bottom: 0;
}

.relative-lead-note {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1.05rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-dim);
  border-radius: 8px;
  background: rgba(154, 165, 177, 0.07);
  font-size: 0.87rem;
  line-height: 1.55;
  color: var(--text);
}

/* Results — bars */

.bar-row {
  margin-bottom: 1rem;
}

.bar-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.bar-score {
  margin-left: 0.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Diverging track: the centre line is neutral, fills grow out from it. */
.bar-track.diverging {
  position: relative;
  overflow: visible;
}

.bar-axis {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: var(--border-hover);
}

.bar-track.diverging .bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
}

.bar-line {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.bar-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  /* Driven from 0% by revealBars() so the payoff screen animates in. */
  transition: width 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.bar-pct {
  flex: 0 0 auto;
  min-width: 2.9rem;
  text-align: right;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.noise-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.breakdown-note {
  margin: 1.1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-dim);
}

/* Results — sharing */

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.share-status {
  margin: 0.85rem 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--text-dim);
}
