/* Fonty (SIL OFL) – viz složka fonts/ a README.md.
   Psací písmo lze později vyměnit za školní (Comenia Script apod.) změnou jedné řádky níže. */
@font-face {
  font-family: "Andika";
  src: url("fonts/Andika-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Andika";
  src: url("fonts/Andika-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
/* Psací písmo: Playwrite CZ doplněný o napojovací tahy u samostatných/úvodních písmen i, í a samostatného b
   (původní font je nemá). Vyrobeno skriptem scripts/make_plus_font.py ze souboru fonts/PlaywriteCZ.ttf; licence OFL. */
@font-face {
  font-family: "Playwrite CZ";
  src: url("fonts/PlaywriteCZ-plus.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --font-ui: "Andika", system-ui, sans-serif;
  --font-print: "Andika", system-ui, sans-serif;
  --font-script: "Playwrite CZ", "Andika", cursive;

  --bg: #fff4f8;
  --card: #ffffff;
  --ink: #3a2230;
  --muted: #7d5f70;
  --line: #f1cfdd;
  --accent: #d6337f;
  --accent-ink: #ffffff;
  --vowel: #efe3ff;
  --good: #2e9e5b;
  --good-bg: #d9f3e3;
  --bad: #d64545;
  --bad-bg: #fbdcdc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2a1822;
    --card: #3a2330;
    --ink: #fbeef4;
    --muted: #c9a5b8;
    --line: #5c3a4c;
    --accent: #ff78b0;
    --accent-ink: #2a0f1b;
    --vowel: #54406e;
    --good: #5fd08c;
    --good-bg: #1f4030;
    --bad: #ff7a7a;
    --bad-bg: #4a2626;
  }
}

/* Palety podle <html data-mode data-color> (nastavuje theme.js; bez něj platí růžová a režim podle zařízení) */
:root[data-mode="light"] { --bg: #fff4f8; --card: #ffffff; --ink: #3a2230; --muted: #7d5f70; --line: #f1cfdd; --accent: #d6337f; --accent-ink: #ffffff; --vowel: #efe3ff; --good: #2e9e5b; --good-bg: #d9f3e3; --bad: #d64545; --bad-bg: #fbdcdc; }
:root[data-mode="dark"] { --bg: #2a1822; --card: #3a2330; --ink: #fbeef4; --muted: #c9a5b8; --line: #5c3a4c; --accent: #ff78b0; --accent-ink: #2a0f1b; --vowel: #54406e; --good: #5fd08c; --good-bg: #1f4030; --bad: #ff7a7a; --bad-bg: #4a2626; }
:root[data-color="blue"][data-mode="light"] { --bg: #f1f7ff; --card: #ffffff; --ink: #1f2d4a; --muted: #5f6f93; --line: #d3e1f7; --accent: #3b6fd4; --accent-ink: #ffffff; --vowel: #e2ecff; }
:root[data-color="blue"][data-mode="dark"] { --bg: #141a2e; --card: #1f2845; --ink: #edf2ff; --muted: #a9b6da; --line: #34406a; --accent: #6c9bf0; --accent-ink: #0d1428; --vowel: #2b3a66; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.4;
}
/* Appbar */
.appbar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 2px solid var(--line); }
.appbar nav { max-width: 640px; margin: 0 auto; padding: 4px 16px; display: flex; align-items: center; gap: 4px; min-height: 56px; position: relative; }
.appbar a { color: var(--ink); text-decoration: none; padding: 8px 14px; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center; }
.appbar a:hover { background: var(--bg); }
.appbar a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.appbar a[aria-current="page"]:not(.appbar-brand) { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.appbar-brand { font-weight: 700; font-size: 1.15rem; margin-right: auto; }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { margin: 8px 0 4px; text-align: center; font-size: 2rem; }
.hint { color: var(--muted); text-align: center; margin: 4px 0 16px; }
.center { text-align: center; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.chip {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 48px;
  font-size: 1.05rem;
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.presets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }

/* Velká tlačítka s písmeny */
.letters {
  display: grid;
  grid-template-columns: repeat(14, 1fr);      /* 42 písmen = 3 řádky po 14 */
  gap: 6px;
  margin-bottom: 20px;
}
@media (max-width: 640px) { .letters { grid-template-columns: repeat(7, 1fr); } }
.letter {
  aspect-ratio: 1;
  font-family: var(--font-print);
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 10px;
  transition: transform .08s;
}
.letter.vowel { background: var(--vowel); }
.letter:active { transform: scale(.94); }
.letter[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.options { display: grid; gap: 10px; margin-bottom: 12px; }
.opt-group { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.opt-label { width: 130px; color: var(--muted); }

.big {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  padding: 16px;
  font-size: 1.3rem;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--card);
}
.big.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.big:disabled { opacity: .5; cursor: not-allowed; }

.msg { text-align: center; min-height: 1.4em; margin: 8px 0 0; color: var(--muted); }
.msg.warn { color: var(--bad); }

/* Cvičení */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.score { display: flex; gap: 16px; align-items: baseline; }
.points strong { font-size: 1.5rem; }
.link { background: none; border: none; padding: 8px 0; color: var(--muted); font-size: 1rem; }

.speak {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%;
  padding: 24px;
  margin: 12px 0 0;
  font-size: 4rem;
  background: var(--card);
  border: 3px dashed var(--line);
  border-radius: 24px;
}
.speak span { font-size: 1rem; color: var(--muted); }
.speak.speaking { border-color: var(--accent); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.choice {
  min-height: 120px;
  font-size: 3.6rem;
  line-height: 1.1;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 20px;
  transition: transform .08s;
}
.choice.print { font-family: var(--font-print); }
.choice.script { font-family: var(--font-script); }
.choice:active:not(:disabled) { transform: scale(.96); }
.choice:disabled { cursor: default; }
.choice.good { background: var(--good-bg); border-color: var(--good); }
.choice.bad { background: var(--bad-bg); border-color: var(--bad); animation: shake .35s; }
.choice.dim { opacity: .45; }

.feedback { text-align: center; font-size: 1.4rem; min-height: 2em; margin: 12px 0 0; font-weight: 700; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.footer-link { text-align: center; margin-top: 24px; }
.footer-link a { color: var(--muted); }

.big-score { text-align: center; font-size: 3rem; margin: 12px 0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
@media (prefers-reduced-motion: reduce) {
  .choice.bad { animation: none; }
  .letter, .choice { transition: none; }
}
@media (max-width: 380px) {
  .choice { font-size: 3rem; min-height: 100px; }
}

/* Dlaždice cvičení na úvodní stránce a tlačítka-odkazy */
.section-title { font-size: 1.15rem; margin: 28px 0 10px; text-align: left; }
.cards { display: grid; gap: 12px; }
.card-link { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--card); border: 3px solid var(--line); border-radius: 18px; color: var(--ink); text-decoration: none; min-height: 84px; }
.card-link:hover { border-color: var(--accent); }
.card-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-link .card-ico { font-size: 2.2rem; }
.card-link strong { display: block; font-size: 1.2rem; }
.card-link small { display: block; color: var(--muted); font-size: .95rem; margin-top: 2px; }
a.link-btn { text-decoration: none; text-align: center; color: inherit; }
a.link-btn.primary { color: var(--accent-ink); }

/* Značky pro barvoslepé: správná odpověď ✓, chybná ✗ (nespoléhá jen na zelenou a červenou) – cvičení, souboj, test písmen */
.choice, .opt { position: relative; }
.choice.good::after, .opt.good::after, .opt.hatch::after,
.choice.bad::after, .opt.bad::after {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 1.7rem/1 system-ui, sans-serif;
  background: var(--card);
  border: 3px solid currentColor;
  border-radius: 50%;
}
.choice.good::after, .opt.good::after, .opt.hatch::after { content: "✓"; color: var(--good); }
.choice.bad::after, .opt.bad::after { content: "✗"; color: var(--bad); }

/* Hvězdičky v liště (odkaz do světa) */
.appbar a.stars-pill { font-weight: 700; margin-left: 4px; background: var(--vowel); }
.appbar a.stars-pill[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.stars-pill.bump { animation: stars-bump .55s ease-out; }
@keyframes stars-bump { 0% { transform: scale(1); } 35% { transform: scale(1.22); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .stars-pill.bump { animation: none; } }

/* hamburger a rozbalovací nabídka */
.menu-btn { width: 48px; height: 44px; font-size: 1.6rem; line-height: 1; color: var(--ink); background: none; border: 0; border-radius: 12px; cursor: pointer; }
.menu-btn:hover { background: var(--bg); }
.menu-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.menu { position: absolute; right: 12px; top: calc(100% + 4px); z-index: 20; min-width: 220px; padding: 8px; display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.menu[hidden] { display: none; }
.menu a { border-radius: 12px; padding: 10px 14px; gap: 10px; font-size: 1.05rem; }
.menu-ico { width: 1.6em; text-align: center; }
.menu a.stars-pill { margin: 0 0 4px; justify-content: center; }

/* úvodní stránka: Hra velkým tlačítkem, ostatní menší */
.cards.home { grid-template-columns: repeat(2, 1fr); }
.cards.home .card-link { min-height: 64px; padding: 10px 14px; gap: 10px; border-radius: 16px; }
.cards.home .card-link .card-ico { font-size: 1.6rem; }
.cards.home .card-link strong { font-size: 1.05rem; }
.cards.home .card-link.big-card { grid-column: 1 / -1; min-height: 130px; padding: 18px; gap: 18px; justify-content: center; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cards.home .card-link.big-card .card-ico { font-size: 3.4rem; }
.cards.home .card-link.big-card strong { font-size: 2rem; }

/* lišta: zpět, předměty s nabídkou, hra */
.appbar nav { gap: 2px; }
.appbar .back-btn { width: 44px; height: 44px; font-size: 1.5rem; line-height: 1; color: var(--ink); background: none; border: 0; border-radius: 999px; cursor: pointer; flex: none; }
.appbar .back-btn:hover { background: var(--bg); }
.appbar .back-btn:focus-visible, .nav-grp:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.appbar-brand { padding: 8px 8px !important; }
.nav-grp { font: inherit; font-weight: 700; color: var(--ink); background: none; border: 0; border-radius: 999px; padding: 8px 12px; min-height: 44px; cursor: pointer; }
.nav-grp:hover { background: var(--bg); }
.nav-grp[aria-current], .nav-grp[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
.appbar a.nav-hra { font-weight: 700; padding: 8px 12px; }
.appbar a.stars-pill { padding: 8px 10px; }
@media (max-width: 480px) { .brand-text { display: none; } .appbar nav { padding: 4px 8px; } }

/* přepínač vzhledu v liště */
.nav-theme { padding: 8px 10px; font-size: 1.15rem; }
.th-row { display: flex; gap: 6px; margin: 2px 0 6px; }
.th-opt { flex: 1; font: inherit; font-weight: 700; color: var(--ink); background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 8px 10px; min-height: 40px; white-space: nowrap; }
.th-opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#nav-theme { min-width: 250px; }

.site-foot { text-align: center; padding: 8px 16px 28px; }
.site-foot a { color: var(--muted); }
.cards.home .card-link.big-card { min-height: 110px; }

/* úvod: velké neutrální dlaždice předmětů (barevná výplň je vyhrazená pro „vybráno“) */
.cards.home .card-link.subj { grid-column: 1 / -1; min-height: 110px; padding: 18px; gap: 18px; justify-content: center; }
.cards.home .card-link.subj .card-ico { font-size: 3rem; }
.cards.home .card-link.subj strong { font-size: 1.8rem; }

/* O aplikaci úplně dole na obrazovce */
body.has-foot { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.has-foot > main { flex: 1 0 auto; width: 100%; }
body.has-foot > .appbar, body.has-foot > .site-foot { flex: none; }
.site-foot { margin-top: auto; }
body.has-foot > .battle-screen { flex: 1 0 auto; width: 100%; }

/* zjednodušená horní lišta samostatných stránek */
.appbar { padding-top: env(safe-area-inset-top); }
.appbar-title { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .stars-pill { margin-left: 0; }

.letter { min-width: 0; padding: 0; }
#view { overflow-x: hidden; }
