/* ==========================================================================
   styles.css – Chemie Klasse 7 Lern-App (kinderfest, iPad + Handy)
   ========================================================================== */
:root {
  --bg: #eaf4ff;
  --card: #ffffff;
  --ink: #17324d;
  --muted: #5b7186;
  --accent: #0284c7;
  --accent-dark: #075985;
  --good: #15803d;
  --good-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --radius: 20px;
  --shadow: 0 4px 14px rgba(2, 60, 110, .14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 18px; } /* Basis mindestens 18px */

body {
  margin: 0;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #d6ecff 0%, var(--bg) 45%);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden; /* kein horizontales Scrollen */
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 14px 48px;
}

.loading { text-align: center; padding: 3rem 1rem; font-size: 1.2rem; color: var(--muted); }

h1 { font-size: 1.55rem; margin: 10px 0 4px; }
h2 { font-size: 1.25rem; margin: 0 0 8px; }
h3 { font-size: 1.15rem; margin: 0 0 8px; color: var(--accent-dark); }
p { line-height: 1.55; }

.subtitle { color: var(--muted); margin: 0 0 16px; font-size: 1.05rem; }

/* ---------- Breadcrumbs ---------- */
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 1rem; font-weight: 600; margin: 6px 0 10px;
}
.crumbs a {
  color: var(--accent-dark); text-decoration: none;
  background: #fff; padding: 8px 14px; border-radius: 999px;
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
}
.crumbs a:active { transform: scale(.96); }
.crumbs .cur { color: var(--muted); padding: 8px 6px; }

/* ---------- Zurück-Button (mind. 48x48px) ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.back-btn {
  min-width: 48px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800;
  background: #fff; color: var(--ink);
  border: none; border-radius: 16px;
  box-shadow: 0 3px 0 rgba(0,0,0,.12);
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease;
}
.back-btn:active { transform: scale(.94); }

/* ---------- Startseite: Suche ---------- */
.search-wrap { position: sticky; top: 8px; z-index: 10; margin: 4px 0 16px; }
#search {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.15rem;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  outline: none;
}
#search:focus { border-color: var(--accent-dark); }
#search::placeholder { color: #94a3b8; }

/* ---------- Jahrgangs-Gruppen ---------- */
.grade-head {
  font-size: 1.3rem;
  margin: 22px 4px 10px;
  color: var(--accent-dark);
}
.grade-group:first-of-type .grade-head { margin-top: 4px; }

