/* Lesebuch. Palette and type follow the AI the Classics site (app/globals.css):
   warm paper and ink, oxblood primary, restrained gold. German is set in
   Gentium Book Plus, English in Newsreader, labels in Inter. */

@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 600; font-display: swap; src: url(/lesebuch/fonts/newsreader.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 600; font-display: swap; src: url(/lesebuch/fonts/newsreader-i.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap; src: url(/lesebuch/fonts/inter.woff2) format("woff2"); }
@font-face { font-family: "Gentium Book Plus"; font-style: normal; font-weight: 400; font-display: swap; src: url(/lesebuch/fonts/gentium-400.woff2) format("woff2"); }
@font-face { font-family: "Gentium Book Plus"; font-style: normal; font-weight: 700; font-display: swap; src: url(/lesebuch/fonts/gentium-700.woff2) format("woff2"); }
@font-face { font-family: "Gentium Book Plus"; font-style: italic; font-weight: 400; font-display: swap; src: url(/lesebuch/fonts/gentium-400i.woff2) format("woff2"); }
@font-face { font-family: "Gentium Book Plus"; font-style: italic; font-weight: 700; font-display: swap; src: url(/lesebuch/fonts/gentium-700i.woff2) format("woff2"); }
@font-face { font-family: "UnifrakturMaguntia"; font-style: normal; font-weight: 400; font-display: swap; src: url(/lesebuch/fonts/fraktur.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --paper: oklch(0.968 0.009 84);
  --surface: oklch(0.984 0.007 84);
  --ink: oklch(0.248 0.014 55);
  --muted: oklch(0.505 0.02 55);
  --rule: oklch(0.878 0.014 74);
  --primary: oklch(0.415 0.108 27);
  --on-primary: oklch(0.975 0.012 84);
  --accent: oklch(0.74 0.082 74);
  --gold: oklch(0.53 0.095 70);
  --again: oklch(0.505 0.18 27);
  --easy: oklch(0.47 0.08 150);

  --serif: "Newsreader", ui-serif, Georgia, serif;
  --de: "Gentium Book Plus", "Gentium Plus", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --fraktur: "UnifrakturMaguntia", "Gentium Book Plus", Georgia, serif;
  --radius: 0.25rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: oklch(0.198 0.012 55);
    --surface: oklch(0.238 0.014 52);
    --ink: oklch(0.915 0.014 82);
    --muted: oklch(0.7 0.02 72);
    --rule: oklch(0.86 0.03 78 / 14%);
    --primary: oklch(0.62 0.13 30);
    --on-primary: oklch(0.16 0.01 55);
    --accent: oklch(0.72 0.088 74);
    --gold: oklch(0.76 0.095 74);
    --again: oklch(0.7 0.14 25);
    --easy: oklch(0.74 0.09 150);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: oklch(0.198 0.012 55);
  --surface: oklch(0.238 0.014 52);
  --ink: oklch(0.915 0.014 82);
  --muted: oklch(0.7 0.02 72);
  --rule: oklch(0.86 0.03 78 / 14%);
  --primary: oklch(0.62 0.13 30);
  --on-primary: oklch(0.16 0.01 55);
  --accent: oklch(0.72 0.088 74);
  --gold: oklch(0.76 0.095 74);
  --again: oklch(0.7 0.14 25);
  --easy: oklch(0.74 0.09 150);
}

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

html { height: 100%; }

body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

[lang="de"] { font-family: var(--de); }

::selection { background: color-mix(in oklab, var(--accent) 45%, transparent); color: var(--ink); }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 2px; }

.label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 500;
}

/* ---------- shell ---------- */

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 1.25rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.brand { display: flex; text-decoration: none; }
.mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 2px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.875rem;
  line-height: 1;
}
.top h1 {
  font-family: var(--fraktur);
  font-weight: 400;
  font-size: 1.9rem;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}
.top p {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  text-align: right;
}

main { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 36rem; margin: 0 auto; padding: 1.25rem 1.25rem 1.5rem; min-height: 100%; display: flex; flex-direction: column; }

