/* ==========================================================================
   Übungsseite Accessibility Testing – Rahmen

   Diese Datei regelt Aufbau und Aussehen des Rahmens der Seite: Kopf, Fuß,
   Navigation, Erklärtexte, Auflösungen. Sie enthält keine Markenfarbe und
   keine Markenschrift – beides kommt aus dem Thema (themen/<name>/thema.css).

   Drei Dateien, drei Aufgaben:
     rahmen.css      Aufbau des Rahmens. Greift nur auf --thema-…-Werte zu.
     beispiele.css   Die Prüfobjekte. Feste Werte, vom Thema abgeschirmt.
     thema.css       Die Marke: Farben, Schrift, Form. Nur Werte, keine Regeln.

   Reihenfolge in dieser Datei:
     1  Vertrag mit dem Thema (alle --thema-…-Werte mit neutralem Standard)
     2  Arbeitswerte für den Rahmen
     3  Grundregeln für Elemente
     4  Bausteine des Rahmens

   Elementregeln stehen in :where(), damit jede Klasse eines Beispiels sie
   ohne Aufwand überschreiben kann.
   ========================================================================== */

/* ---------- 1 Vertrag mit dem Thema ----------
   Jeder Wert hier darf von einem Thema überschrieben werden. Was ein Thema
   weglässt, behält den Standard. Viele Standards leiten sich von anderen
   Werten ab: Wer nur Text, Fläche und Akzent setzt, bekommt ein stimmiges
   Thema. :where() hält die Spezifität bei null: Das Thema gewinnt, egal in
   welcher Reihenfolge die Dateien laden.
   Welche Kontraste ein Thema einhalten muss, steht in THEMEN.md. */

:where(:root) {
  /* Flächen und Text */
  --thema-seite: #edf0f3;              /* Hintergrund der Seite */
  --thema-flaeche: #ffffff;            /* Karten, Schaltflächen */
  --thema-text: #16233a;               /* Fließtext */
  --thema-text-leise: #3f4a5e;         /* Nebentext */
  --thema-linie: #5b6577;              /* Rahmenlinien */

  /* Hauptfarbe: Kartenkante, Beispiel-Etikett, Kante der Bühne, Text und Kante der Schaltflächen */
  --thema-primaer: var(--thema-text);
  --thema-auf-primaer: var(--thema-flaeche);   /* Text auf der Hauptfarbe */

  /* Akzent: Links und Auflösungen */
  --thema-akzent: #6a1b9a;
  --thema-akzent-flaeche: #f3e9f8;     /* Hintergrund der Auflösungen */

  /* Überschriften */
  --thema-titel: var(--thema-text);            /* h1 */
  --thema-ueberschrift: var(--thema-text);     /* h2, h3, Hauptpunkte der Navigation */
  --thema-trennlinie: var(--thema-primaer);    /* Linie unter h2 */

  /* Zustände und Hinweise */
  --thema-fokus: var(--thema-akzent);                    /* Fokusrahmen */
  --thema-hover-flaeche: var(--thema-akzent-flaeche);    /* Navigation und Schaltflächen bei Hover */
  --thema-code-flaeche: var(--thema-seite);              /* Hintergrund von Code im Fließtext */
  --thema-steuerung-flaeche: var(--thema-akzent-flaeche); /* Steuerleisten der Übungsseite neben den Beispielen */
  --thema-steuerung-linie: var(--thema-akzent);
  --thema-achtung-flaeche: #fff1c2;    /* Warnhinweise */
  --thema-achtung-linie: #8a5a00;

  /* Kopf */
  --thema-kopf-flaeche: var(--thema-primaer);
  --thema-kopf-text: var(--thema-auf-primaer);
  --thema-kopf-text-leise: var(--thema-kopf-text);
  --thema-kopf-fokus: var(--thema-kopf-text);
  --thema-kopf-schmuck: none;          /* Schmuckstreifen unter dem Kopf: ein CSS-Bild, etwa url("data:image/svg+xml,…") oder ein Verlauf */
  --thema-kopf-schmuck-hoehe: 0rem;    /* Höhe des Streifens; 0rem = kein Streifen */
  --thema-logo-breite: 11rem;

  /* Fuß */
  --thema-fuss-flaeche: var(--thema-kopf-flaeche);
  --thema-fuss-text: var(--thema-kopf-text);
  --thema-fuss-link: var(--thema-fuss-text);
  --thema-fuss-fokus: var(--thema-fuss-text);

  /* Schrift */
  --thema-schrift: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --thema-schrift-titel: var(--thema-schrift);
  --thema-schrift-code: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --thema-titel-gewicht: 700;

  /* Form */
  --thema-radius: 0;                   /* Karten */
  --thema-radius-klein: 0.3rem;        /* Schaltflächen, Kästen, Etiketten */
}

