/* Ailumi — The Magical Fairy Tales
   A storybook you turn. Night-forest ground, lantern amber, blossom, crystal. */

:root {
  /* ground: the glade after sunset, not paper */
  --night:        #13211a;
  --night-deep:   #0c1711;
  --bark:         #2a4032;
  --moss:         #456b4e;

  /* light sources in this world */
  --amber:        #f0b54e;
  --amber-warm:   #e08c3a;
  --blossom:      #f2a6c0;
  --crystal:      #a881e8;
  --water:        #86cdd8;

  --ink:          #f6efe2;
  --ink-soft:     #cdbfa9;
  --ink-faint:    #96886f;

  --spine:        rgba(240, 181, 78, .22);

  --page-pad:     clamp(1.5rem, 4vw, 5rem);
  --rhythm:       clamp(1rem, 2.2vw, 2rem);

  --display: "Gloock", Georgia, serif;
  --body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

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

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--night-deep);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1rem, .55vw + .88rem, 1.18rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: .5rem; top: -4rem; z-index: 60;
  background: var(--amber); color: var(--night-deep);
  padding: .7rem 1.1rem; border-radius: .6rem; font-weight: 700;
  text-decoration: none; transition: top .18s;
}
.skip:focus { top: .5rem; }

/* ─── masthead ─────────────────────────────────────────── */

.masthead {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: clamp(.7rem, 1.6vw, 1.3rem) var(--page-pad);
  background: linear-gradient(to bottom, rgba(12,23,17,.92), rgba(12,23,17,0));
  pointer-events: none;
}
.masthead > * { pointer-events: auto; }

.wordmark {
  font-family: var(--display);
  font-size: clamp(1.3rem, 2vw, 1.75rem);
  letter-spacing: .01em;
  color: var(--amber);
  text-shadow: 0 2px 14px rgba(0,0,0,.6);
}

.masthead nav { display: flex; gap: .15rem; flex-wrap: wrap; }

.masthead nav button {
  font: inherit; font-size: .84rem; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); background: none; border: 0;
  padding: .55rem .7rem; border-radius: .5rem; cursor: pointer;
  min-height: 44px;
  transition: color .18s, background .18s;
}
.masthead nav button:hover,
.masthead nav button:focus-visible { color: var(--amber); background: rgba(240,181,78,.1); }
.masthead nav button[aria-current="true"] { color: var(--amber); }

/* ─── the book ─────────────────────────────────────────── */

.book {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  height: 100svh;
  scrollbar-width: none;
}
.book::-webkit-scrollbar { display: none; }

@media (prefers-reduced-motion: reduce) {
  .book { scroll-behavior: auto; }
}

.page {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100svh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: grid;
  align-content: center;
  padding: calc(var(--page-pad) + 3.5rem) var(--page-pad) calc(var(--page-pad) + 4.5rem);
  /* the binding seam: every page carries the spine on its left edge */
  border-left: 1px solid var(--spine);
  background: var(--night);
}
.page::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: clamp(14px, 3vw, 46px);
  background: linear-gradient(to right, rgba(0,0,0,.45), rgba(0,0,0,0));
  pointer-events: none; z-index: 3;
}

