/*
 * Huisstijl Facilicom Groep, overgenomen uit het workshopdeck (thema en
 * slidemaster). Alle kleuren staan hieronder als token; verderop in dit
 * bestand geen losse kleurwaarden, behalve schaduwen op rgba(20,22,31,…).
 *
 * Tekstkleuren: alleen --navy, --red-text en --white (op een navy, rood of
 * blauw vlak). --red, --blue en de taupes zijn vlakkleuren, nooit tekst:
 * ze halen geen 4,5:1 op de achtergrond. tests/styles.test.js bewaakt dit.
 */
:root {
  --canvas: #d7ccc8;
  --card: #ffffff;
  --white: #ffffff;
  --navy: #004077;
  --red: #c8261b;
  --red-text: #ab2117;
  --blue: #1473c4;
  --taupe: #a1887f;
  --taupe-light: #bcaaa4;
  --sand: #e3dcd9;

  --shadow: 0 1px 2px rgba(20, 22, 31, 0.08), 0 6px 18px rgba(20, 22, 31, 0.08);
  --shadow-lift: 0 2px 4px rgba(20, 22, 31, 0.12), 0 10px 24px rgba(20, 22, 31, 0.14);

  --font: Aptos, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Aptos Display", Aptos, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 16px;
  --focus: 3px solid var(--blue);
}

/* ── Basis ─────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--navy);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px var(--gutter) 0;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

.footer {
  padding: 16px 0 20px;
}

/* Alleen tonen als het spel na 2 seconden nog niet geladen is; zonder
   styles.css is hij meteen zichtbaar (dan ontbreken de scripts waarschijnlijk ook). */
.load-error {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-left: 4px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-weight: 700;
  opacity: 0;
  animation: load-error-appear 0s 2s forwards;
}

@keyframes load-error-appear {
  to {
    opacity: 1;
  }
}

.footer__logo {
  display: block;
  width: 150px;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* ── Typografie ───────────────────────────────────────────────────────── */

.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
  line-height: 1.15;
}

.title--display {
  font-size: clamp(2.1rem, 1.5rem + 3vw, 3.4rem);
}

.title:focus,
.question__text:focus,
.instruction:focus {
  outline: none;
}

.title-rule {
  display: block;
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background: var(--red);
  margin-top: -4px;
}

.lead {
  margin: 0;
  font-size: 1.1rem;
  max-width: 38rem;
}

.small {
  margin: 0;
  font-size: 0.9rem;
}

/* ── Vormtaal uit het deck ────────────────────────────────────────────── */

.pill {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 12px;
  border: 1.5px solid var(--navy);
  border-radius: 6px;
  background: var(--card);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
}

.pill--red {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}

.badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
}

.badge--red {
  background: var(--red);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.bar {
  margin: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  text-align: center;
}

.notice {
  margin: 0;
  padding: 10px 14px;
  border-left: 4px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--sand);
  color: var(--navy);
}

.error {
  margin: 0;
  color: var(--red-text);
  font-weight: 700;
}

/* ── Knoppen en velden ────────────────────────────────────────────────── */

.btn {
  align-self: flex-start;
  user-select: none;
  -webkit-user-select: none;
  min-height: 48px;
  padding: 12px 28px;
  border: 2px solid var(--navy);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn--primary {
  background: var(--navy);
  color: var(--white);
}

.btn--secondary {
  background: var(--card);
  color: var(--navy);
}

/* Geen kleurwissel bij hover: de knop tilt op. */
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}

.link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--navy);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  max-width: 34rem;
}

.form__row {
  display: grid;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-weight: 700;
  font-size: 0.95rem;
}

.input {
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--taupe);
  border-radius: 10px;
  background: var(--card);
}

.input[aria-invalid="true"] {
  border-color: var(--red);
}

/* ── Welkom ───────────────────────────────────────────────────────────── */

.welcome {
  display: grid;
  gap: 24px;
}

