/* =========================================================================
   Kleine Wunder — Uebersicht der Reihe (lab/kleine-wunder.html)
   „Setzkasten“: ein Holz-Setzkasten haengt an der Nachtwand, zehn Faecher,
   in jedem lebt die kleine Welt einer Folge. Ein Tipp taucht ins Fach ein
   und startet die Folge. Ablauf und Bilder: assets/js/kleine-wunder.js
   ========================================================================= */

@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka-latin-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka-latin-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --nacht: #1C1E45;
  --creme: #FFF4DC;
  --sonne: #FFC93C;
  --koralle: #F06B54;
  /* Holz des Setzkastens */
  --holz: #D99A4E;
  --holz-hell: #F2BC6E;
  --holz-tief: #8A5426;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --feder: cubic-bezier(.34, 1.56, .64, 1);
  --rund: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 64px);
  --breite: 1640px;
  --rand: max(var(--gutter), calc((100vw - var(--breite)) / 2 + var(--gutter)));
  --rahmen: clamp(10px, 1.1vw, 18px);   /* aeussere Holzleiste */
  --steg: clamp(6px, .75vw, 12px);      /* Trennstege zwischen den Faechern */
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--nacht); -webkit-text-size-adjust: 100%; scrollbar-color: color-mix(in srgb, var(--creme) 40%, transparent) var(--nacht); }
body { margin: 0; font-family: var(--rund); color: var(--creme); background: var(--nacht); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
::selection { background: var(--sonne); color: var(--nacht); }
a { color: inherit; }
img, svg { display: block; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; background: var(--sonne); color: var(--nacht); border-radius: 30px; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--sonne); outline-offset: 4px; border-radius: 12px; }

