/* =========================================================================
   Papiertheater – Kamishibai
   ========================================================================= */

:root {
  --paper:        #fdf6e9;
  --paper-2:      #f6ead4;
  --ink:          #3d3026;
  --ink-soft:     #6b5947;
  --wood-1:       #a9713f;
  --wood-2:       #8a5527;
  --wood-3:       #6d411d;
  --wood-edge:    #5a3416;
  --accent:       #c2622c;
  --accent-soft:  #f0d3ac;
  --shadow:       0 18px 44px rgba(90, 52, 22, .22);
  --radius:       18px;
  --focus:        #2f6ea8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #241d18;
    --paper-2:     #2e251d;
    --ink:         #f3e7d5;
    --ink-soft:    #c4b09a;
    --wood-1:      #7d5330;
    --wood-2:      #5f3c1f;
    --wood-3:      #472c15;
    --wood-edge:   #331e0e;
    --accent:      #e39158;
    --accent-soft: #4a3524;
    --shadow:      0 18px 44px rgba(0, 0, 0, .5);
    --focus:       #8fc0ec;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(255, 214, 150, .35), transparent 60%),
    radial-gradient(900px 500px at 92% 4%, rgba(255, 176, 120, .28), transparent 60%),
    var(--paper);
  min-height: 100vh;
  line-height: 1.55;
}

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.wrap-stage { width: min(1180px, 100% - 1.5rem); }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 50;
  background: var(--ink); color: var(--paper); padding: .7rem 1.1rem; border-radius: 0 0 12px 0;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------ Kopf ------------------------------------ */

.site-head { padding: clamp(2rem, 5vw, 3.6rem) 0 1.4rem; text-align: center; }

.kicker {
  margin: 0 0 .45rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
}

.site-head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6.5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -.015em;
}

.lead {
  margin: .7rem auto 0;
  max-width: 46ch;
  font-size: clamp(1rem, 2.1vw, 1.2rem);
  color: var(--ink-soft);
}

/* --------------------------- Geschichten-Gitter ------------------------- */

.story-grid {
  list-style: none;
  margin: 2rem 0 3.6rem;
  padding: 0;
  display: grid;
  gap: clamp(1.2rem, 3vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.story-card {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
  transition: transform .22s ease;
}
.story-card:hover { transform: translateY(-6px) rotate(-.4deg); }
.story-card:active { transform: translateY(-2px) scale(.995); }

.story-thumb {
  position: relative;
  aspect-ratio: 25 / 16;
  border-radius: 14px;
  overflow: hidden;
  background: var(--wood-2);
  padding: 10px;
  box-shadow: var(--shadow);
  background-image: linear-gradient(160deg, var(--wood-1), var(--wood-3));
}
.story-thumb > .inner {
  height: 100%;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .18), inset 0 8px 20px rgba(0, 0, 0, .22);
}
.story-thumb svg { display: block; width: 100%; height: 100%; }

.story-meta { padding: .95rem .3rem 0; }
.story-meta h3 { margin: 0; font-size: 1.32rem; line-height: 1.2; }
.story-meta p { margin: .25rem 0 0; color: var(--ink-soft); font-size: .98rem; }

.badge {
  display: inline-block;
  margin-top: .55rem;
  margin-right: .35rem;
  padding: .22rem .7rem;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-herkunft {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 2px rgba(140, 105, 70, .28);
}

/* -------------------------------- Anleitung ----------------------------- */

.howto {
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: clamp(1.3rem, 3vw, 2.2rem);
  margin-bottom: 3rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .04);
}
.howto h2 { margin: 0 0 .8rem; font-size: 1.5rem; }
.howto ol { margin: 0; padding-left: 1.3rem; }
.howto li { margin-bottom: .5rem; max-width: 68ch; }
.howto-note {
  margin: 1rem 0 0;
  padding-top: .9rem;
  border-top: 2px dashed rgba(140, 105, 70, .3);
  color: var(--ink-soft);
  max-width: 68ch;
}

/* ------------------------------ Bühnenkopf ------------------------------ */

.view#view-story { padding-top: .5rem; }

.stage-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.stage-head h2 {
  margin: 0;
  flex: 1 1 12rem;
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  line-height: 1.2;
}
.stage-head-tools { display: flex; gap: .4rem; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border-radius: 999px;
  padding: .5rem 1rem;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: rgba(140, 105, 70, .3);
}
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-ghost[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-solid {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: .7rem 1.5rem;
  font-size: 1.05rem;
}
.btn-solid:hover { filter: brightness(1.07); }

/* --------------------------------- Butai -------------------------------- */

.butai {
  border-radius: 22px;
  padding: clamp(12px, 2.2vw, 22px);
  background-image:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .05) 0 3px, rgba(0, 0, 0, .05) 3px 7px),
    linear-gradient(158deg, var(--wood-1), var(--wood-2) 55%, var(--wood-3));
  box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 255, 255, .18);
  border: 2px solid var(--wood-edge);
}

