/* Nederlands Drill — house style (adapted from the Andries worksheets), mobile-first.
   Palette + Lexend + dyslexia-friendly spacing carried over from the worksheet template. */

:root {
  --bg: #fff;
  --text: #2d2d2d;
  --accent: #2a6496;
  --accent-dark: #1f4d74;
  --accent-light: #d6eaf8;
  --box-bg: #f7f7f2;
  --border: #b0b0b0;
  --good: #2e7d32;
  --good-bg: #e7f5e8;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --warn-bg: #fff3cd;
  --warn-border: #f0c040;
  --radius: 12px;
  --tap: 56px; /* minimum touch target */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Lexend', system-ui, sans-serif;
  font-size: 19px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0.02em;
  word-spacing: 0.08em;
  padding-bottom: 40px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent); color: #fff;
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05em; }
.logout { display: flex; align-items: center; gap: 10px; }
.who { font-size: 0.8em; opacity: 0.9; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-link { background: rgba(255,255,255,0.18); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; font: inherit; font-size: 0.85em; cursor: pointer; }

/* ---------- layout ---------- */
.shell { width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px 0; }

h1 { color: var(--accent); font-size: 1.6em; font-weight: 700; margin-bottom: 4px; }
h2 { color: var(--accent); font-size: 1.25em; font-weight: 600; margin: 28px 0 10px; }
.subtitle { color: #666; font-size: 0.92em; margin-bottom: 20px; }
p { margin-bottom: 10px; }
strong { font-weight: 600; }
a { color: var(--accent); }

/* ---------- intro box (dark gradient, worksheet idiom) ---------- */
.intro-box {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff; border-radius: 16px; padding: 22px 20px; margin: 4px 0 22px;
  border: 3px solid #f39c12; box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}
.intro-box h2 { color: #f39c12; border: 0; margin: 0 0 12px; text-align: center;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 1.3em; }
.intro-box p { margin-bottom: 10px; }

/* ---------- cards ---------- */
.card {
  background: var(--box-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin: 16px 0;
}
.example-box {
  background: #eaf4fb; border: 2px solid var(--accent); border-radius: 10px;
  padding: 16px 18px; margin: 14px 0;
}
.example-box .example-title { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.pencil-instruction {
  background: var(--warn-bg); border: 2px solid var(--warn-border); border-radius: 8px;
  padding: 12px 16px; margin: 12px 0; font-weight: 600; text-align: center;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px;
  border: 0; border-radius: 12px; font: inherit; font-weight: 600; font-size: 1.05em;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-light); color: var(--accent-dark); }
.btn-block { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 8px; }
input[type="email"], input[type="text"] {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; font-size: 1.1em;
  border: 2px solid var(--border); border-radius: 12px; background: #fff;
}
input[type="email"]:focus, input[type="text"]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.login-form { background: #fff; }
.form-error { color: var(--bad); font-weight: 600; margin-top: 10px; }

/* ---------- flash ---------- */
.flash { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; }
.flash-error { background: var(--bad-bg); color: var(--bad); border: 1.5px solid var(--bad); }
.flash-info  { background: var(--accent-light); color: var(--accent-dark); }

/* ---------- mode / tense tiles ---------- */
.mode-tiles { display: grid; gap: 14px; margin: 18px 0; }
.tile {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 16px;
  background: var(--box-bg); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-decoration: none; color: var(--text);
}
.tile:active { background: var(--accent-light); }
.tile-emoji { grid-row: span 2; font-size: 2em; }
.tile-title { font-weight: 700; color: var(--accent); font-size: 1.1em; }
.tile-sub { font-size: 0.85em; color: #555; line-height: 1.5; }

/* ---------- difficulty meter (kort/middel/lang -> 1/2/3) ---------- */
.meter { display: inline-flex; gap: 4px; vertical-align: middle; }
.meter .seg { width: 22px; height: 8px; border-radius: 4px; background: #ddd; }
.meter[data-level="1"] .seg:nth-child(1) { background: #2e7d32; }
.meter[data-level="2"] .seg:nth-child(-n+2) { background: #f0a020; }
.meter[data-level="3"] .seg { background: #d24b3e; }

/* ---------- drill card + correction (used from M4) ---------- */
.drill-card { background: #fff; border: 2px solid var(--accent); border-radius: var(--radius); padding: 20px 18px; margin: 16px 0; }
.drill-prompt { font-size: 1.1em; margin-bottom: 6px; }
.drill-prompt .inf { color: var(--accent); font-weight: 700; }
/* the verb to conjugate — a prominent coloured pill so it's unmistakable */
.verb-chip {
  display: inline-block; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 1.15em; padding: 5px 18px; border-radius: 999px;
  letter-spacing: 0.02em; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.drill-cue { font-size: 1.4em; margin: 10px 0 4px; }
/* which tense is expected — stated explicitly so the answer is unambiguous */
.tense-badge {
  display: inline-block; background: var(--accent-light); color: var(--accent-dark);
  border-radius: 8px; padding: 6px 12px; font-size: 0.9em; font-weight: 600; margin: 2px 0 12px;
}
.tense-num { color: #8a6d00; }
.tense-when { color: #555; font-weight: 400; }
.blank-cue {
  display: inline-block; min-width: 84px; border-bottom: 3px dotted var(--accent);
  height: 1.2em; vertical-align: bottom; margin-left: 6px;
}
/* ---------- correction block: labelled wrong/right rows + sentence in context ---------- */
/* visually-hidden helper for the screen-reader verdict (one clean string in the live region) */
.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;
}
.cor {
  border-radius: var(--radius); border: 2px solid var(--border); background: #fff;
  padding: 16px 16px 18px; margin-top: 16px; text-align: left; line-height: 1.5;
}
.cor--ok { border-color: var(--good); background: var(--good-bg); }
.cor--no { border-color: var(--bad);  background: var(--bad-bg);  }
/* 1 — status header */
.cor-head { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.2em; font-weight: 700; }
.cor-ico {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.1em; line-height: 1;
}
.cor--ok .cor-ico { background: var(--good); }
.cor--no .cor-ico { background: var(--bad);  }
.cor--ok .cor-verdict { color: var(--good); }
.cor--no .cor-verdict { color: var(--bad);  }
/* 2 — stacked labelled rows */
.cor-rows { display: grid; gap: 10px; margin-bottom: 14px; }
.cor-row { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 2px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.cor-row--no { border-color: var(--bad); }
.cor-row--ok { border-color: var(--good); }
.cor-tag { font-size: 0.8em; font-weight: 700; color: var(--text); }
.cor-word { font-size: 1.35em; font-weight: 700; line-height: 1.3; word-break: break-word; }
.cor-word--no { color: var(--text); }
.cor-word--ok { color: var(--good); }
/* only the differing ENDING is marked — never by colour/strike alone (also bold + weight) */
.cor-mark { border-radius: 4px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.cor-mark--no { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; text-decoration-thickness: 2px; }
.cor-mark--ok { background: var(--good-bg); color: var(--good); }
/* 3 — corrected sentence in context: the one blue reinforcement zone */
.cor-sentence { margin: 0 0 12px; font-size: 1.25em; line-height: 1.8; color: var(--text); }
.cor-slot {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 700;
  border-radius: 8px; padding: 1px 10px; margin: 0 1px; white-space: nowrap;
}
/* 4 — warm one-liner / cheer */
.cor-note { margin: 0; font-size: 1em; font-weight: 600; color: var(--text); }
/* 5 — Beluister: hidden until app.js reveals it; full-width, >= tap target */
.cor-listen {
  display: none; width: 100%; min-height: var(--tap);
  align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px; padding: 10px 18px;
  border: 2px solid var(--accent); border-radius: 12px;
  background: var(--accent-light); color: var(--accent-dark);
  font: inherit; font-weight: 700; font-size: 1.05em; cursor: pointer;
}
.cor-listen:not([hidden]) { display: inline-flex; }
.cor-listen:active { background: var(--accent); color: #fff; }
.cor-listen:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- progress ---------- */
.progress-bar { background: #eee; border-radius: 999px; height: 14px; overflow: hidden; margin: 6px 0; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); }
.badge-shelf { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.badge { font-size: 1.6em; filter: grayscale(1); opacity: 0.35; }
.badge.earned { filter: none; opacity: 1; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78em; font-weight: 700; }
.status-pill.done { background: var(--good-bg); color: var(--good); }
.status-pill.redo { background: var(--warn-bg); color: #8a6d00; }
.status-pill.new  { background: #eee; color: #555; }

/* ---------- sticky bottom bar (drill nav) ---------- */
.bottombar {
  position: sticky; bottom: 0; z-index: 15;
  background: rgba(255,255,255,0.96); border-top: 1.5px solid var(--border);
  padding: 12px 16px; display: flex; gap: 12px;
}
.bottombar .btn { flex: 1; }

/* ---------- mode A: tense list, intro, result ---------- */
.lead { font-size: 1.05em; margin-bottom: 14px; }
.tense-list { display: grid; gap: 10px; margin: 16px 0; }
.tense-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--box-bg); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 14px 16px; text-decoration: none; color: var(--text);
}
.tense-row:active { background: var(--accent-light); }
.tense-name { font-weight: 600; color: var(--accent); }
.ex-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.ex-table td { padding: 6px 8px; }
.ex-table .arrow { color: #999; text-align: center; }
.formule { text-align: center; font-weight: 600; color: var(--accent); font-size: 1.05em; }
.result-card { text-align: center; }
.result-card.pass { border-color: var(--good); background: var(--good-bg); }
.result-card.fail { border-color: var(--warn-border); background: var(--warn-bg); }
.result-score { font-size: 3em; font-weight: 700; color: var(--accent); line-height: 1.1; }
.result-detail { color: #555; margin-bottom: 10px; }
.btn-row { display: flex; gap: 10px; margin: 14px 0; }
.btn-row .btn { flex: 1; }
.btn-row form { display: contents; }  /* let the button be the flex item */

/* ---------- mode B: ladder + sentence card ---------- */
.ladder { display: grid; gap: 10px; margin: 16px 0; }
.ladder-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--box-bg); border: 1.5px solid var(--border); border-radius: 10px; padding: 14px 16px;
}
.ladder-row.locked { opacity: 0.55; }
.ladder-info { display: flex; flex-direction: column; }
.ladder-name { font-weight: 700; color: var(--accent); }
.ladder-tenses { font-size: 0.8em; color: #666; }
.lock { font-size: 1.4em; }
.sentence-card .sentence-meta { margin-bottom: 10px; }
.sentence { font-size: 1.2em; line-height: 1.7; margin: 6px 0 16px; }
.sentence-blank {
  display: inline-block; min-width: 70px; border-bottom: 3px dotted var(--accent);
  margin: 0 4px; color: transparent; user-select: none;
}

/* ---------- gamification + charts ---------- */
.gami { background: var(--box-bg); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 8px 0 18px; }
.gami-top { display: flex; justify-content: space-between; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.gami-xp { font-size: 0.82em; color: #555; margin-top: 6px; }
.chart-wrap { background: #fff; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px; margin: 8px 0 4px; }
.chart-empty { color: #777; font-style: italic; }
.chart-note { color: #666; font-size: 0.85em; margin: -2px 0 8px; }

/* ---------- loading overlay ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: rgba(255, 255, 255, 0.93);
}
/* show only when not [hidden] — a base `display:flex` would override the hidden attribute */
.loading-overlay:not([hidden]) { display: flex; }
.spinner {
  width: 56px; height: 56px; border: 6px solid var(--accent-light);
  border-top-color: var(--accent); border-radius: 50%; animation: nd-spin 0.8s linear infinite;
}
@keyframes nd-spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--accent); font-weight: 600; text-align: center; padding: 0 20px; }

/* ---------- practice timer + celebration ---------- */
.topbar-right { display: flex; align-items: center; gap: 8px; }
.timer-chip {
  background: rgba(255,255,255,0.18); color: #fff; border: 0; border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 0.85em; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.timer-chip.running { background: rgba(255,255,255,0.34); }
.timer-panel {
  position: fixed; top: 54px; right: 10px; z-index: 90; width: 230px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 12px; padding: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.2);
}
.timer-panel:not([hidden]) { display: block; }
.timer-label { display: block; font-weight: 600; margin-bottom: 6px; }
#timer-min {
  width: 100%; min-height: 46px; padding: 8px 12px; font: inherit; font-size: 1.15em;
  border: 2px solid var(--border); border-radius: 10px;
}
.timer-buttons { display: flex; gap: 8px; margin-top: 10px; }
.timer-buttons .btn { flex: 1; min-height: 46px; padding: 8px 10px; font-size: 1em; }
.timer-buttons .btn[title] { flex: 0 0 52px; }
.timer-hint { font-size: 0.8em; color: #666; margin-top: 8px; }

.celebrate-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(18,28,48,0.55); }
.celebrate-overlay:not([hidden]) { display: flex; align-items: center; justify-content: center; }
.celebrate-card {
  position: relative; z-index: 2; background: #fff; border-radius: 18px; padding: 28px 24px;
  text-align: center; max-width: 340px; width: 88%; box-shadow: 0 12px 44px rgba(0,0,0,0.35);
}
.celebrate-emoji { font-size: 4em; line-height: 1; }
.celebrate-emoji.pop { animation: trophy-pop 0.9s ease; }
@keyframes trophy-pop {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  55% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.celebrate-card h2 { color: var(--accent); margin: 6px 0 4px; }
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.confetti-piece {
  position: absolute; top: -16px; width: 10px; height: 14px; border-radius: 2px; opacity: 0.92;
  animation-name: confetti-fall; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(720deg); } }
.emoji-piece {
  position: absolute; left: 50%; top: 45%; font-size: 2.2em; animation: emoji-fly 1.5s ease-out forwards;
}
@keyframes emoji-fly {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; }
}

/* ---------- desktop niceties ---------- */
@media (min-width: 720px) {
  body { font-size: 20px; }
  .mode-tiles { grid-template-columns: 1fr; }
}