/* ---------- Kopf ------------------------------------------------------------- */
.kopf { position: absolute; z-index: 20; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 14px; padding: 16px var(--rand); }
.kopf__marke img { width: 34px; height: 34px; }
.kopf__weg {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: 999px; text-decoration: none;
  font-weight: 600; font-size: 15px; border: 2px solid color-mix(in srgb, currentColor 34%, transparent); transition: border-color .3s;
}
.kopf__weg:hover { border-color: currentColor; }
.pfeil { width: 17px; height: 17px; margin-left: -4px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Wand: Titelzeile, Setzkasten, Hinweis ------------------------------ */
.wand { padding: 84px var(--rand) clamp(48px, 7vw, 100px); }
.wand__kopf { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px clamp(24px, 4vw, 72px); margin-bottom: clamp(18px, 2.6svh, 30px); }
.titel { margin: 0; font-weight: 600; font-size: clamp(48px, 6vw, 104px); line-height: .9; letter-spacing: -.02em; }
.wand__neben { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px 22px; padding-bottom: 4px; }
.versprechen { margin: 0; max-width: 30ch; text-wrap: pretty; font-size: clamp(17px, 1.3vw, 22px); line-height: 1.3; }
.wand__tun { display: flex; align-items: center; gap: 14px; }
.zaehler { margin: 0; font-weight: 600; font-size: 15px; color: color-mix(in srgb, var(--creme) 88%, transparent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wand__fuss { margin: clamp(22px, 3vw, 40px) 0 0; max-width: 62ch; font-size: clamp(17px, 1.2vw, 20px); line-height: 1.45; color: color-mix(in srgb, var(--creme) 88%, transparent); }

.knopf {
  display: inline-flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 24px 0 18px; border-radius: 999px; cursor: pointer; border: 0;
  font-family: var(--rund); font-weight: 600; font-size: 17px; text-decoration: none;
  transition: transform .35s var(--feder), box-shadow .2s;
}
.knopf--sonne { background: var(--sonne); color: var(--nacht); box-shadow: inset 0 -5px 0 rgba(0,0,0,.14), 0 10px 22px -10px rgba(0,0,0,.6); }
.knopf--sonne:hover { transform: translateY(-2px) scale(1.03); }
.knopf--sonne:active { transform: translateY(2px) scale(.97); box-shadow: inset 0 -1px 0 rgba(0,0,0,.14), 0 4px 8px -4px rgba(0,0,0,.5); }
.knopf[disabled] { cursor: progress; }
.wuerfel { width: 24px; height: 24px; fill: currentColor; }
.wuerfel rect { fill: none; stroke: currentColor; stroke-width: 2.4; }
.knopf--sonne:hover .wuerfel { animation: rollen .6s var(--feder); }
@keyframes rollen { from { transform: rotate(-90deg); } }

/* ---------- Der Setzkasten -------------------------------------------------- */
.kasten {
  --kb: calc(100vw - 2 * var(--rand));
  list-style: none; margin: 0; position: relative;
  /* Der Kasten waechst nach unten (die Seite scrollt): Zeilen haben eine feste Hoehe aus der Spaltenbreite */
  --zelle: calc((var(--kb) - 2 * var(--rahmen) - 11 * var(--steg)) / 12 * .78);
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--zelle);
  gap: var(--steg); padding: var(--rahmen);
  border-radius: 22px;
  /* Holz: flache Flaeche, helle Oberkante, Schatten unter dem Kasten */
  background: linear-gradient(180deg, var(--holz-hell), var(--holz) 9%, var(--holz) 88%, #C4843E);
  box-shadow: inset 0 3px 0 rgba(255,236,190,.55), inset 0 -4px 0 rgba(90,45,5,.35), 0 34px 60px -26px rgba(0,0,0,.75);
}
/* zwei Messingschrauben in den oberen Ecken der Leiste */
.kasten::before, .kasten::after {
  content: ''; position: absolute; top: calc(var(--rahmen) / 2 - 4px); width: 8px; height: 8px; border-radius: 50%;
  /* flache Messingscheibe mit Schlitz, wie die Bilder gezeichnet */
  background: linear-gradient(135deg, transparent 44%, #9C6A16 44% 58%, transparent 58%), #E8B04A;
}
.kasten::before { left: calc(var(--rahmen) / 2 - 4px); } .kasten::after { right: calc(var(--rahmen) / 2 - 4px); }

.fach {
  position: relative; min-width: 0; min-height: 0; border-radius: 3px; overflow: hidden; isolation: isolate;
  background: var(--k, var(--holz-tief));
  transition: filter .45s var(--ease), transform .45s var(--ease);
}
/* Innenwaende: oben im Schatten, links etwas heller, unten die Vorderkante */
.fach::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 14px 12px -8px rgba(60,25,0,.6), inset 10px 0 10px -8px rgba(60,25,0,.4), inset -6px 0 8px -6px rgba(60,25,0,.3), inset 0 -3px 0 rgba(255,220,160,.35);
}
.fach__link { position: absolute; inset: 0; display: block; text-decoration: none; color: inherit; border-radius: inherit; -webkit-tap-highlight-color: transparent; }
.fach__link:focus-visible { outline: none; }
.fach:has(.fach__link:focus-visible) { outline: 4px solid var(--nacht); outline-offset: 2px; }
.fach__bild { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; transition: transform .6s var(--ease); }

/* Lage der Faecher: 12 Spalten, Baender zu je 4 Zeilen (Zeile-Anfang / Spalte-Anfang / Zeile-Ende / Spalte-Ende).
   Neue Folgen bekommen unten ein neues Band. */
.f1 { grid-area: 1 / 1 / 5 / 5; } .f2 { grid-area: 1 / 5 / 3 / 9; } .f3 { grid-area: 3 / 5 / 5 / 9; } .f4 { grid-area: 1 / 9 / 5 / 13; }
.f5 { grid-area: 5 / 1 / 9 / 4; } .f6 { grid-area: 5 / 4 / 7 / 7; } .f7 { grid-area: 7 / 4 / 9 / 7; } .f8 { grid-area: 5 / 7 / 9 / 10; }
.f9 { grid-area: 5 / 10 / 7 / 13; } .f10 { grid-area: 7 / 10 / 9 / 13; } .f11 { grid-area: 9 / 1 / 13 / 6; } .f12 { grid-area: 9 / 6 / 11 / 10; }
.f13 { grid-area: 11 / 6 / 13 / 10; } .f14 { grid-area: 9 / 10 / 13 / 13; } .f15 { grid-area: 13 / 1 / 15 / 4; } .f16 { grid-area: 15 / 1 / 17 / 4; }
.f17 { grid-area: 13 / 4 / 17 / 10; } .f18 { grid-area: 13 / 10 / 15 / 13; } .k1 { grid-area: 15 / 10 / 17 / 11; } .k2 { grid-area: 15 / 11 / 17 / 13; }
.f19 { grid-area: 17 / 1 / 21 / 7; } .f20 { grid-area: 17 / 7 / 21 / 13; }

/* Krimskrams-Faecher: eine Bleiletter, eine Murmel */
.fach--krams { background: #7A4A1E; }
.krams { position: absolute; inset: 12%; width: 76%; height: 76%; }

/* Schild: cremefarbene Karte im sonnengelben Halter, Nummer in der Farbe der Folge */
.schild {
  position: absolute; z-index: 4; left: clamp(6px, .8vw, 12px); bottom: clamp(6px, .8vw, 12px); max-width: calc(100% - 2 * clamp(6px, .8vw, 12px));
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px;
  background: var(--creme); color: var(--nacht); box-shadow: 0 0 0 3px var(--sonne), 0 5px 0 rgba(28,30,69,.25);
  transition: transform .4s var(--feder);
}
.schild__nr {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--k); color: #fff;
  font-weight: 600; font-size: 16px; line-height: 1; font-variant-numeric: tabular-nums;
}
.schild__titel { min-width: 0; font-weight: 600; font-size: clamp(14px, 1.05vw, 18px); line-height: 1.1; text-wrap: balance; }
.schild__status {
  position: absolute; z-index: 4; top: clamp(6px, .7vw, 10px); right: clamp(6px, .7vw, 10px); transform: rotate(5deg);
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px 6px; border-radius: 10px;
  font-weight: 600; font-size: 12px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 4px 0 rgba(28,30,69,.25);
}
.schild__status--neu { background: var(--koralle); color: var(--nacht); }
.schild__status--gesehen { background: var(--sonne); color: var(--nacht); transform: rotate(-4deg); }
.schild__status svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }

/* Sprechblase mit der Frage der Folge */
.blase {
  position: absolute; z-index: 5; left: 50%; top: clamp(8px, 1vw, 14px); width: max-content; max-width: min(92%, 300px);
  padding: 10px 14px 11px; border-radius: 18px; background: var(--creme); color: var(--nacht);
  font-weight: 600; font-size: clamp(14px, 1.05vw, 17px); line-height: 1.22; text-align: center; text-wrap: balance;
  box-shadow: 0 6px 0 rgba(28,30,69,.22);
  opacity: 0; transform: translate(-50%, 10px) scale(.9); transform-origin: 50% 100%; pointer-events: none;
  transition: opacity .25s var(--ease), transform .45s var(--feder);
}
.blase::after { content: ''; position: absolute; left: var(--zeiger, 50%); bottom: -9px; width: 18px; height: 18px; margin-left: -9px; transition: left .2s linear; background: inherit; border-radius: 0 0 5px 0; transform: rotate(45deg); }

/* Geweckt (Maus darueber, Fokus, Zufallslicht): Fach kommt nach vorn, der Rest dimmt */
.fach.ist-wach .blase { opacity: 1; transform: translate(-50%, 0) scale(1); }
.fach.ist-wach .schild { transform: translateY(-3px); }
.fach.ist-wach .fach__bild { transform: scale(1.06); }
/* gedimmt wie im Lampenlicht: eine warme Bernstein-Schicht legt sich (multiplizierend) ueber die schlafenden Faecher */
.fach::before {
  content: ''; position: absolute; inset: 0; z-index: 6; pointer-events: none; border-radius: inherit;
  background: #C9853A; mix-blend-mode: multiply; opacity: 0; transition: opacity .45s var(--ease);
}
.kasten.ist-gedimmt .fach:not(.ist-wach)::before { opacity: .92; }

/* Eintauchen: das Bild des Fachs waechst zum Bildschirm, dann schliesst die Startfarbe der Folge */
.tauchen { position: fixed; inset: 0; z-index: 50; pointer-events: none; visibility: hidden; }
.tauchen.ist-an { visibility: visible; pointer-events: auto; }
.tauchen__bild { position: absolute; overflow: hidden; border-radius: 3px; background: var(--k, var(--nacht)); }
.tauchen__bild svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tauchen__kreis { position: absolute; inset: 0; background: var(--start, var(--nacht)); clip-path: circle(0% at 50% 50%); }

/* Ohne JavaScript: Faecher zeigen ihre Farbe, Schilder sind sichtbar, kein Wuerfel */
html:not(.js) .blase { display: none; }

/* ---------- Hoch- und Schmalformat ------------------------------------------ */
@media (max-width: 1100px) {
  .schild { gap: 6px; padding: 3px 10px 3px 3px; }
  .schild__nr { width: 26px; height: 26px; font-size: 14px; }
  .schild__titel { font-size: 14px; }
}
@media (max-width: 719px) {
  .wand { padding: 72px 16px 56px; }
}
/* Hochformat und Telefon: Titel, Versprechen, Knopf untereinander */
@media (max-width: 719px), (max-aspect-ratio: 1/1) and (max-width: 1100px) {
  .wand__kopf { display: block; margin-bottom: 18px; }
  .titel { font-size: clamp(44px, 13vw, 64px); margin-bottom: 10px; }
  .wand__neben { justify-content: flex-start; gap: 12px; }
  .versprechen { font-size: 17px; max-width: 32ch; }
  .wand__tun { width: 100%; justify-content: space-between; }
  .knopf { min-height: 46px; font-size: 16px; }
  .kasten { min-height: 0; border-radius: 18px; }
  .schild { left: 6px; bottom: 6px; max-width: calc(100% - 12px); flex-wrap: wrap; row-gap: 2px; border-radius: 18px; }
  .schild__titel { font-size: clamp(14px, 2.1vw, 18px); flex: 1 1 0; }
  .schild__nr { width: clamp(26px, 3.8vw, 32px); height: clamp(26px, 3.8vw, 32px); font-size: clamp(14px, 2vw, 17px); }
  .blase { font-size: clamp(14px, 1.9vw, 17px); padding: 8px 11px 9px; max-width: 94%; }
}
/* Telefon und Tablet hochkant: 4 Spalten mit grossen Faechern */
@media (max-width: 719px), (max-width: 1100px) and (max-aspect-ratio: 1/1) {
  .kasten {
    --zeile: calc((100vw - 2 * var(--rand) - 2 * var(--rahmen) - 3 * var(--steg)) / 4 * .82);
    grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: var(--zeile);
  }
  .f1 { grid-area: 1 / 1 / 4 / 3; }   .f2 { grid-area: 1 / 3 / 3 / 5; }   .f3 { grid-area: 3 / 3 / 6 / 5; }
  .f4 { grid-area: 4 / 1 / 6 / 3; }   .f5 { grid-area: 6 / 1 / 8 / 5; }   .f6 { grid-area: 8 / 1 / 11 / 3; }
  .f7 { grid-area: 8 / 3 / 10 / 5; }  .f8 { grid-area: 10 / 3 / 13 / 5; } .f9 { grid-area: 11 / 1 / 13 / 3; }
  .f10 { grid-area: 13 / 1 / 15 / 5; }
  .f11 { grid-area: 15 / 1 / 17 / 3; } .f12 { grid-area: 15 / 3 / 17 / 5; }
  .f13 { grid-area: 17 / 1 / 20 / 3; } .f14 { grid-area: 17 / 3 / 20 / 5; }
  .f15 { grid-area: 20 / 1 / 23 / 3; } .f16 { grid-area: 20 / 3 / 23 / 5; }
  .f17 { grid-area: 23 / 1 / 26 / 3; } .f18 { grid-area: 23 / 3 / 26 / 5; }
  .f19 { grid-area: 26 / 1 / 29 / 3; } .f20 { grid-area: 26 / 3 / 29 / 5; }
  .k1, .k2 { display: none; }
}
/* Schmale Faecher (z. B. Tablet hochkant): kleineres Schild, damit der Titel ganz bleibt */
.fach[data-nr] { container-type: inline-size; }
@container (max-width: 172px) {
  .schild { padding: 3px 9px 3px 3px; gap: 5px; }
  .schild__nr { width: 24px; height: 24px; font-size: 13px; }
  .schild__titel { font-size: 13.5px; }
}
@container (max-width: 136px) {
  .schild { padding: 2px 7px 2px 2px; gap: 4px; }
  .schild__nr { width: 21px; height: 21px; font-size: 12px; }
  .schild__titel { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; }
}

/* Fuss */
.fuss { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px 28px; padding: 26px var(--rand); background: var(--nacht); color: rgba(255,244,220,.72); font-size: 15px; border-top: 2px solid rgba(255,244,220,.08); }
.fuss nav { display: flex; gap: 22px; }
.fuss a { text-decoration: none; } .fuss a:hover { color: var(--creme); }