body > nav {
  flex: none;
  display: flex;
  border-top: 1px solid var(--rule);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body > nav a {
  flex: 1;
  padding: 0.95rem 0.5rem 0.9rem;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  border-top: 2px solid transparent;
  margin-top: -1px;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 500;
}
body > nav a[aria-current="page"] { color: var(--primary); border-top-color: var(--primary); }

/* ---------- dictionary-entry card ---------- */

.entry {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.4rem 1.35rem 1.5rem;
}
.head { font-family: var(--de); font-size: 2.1rem; line-height: 1.15; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.star { color: var(--gold); font-weight: 400; }
.head .star { font-size: 1.1rem; vertical-align: super; margin-left: 0.3rem; }
.ctx { margin: 1.1rem 0 0; padding-left: 0.9rem; border-left: 2px solid var(--accent); font-style: italic; font-size: 1.1rem; }
.ctx cite { display: block; font-style: normal; color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.answer { margin-top: 1.3rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.mean { font-size: 1.45rem; line-height: 1.3; margin: 0; color: var(--primary); }
.info { margin: 0.5rem 0 0; font-style: italic; color: var(--muted); }
.nz { margin: 0.9rem 0 0; }
.nz b { color: var(--gold); font-weight: 500; }
.linegloss { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.95rem; }
.linegloss .label { display: block; font-size: 0.65rem; margin-bottom: 0.1rem; }
.tools.hear { margin: 1rem 0 0; }

.count { margin: 0 0 0.8rem; color: var(--muted); }
.count.label { font-size: 0.68rem; }
.actions { margin-top: auto; padding-top: 1.25rem; display: flex; gap: 0.6rem; }
.btn {
  flex: 1;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.5rem;
  text-align: center;
  line-height: 1.25;
  min-height: 3.25rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
}
.btn small { display: block; color: var(--muted); font-family: var(--serif); font-size: 0.85rem; font-style: italic; font-weight: 400; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.again { border-color: var(--again); color: var(--again); }
.btn.easy { border-color: var(--easy); color: var(--easy); }
.btn.again small, .btn.easy small { color: inherit; opacity: 0.85; }
.link { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.link.danger { color: var(--again); }
.link.quiet { color: var(--muted); text-decoration-style: dotted; }

.state { margin: auto 0; padding: 2rem 0; }
.state h2 { font-size: 1.75rem; line-height: 1.2; font-weight: 500; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.state p { margin: 0.4rem 0; color: var(--muted); }
.state .label { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1.4rem; }

.note { margin: 0 0 1rem; padding: 0.6rem 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius); font-size: 0.95rem; background: var(--surface); }
.note.warn { border-color: var(--again); color: var(--again); }

/* ---------- poems ---------- */

.intro { margin: 0 0 0.75rem; color: var(--muted); }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { border-bottom: 1px solid var(--rule); }
.plist a { display: flex; gap: 0.9rem; padding: 0.95rem 0; text-decoration: none; }
.plist .num { flex: none; width: 1.4rem; padding-top: 0.45rem; color: var(--primary); }
.plist .pbody { display: block; min-width: 0; }
.plist .first { font-size: 1.2rem; font-style: italic; display: block; }
.plist .src { color: var(--muted); font-size: 0.9rem; display: block; }
.ten { display: block; color: var(--primary); font-size: 0.95rem; margin: 0; }

.poem .back { display: inline-block; }
.poemnav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.stepper { display: flex; align-items: center; gap: 0.25rem; }
.stepper .pos { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 0 0.35rem; }
.stepper .step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  text-decoration: none;
  color: var(--primary);
  font-size: 1.35rem;
  line-height: 1;
  padding-bottom: 0.15rem;
}
.stepper .step.off { color: var(--rule); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  min-width: 0;
}
.pager .next { grid-column: 2; text-align: right; }
.pager .label { color: var(--primary); font-size: 0.65rem; }
.pager .prev .label::before { content: "‹ "; }
.pager .next .label::after { content: " ›"; }
.pager .ptitle { font-style: italic; line-height: 1.3; overflow-wrap: anywhere; }
.pager .pten { color: var(--muted); font-size: 0.85rem; line-height: 1.3; }
.poem h2 { font-family: var(--de); font-size: 1.4rem; line-height: 1.3; margin: 0.8rem 0 0.15rem; font-style: italic; font-weight: 400; }
.poem .ten { margin: 0 0 0.35rem; }
.poem .src { color: var(--muted); margin: 0 0 1rem; font-size: 0.95rem; }
.poem .src [lang="de"] { display: block; }
.srcen { display: block; font-style: italic; }
.tools { display: flex; gap: 0.6rem 1.2rem; flex-wrap: wrap; margin: 0 0 1rem; }
.lines { margin: 0; padding: 0; list-style: none; }
.lines li { margin: 0; }
.lines li.br { margin-top: 1rem; }
.lines button { display: block; width: 100%; padding: 0.22rem 0; font-size: 1.15rem; line-height: 1.45; }
.lines li.audible { display: grid; grid-template-columns: 1fr auto; align-items: start; column-gap: 0.4rem; }
.lines .lineplay {
  width: 2.25rem;
  height: 2.25rem;
  margin-top: 0.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
}
.lines .lineplay svg { width: 0.85rem; height: 0.85rem; fill: currentColor; }
.lines .lineplay.on { color: var(--on-primary); background: var(--primary); }
.lines li.reading > button:first-child [lang="de"] { color: var(--primary); }
.lines .en {
  display: block;
  color: var(--primary);
  font-family: var(--serif);
  font-size: 0.95rem;
  padding: 0 0 0.35rem 0.9rem;
  border-left: 2px solid var(--accent);
  margin: 0.1rem 0 0.3rem;
}
.notes { margin-top: 2rem; border-top: 1px solid var(--rule); padding-top: 1.1rem; }
.notes > .label { color: var(--primary); margin: 0; }
.notes h3 { font-size: 1.1rem; font-weight: 600; margin: 1rem 0 0.2rem; }
.notes p { margin: 0; }

/* ---------- words ---------- */

.words h2 { font-size: 1rem; font-weight: 400; font-style: italic; margin: 1.6rem 0 0.2rem; }
.words h2 .ten { font-style: normal; font-size: 0.9rem; }
.wlist { list-style: none; margin: 0; padding: 0; }
.wlist li { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.8rem; padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.wlist .de { font-weight: 700; overflow-wrap: anywhere; }
.wlist .de .star { margin-left: 0.25rem; }
.wlist .en { grid-column: 1; color: var(--muted); }
.wlist .st { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: italic; font-size: 0.9rem; color: var(--muted); }
.wlist .st.known { color: var(--easy); }
.wlist .st.learning { color: var(--primary); }

.foot { margin-top: 2.2rem; color: var(--muted); font-size: 0.95rem; }
.foot p { margin: 0.3rem 0; }
.foot h3 { color: var(--primary); margin: 1.8rem 0 0.4rem; }
.foot .tools { margin-top: 0.7rem; }
.backup-note { color: var(--ink); }
.confirm { margin-top: 0.8rem; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.confirm .actions { padding-top: 0.9rem; }

@media (min-width: 40rem) {
  .top { padding-left: 2rem; padding-right: 2rem; }
  .wrap { padding-top: 2rem; }
  .head { font-size: 2.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .answer { animation: rise 0.18s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
