/* Mobile-first Leseseite: ruhiger Satz, MathML und SVGs ohne Zoom. */
.lese-leiste .leiste-inner { gap: 10px; }
.lese-schrift { display: inline-flex; gap: 2px; margin-left: 4px; }
.lese-schrift button {
  min-width: 44px; min-height: 44px; padding: 3px 7px; border: 1px solid var(--linie);
  border-radius: 6px; background: var(--karte); color: var(--fg); cursor: pointer;
  font: inherit; font-size: .78rem; line-height: 1;
}
.lese-schrift button:hover { border-color: var(--akzent); color: var(--akzent); }

.lese-fortschritt {
  position: sticky; top: 0; z-index: 19; height: 3px; background: transparent;
}
.lese-fortschritt span {
  display: block; height: 100%; width: 0; background: var(--akzent);
  transition: width .08s linear;
}

.leser { max-width: 790px; margin: 0 auto; padding-top: 22px; }
.lese-zurueck { margin: 0 0 12px; font-size: .85rem; }
.lese-zurueck a { color: var(--grau); text-decoration: none; }
.lese-zurueck a:hover { color: var(--akzent); }

.lese-text {
  font-family: "Libertinus Serif", "Source Serif 4", "Noto Serif", Georgia, serif;
  font-size: calc(1.08rem * var(--lese-scale, 1));
  line-height: 1.72; overflow-wrap: break-word; hyphens: auto;
}
@media (min-width: 700px) {
  .lese-text { font-size: calc(1.16rem * var(--lese-scale, 1)); line-height: 1.7; }
}
.lese-text > p { margin: 0 0 .85em; }
.lese-text > p:first-of-type {
  margin-bottom: .25em; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .72em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--grau);
}
.lese-text > p:nth-of-type(2) {
  margin: 0 0 .3em; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(1.65rem, 6vw, 2.15rem); font-weight: 750; line-height: 1.12;
  letter-spacing: -.025em; color: var(--akzent);
}
.lese-text > p:nth-of-type(3) {
  margin: 0 0 1.1em; font-size: 1.02em; line-height: 1.45; color: var(--grau);
}
.lese-text > div:nth-of-type(1) {
  margin: 1em 0 1.3em; padding: 12px 14px; border-left: 3px solid var(--akzent);
  background: var(--merk); border-radius: 0 8px 8px 0; font-size: .92em; line-height: 1.5;
}
.lese-text > div:nth-of-type(2) {
  margin: 0 0 1.4em; font-size: .74em; line-height: 1.45; color: var(--grau);
}

.lese-text h2 {
  margin: 2.2em 0 .55em; padding-top: .55em;
  border-top: 1px solid var(--linie);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(1.35rem, 4.5vw, 1.7rem); line-height: 1.2; letter-spacing: -.015em;
  color: var(--fg);
}
.lese-text h2:first-of-type { margin-top: 1.4em; }
.lese-text h3 {
  margin: 1.8em 0 .45em; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.12em; line-height: 1.3;
}
.lese-text strong { font-weight: 700; }
.lese-text a { color: var(--akzent); text-underline-offset: .14em; }
.lese-text ul, .lese-text ol { padding-left: 1.25em; margin: .4em 0 1em; }
.lese-text li { margin: .18em 0; }

.lese-text { overflow-x: clip; }
.lese-text math { font-size: 1.08em; max-width: 100%; }
.lese-text p:has(> math) { overflow-x: auto; overflow-y: hidden; }
.lese-text math[display="block"] {
  display: block; overflow-x: auto; overflow-y: hidden;
  margin: .75em 0; padding: .2em 0 .3em;
}
.lese-text table {
  display: block; width: 100%; max-width: 100%; overflow-x: auto; margin: 1em 0;
  border-collapse: collapse; table-layout: fixed; font-size: .84em; line-height: 1.4;
}
.lese-text th, .lese-text td {
  padding: 5px 8px; border: 1px solid var(--linie); text-align: left; vertical-align: top;
  overflow-wrap: anywhere;
}
.lese-text th { background: var(--merk); font-weight: 700; }
.lese-text figure { margin: 1.5em 0; }
.lese-text figure img {
  display: block; width: 100%; height: auto; margin: 0 auto;
  background: #fff; border-radius: 6px; padding: 4px;
}
.lese-text figcaption {
  margin-top: .55em; font-size: .78em; line-height: 1.45; color: var(--grau);
}
.lese-text figure img { cursor: zoom-in; }
.lese-text figure img:focus-visible {
  outline: 3px solid var(--akzent); outline-offset: 3px;
}
.lese-text h2 { scroll-margin-top: 74px; }
.lese-text mark.suchtreffer {
  background: #ffe08a; color: inherit; padding: 0 .08em; border-radius: 2px;
}
[data-theme="dark"] .lese-text mark.suchtreffer {
  background: #8a6a12; color: #fff;
}
@media (prefers-reduced-motion: no-preference) {
  .lese-text mark.suchtreffer { animation: treffer-puls 1.1s ease-out 1; }
  @keyframes treffer-puls {
    0% { box-shadow: 0 0 0 0 rgb(255 176 0 / .55); }
    100% { box-shadow: 0 0 0 7px rgb(255 176 0 / 0); }
  }
}
.lese-inhalt a.aktiv {
  color: var(--fg); font-weight: 700;
  background: var(--merk); border-radius: 4px; padding: 0 .25em;
}
.lese-oben {
  position: fixed; right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--linie); background: var(--karte); color: var(--akzent);
  font-size: 1.05rem; cursor: pointer; box-shadow: 0 2px 10px rgb(0 0 0 / .16);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .18s, transform .18s, border-color .18s;
  z-index: 30;
}
.lese-oben.sichtbar { opacity: 1; pointer-events: auto; transform: none; }
.lese-oben:hover { border-color: var(--akzent); }
.bild-dialog {
  max-width: min(1100px, calc(100vw - 16px));
  max-height: calc(100vh - 16px); padding: 0; border: 0; border-radius: 12px;
  background: var(--karte); color: var(--fg); overflow: auto;
}
.bild-dialog::backdrop { background: rgb(0 0 0 / .78); }
.bild-dialog img {
  display: block; max-width: min(1080px, calc(100vw - 40px));
  max-height: 82vh; width: auto; height: auto; margin: 36px auto 8px;
  background: #fff; border-radius: 8px; padding: 6px;
}
.bild-dialog p {
  margin: 0; padding: 8px 16px 14px; color: var(--grau);
  font-size: .82rem; line-height: 1.45;
}
.bild-schliessen {
  position: sticky; top: 6px; float: right; margin: 6px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--linie); background: var(--karte); color: var(--fg);
  font-size: 1.3rem; line-height: 1; cursor: pointer; z-index: 2;
}
.bild-schliessen:hover { border-color: var(--akzent); color: var(--akzent); }
@media (prefers-reduced-motion: reduce) {
  .lese-oben { transition: none; }
}