.welcome__text {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome__links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.welcome__demo {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.welcome__art {
  display: none;
}

.blk {
  position: absolute;
  border-radius: 16px;
}

.blk--navy {
  top: 0;
  left: 8%;
  width: 56%;
  height: 46%;
  background: var(--navy);
}

.blk--taupe {
  top: 26%;
  right: 0;
  width: 60%;
  height: 44%;
  background: var(--taupe-light);
}

.blk--red {
  top: 56%;
  left: 0;
  width: 34%;
  height: 26%;
  background: var(--red);
}

/* ── Rondes: kopregel, timer ──────────────────────────────────────────── */

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.hud__meta {
  font-weight: 700;
}

.hud__score {
  margin-left: auto;
  font-size: 1.05rem;
}

.hud__score strong {
  font-size: 1.3rem;
}

.timer {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.timer__fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 5px;
  background: var(--navy);
  transform-origin: left center;
}

.timer--low .timer__fill {
  background: var(--red);
}

.timer__num {
  min-width: 2.6ch;
  font-weight: 700;
  font-size: 1.4rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer--low .timer__num {
  color: var(--red-text);
}

.score-banner {
  margin: 0;
  align-self: flex-start;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: var(--white);
  font-size: 1.1rem;
}

.rules {
  margin: 0;
  padding: 18px 18px 18px 38px;
  max-width: 40rem;
}

.rules li + li {
  margin-top: 8px;
}

/* ── Ronde 1: de digitale sprong ──────────────────────────────────────── */

.lives {
  color: var(--red-text);
  font-size: 1.3rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

.play {
  position: relative;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: manipulation; /* snel tikken zonder te zoomen */
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.play__canvas {
  display: block;
  width: 100%;
  aspect-ratio: 640 / 220;
}

.play__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 1.2rem + 4vw, 3.6rem);
  pointer-events: none;
}

.btn--jump {
  align-self: stretch;
  min-height: 60px;
  font-size: 1.2rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn__hint {
  font-weight: 400;
  font-size: 0.95rem;
}

/* ── Quiz ─────────────────────────────────────────────────────────────── */

.question {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.source {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.source cite {
  font-style: italic;
}

.question__text {
  margin: 0;
  font-size: clamp(1.15rem, 1rem + 0.8vw, 1.45rem);
  line-height: 1.3;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 2px solid var(--sand);
  border-radius: 12px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.option:hover:not(:disabled) {
  border-color: var(--navy);
  transform: translateY(-1px);
}

/* Na het antwoorden direct de uitslag tonen, zonder overgang. */
.option:disabled {
  cursor: default;
  transition: none;
}

.option__text {
  flex: 1;
}

.option__mark {
  flex: none;
  font-weight: 800;
  font-size: 1.2rem;
}

.option--correct {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}

.option--correct .badge {
  background: var(--white);
  color: var(--navy);
}

.option--wrong {
  border-color: var(--red);
  border-width: 3px;
}

.option--wrong .badge {
  background: var(--red);
}

.option--wrong .option__mark {
  color: var(--red-text);
}

.feedback {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--sand);
}

.feedback__verdict {
  margin: 0;
  font-weight: 800;
  font-size: 1.15rem;
}

.feedback__verdict--bad {
  color: var(--red-text);
}

.feedback__text {
  margin: 0;
}

/* ── Koppelen ─────────────────────────────────────────────────────────── */

.instruction {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.match {
  display: grid;
  gap: 14px;
}

.match__col {
  display: grid;
  gap: 8px;
  align-content: start;
}

.match__col--terms {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  border: 2px solid var(--sand);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.tile--term {
  font-weight: 700;
  justify-content: center;
  text-align: center;
  hyphens: auto;
  overflow-wrap: break-word;
}

.tile__text {
  min-width: 0;
}

.tile:hover:not(:disabled) {
  border-color: var(--navy);
}

.tile[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.tile--matched,
.tile--matched:disabled {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
  box-shadow: none;
  cursor: default;
}

/* Paarnummer en ✗ in de hoek, zodat de tekst de volle breedte houdt. */
.tile__mark {
  position: absolute;
  top: -9px;
  right: -9px;
  font-weight: 800;
}

.tile__mark:empty {
  display: none;
}

.tile--matched .badge {
  width: 26px;
  height: 26px;
  border: 2px solid var(--white);
  font-size: 0.85rem;
}

.tile--wrong {
  border-color: var(--red);
  border-width: 3px;
  transition: none;
  animation: shake 360ms ease;
}

.tile--wrong .tile__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: 0.85rem;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.missed {
  display: grid;
  gap: 6px;
  margin: 0;
}

.missed dt {
  font-weight: 700;
}

.missed dd {
  margin: 0 0 6px;
}

/* ── Eindscore en ranglijst ───────────────────────────────────────────── */

.big-score {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 2rem + 5vw, 4.6rem);
  line-height: 1;
}

.big-score__unit {
  font-size: 1.3rem;
  font-weight: 700;
}

.stats {
  display: grid;
  gap: 12px;
}

.stat {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 16px 18px;
}

.stat__title {
  margin: 0;
  font-size: 1.1rem;
}

.stat__num {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: right;
}

.stat__detail {
  grid-column: 2 / -1;
  margin: 0;
}

.board-card {
  padding: 6px 0;
  max-width: 40rem;
}

.board {
  width: 100%;
  border-collapse: collapse;
}

.board th,
.board td {
  padding: 10px 16px;
  text-align: left;
}

.board thead th {
  font-size: 0.85rem;
  border-bottom: 2px solid var(--sand);
}

.board tbody tr + tr td {
  border-top: 1px solid var(--sand);
}

.board__pos {
  width: 3.5rem;
}

.board__score {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.board td.board__score {
  font-weight: 800;
}

.board__own td {
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
}

.board__gap td {
  padding: 2px 16px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.board__empty {
  margin: 0;
  padding: 14px 16px;
}

/* ── Breder scherm ────────────────────────────────────────────────────── */

@media (min-width: 560px) {
  .form__row {
    grid-template-columns: 1fr 1fr;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
    max-width: 40rem;
  }
}

@media (min-width: 760px) {
  .app {
    padding: 32px 32px 0;
  }
  .welcome {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: start;
  }
  .welcome__art {
    display: block;
    position: relative;
    aspect-ratio: 1 / 1;
    margin-top: 40px;
  }
  .options {
    grid-template-columns: 1fr 1fr;
  }
  .stats {
    grid-template-columns: repeat(3, 1fr);
    max-width: none;
  }
  .btn--jump {
    align-self: flex-start;
    min-width: 16rem;
  }
  .match {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }
  .match__col--terms {
    grid-template-columns: 1fr;
  }
  .tile--term {
    justify-content: flex-start;
    text-align: left;
  }
}

/* ── Minder beweging ──────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .btn:hover,
  .option:hover:not(:disabled),
  .tile[aria-pressed="true"] {
    transform: none;
  }
  /* Geen beweging, alleen een vertraagd verschijnen: die moet blijven. */
  .load-error {
    animation: load-error-appear 0s 2s forwards !important;
  }
}