/* ---------- 2 Arbeitswerte für den Rahmen ----------
   Die Grundregeln für Elemente (Abschnitt 3) gelten für den Rahmen und für
   die Beispiele. Sie greifen deshalb nicht direkt auf das Thema zu, sondern
   auf diese Arbeitswerte. Im Rahmen zeigen sie auf das Thema; in den
   Beispielen setzt beispiele.css sie auf feste Werte zurück (.buehne). */

:root {
  color-scheme: light;
  --tinte: var(--thema-text);
  --tinte-leise: var(--thema-text-leise);
  --papier: var(--thema-flaeche);
  --werkbank: var(--thema-code-flaeche);
  --linie: var(--thema-linie);
  --marke: var(--thema-akzent);
  --marke-flaeche: var(--thema-akzent-flaeche);
  --achtung-flaeche: var(--thema-achtung-flaeche);
  --achtung-linie: var(--thema-achtung-linie);
  --fokus: var(--thema-fokus);
  --schrift: var(--thema-schrift);
  --schrift-code: var(--thema-schrift-code);
  --mass: 1rem;
}

/* ---------- 3 Grundregeln für Elemente ---------- */

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

html { scroll-padding-top: 1rem; }

body {
  margin: 0;
  background: var(--thema-seite);
  color: var(--tinte);
  font-family: var(--schrift);
  font-size: 1rem;
  line-height: 1.55;
}

:where(h1, h2, h3, h4, h5, h6) { line-height: 1.25; margin: 0 0 0.5em; overflow-wrap: anywhere; }
:where(p, ul, ol, dl, table, figure) { margin: 0 0 1em; }
:where(a) { color: var(--marke); text-decoration: underline; text-underline-offset: 0.15em; }
:where(a:hover) { text-decoration-thickness: 0.15em; }
:where(img, svg) { max-width: 100%; height: auto; }
:where(code, kbd) { font-family: var(--schrift-code); font-size: 0.92em; }
:where(code) { background: var(--werkbank); padding: 0.05em 0.3em; border-radius: 0.2em; overflow-wrap: anywhere; }
:where(kbd) { border: 1px solid var(--linie); border-bottom-width: 2px; border-radius: 0.25em; padding: 0 0.3em; background: var(--papier); white-space: nowrap; }
:where(button, input, select, textarea) { font: inherit; }

:where(a, button, input, select, textarea, summary, [tabindex], iframe, video, audio):focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--papier);
}