.page__bg {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.page--cover .page__bg { filter: saturate(1.05); }
.page__bg--soft { opacity: .3; filter: blur(2px) saturate(.85); }

/* The world is the best material here — veil it, do not bury it. */
.page--cover::after,
.page--cast::after,
.page--about::after {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(130% 100% at 50% 45%, rgba(12,23,17,0), rgba(12,23,17,.55) 85%),
    linear-gradient(to bottom, rgba(12,23,17,.55), rgba(12,23,17,0) 26%, rgba(12,23,17,0) 55%, rgba(12,23,17,.8));
}
.page--cast::after, .page--about::after {
  background:
    radial-gradient(130% 100% at 50% 45%, rgba(12,23,17,.45), rgba(12,23,17,.9) 85%),
    linear-gradient(to bottom, rgba(12,23,17,.7), rgba(12,23,17,.45) 40%, rgba(12,23,17,.9));
}
/* .cutouts is excluded: it positions itself against the page edge, and this
   rule is specific enough to win over it. */
.page > *:not(.page__bg):not(.cutouts) { position: relative; z-index: 2; }

/* ─── cover ────────────────────────────────────────────── */

.page--cover {
  justify-items: center; text-align: center;
  align-content: center;
  padding-top: clamp(5rem, 11vh, 7rem);
  padding-bottom: clamp(7rem, 16vh, 11rem);
}

.plate { max-width: 46ch; }

.plate__title { margin: 0; line-height: 0; }

.plate__logo {
  display: block;
  width: min(66vw, 34rem);
  height: auto;
  margin-inline: auto;
  filter: drop-shadow(0 1rem 2.4rem rgba(0,0,0,.7));
}

.plate__line {
  margin: calc(var(--rhythm) * 1.2) auto 0;
  max-width: 36ch;
  color: var(--ink);
  text-wrap: balance;
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}

/* The two of them stand on the bottom edge of the cover, breaking the frame —
   at the outer margins, so the title and the invitation keep the middle. */
.cutouts {
  position: absolute; inset: auto 0 0 0; z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-inline: clamp(1.5rem, 7vw, 8rem);
  pointer-events: none;
}
.cutout {
  display: block; width: auto;
  filter: drop-shadow(0 .8rem 1.6rem rgba(0,0,0,.6));
  animation: breathe 7s ease-in-out infinite;
}
.cutout--fairy  { height: clamp(7rem, 24vh, 15rem); }
.cutout--dragon { height: clamp(5.2rem, 17.5vh, 11rem); animation-delay: -3.5s; }

@keyframes breathe {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(-.45rem) }
}
@media (prefers-reduced-motion: reduce) { .cutout { animation: none } }

.plate__hint {
  margin: calc(var(--rhythm) * 1.6) 0 0;
  font-size: .9rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  /* it sits over a sunlit hillside — it needs its own backing to stay readable */
  text-shadow: 0 1px 10px rgba(12,23,17,.95), 0 0 24px rgba(12,23,17,.8);
}
.turn-arrow {
  display: inline-block; color: var(--amber); font-size: 1.3rem;
  animation: nudge 2.6s ease-in-out infinite;
}
@keyframes nudge { 0%,100% { transform: translateX(0) } 50% { transform: translateX(.4rem) } }
@media (prefers-reduced-motion: reduce) { .turn-arrow { animation: none } }

/* ─── a story page ─────────────────────────────────────── */

.page--story {
  --perf: clamp(.7rem, 1.5vw, 1.1rem);
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  grid-template-rows: auto auto;
  column-gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  align-content: center;
  background:
    radial-gradient(90% 70% at 15% 30%, rgba(69,107,78,.3), transparent 70%),
    var(--night);
}

.still { margin: 0; position: relative; }

/* The frame sits in a strip of film: sprocket holes top and bottom, the way the
   still was pulled out of the reel. */
.reel {
  --perf: clamp(.7rem, 1.5vw, 1.1rem);
  position: relative;
  padding-block: var(--perf);
  background: #0a0f0c;
  border-radius: .3rem;
  box-shadow: 0 1.4rem 3.5rem rgba(0,0,0,.6);
}
/* Sprocket holes: light, because on real film they are the gaps the light
   comes through. Dark-on-dark made them invisible. */
.reel::before, .reel::after {
  content: "";
  position: absolute; left: 0; right: 0;
  height: var(--perf);
  background-image: radial-gradient(
    closest-side, rgba(246,239,226,.5) 0 62%, transparent 66%);
  background-size: calc(var(--perf) * 2.1) 100%;
  background-position: center;
}
.reel::before { top: 0; }
.reel::after  { bottom: 0; }

.reel img {
  display: block; width: 100%; height: auto;
  max-height: 54vh;
  object-fit: cover;
}

