/* ============ Princess Castle ============ */
:root {
  color-scheme: light;
  --ink: #321714;
  --ink-soft: #4a2c27;
  --paper: #fcfbf8;
  --table: #d8cdbd;
  --table-dark: #b9ab97;
  --env: #efe6d6;
  --env-shade: #e3d7c2;
  --env-dark: #d6c7ae;
  --wax: #6e1a22;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --script: "Pinyon Script", "Snell Roundhand", cursive;

  /* feine Papierstruktur */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .2  0 0 0 0 .15  0 0 0 .06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 35%, #e6ddcf 0%, var(--table) 55%, var(--table-dark) 100%) fixed;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: var(--grain);
  pointer-events: none;
  opacity: .9;
}
body.intro { overflow: hidden; }

/* ============ Szene / Umschlag ============ */
.scene {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity .7s ease, transform .7s ease;
}

.card-wrap {
  width: min(88vw, 620px);
  perspective: 1600px;
  transition: transform 1s cubic-bezier(.5, 0, .2, 1);
}

.card {
  all: unset;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 752;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(.45, .05, .2, 1);
  transform: rotateX(8deg) rotateZ(-2deg);
  animation: float 6s ease-in-out infinite;
}
.card:hover { transform: rotateX(4deg) rotateZ(-1deg) translateY(-6px); }
.card:focus-visible { outline: 2px solid var(--wax); outline-offset: 10px; }

@keyframes float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -8px; }
}

.face {
  position: absolute;
  inset: 0;
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.front {
  background: #f4ecdc;
  padding: 2.2%;
  box-shadow: 0 18px 40px rgba(50, 23, 20, .35), 0 2px 6px rgba(50, 23, 20, .25);
}
.front img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(.15) contrast(1.02);
}

.back {
  transform: rotateY(180deg);
  background: var(--env-dark);
  box-shadow: 0 18px 40px rgba(50, 23, 20, .35), 0 2px 6px rgba(50, 23, 20, .25);
}

.env-inside {
  position: absolute; inset: 0;
  background: linear-gradient(#c9b89c, #d9cbb3 60%);
}

/* Der Brief im Umschlag */
.letter {
  position: absolute;
  left: 5%; right: 5%;
  top: 5%; height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4% 8%;
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: 0 2px 8px rgba(50, 23, 20, .18);
  z-index: 1;
  transition: transform 1s cubic-bezier(.3, .1, .2, 1);
}
.letter img { width: 72%; height: auto; }
.letter .lines { display: flex; flex-direction: column; gap: 7px; width: 100%; margin-top: 6%; }
.letter .lines i {
  display: block; height: 2px;
  background: rgba(50, 23, 20, .18);
}
.letter .lines i:nth-child(3n) { width: 82%; }

.pocket-sides,
.pocket-bottom {
  position: absolute; inset: 0;
  z-index: 2;
}
.pocket-sides {
  background: linear-gradient(90deg, var(--env-shade), var(--env) 30%, var(--env) 70%, var(--env-shade));
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.pocket-bottom {
  background: linear-gradient(to top, var(--env) 50%, #f6efe3);
  clip-path: polygon(0 100%, 50% 44%, 100% 100%);
  filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, .12));
}

.flap {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 58%;
  z-index: 3;
  background: linear-gradient(to bottom, #f3ebdd, var(--env-shade));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transform: perspective(900px) rotateX(0deg);
  transition: transform .8s cubic-bezier(.4, 0, .2, 1), background .8s;
}

.seal {
  position: absolute;
  left: 50%; top: 58%;
  width: 15%;
  aspect-ratio: 1;
  translate: -50% -50%;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #9a2b35, var(--wax) 55%, #4a0f15);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .35), inset 0 0 0 4px rgba(0, 0, 0, .12), inset 0 0 0 7px rgba(255, 255, 255, .06);
  transition: opacity .4s ease, scale .4s ease;
}
.seal span {
  font-family: var(--script);
  font-size: clamp(14px, 3.6vw, 26px);
  color: rgba(255, 220, 210, .55);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .4);
  translate: 0 4%;
}

.hint {
  margin: 34px 0 0;
  font-size: 13px;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--ink-soft);
  animation: pulse 2.8s ease-in-out infinite;
  transition: opacity .4s;
}
@keyframes pulse { 50% { opacity: .45; } }

/* ---- Ablauf ---- */
.scene.flipped .card,
.scene.flipped .card:hover { transform: rotateY(180deg); animation: none; }
.scene.flipped .hint { opacity: 0; }
.scene.unsealed .seal { opacity: 0; scale: 1.4; }
.scene.unsealed .flap { transform: perspective(900px) rotateX(180deg); background: linear-gradient(to bottom, #e2d4bc, #d3c2a6); }
.scene.flap-behind .flap { z-index: 0; }
.scene.rising .card-wrap { transform: translateY(22%); }
.scene.rising .letter { transform: translateY(-62%); }
.scene.leaving { opacity: 0; transform: scale(1.06); }

/* ============ Der Brief (Seite) ============ */
.page {
  position: relative;
  padding: clamp(16px, 5vw, 64px) 16px 48px;
  animation: page-in 1s cubic-bezier(.2, .7, .2, 1) both;
}
.page[hidden],
.scene[hidden] { display: none; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(60px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.sheet {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) clamp(20px, 6vw, 80px) clamp(28px, 4vw, 48px);
  background: var(--paper);
  background-image: var(--grain);
  box-shadow: 0 30px 60px rgba(50, 23, 20, .28), 0 3px 10px rgba(50, 23, 20, .16);
}

.letterhead { text-align: center; }
.letterhead h1 { margin: 0; }
.letterhead img {
  display: block;
  width: min(100%, 680px);
  height: auto;
  margin: 0 auto;
}

.spaced {
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: .38em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink);
}
.letterhead .spaced { margin: 14px 0 clamp(28px, 4vw, 44px); }

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(28px, 4vw, 52px);
}

.columns p {
  margin: 0 0 .75em;
  font-size: clamp(15px, 1.55vw, 16.5px);
  line-height: 1.5;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.caps {
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.caps-plain { letter-spacing: .02em; }

h2 {
  margin: 1.1em 0 .35em;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(26px, 2.7vw, 30px);
  line-height: 1.15;
  color: var(--ink);
}
.columns section > h2:first-child { margin-top: 0; }

blockquote {
  margin: 1.4em 0 0;
  padding: 0 4%;
  font-family: var(--script);
  font-size: clamp(24px, 2.6vw, 28px);
  line-height: 1.3;
  text-align: center;
}

.foot { margin: clamp(32px, 5vw, 56px) 0 0; }
.foot a { color: inherit; text-decoration: none; border-bottom: 1px solid rgba(50, 23, 20, .25); }
.foot a:hover { border-bottom-color: var(--ink); }

.replay {
  display: block;
  margin: 28px auto 0;
  padding: 10px 18px;
  border: 1px solid rgba(50, 23, 20, .3);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
}
.replay:hover { background: rgba(255, 255, 255, .3); }

/* ============ Mobil ============ */
@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .columns section + section { margin-top: .5em; }
  .columns section + section > h2:first-child { margin-top: 1.1em; }
  .spaced { letter-spacing: .24em; }
}

/* ============ weniger Bewegung ============ */
@media (prefers-reduced-motion: reduce) {
  .card, .hint { animation: none; }
  .card, .card-wrap, .letter, .flap, .seal, .scene { transition-duration: .01s; }
  .page { animation-duration: .3s; }
}