.nur-screenreader {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 4 Bausteine des Rahmens ---------- */

/* ---------- Sprunglink, Kopf, Fuß ---------- */

.sprunglink {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 10;
  background: var(--thema-flaeche); color: var(--thema-akzent); padding: 0.6rem 1rem;
  border: 2px solid var(--thema-akzent); border-radius: var(--thema-radius-klein); font-weight: 600;
}
.sprunglink:focus { top: 0.5rem; }

.seitenkopf { background: var(--thema-kopf-flaeche); color: var(--thema-kopf-text); }
/* Schmuckstreifen des Themas. Er liegt unter dem Text des Kopfes, nicht dahinter:
   So steht der Text auf einer einfarbigen Fläche und der Kontrast bleibt messbar. */
.seitenkopf::after {
  content: ""; display: block; height: var(--thema-kopf-schmuck-hoehe);
  background: var(--thema-seite) var(--thema-kopf-schmuck) top center / max(100%, 50rem) 100% no-repeat;
}
.seitenkopf-innen {
  max-width: 92rem; margin: 0 auto; padding: 1rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem;
}
.seitenkopf-titel { min-width: 0; }
.seitenname { margin: 0; font-family: var(--thema-schrift-titel); font-size: 1.25rem; font-weight: var(--thema-titel-gewicht); line-height: 1.3; }
.seitenzusatz { margin: 0.15rem 0 0; color: var(--thema-kopf-text-leise); }

/* Logo des Themas. Das Bild liegt im Themenordner, Linkziel und Alternativtext stehen in index.html. */
.marke { display: block; flex: none; width: var(--thema-logo-breite); max-width: 100%; border-radius: var(--thema-radius-klein); color: var(--thema-kopf-text); font-weight: 700; }
.marke img { display: block; width: 100%; height: auto; }

.seitenkopf :where(a, button):focus-visible { outline-color: var(--thema-kopf-fokus); box-shadow: none; outline-offset: 4px; }

.seitenfuss { background: var(--thema-fuss-flaeche); color: var(--thema-fuss-text); padding: 1.5rem 1.25rem; }
.seitenfuss p { max-width: 70rem; margin: 0 auto 0.5rem; }
.seitenfuss nav { max-width: 70rem; margin: 0 auto; }
.seitenfuss ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.seitenfuss li { margin: 0; }
.seitenfuss a { display: inline-block; padding: 0.3rem 0; color: var(--thema-fuss-link); font-weight: 600; }
.seitenfuss :where(a, button):focus-visible { outline-color: var(--thema-fuss-fokus); box-shadow: none; }

/* ---------- Gerüst und Navigation ---------- */

.geruest { max-width: 92rem; margin: 0 auto; padding: 0 1.25rem 3rem; display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }

.seitennav { padding-top: 1.25rem; }
.seitennav ul { list-style: none; margin: 0; padding: 0; }
.seitennav li { margin: 0; }
.seitennav a { display: block; padding: 0.3rem 0.5rem; color: var(--thema-text); text-decoration: none; border-radius: var(--thema-radius-klein); }
.seitennav a:hover { background: var(--thema-hover-flaeche); text-decoration: underline; }
/* Die Navigation rollt für sich (overflow). Ein Fokusrahmen außen würde links und rechts abgeschnitten, deshalb liegt er innen. */
.seitennav a:focus-visible { outline-offset: -3px; box-shadow: none; }
.seitennav .nav-ebene1 > li > a { font-weight: 700; margin-top: 0.6rem; color: var(--thema-ueberschrift); }
.seitennav .nav-ebene2 a { padding-left: 1rem; font-size: 0.95rem; }
.seitennav .nav-nr { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 0.3em; }

.nav-schalter {
  width: 100%; text-align: left; padding: 0.7rem 1rem; background: var(--thema-flaeche);
  border: 2px solid var(--thema-primaer); border-radius: var(--thema-radius-klein); color: var(--thema-primaer); font-weight: 700; cursor: pointer;
}
.nav-schalter::after { content: " ▾"; }
.nav-schalter[aria-expanded="true"]::after { content: " ▴"; }

@media (min-width: 64rem) {
  .geruest { grid-template-columns: 17.5rem minmax(0, 1fr); gap: 2rem; }
  .seitennav { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding-bottom: 1.5rem; }
  .nav-schalter { display: none; }
  #nav-liste[hidden] { display: block; }
}

/* ---------- Hauptinhalt ---------- */

main { min-width: 0; padding-top: 1.5rem; }
main:focus { outline: none; }
main h1 { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem); max-width: 26ch; letter-spacing: -0.01em; margin-bottom: 1.25rem; }
main > h1 { color: var(--thema-titel); font-family: var(--thema-schrift-titel); font-weight: var(--thema-titel-gewicht); }
.abschnitt { margin-bottom: 3rem; }
.abschnitt > h2 {
  font-size: 1.55rem; padding-bottom: 0.35rem; border-bottom: 3px solid var(--thema-trennlinie); margin-bottom: 1rem;
  color: var(--thema-ueberschrift); font-family: var(--thema-schrift-titel); font-weight: var(--thema-titel-gewicht);
}
.abschnitt > h3 { color: var(--thema-ueberschrift); font-family: var(--thema-schrift-titel); font-weight: var(--thema-titel-gewicht); }
.abschnitt-einleitung { max-width: 70ch; }