/* The moments run the full width of the page, under both columns — enough to
   build an appetite, not enough to give the tale away.
   The strip is not laid flat: each frame carries its own sprocket edges and sits
   on a curve, so the band waves across the page the way a cut length of film
   does when you hold it up. */
.strip {
  --perf: clamp(.5rem, .95vw, .78rem);   /* narrower than the frame it borders */
  grid-column: 1 / -1;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0;
  margin: clamp(2rem, 4.5vw, 3.6rem) 0 clamp(1.4rem, 3vw, 2.4rem);
  padding: 0;
  filter: drop-shadow(0 .9rem 2.2rem rgba(0,0,0,.55));
}

.strip li {
  --shear: 0deg;
  --lift: 0%;
  flex: 1 1 0;
  margin: 0;
  position: relative;
  padding-block: var(--perf, .9rem);
  padding-inline: clamp(2px, .35vw, 5px);   /* the bar between two frames */
  background: #0a0f0c;
  /* Shear, not rotate: the vertical cuts stay vertical, so the frames meet
     edge to edge and the top and bottom read as one continuous wave.
     --lift is the running offset so each frame starts where the last one ended. */
  transform: translateY(var(--lift)) skewY(var(--shear));
  transform-origin: left center;
  transition: transform .5s cubic-bezier(.22,.8,.3,1), filter .5s;
}

/* sprocket holes on every frame, so the band keeps its teeth around the bend */
.strip li::before, .strip li::after {
  content: "";
  position: absolute; left: 0; right: 0;
  height: var(--perf, .9rem);
  background-image: radial-gradient(
    closest-side, rgba(246,239,226,.5) 0 62%, transparent 66%);
  background-size: calc(var(--perf, .9rem) * 1.9) 100%;
  background-position: center;
  pointer-events: none;
}
.strip li::before { top: 0; }
.strip li::after  { bottom: 0; }

/* The wave. Each frame is 16:9, so a shear of α moves its right edge by
   (16/9)·tan α of its own height — that figure is the next frame's offset,
   which is what keeps the band joined. Climb, level, fall, level, climb:
   one full swing across the five frames. */
.strip li:nth-child(1) { --shear: -5deg; --lift:   0%;   }
.strip li:nth-child(2) { --shear:  0deg; --lift: -15.6%; }
.strip li:nth-child(3) { --shear:  5deg; --lift: -15.6%; }
.strip li:nth-child(4) { --shear:  0deg; --lift:   0%;   }
.strip li:nth-child(5) { --shear: -5deg; --lift:   0%;   }

.strip img {
  display: block; width: 100%; height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  opacity: .88;
  transition: opacity .45s;
}

/* straighten one frame out of the curve to look at it properly */
.strip li:hover,
.strip li:focus-within {
  --shear: 0deg;
  z-index: 4;
  filter: drop-shadow(0 1rem 1.8rem rgba(0,0,0,.65));
}
.strip li:hover img, .strip li:focus-within img { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .strip li { transition: none; }
}

.still__no {
  position: absolute; top: -.4rem; left: -.2rem;
  transform: translateY(-100%);
  font-size: .76rem; letter-spacing: .26em; text-transform: uppercase;
  color: var(--amber); font-weight: 700;
}

.tale__title {
  font-family: var(--display);
  font-size: clamp(2.2rem, 5.5vw, 4.2rem);
  line-height: 1.02;
  margin: 0 0 var(--rhythm);
  color: var(--ink);
  text-wrap: balance;
}

.tale__text {
  margin: 0 0 var(--rhythm);
  color: var(--ink-soft);
  max-width: 36ch;
  font-size: 1.06em;
}
.tale__text em { color: var(--blossom); font-style: italic; }

