/* German Growth — web app
 *
 * The app's identity, ported: white / true-black grounds (never cream), and
 * der=blue, die=red, das=green as fixed learning anchors that NEVER recolour,
 * because the whole method leans on that association.
 *
 * No framework and no build step on purpose: this has to load fast on a phone
 * over a bad connection and keep working offline.
 */

:root {
  --ground: #f2f2f7;
  --paper: #ffffff;
  --ink: #11131a;
  --ink-soft: #5b6070;
  --edge: rgba(0, 0, 0, .10);
  --accent: #5957d6;
  --der: #2f6df6;
  --die: #e0384f;
  --das: #23a05a;
  --amber: #eba921;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 18px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #000000;
    --paper: #1c1c1e;
    --ink: #ffffff;
    --ink-soft: #a1a1aa;
    --edge: rgba(255, 255, 255, .12);
    --accent: #8886ff;
    --der: #5a92ff;
    --die: #ff6b7e;
    --das: #43c97f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  /* Room for the fixed tab bar, plus the iPhone home indicator. */
  padding: 0 0 calc(76px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--edge);
}
.brand { font-weight: 800; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.bar-stats { display: flex; gap: 8px; }
.chip {
  font-size: 14px; font-variant-numeric: tabular-nums;
  background: var(--paper); border: 1px solid var(--edge);
  padding: 4px 10px; border-radius: 999px;
}

/* ---------- layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 20px 16px 8px; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 6px; letter-spacing: -.01em; }
.lede { color: var(--ink-soft); margin: 0; }
.hero { margin-bottom: 22px; }

.cards { display: grid; gap: 14px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--paper); border: 1px solid var(--edge);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card p { color: var(--ink-soft); margin: 0 0 10px; }
.card .go { font-weight: 650; color: var(--accent); }
.card-der h2 { color: var(--der); }
.card-case h2 { color: var(--accent); }

/* ---------- drill ---------- */
.drill { display: grid; gap: 16px; }
.prompt {
  background: var(--paper); border: 1px solid var(--edge);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 20px; text-align: center; min-height: 190px;
  display: grid; align-content: center; gap: 8px;
}
/* A card you have got wrong before comes back with a warm ground, so the
   repeat is recognisable — the same idea as the iOS app's yellow card. */
.prompt.slipped { background: color-mix(in srgb, var(--amber) 14%, var(--paper)); }
.prompt .emoji { font-size: 54px; line-height: 1; }
.prompt .word { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.prompt .english { color: var(--ink-soft); }
.prompt .sentence { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.gap { display: inline-block; min-width: 68px; border-bottom: 3px solid var(--accent); }
.gap.filled { border-bottom-color: transparent; }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice {
  min-height: var(--tap); font: inherit; font-weight: 750; font-size: 19px;
  border-radius: 14px; border: 2px solid var(--edge); background: var(--paper);
  color: var(--ink); cursor: pointer; padding: 12px 8px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
}
.choice:active { transform: scale(.97); }
.choice[data-g="der"] { color: var(--der); }
.choice[data-g="die"] { color: var(--die); }
.choice[data-g="das"] { color: var(--das); }
.choice.right { background: var(--das); border-color: var(--das); color: #fff; }
.choice.wrong { background: var(--die); border-color: var(--die); color: #fff; }
.choice.reveal { border-color: var(--das); }
.choice:disabled { cursor: default; }

.feedback {
  border-radius: 14px; padding: 14px 16px; border: 1px solid var(--edge);
  background: var(--paper); display: grid; gap: 6px;
}
.feedback .head { font-weight: 750; }
.feedback.ok .head { color: var(--das); }
.feedback.no .head { color: var(--die); }
.feedback .why { color: var(--ink-soft); font-size: 15px; }

.btn {
  min-height: var(--tap); font: inherit; font-weight: 700; font-size: 17px;
  border: none; border-radius: 14px; background: var(--accent); color: #fff;
  cursor: pointer; padding: 13px 18px; width: 100%;
}
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--edge); }
.meter { height: 6px; border-radius: 999px; background: var(--edge); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s ease; }
.rowline { display: flex; justify-content: space-between; align-items: center;
           color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- dictionary ---------- */
.search {
  width: 100%; min-height: var(--tap); font: inherit; font-size: 17px;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--edge); background: var(--paper); color: var(--ink);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; font: inherit; font-size: 14px; padding: 7px 13px;
  border-radius: 999px; border: 1px solid var(--edge);
  background: var(--paper); color: var(--ink); cursor: pointer; white-space: nowrap;
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.words { display: grid; gap: 8px; }
.word-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--paper); border: 1px solid var(--edge); border-radius: 14px;
}
.word-row .art { font-size: 24px; width: 30px; text-align: center; }
.word-row .de { font-weight: 700; }
.word-row .art-word { font-weight: 800; }
.word-row .en { color: var(--ink-soft); font-size: 15px; }
.word-row.der .art-word { color: var(--der); }
.word-row.die .art-word { color: var(--die); }
.word-row.das .art-word { color: var(--das); }
.word-row .mastered { margin-left: auto; color: var(--das); }

/* ---------- progress ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--edge); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 30px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-soft); font-size: 14px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 10px; border-radius: 999px; background: var(--edge); overflow: hidden; }
.bar-track > i { display: block; height: 100%; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; }
.note { color: var(--ink-soft); font-size: 14px; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--edge);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: grid; gap: 2px; justify-items: center; padding: 9px 2px 8px;
  text-decoration: none; color: var(--ink-soft); font-size: 11px; font-weight: 600;
}
.tabs a span { font-size: 20px; line-height: 1.1; }
.tabs a[aria-current="page"] { color: var(--accent); }

.foot { max-width: 720px; margin: 0 auto; padding: 8px 16px 20px; color: var(--ink-soft); font-size: 13px; }
.foot a { color: var(--ink-soft); }
.foot-note { display: block; margin-top: 4px; }

@media (min-width: 700px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .cards .card:first-child { grid-column: 1 / -1; }
  h1 { font-size: 34px; }
}

/* ---------- landing sections on the Home tab ----------
 * derdiedas.cc is both the product and the pitch: someone who lands here can
 * start drilling in one tap, but the page still has to explain what this is and
 * be honest about which parts live in the browser vs the iPhone app. */
.eyebrow {
  text-transform: uppercase; letter-spacing: .08em; font-size: 12px;
  font-weight: 700; color: var(--ink-soft); margin: 0 0 6px;
}
.g-der { color: var(--der); }
.g-die { color: var(--die); }
.g-das { color: var(--das); }

.section { margin: 30px 0 0; }
.section h2 { margin-bottom: 8px; }
.section h3 { font-size: 16px; margin: 0 0 8px; }

.split { display: grid; gap: 12px; }
.pane {
  background: var(--paper); border: 1px solid var(--edge);
  border-radius: var(--radius); padding: 16px;
}
.pane ul { margin: 0; padding-left: 18px; color: var(--ink-soft); }
.pane li { margin-bottom: 4px; }
.pane .note { margin: 10px 0 0; font-weight: 650; color: var(--accent); font-size: 14px; }

@media (min-width: 700px) {
  .split { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   Design pass — give the page a face
   ==========================================================================
   The trainer screens stay plain on purpose: when a learner is answering, the
   German word is the only thing that should compete for attention. The
   personality lives on the landing surfaces instead. */

/* Fraunces on headings only. Body text and, crucially, the German words stay on
   the system stack — it renders instantly and matches the iOS app's typography,
   and a webfont failing to load must never delay a drill. */
h1, h2, .stat b, .prompt .word {
  font-family: Fraunces, ui-serif, Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
}
h1 { font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
h2 { font-weight: 600; }
/* The drilled word is the exception to the exception: it must be unambiguous,
   so it keeps the sans. Fraunces' serifs blur an ä at a glance. */
.prompt .word { font-family: inherit; }

/* ---------- hero ---------- */
.hero { position: relative; padding-top: 6px; }
.hero-tree {
  display: block; width: 260px; height: auto; margin: 18px auto -10px;
  /* The blossom carries the brand colours, so let it glow rather than sit flat. */
  filter: drop-shadow(0 18px 40px rgba(89, 87, 214, .28));
}
@media (prefers-color-scheme: dark) {
  .hero-tree { filter: drop-shadow(0 18px 44px rgba(140, 138, 255, .22)); }
}

/* ---------- cards with a gender edge ---------- */
.card {
  position: relative; overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.card-der::before {
  background: linear-gradient(180deg, var(--der) 0 33%, var(--die) 33% 66%, var(--das) 66% 100%);
}
.card-case::before { background: var(--accent); }
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--edge));
  box-shadow: 0 10px 30px rgba(0,0,0,.10);
}
.card h2 { font-size: 21px; }

/* Bigger, calmer type on the landing sections. */
.section h2 { font-size: 22px; }
.hero h1 { font-size: 30px; margin-bottom: 10px; }

@media (min-width: 700px) {
  main { max-width: 860px; }
  .hero h1 { font-size: 42px; }
  /* Two-column hero: words left, tree right, so desktop stops looking like a
     stretched phone. */
  .hero {
    display: grid; grid-template-columns: 1.15fr .85fr;
    align-items: center; gap: 26px; margin-bottom: 30px;
  }
  .hero .eyebrow, .hero h1, .hero .lede { grid-column: 1; }
  .hero-tree {
    grid-column: 2; grid-row: 1 / span 3;
    width: 380px; margin: 0;
  }
  .section h2 { font-size: 26px; }
}

/* ==========================================================================
   The course
   ========================================================================== */
.meter-lg { height: 10px; margin-top: 16px; }
.meter > i { background: linear-gradient(90deg, var(--der), var(--die), var(--das)); }
.learn-hero { margin-bottom: 26px; }

.level { margin: 0 0 26px; }
.level-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.level-badge {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  color: #fff; background: linear-gradient(135deg, var(--accent), #7b79e8);
  box-shadow: 0 6px 18px rgba(89,87,214,.28);
}
.level-badge.done { background: linear-gradient(135deg, var(--das), #4fd090); box-shadow: none; }
.level-head h2 { font-size: 18px; margin: 0; }
.level-count {
  margin-left: auto; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); font-size: 14px; font-weight: 650;
}

/* The trail. A connecting line runs behind the rows so the level reads as a
   route you walk, not a list you scan. */
.trail { position: relative; display: grid; gap: 8px; padding-left: 4px; }
.trail::before {
  content: ""; position: absolute; left: 26px; top: 12px; bottom: 12px; width: 2px;
  background: var(--edge); border-radius: 2px;
}

.lesson-row {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; text-align: left; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--edge);
  border-radius: 16px; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.lesson-row:hover { transform: translateX(2px); }
.lesson-row.is-locked { cursor: default; opacity: .55; }
.lesson-row.is-next { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.lesson-mark {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--ground); border: 1px solid var(--edge);
}
.lesson-text { display: grid; gap: 2px; min-width: 0; }
.lesson-title { font-weight: 700; }
.lesson-goal { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-score { margin-left: auto; font-weight: 800; }
/* The same three bands as the app: a finished lesson carries how it went. */
.band-clean  .lesson-score, .lesson-row.band-clean  .lesson-score { color: var(--das); }
.band-shaky  .lesson-score, .lesson-row.band-shaky  .lesson-score { color: var(--amber); }
.band-failed .lesson-score, .lesson-row.band-failed .lesson-score { color: var(--die); }
.lesson-row.band-clean  .lesson-mark { border-color: color-mix(in srgb, var(--das) 55%, var(--edge)); }
.lesson-row.band-shaky  .lesson-mark { border-color: color-mix(in srgb, var(--amber) 60%, var(--edge)); }
.lesson-row.band-failed .lesson-mark { border-color: color-mix(in srgb, var(--die) 55%, var(--edge)); }

/* ==========================================================================
   The lesson player — full attention, no chrome
   ========================================================================== */
body.in-lesson .tabs, body.in-lesson .foot, body.in-lesson .bar { display: none; }
body.in-lesson { padding-bottom: 0; }

.lesson-wrap {
  min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto;
  gap: 16px; padding: calc(12px + env(safe-area-inset-top)) 0 16px;
}
.lesson-bar { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--paper); color: var(--ink);
  font-size: 15px; cursor: pointer;
}
.lesson-step-count { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.step { display: grid; gap: 14px; align-content: start; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step-foot { display: grid; gap: 10px; }

.teach-card, .prompt-card {
  background: var(--paper); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 26px 20px; text-align: center; box-shadow: var(--shadow);
  display: grid; gap: 8px; justify-items: center;
}
.teach-emoji { font-size: 52px; line-height: 1; }
.teach-de {
  font-size: 32px; font-weight: 800; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 10px;
}
.teach-en { color: var(--ink-soft); font-size: 17px; }
.teach-tip {
  margin-top: 6px; font-size: 14px; color: var(--ink-soft);
  background: var(--ground); border-radius: 12px; padding: 10px 14px;
}
.speak-btn, .listen-btn {
  border: none; background: transparent; cursor: pointer; font-size: 22px;
  line-height: 1; padding: 4px;
}
.listen-btn {
  font-size: 42px; width: 92px; height: 92px; border-radius: 50%;
  background: var(--ground); border: 1px solid var(--edge);
}
.prompt-big { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
.prompt-big.cloze { line-height: 1.5; }
.prompt-sub { color: var(--ink-soft); }

.options { display: grid; gap: 10px; }
.option {
  min-height: var(--tap); font: inherit; font-size: 17px; font-weight: 650;
  padding: 13px 16px; border-radius: 14px; border: 2px solid var(--edge);
  background: var(--paper); color: var(--ink); cursor: pointer; text-align: left;
  transition: transform .06s ease, background .15s, border-color .15s;
}
.option:active { transform: scale(.99); }
.option.right { background: var(--das); border-color: var(--das); color: #fff; }
.option.wrong { background: var(--die); border-color: var(--die); color: #fff; }
.option.reveal { border-color: var(--das); }

/* arrange */
.arrange-line {
  min-height: 62px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; border-radius: 14px; border: 2px dashed var(--edge); background: var(--paper);
}
.arrange-line.right { border-style: solid; border-color: var(--das); }
.arrange-line.wrong { border-style: solid; border-color: var(--die); }
.arrange-hint { color: var(--ink-soft); font-size: 14px; }
.arrange-bank { display: flex; flex-wrap: wrap; gap: 8px; }
.word-chip {
  font: inherit; font-size: 16px; font-weight: 650; padding: 9px 14px;
  border-radius: 999px; border: 1px solid var(--edge);
  background: var(--accent); color: #fff; cursor: pointer;
}
.word-chip.ghost { background: var(--paper); color: var(--ink); }

/* type */
.type-input {
  width: 100%; min-height: var(--tap); font: inherit; font-size: 19px; font-weight: 600;
  padding: 13px 16px; border-radius: 14px; border: 2px solid var(--edge);
  background: var(--paper); color: var(--ink); text-align: center;
}
.type-input:focus { outline: none; border-color: var(--accent); }
.type-input.right { border-color: var(--das); }
.type-input.wrong { border-color: var(--die); }

/* match */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.match-cell {
  font: inherit; font-size: 15px; font-weight: 600; padding: 13px 10px;
  border-radius: 12px; border: 1px solid var(--edge);
  background: var(--paper); color: var(--ink); cursor: pointer; min-height: 46px;
}
.match-cell.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--paper)); }
.match-cell.matched { opacity: .42; border-style: dashed; cursor: default; }
.match-cell.missed { animation: shake .4s; border-color: var(--die); }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* summary */
.summary { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 30px 0; animation: rise .3s ease both; }
.summary-icon {
  font-size: 46px; width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ground); border: 1px solid var(--edge);
}
.summary.band-clean  .summary-icon { border-color: var(--das); box-shadow: 0 0 0 6px color-mix(in srgb, var(--das) 14%, transparent); }
.summary.band-shaky  .summary-icon { border-color: var(--amber); }
.summary.band-failed .summary-icon { border-color: var(--die); }
.summary-score { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.summary-actions { display: grid; gap: 10px; width: 100%; max-width: 340px; margin-top: 8px; }

@media (min-width: 700px) {
  .lesson-wrap { max-width: 640px; margin: 0 auto; }
  .options { grid-template-columns: 1fr 1fr; }
}

/* The course card leads the set now that lessons run in the browser. */
.card-course::before { background: linear-gradient(180deg, var(--accent), #8f8dff); }
.card-course h2 { color: var(--accent); }
@media (min-width: 700px) {
  .cards .card:first-child { grid-column: 1 / -1; }
}

/* ---------- share card ---------- */
.share-host { display: grid; justify-items: center; margin: 4px 0 12px; }
.share-preview {
  width: 100%; max-width: 340px; height: auto; border-radius: var(--radius);
  border: 1px solid var(--edge); box-shadow: var(--shadow);
}

/* ---------- keyboard hints ----------
   Only on devices that actually have a keyboard: a number badge on a phone
   would be a lie, since there is nothing to press. */
@media (hover: hover) and (pointer: fine) {
  .option, .choice { position: relative; }
  .options .option::after,
  .choices .choice::after {
    content: attr(data-key);
    position: absolute; top: 6px; right: 8px;
    font-size: 11px; font-weight: 700; line-height: 1;
    padding: 3px 5px; border-radius: 5px;
    color: var(--ink-soft); background: var(--ground); border: 1px solid var(--edge);
    opacity: .75;
  }
  .option:disabled::after, .choice:disabled::after { display: none; }
  .kbd-hint { color: var(--ink-soft); font-size: 13px; text-align: center; margin: 2px 0 0; }
}
@media not all and (hover: hover) { .kbd-hint { display: none; } }