.butai-frame {
  position: relative;
  aspect-ratio: 25 / 16;
  border-radius: 10px;
  overflow: hidden;
  background: #2b1b0f;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, .25), inset 0 10px 26px rgba(0, 0, 0, .32);
}

.stage { position: absolute; inset: 0; cursor: pointer; }

.card {
  position: absolute;
  inset: 0;
  will-change: transform;
}
.card svg { display: block; width: 100%; height: 100%; }

@keyframes cardInRight { from { transform: translateX(102%); } to { transform: translateX(0); } }
@keyframes cardInLeft  { from { transform: translateX(-102%); } to { transform: translateX(0); } }
@keyframes cardOutLeft { from { transform: translateX(0); } to { transform: translateX(-102%); } }
@keyframes cardOutRight{ from { transform: translateX(0); } to { transform: translateX(102%); } }

.card.in-right  { animation: cardInRight  .42s cubic-bezier(.32, .72, .3, 1) both; }
.card.in-left   { animation: cardInLeft   .42s cubic-bezier(.32, .72, .3, 1) both; }
.card.out-left  { animation: cardOutLeft  .42s cubic-bezier(.32, .72, .3, 1) both; z-index: 2; }
.card.out-right { animation: cardOutRight .42s cubic-bezier(.32, .72, .3, 1) both; z-index: 2; }

/* Textstreifen unter dem Bild – beim echten Kamishibai steht er auf der Rückseite */
.text-panel {
  margin-top: clamp(10px, 1.8vw, 16px);
  background: linear-gradient(180deg, #fffdf6, #f7ecd8);
  border-radius: 12px;
  padding: clamp(1rem, 2.6vw, 1.7rem) clamp(1.1rem, 3vw, 2.2rem);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .07), 0 6px 18px rgba(60, 35, 15, .18);
  min-height: 8.2em;
  display: flex;
  align-items: center;
}

.card-text {
  margin: 0;
  white-space: pre-line;
  color: #3d3026;
  font-size: clamp(1.05rem, 2.15vw, 1.65rem);
  line-height: 1.5;
  font-weight: 600;
  letter-spacing: .003em;
  text-wrap: balance;
}

/* ------------------------------- Steuerung ------------------------------ */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vw, 2.4rem);
  margin: 1.2rem 0 3rem;
}

.nav-btn {
  width: clamp(58px, 9vw, 78px);
  height: clamp(58px, 9vw, 78px);
  border-radius: 50%;
  border: 3px solid var(--wood-2);
  background: var(--paper-2);
  color: var(--wood-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 rgba(110, 70, 30, .28);
  transition: transform .12s ease, box-shadow .12s ease, opacity .15s ease;
}
.nav-btn svg { width: 46%; height: 46%; }
.nav-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(110, 70, 30, .28); }
.nav-btn:disabled { opacity: .32; cursor: default; box-shadow: none; }
.nav-btn:disabled:hover { background: var(--paper-2); color: var(--wood-2); border-color: var(--wood-2); }