.tale__meta {
  margin: 0;
  font-size: .84rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ─── characters ───────────────────────────────────────── */

.page--cast { align-content: center; }

.cast__title {
  font-family: var(--display);
  font-size: clamp(1.9rem, 4.4vw, 3.2rem);
  margin: 0 0 calc(var(--rhythm) * 1.3);
  color: var(--ink);
  text-align: center;
}

.cast {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: clamp(1rem, 2.4vw, 2.4rem);
  align-items: end;
}

/* One shared baseline: every character stands on the same ground line,
   whatever the length of its name underneath. */
.cast__member {
  text-align: center;
  display: grid;
  grid-template-rows: var(--stage) auto auto;
}

/* One shared stage height, then each character keeps its own scale within it.
   A glowfish the size of a fairy would be a lie about this world. */
.cast__member img {
  display: block;
  width: auto;
  height: var(--size);
  margin: 0 auto .9rem;
  object-fit: contain;
  align-self: end;
  filter: drop-shadow(0 1rem 1.6rem rgba(0,0,0,.55));
}
.cast__member { --stage: clamp(11rem, 26vh, 19rem); }
.cast { align-items: start; }
.cast__member:nth-child(1) img { --size: var(--stage); }               /* fairy  100% */
.cast__member:nth-child(2) img { --size: calc(var(--stage) * .82); }   /* dragon  82% */
.cast__member:nth-child(3) img { --size: calc(var(--stage) * .74); }   /* troll   74% */
.cast__member:nth-child(4) img { --size: calc(var(--stage) * .42); }   /* fish    42% */

.cast__member h3 {
  font-family: var(--display);
  font-size: 1.22rem; margin: 0 0 .4rem;
  color: var(--amber);
}

.cast__member p {
  margin: 0; font-size: .92rem; line-height: 1.5;
  color: var(--ink-soft);
  max-width: 26ch; margin-inline: auto;
}

/* ─── about ────────────────────────────────────────────── */

.page--about { justify-items: center; }

.colophon { max-width: 56ch; }

.colophon h2 {
  font-family: var(--display);
  font-size: clamp(1.9rem, 4.4vw, 3rem);
  margin: 0 0 var(--rhythm);
  color: var(--ink);
}

.colophon p { margin: 0 0 var(--rhythm); color: var(--ink-soft); }

.colophon__lead { font-size: 1.1em; color: var(--ink); }

.disclosure, .whereto {
  margin: calc(var(--rhythm) * 1.4) 0;
  padding: var(--rhythm);
  border-radius: .5rem;
  border: 1px solid rgba(240,181,78,.2);
  background: rgba(240,181,78,.05);
}
.whereto { border-color: rgba(168,129,232,.26); background: rgba(168,129,232,.06); }

.disclosure h3, .whereto h3 {
  font-family: var(--display); font-size: 1.1rem;
  margin: 0 0 .6rem; color: var(--amber);
}
.whereto h3 { color: var(--crystal); }
.disclosure p:last-child, .whereto p:last-child { margin-bottom: 0; }

.whereto__handle { color: var(--ink) !important; }
.whereto__handle strong { color: var(--crystal); letter-spacing: .01em; }

.colophon__nodata { font-size: .92rem; color: var(--ink-faint); }

.legal { display: flex; gap: 1.4rem; margin-top: var(--rhythm); }
.legal a {
  color: var(--ink-faint); font-size: .9rem;
  text-decoration-color: rgba(150,136,111,.4);
  text-underline-offset: .22em;
  padding: .4rem 0;
}
.legal a:hover, .legal a:focus-visible { color: var(--amber); }

/* ─── page turning controls ────────────────────────────── */

.controls {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(1rem, 3vw, 2rem);
  padding: clamp(.8rem, 1.6vw, 1.3rem);
  background: linear-gradient(to top, rgba(12,23,17,.94), rgba(12,23,17,0));
  pointer-events: none;
}
.controls > * { pointer-events: auto; }

.nav-btn {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  font-size: 1.3rem; line-height: 1;
  color: var(--night-deep); background: var(--amber);
  border: 0; border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 .5rem 1.4rem rgba(0,0,0,.45);
  transition: transform .18s, background .18s, opacity .18s;
}
.nav-btn:hover:not(:disabled) { background: #ffcf74; transform: translateY(-2px); }
.nav-btn:disabled { opacity: .3; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .nav-btn:hover:not(:disabled) { transform: none; }
}

.progress {
  margin: 0; min-width: 4.5rem; text-align: center;
  font-size: .9rem; letter-spacing: .14em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
#page-now { color: var(--amber); font-weight: 700; }

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

/* ─── narrow screens: a page is still a page ───────────── */

@media (max-width: 860px) {
  .page--story {
    grid-template-columns: 1fr;
    align-content: center;
    gap: clamp(1.2rem, 4vw, 2rem);
  }
  .still__no { position: static; transform: none; display: block; margin-bottom: .5rem; }
  .tale__text { max-width: none; }
  .cast { grid-template-columns: repeat(2, 1fr); gap: 1.2rem 1rem; }
  .cast__member { --stage: clamp(7rem, 18vh, 11rem); }
  .cast__member p { font-size: .84rem; }
  .page--cover { padding-bottom: clamp(7rem, 20vh, 11rem); }
  .cutout--fairy  { height: clamp(6.5rem, 20vh, 10rem); }
  .cutout--dragon { height: clamp(5rem, 15vh, 7.5rem); }
}

@media (max-width: 560px) {
  /* Keep the masthead on one line — a wrapping nav collides with the wordmark. */
  .masthead { gap: .3rem; padding-inline: .7rem; flex-wrap: nowrap; }
  .wordmark { font-size: 1rem; flex: 0 0 auto; }
  .masthead nav { flex-wrap: nowrap; }
  .masthead nav button {
    font-size: .64rem; letter-spacing: .04em;
    padding: .55rem .34rem; white-space: nowrap;
  }
  .cast__member p { display: none; }
  .cast__member { --stage: clamp(6rem, 15vh, 8.5rem); }
  /* Lift the characters clear of the page-turn buttons. */
  .cutouts { bottom: 4.6rem; padding-inline: .4rem; }
  .cutout--fairy  { height: clamp(5.5rem, 16vh, 8rem); }
  .cutout--dragon { height: clamp(4.2rem, 12vh, 6rem); }
  .page--cover { padding-bottom: clamp(11rem, 26vh, 14rem); }

  /* Five frames across a phone would be 68px each — nobody can read that.
     The strip becomes something you pull through instead. */
  .strip {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    gap: .35rem;
  }
  .strip::-webkit-scrollbar { display: none; }
  .strip li { flex: 0 0 42vw; scroll-snap-align: center; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .page { padding-block: 4rem 4.5rem; }
  .plate__title { font-size: clamp(3rem, 9vh, 5rem); }
}

/* ─── Sprachauswahl ────────────────────────────────────── */

.lang {
  display: flex;
  gap: .25rem;
}

.lang__btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-size: .8rem; font-weight: 500;
  color: var(--ink-soft);
  background: none; border: 1px solid transparent;
  padding: .45rem .6rem; border-radius: .5rem;
  cursor: pointer; min-height: 44px;
  transition: color .18s, background .18s, border-color .18s;
}
.lang__btn:hover { color: var(--amber); background: rgba(240,181,78,.1); }
.lang__btn[aria-pressed="true"] {
  color: var(--amber);
  border-color: rgba(240,181,78,.4);
  background: rgba(240,181,78,.1);
}
.lang__flag { font-size: 1.05rem; line-height: 1; }

@media (max-width: 560px) {
  /* Auf dem Handy nur die Flaggen — der Name bleibt für Vorleseprogramme da */
  .lang__name {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .lang__btn { padding: .45rem .4rem; }
  .lang { gap: .1rem; }
}

@media (max-width: 400px) {
  /* Auf sehr schmalen Geräten (iPhone SE) passt die Kopfzeile sonst nicht:
     Das Wortzeichen entfällt — die Marke steht groß auf der Titelseite,
     Navigation und Sprachwahl sind hier das Nützlichere. */
  .wordmark { display: none; }
  .masthead { justify-content: space-between; }
  .masthead nav button { font-size: .6rem; padding: .5rem .28rem; }
}