/* ---------- Themen-Kacheln ---------- */
.tiles {
  display: grid;
  grid-template-columns: 1fr;          /* Handy: 1 Spalte */
  gap: 14px;
}
@media (min-width: 640px) {
  .tiles { grid-template-columns: 1fr 1fr; } /* iPad: 2 Spalten */
}

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 120px;                   /* große Touch-Fläche */
  padding: 18px 18px 16px;
  background: var(--card);
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none; text-align: left;
  cursor: pointer;
  transition: transform .08s ease;
}
.tile:active { transform: scale(.97); }
.tile .ticon { width: 54px; height: 54px; color: var(--accent); margin-bottom: 4px; }
.tile .ticon svg { width: 100%; height: 100%; }
.tile h2 { margin: 0; font-size: 1.2rem; line-height: 1.25; padding-right: 52px; }
.tile .sub { margin: 0; color: var(--muted); font-size: .98rem; line-height: 1.35; }
.tile .ver {
  position: absolute; top: 10px; right: 12px;
  font-size: .72rem; font-weight: 700; color: var(--muted);
  background: #eef4fa; padding: 3px 9px; border-radius: 999px;
}
.tile .tstars { margin-top: 6px; font-size: 1rem; letter-spacing: 2px; }
.tile .tstars .off { color: #cbd5e1; }

.no-results {
  background: #fff; border-radius: var(--radius);
  padding: 24px; text-align: center; color: var(--muted);
  font-size: 1.1rem; box-shadow: var(--shadow);
}

/* ---------- Karten & Abschnitte ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.card .illu { width: 100%; max-width: 340px; display: block; margin: 0 auto 10px; }
.card .illu svg { width: 100%; height: auto; }
.card .illu-img {
  display: block; margin: 0 auto 6px;
  max-width: 100%; max-height: 240px; width: auto;
  border-radius: 14px; background: #fff;
  border: 2px solid #e2e8f0;
}
.card .credit { font-size: .78rem; color: var(--muted); text-align: center; margin: 2px 0 6px; }
.card p { margin: 8px 0; font-size: 1.08rem; }
.card b { color: var(--accent-dark); }

/* ---------- Fortschrittsbalken ---------- */
.progress {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border-radius: 999px;
  padding: 10px 16px; margin: 10px 0 4px;
  box-shadow: var(--shadow);
  font-weight: 800; font-size: 1.05rem;
}
.dots { display: flex; gap: 7px; }
.dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; font-size: .95rem; font-weight: 800;
  background: #cbd5e1; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
button.dot { cursor: pointer; }
button.dot:active { transform: scale(.9); }
.dot.done { background: var(--good); color: #fff; }
.dot.current { background: var(--accent); color: #fff; outline: 3px solid #bae6fd; }
.dot.locked { opacity: .45; cursor: not-allowed; }

/* ---------- Fragen ---------- */
.qblock { margin-top: 6px; }
.qtext { font-size: 1.2rem; font-weight: 800; line-height: 1.4; margin: 6px 0 12px; }

.opt {
  display: block; width: 100%;
  min-height: 56px;
  padding: 14px 18px; margin: 10px 0;
  font-size: 1.12rem; font-weight: 700; text-align: left;
  color: var(--ink);
  background: #e0f2fe;
  border: 3px solid transparent; border-radius: 16px;
  cursor: pointer;
  transition: transform .08s ease, background .12s;
}
.opt:active { transform: scale(.97); }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); animation: shake .3s; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.feedback { min-height: 1.6em; font-size: 1.1rem; font-weight: 700; margin: 8px 2px; }
.fb-good { color: var(--good); }
.fb-bad { color: var(--bad); }

.hint-btn {
  display: inline-block;
  min-height: 48px;
  padding: 10px 18px; margin: 6px 0;
  font-size: 1.02rem; font-weight: 700;
  color: var(--warn); background: var(--warn-bg);
  border: none; border-radius: 14px;
  cursor: pointer;
  transition: transform .08s ease;
}
.hint-btn:active { transform: scale(.96); }
.hints { margin: 6px 0; }
.hint {
  background: var(--warn-bg);
  border-left: 6px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 14px; margin: 8px 0;
  font-size: 1.02rem; line-height: 1.45;
}

.next-btn, .big-cta {
  display: block; width: 100%;
  min-height: 60px;
  padding: 16px; margin-top: 12px;
  font-size: 1.2rem; font-weight: 800; text-align: center;
  color: #fff; background: var(--accent);
  border: none; border-radius: 18px;
  box-shadow: 0 5px 0 rgba(0,0,0,.15);
  cursor: pointer; text-decoration: none;
  transition: transform .08s ease;
}
.next-btn:active, .big-cta:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.big-cta.secondary { background: #fff; color: var(--accent-dark); box-shadow: var(--shadow); }

.hidden { display: none !important; }

/* ---------- Themen-Übersicht ---------- */
.sec-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px; margin: 10px 0;
  background: var(--card); border: none; border-radius: 18px;
  box-shadow: var(--shadow);
  font-size: 1.1rem; font-weight: 700; color: var(--ink);
  text-decoration: none; text-align: left;
  cursor: pointer;
  transition: transform .08s ease;
}
.sec-row:active { transform: scale(.98); }
.sec-row .num {
  flex: 0 0 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e0f2fe; color: var(--accent-dark); font-weight: 800;
}
.sec-row.done .num { background: var(--good-bg); color: var(--good); }
.sec-row.locked { opacity: .55; cursor: not-allowed; }
.sec-row .st { margin-left: auto; font-size: 1.3rem; }

.topic-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topic-head .ticon { width: 60px; height: 60px; color: var(--accent); }
.topic-head .ticon svg { width: 100%; height: 100%; }
.ver-pill {
  font-size: .75rem; font-weight: 700; color: var(--muted);
  background: #eef4fa; padding: 3px 10px; border-radius: 999px;
}

/* ---------- Abschlussseite ---------- */
.finale { text-align: center; }
.finale .stars-big { font-size: 3.2rem; letter-spacing: 8px; margin: 12px 0; }
.finale .stars-big .off { color: #cbd5e1; }
.finale p { font-size: 1.15rem; }

/* ---------- Fußzeile ---------- */
.footer {
  margin-top: 28px; padding-top: 14px;
  border-top: 2px solid #dbeafe;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--muted); font-size: .9rem;
}
.reset-btn {
  min-height: 48px;
  padding: 10px 16px;
  font-size: .95rem; font-weight: 700;
  color: var(--bad); background: #fff;
  border: 2px solid #fecaca; border-radius: 12px;
  cursor: pointer;
}
.reset-btn:active { transform: scale(.96); }

/* ---------- Barrierefreiheit ---------- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 380px) {
  html { font-size: 17px; }
  h1 { font-size: 1.35rem; }
}

/* ---------- Mathe-spezifisch: Teil-Badges & Banner ---------- */
.badges { position: absolute; top: 10px; right: 12px; display: flex; gap: 6px; align-items: center; }
.badge {
  font-size: .72rem; font-weight: 800; padding: 3px 10px; border-radius: 999px;
}
.badge.b-no { background: #fee2e2; color: #b91c1c; }
.badge.b-yes { background: #dcfce7; color: #15803d; }
.badge.b-ek { background: #ede9fe; color: #6d28d9; }
.tile .ver { position: static; background: #eef4fa; color: var(--muted); font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }

.part-banner {
  border-radius: 16px; padding: 12px 16px; margin: 8px 0;
  font-size: 1.05rem; font-weight: 700; box-shadow: var(--shadow);
}
.part-banner.no-tr { background: #fee2e2; color: #b91c1c; }
.part-banner.with-tr { background: #dcfce7; color: #15803d; }

.dot.done.failed { background: var(--warn); }

/* ---------- KI-Haftungshinweis ---------- */
.disclaimer {
  background: #fffbeb; border: 2px solid #fcd34d; color: #92400e;
  border-radius: 16px; padding: 12px 16px; margin: 4px 0 14px;
  font-size: .95rem; font-weight: 600; line-height: 1.45;
}
.disclaimer-line { flex-basis: 100%; font-size: .8rem; }

/* ---------- SVG: nichts abschneiden (Text nicht verschluckt) ---------- */
.card .illu svg, .ticon svg { overflow: visible; }
.card .illu { margin-bottom: 16px; }