.dots { display: flex; gap: .55rem; flex-wrap: wrap; justify-content: center; }
.dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--wood-2);
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.dot[aria-selected="true"] { background: var(--accent); border-color: var(--accent); transform: scale(1.35); }

/* -------------------------------- Ende ---------------------------------- */

.ende-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 2.4rem);
  background: rgba(40, 24, 12, .72);
  backdrop-filter: blur(7px);
  z-index: 5;
  animation: fadeIn .35s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ende-inner {
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: clamp(1.1rem, 3vw, 2rem);
  max-width: 34rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  max-height: 100%;
  overflow: auto;
}
.ende-wort {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: .04em;
}
.ende-inner h3 { margin: .5rem 0 .6rem; font-size: 1.15rem; }
.ende-inner ul {
  list-style: none;
  margin: 0 0 1.2rem;
  padding: 0;
  display: grid;
  gap: .5rem;
  text-align: left;
}
.ende-inner li {
  background: var(--paper-2);
  border-radius: 10px;
  padding: .6rem .9rem;
  font-size: 1rem;
}
.ende-buttons { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

/* ------------------------------ 404-Seite ------------------------------- */

.oops { text-align: center; padding: clamp(2rem, 8vw, 5rem) 0 4rem; }
.oops .butai { max-width: 620px; margin: 0 auto 2rem; }
.oops h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin: 0 0 .6rem; }
.oops p {
  color: var(--ink-soft);
  font-size: 1.15rem;
  max-width: 40ch;
  margin: 0 auto 1.6rem;
}

/* -------------------------------- Fuß ----------------------------------- */

.site-foot {
  padding: 2rem 0 3rem;
  color: var(--ink-soft);
  font-size: .92rem;
  text-align: center;
}
.site-foot p { max-width: 60ch; margin-inline: auto; }

/* ------------------------------ Vollbild -------------------------------- */

.butai:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 0;
  padding: clamp(10px, 2vh, 26px);
}
.butai:fullscreen .butai-frame { flex: 0 1 auto; max-height: 74vh; margin-inline: auto; width: auto; aspect-ratio: 25/16; }
.butai:fullscreen .text-panel { max-width: min(1200px, 96%); margin-inline: auto; width: 100%; }

/* --------------------------- kleine Bildschirme ------------------------- */

@media (max-width: 620px) {
  .btn-label { display: none; }
  .stage-head h2 { flex-basis: 100%; order: 3; }
  .text-panel { min-height: 7em; }
  .dot { width: 13px; height: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .card.in-right, .card.in-left, .card.out-left, .card.out-right, .ende-panel {
    animation-duration: .01ms;
  }
  .story-card:hover { transform: none; }
}

/* --------------------------------- Druck -------------------------------- */

#printArea { display: none; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }

  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .site-head, .site-foot, .view, .skip { display: none !important; }

  #printArea { display: block; }

  .print-card {
    page-break-after: always;
    break-after: page;
    break-inside: avoid;
    height: 186mm;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .print-card:last-child { page-break-after: auto; break-after: auto; }

  .print-nr {
    font-size: 10pt;
    color: #6d411d;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin: 0 0 3mm;
  }

  .print-pic {
    height: 126mm;
    aspect-ratio: 25 / 16;
    border: 2px solid #6d411d;
    border-radius: 6px;
    overflow: hidden;
  }
  .print-pic svg { display: block; width: 100%; height: 100%; }

  .print-text {
    margin: 8mm 0 0;
    max-width: 200mm;
    font-size: 17pt;
    line-height: 1.45;
    font-weight: 600;
    white-space: pre-line;
    text-align: center;
    color: #000;
  }
}
