/* Wortfeld – Gestaltung angelehnt an Vokabelheft und Karteikarte:
   Linien in Heftblau, roter Randstrich, Füllerblau als Akzent.
   Schriften lokal (keine Google-Fonts-Einbindung wegen DSGVO). */

:root {
  --paper: #fbfcff;
  --ink: #1a2240;
  --ink-soft: #55607f;
  --rule: #d4def3;
  --margin: #de4b3a;
  --pen: #2c47c9;
  --pen-dark: #1f359c;
  --surface: #ffffff;

  --c-neu: #b3bbd3;
  --c-schwach: #de4b3a;
  --c-mittel: #e2a019;
  --c-sicher: #2f95d6;
  --c-gemeistert: #1d9a5f;

  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-hand: "Patrick Hand", "Segoe Print", "Bradley Hand", "Comic Neue", var(--font);
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121729;
    --ink: #e6eaf7;
    --ink-soft: #a3acc8;
    --rule: #2a3352;
    --surface: #1a2037;
    --pen: #8ea2ff;
    --pen-dark: #b1bfff;
    --c-neu: #5d6788;
  }
}

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

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

body {
  margin: 0;
  font: 17px/1.55 var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

a { color: var(--pen); text-underline-offset: 2px; }
a:hover { color: var(--pen-dark); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.25rem; }

:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 3px; }

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

/* ---------- Kopf und Fuß ---------- */

.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
  padding: .9rem 1.25rem;
  border-bottom: 2px solid var(--margin);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 22px; height: 26px; border-radius: 3px;
  background: repeating-linear-gradient(var(--surface) 0 5px, var(--rule) 5px 6px);
  border: 2px solid var(--ink); border-left: 4px solid var(--margin);
}
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.1rem; }
.top nav a { color: var(--ink); text-decoration: none; font-weight: 600; }
.top nav a:hover { color: var(--pen); }
.top nav form { margin: 0; }
.nav-premium { color: var(--pen) !important; }

.foot { display: flex; gap: 1.25rem; justify-content: center; padding: 1.5rem; font-size: .9rem; border-top: 1px solid var(--rule); }
.foot a { color: var(--ink-soft); }

/* ---------- Grundbausteine ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.2rem; border: 2px solid var(--pen); border-radius: var(--radius);
  background: var(--pen); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--pen-dark); border-color: var(--pen-dark); color: #fff; }
.btn.ghost { background: transparent; color: var(--pen); }
.btn.ghost:hover { background: color-mix(in srgb, var(--pen) 10%, transparent); color: var(--pen-dark); }
.btn.small { padding: .35rem .8rem; font-size: .95rem; color: #fff !important; }
.btn.right { background: var(--c-gemeistert); border-color: var(--c-gemeistert); }
.btn.wrong { background: transparent; color: var(--c-schwach); border-color: var(--c-schwach); }

.link { background: none; border: 0; padding: 0; font: inherit; color: var(--pen); text-decoration: underline; cursor: pointer; }
.link.danger, .danger { color: var(--margin); }

input, select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  padding: .6rem .7rem; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--surface); border: 2px solid var(--rule); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--pen); outline: none; }
textarea { resize: vertical; }
label { display: block; font-weight: 600; }
label small { font-weight: 400; color: var(--ink-soft); }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
label.check input { width: auto; margin-top: .3rem; }

.stack { display: grid; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row .grow { flex: 1 1 220px; }

.narrow { max-width: 440px; margin: 1.5rem auto; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.two-col { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.two-col .panel { margin-bottom: 0; }
.two-col + .panel, .two-col + section { margin-top: 1.25rem; }

.hint { font-size: .92rem; color: var(--ink-soft); margin: .25rem 0; }
.empty { padding: 1.5rem; border: 2px dashed var(--rule); border-radius: var(--radius); text-align: center; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); border-left: 5px solid var(--c-gemeistert); background: color-mix(in srgb, var(--c-gemeistert) 10%, var(--surface)); }
.flash.error { border-left-color: var(--margin); background: color-mix(in srgb, var(--margin) 10%, var(--surface)); }

.page-head { margin-bottom: 1.5rem; }
.page-head .sub { color: var(--ink-soft); margin: 0; }
.crumb { margin: 0 0 .25rem; font-size: .95rem; }

/* ---------- Kategorien ---------- */

.dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; vertical-align: .05em; }
.c-neu { background: var(--c-neu); }
.c-schwach { background: var(--c-schwach); }
.c-mittel { background: var(--c-mittel); }
.c-sicher { background: var(--c-sicher); }
.c-gemeistert { background: var(--c-gemeistert); }

.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--rule); gap: 2px; }
.bar span { flex-basis: 0; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; list-style: none; padding: 0; margin: .8rem 0 0; font-size: .95rem; }
.legend .dot { margin-right: .35rem; }
.goal { margin: 1rem 0 0; padding-top: .9rem; border-top: 1px solid var(--rule); }

/* ---------- Karteikarte (das eine auffällige Element) ---------- */

.index-card {
  position: relative;
  background:
    linear-gradient(90deg, transparent 2.6rem, var(--margin) 2.6rem, var(--margin) calc(2.6rem + 2px), transparent calc(2.6rem + 2px)),
    repeating-linear-gradient(var(--surface) 0 2.05rem, var(--rule) 2.05rem calc(2.05rem + 1px));
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--rule), 0 14px 28px -18px rgba(26, 34, 64, .45);
  padding: 1.1rem 1.5rem 1.4rem 3.6rem;
  border-top: 6px solid var(--margin);
}
.ic-lang { display: block; font-size: .85rem; color: var(--ink-soft); }
.ic-word { font-family: var(--font-hand); font-size: clamp(1.9rem, 6vw, 2.8rem); line-height: 1.25; margin: .4rem 0 .2rem; overflow-wrap: anywhere; }
.ic-answer { font-family: var(--font-hand); font-size: clamp(1.5rem, 4.5vw, 2.1rem); color: var(--pen); margin: .3rem 0 0; overflow-wrap: anywhere; }
.ic-note { font-size: .95rem; color: var(--ink-soft); margin: 0; }
.ic-dots { display: flex; gap: .35rem; margin-top: 1rem; }
.ic-dots .dot { opacity: .35; }
.ic-dots .dot.on { opacity: 1; transform: scale(1.35); }

.tilt { transform: rotate(-2.5deg); }

/* ---------- Startseite ---------- */

.hero { display: grid; gap: 2.5rem; grid-template-columns: 1.15fr 1fr; align-items: center; padding: 2rem 0 3rem; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); line-height: 1.05; letter-spacing: -.025em; max-width: 13ch; }
.lead { font-size: 1.15rem; max-width: 52ch; color: var(--ink-soft); }
.hero .btn { margin: .3rem .5rem .3rem 0; }
.hero-card { padding: 1rem; }
.features { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); border-top: 2px solid var(--ink); padding-top: 1.5rem; }
.features p { color: var(--ink-soft); margin: 0; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: .5rem; }
}

/* ---------- Listen ---------- */

.page-head:has(.streak) { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; }
.streak { margin: 0; color: var(--ink-soft); }
.streak strong { font-size: 1.6rem; color: var(--ink); }
.streak.on strong { color: var(--margin); }

.list-grid, .shop-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 1.5rem; }
.list-tile, .product {
  display: flex; flex-direction: column; gap: .45rem;
  padding: 1rem 1.1rem; min-height: 9rem;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border: 1px solid var(--rule); border-left: 4px solid var(--margin); border-radius: var(--radius);
}
.list-tile:hover, .product:hover { border-color: var(--pen); border-left-color: var(--margin); color: var(--ink); }
.lt-lang { font-size: .85rem; color: var(--ink-soft); }
.lt-title { font-weight: 700; font-size: 1.1rem; line-height: 1.25; flex: 1; }
.lt-meta { font-size: .9rem; color: var(--ink-soft); }
.price { font-weight: 700; color: var(--pen); }