/* Typst gibt Inhaltsverzeichnis und Kästen ohne Klassen aus. */
.lese-inhalt {
  margin: 1.2em 0 1.5em; border: 1px solid var(--linie); border-radius: 10px;
  padding: .65em .9em; background: var(--karte);
}
.lese-inhalt summary {
  cursor: pointer; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .9rem; font-weight: 700; color: var(--akzent);
}
.lese-inhalt nav[role="doc-toc"] { margin-top: .55em; }
.lese-inhalt ol {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .1em 1.4em; margin: .2em 0 0; padding-left: 0; list-style: none;
}
.lese-inhalt li { margin: .14em 0; min-width: 0; }
@media (max-width: 640px) {
  .lese-inhalt ol { grid-template-columns: minmax(0, 1fr); max-height: 13rem; overflow-y: auto; }
}

.callout {
  margin: 1.1em 0; padding: .8em 1em; border: 1px solid var(--linie);
  border-left: 3px solid var(--grau); border-radius: 0 8px 8px 0; background: var(--merk);
}
.callout > p:first-child { margin-top: 0; }
.callout > p:last-child { margin-bottom: 0; }
.callout p:first-child, .callout > p:first-child strong {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .82em; letter-spacing: .04em; text-transform: uppercase; color: var(--akzent);
}
.callout-definition { border-left-color: #6b8e23; }
.callout-merksatz { border-left-color: #b8860b; }
.callout-achtung { border-left-color: #b22222; }
.callout-herleitung { border-left-color: #1f6f8b; }
.callout-experiment { border-left-color: #6a5acd; }
.callout-aufgabe { border-left-color: #1f3864; }
.callout-losung { border-left-color: #2e7d32; }

.lese-fuss {
  margin: 2.6em 0 0; padding-top: 1.2em; border-top: 1px solid var(--linie);
  font-size: .82rem; color: var(--grau);
}
.lese-fuss p { margin: 0 0 .7em; }
.lese-fuss a { color: var(--akzent); }

/* Auf schmalen Geräten bleibt die Kopfzeile flach und ohne Suchfeld. */
@media (max-width: 520px) {
  .leser { padding: 16px env(safe-area-inset-right) 56px env(safe-area-inset-left); }
  .lese-leiste .leiste-inner { padding-top: 7px; padding-bottom: 7px; flex-wrap: wrap; }
  .lese-leiste .marke { font-size: .78rem; }
  .lese-leiste .seiten-nav { gap: 6px; flex-wrap: wrap; }
  .lese-leiste .seiten-nav a { font-size: .74rem; }
  .lese-schrift { margin-left: 0; }
  .lese-text > p:nth-of-type(2) { font-size: 1.75rem; }
  .lese-text h2 { margin-top: 1.8em; }
  .lese-text table { font-size: .78em; }
}

@media print {
  .leiste, .lese-fortschritt, .lese-zurueck, .lese-fuss,
  .lese-oben, .bild-dialog, .lese-inhalt { display: none !important; }
  .leser { max-width: none; padding: 0; }
  .lese-text { font-size: 11pt; }
  .lese-text figure img { background: #fff; }
}

/* Bezug zum Kerncurriculum */
.kerncurriculum {
  margin: 0 0 1.1em;
  padding: 8px 11px;
  border-left: 3px solid var(--akzent);
  background: var(--merk);
  color: var(--fg);
  font-size: .86em;
  line-height: 1.45;
}