.hinweis-kasten { background: var(--thema-achtung-flaeche); border: 2px solid var(--thema-achtung-linie); border-radius: var(--thema-radius-klein); padding: 1rem 1.1rem; max-width: 75ch; margin-bottom: 1.25rem; }
.hinweis-kasten p:last-child { margin-bottom: 0; }
.schritte, .merkliste { max-width: 75ch; padding-left: 1.4rem; }
.schritte li, .merkliste li { margin-bottom: 0.5rem; }

.werkzeugleiste { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.rahmen-knopf {
  background: var(--thema-flaeche); color: var(--thema-primaer); border: 2px solid var(--thema-primaer); border-radius: var(--thema-radius-klein);
  padding: 0.5rem 0.9rem; min-height: 2.75rem; font-weight: 600; cursor: pointer;
}
.rahmen-knopf:hover { background: var(--thema-hover-flaeche); }
.rahmen-knopf[aria-pressed="true"] { background: var(--thema-primaer); color: var(--thema-auf-primaer); }
.rahmen-status { font-weight: 600; }

/* ---------- Kriterium ---------- */

.kriterium, .komponente, .demo {
  background: var(--thema-flaeche); border: 1px solid var(--thema-linie); border-top: 0; border-radius: var(--thema-radius);
  padding: 1.25rem; margin-bottom: 1.75rem;
  box-shadow: inset 0 0.4rem 0 var(--thema-primaer);
  padding-top: 1.6rem;
}
.kriterium > h3, .komponente > h3, .demo > h3 {
  font-size: 1.3rem; margin-bottom: 0.25rem;
  color: var(--thema-ueberschrift); font-family: var(--thema-schrift-titel); font-weight: var(--thema-titel-gewicht);
}
.kriterium > h3 .nr { font-variant-numeric: tabular-nums; margin-right: 0.35em; }
.meta { color: var(--thema-text-leise); font-size: 0.95rem; margin-bottom: 0.9rem; }
.meta .stufe { font-weight: 700; color: var(--thema-text); }
.kern { font-size: 1.08rem; max-width: 75ch; }
.pruefen { max-width: 75ch; }
.kontext { max-width: 75ch; }

.beispiele { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); margin: 1.25rem 0; align-items: start; }
.beispiele--breit { grid-template-columns: minmax(0, 1fr); }
.beispiel { min-width: 0; }
.beispiel-titel {
  display: inline-block; margin: 0; font-size: 1rem; font-weight: 700;
  background: var(--thema-primaer); color: var(--thema-auf-primaer); padding: 0.25rem 0.75rem;
  border-radius: var(--thema-radius-klein) var(--thema-radius-klein) 0 0;
}

/* Die Bühne: der gestrichelte Kasten um ein Beispiel. Zum Rahmen gehört nur
   ihre Kante. Alles darin ist Prüfobjekt – siehe „Schutz“ in beispiele.css.
   Maße, Innenabstand und Linienstärke bleiben in jedem Thema gleich. */
.buehne {
  background: #ffffff; border: 2px dashed var(--thema-primaer); padding: 1rem; min-width: 0;
}
.buehne > :last-child:not(dialog) { margin-bottom: 0; }
.buehne--rollt { overflow: auto; }