.filter { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.filter a { padding: .3rem .8rem; border: 2px solid var(--rule); border-radius: 99px; text-decoration: none; color: var(--ink); font-weight: 600; }
.filter a[aria-current] { border-color: var(--pen); color: var(--pen); }

.modes { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: .5rem; }
.mode { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.1rem; background: var(--pen); color: #fff; border-radius: var(--radius); text-decoration: none; }
.mode:hover { background: var(--pen-dark); color: #fff; }
.mode span { font-size: .9rem; opacity: .85; }
.mode.locked { background: var(--surface); color: var(--ink-soft); border: 2px dashed var(--rule); }
.mode.locked strong { color: var(--ink); }
.dir-switch { font-size: .92rem; color: var(--ink-soft); margin: 0 0 1.5rem; }

.table-wrap { overflow-x: auto; }
table.vocab { width: 100%; border-collapse: collapse; }
.vocab th { text-align: left; font-size: .9rem; color: var(--ink-soft); font-weight: 600; padding: .4rem .5rem; border-bottom: 2px solid var(--ink); }
.vocab td { padding: .55rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.vocab td small { color: var(--ink-soft); }
.vocab form { margin: 0; }
.vocab tr.is-wrong td:nth-child(2) { color: var(--margin); text-decoration: line-through; }
.vocab tr.is-right td:nth-child(2) { color: var(--c-gemeistert); }

.tests { list-style: none; padding: 0; margin: 0; }
.tests li { padding: .35rem 0; border-bottom: 1px solid var(--rule); }
.delete-list { text-align: right; margin-top: 1rem; }

/* ---------- Lernen ---------- */

.learn { max-width: 620px; margin: 0 auto; }
.learn-top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.learn-progress { flex: 1; height: 8px; background: var(--rule); border-radius: 4px; overflow: hidden; }
.learn-progress span { display: block; height: 100%; width: 0; background: var(--c-gemeistert); transition: width .3s ease; }
.learn-count { font-size: .9rem; color: var(--ink-soft); white-space: nowrap; }
.learn-card { min-height: 13rem; }
.learn-card.flipped .ic-answer { animation: write-in .35s ease-out; }
@keyframes write-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; align-items: center; margin-top: 1.1rem; }
.answer-form { margin-top: 1.25rem; }
.answer-form input { font-size: 1.3rem; padding: .75rem .9rem; }
.keys { text-align: right; font-size: .85rem; color: var(--ink-soft); margin: .6rem 0 0; }

.feedback { margin-top: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius); border-left: 5px solid; }
.feedback p { margin: 0 0 .25rem; font-size: 1.1rem; }
.feedback.is-right { border-color: var(--c-gemeistert); background: color-mix(in srgb, var(--c-gemeistert) 10%, var(--surface)); }
.feedback.is-wrong { border-color: var(--margin); background: color-mix(in srgb, var(--margin) 10%, var(--surface)); }
.feedback .given { font-size: .95rem; color: var(--ink-soft); }
.cat-tag { margin-right: auto; font-size: .9rem; display: inline-flex; gap: .4rem; align-items: center; }

.done { text-align: center; padding: 1rem 0; }
.done .actions { justify-content: center; }
.score { font-size: 1.4rem; margin: 0 0 .25rem; }
.score strong { font-size: 3.2rem; display: block; line-height: 1.1; color: var(--pen); }
.done .table-wrap { text-align: left; margin-top: 1.5rem; }
.loading { text-align: center; color: var(--ink-soft); }

/* ---------- Shop und Premium ---------- */

.buy { text-align: left; }
.big-price { font-size: 2.2rem; font-weight: 700; margin: 0 0 1rem; }
.compare { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.compare .panel { margin: 0; }
.panel.featured { border: 2px solid var(--pen); }
.checks { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.checks li { padding: .4rem 0 .4rem 1.6rem; position: relative; border-bottom: 1px solid var(--rule); }
.checks li::before { content: ""; position: absolute; left: .2rem; top: .8rem; width: .7rem; height: .35rem; border: solid var(--c-gemeistert); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.plan { display: flex; gap: .7rem; align-items: center; padding: .7rem .9rem; border: 2px solid var(--rule); border-radius: var(--radius); font-weight: 400; cursor: pointer; }
.plan input { width: auto; margin: 0; }
.plan:has(input:checked) { border-color: var(--pen); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tilt { transform: none; }
}

/* ---------- Foto-Import ---------- */

.drop {
  position: relative; display: flex; flex-direction: column; gap: .25rem; align-items: center; text-align: center;
  padding: 1.6rem 1rem; margin: .75rem 0 .5rem; cursor: pointer;
  border: 2px dashed var(--pen); border-radius: var(--radius);
  background: color-mix(in srgb, var(--pen) 5%, var(--surface));
  font-weight: 400;
}
.drop:hover, .drop:focus-within { background: color-mix(in srgb, var(--pen) 10%, var(--surface)); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.drop strong { color: var(--pen); font-size: 1.05rem; }
.drop span { font-size: .92rem; color: var(--ink-soft); max-width: 46ch; }
.drop[hidden] { display: none; }

.scan-steps { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.scan-steps li { display: flex; align-items: center; gap: .75rem; font-size: .95rem; }
.scan-thumb { width: 44px; height: 56px; flex: none; border-radius: 3px; background: var(--rule); overflow: hidden; }
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-steps li.busy .scan-state::after { content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .5em; border: 2px solid var(--pen); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -.1em; }
.scan-steps li.ok .scan-state { color: var(--c-gemeistert); font-weight: 600; }
.scan-steps li.failed .scan-state, .scan-steps li.empty .scan-state { color: var(--margin); }
@keyframes spin { to { transform: rotate(360deg); } }

#scan-review { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.scan-pages { display: flex; gap: .5rem; overflow-x: auto; margin: .5rem 0 1rem; }
.scan-pages img { height: 110px; border-radius: 3px; border: 1px solid var(--rule); display: block; }
.scan-table td { padding: .3rem .25rem; vertical-align: middle; }
.scan-table td:first-child { width: 2rem; text-align: center; }
.scan-table input:not([type=checkbox]) { margin: 0; padding: .4rem .5rem; min-width: 8rem; }
.scan-table input[type=checkbox] { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--pen); }
.scan-table tr.unsure input:not([type=checkbox]) { border-color: var(--c-mittel); background: color-mix(in srgb, var(--c-mittel) 10%, var(--surface)); }
.scan-table tr:has(.use:not(:checked)) input:not([type=checkbox]) { opacity: .45; text-decoration: line-through; }
.unsure-mark { display: inline-block; width: .8em; height: .8em; border-radius: 2px; margin-right: .35em; vertical-align: -.05em; border: 2px solid var(--c-mittel); background: color-mix(in srgb, var(--c-mittel) 15%, var(--surface)); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 640px) {
  .scan-table thead { display: none; }
  .scan-table, .scan-table tbody { display: block; }
  .scan-table tr {
    display: grid; grid-template-columns: 1.6rem 1fr 1fr; gap: .35rem .4rem; align-items: center;
    padding: .55rem 0; border-bottom: 1px solid var(--rule);
  }
  .scan-table td { display: block; padding: 0; border: 0; width: auto !important; }
  .scan-table td:last-child { grid-column: 2 / 4; }
  .scan-table input:not([type=checkbox]) { min-width: 0; font-size: 1rem; }
  .scan-table td:last-child input { font-size: .9rem; padding: .3rem .5rem; }
}