/* Hinweise und Steuerung der Übungsseite, die neben einem Beispiel stehen, aber nicht dazugehören */
.rahmen-steuerung {
  background: var(--thema-steuerung-flaeche); border-left: 0.4rem solid var(--thema-steuerung-linie);
  border-radius: var(--thema-radius-klein);
  padding: 0.6rem 0.8rem; margin: 0 0 0.6rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
}
.rahmen-steuerung .rahmen-hinweis { margin: 0; flex: 1 1 14rem; font-size: 0.95rem; }
.beispiel-notiz { font-size: 0.95rem; color: var(--thema-text-leise); margin: 0.5rem 0 0; }
.warnung { background: var(--thema-achtung-flaeche); border: 2px solid var(--thema-achtung-linie); border-radius: var(--thema-radius-klein); padding: 0.7rem 0.9rem; max-width: 75ch; }
.warnung > :last-child { margin-bottom: 0; }

/* ---------- Auflösung ---------- */

.aufloesung { border: 2px solid var(--thema-akzent); border-radius: var(--thema-radius-klein); background: var(--thema-akzent-flaeche); max-width: 85ch; margin-bottom: 1rem; overflow-wrap: anywhere; }
.kriterium > .aufloesung:last-child, .komponente > .aufloesung:last-child, .demo > .aufloesung:last-child { margin-bottom: 0; }
.aufloesung > summary { cursor: pointer; padding: 0.7rem 1rem; font-weight: 700; color: var(--thema-akzent); border-radius: var(--thema-radius-klein); }
.aufloesung[open] > summary { border-bottom: 1px solid var(--thema-akzent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.aufloesung > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.aufloesung > summary + * { margin-top: 0.9rem; }
.aufloesung ul, .aufloesung ol { padding-left: 1.3rem; }
.aufloesung li { margin-bottom: 0.5rem; }
.aufloesung code { background: var(--thema-flaeche); }
.aufloesung table { border-collapse: collapse; width: 100%; min-width: 34rem; background: var(--thema-flaeche); overflow-wrap: normal; hyphens: manual; }
.aufloesung th, .aufloesung td { border: 1px solid var(--thema-linie); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; }
.tabellen-huelle { overflow-x: auto; margin-bottom: 1em; }
.tabellen-huelle > table { margin-bottom: 0; }
.urteil { font-weight: 700; }

/* ---------- Schmale Fenster (Smartphone) ----------
   Gerüst, Karte, Bühne und Auflösung liegen ineinander, ihre Abstände nach
   links und rechts addieren sich: Bei 320 Pixeln Breite blieben für ein
   Beispiel nur 202 Pixel. Hier schrumpfen deshalb die Seitenabstände – und
   nur sie. Kanten, Linienstärken, Rundungen und alle Abstände nach oben und
   unten bleiben wie sie sind.
   Untergrenze ist 0.5rem: Der Fokusrahmen (2px Abstand, 3px Linie, 6px Hof)
   passt damit weiter zwischen ein Element und die nächste Kante.
   Die Grenze steht in rem. So greift die Regel auch bei starkem Zoom, wenn
   der Ansichtsbereich schmal wird (1.4.10). */
@media (max-width: 40rem) {
  .seitenkopf-innen, .seitenfuss, .geruest { padding-inline: 0.5rem; }
  .kriterium, .komponente, .demo { padding-inline: 0.625rem; }
  .buehne { padding-inline: 0.5rem; }
  .aufloesung > summary { padding-inline: 0.625rem; }
  .aufloesung > :not(summary) { margin-inline: 0.625rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Erzwungene Farben (zum Beispiel Kontrastmodus unter Windows): Das Logo behält seine
   Farben und bekommt die Kopffläche des Themas als Unterlage, der Schmuckstreifen entfällt. */
@media (forced-colors: active) {
  .seitenkopf::after { display: none; }
  .marke { forced-color-adjust: none; background: var(--thema-kopf-flaeche); padding: 0.3rem 0.5rem; }
  .seitenkopf .marke:focus-visible { outline-color: Highlight; }
}

@media print {
  .seitennav, .werkzeugleiste, .sprunglink { display: none; }
  .geruest { display: block; }
}
