/* ---------- Tokens ---------- */
:root {
  --bg: #F2ECE1;
  --bg-deep: #E8DFD0;
  --sheet: #FCF9F3;
  --ink: #2A211C;
  --ink-soft: #6A5C50;
  --ink-faint: #9A8B7D;
  --accent: #A8322D;
  --accent-deep: #82231F;
  --gold: #B08A4E;
  --line: rgba(42, 33, 28, .12);

  /* Briefpapier-Farben */
  --c-kraft: #C9A47A;
  --c-rose: #E4C6BC;
  --c-sage: #B4BDA2;
  --c-cream: #F1E7D6;
  --c-red: #A8322D;
  --c-ink: #3B4757;
  --c-plum: #6E3B45;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-ui: cubic-bezier(0.2, 0.8, 0.2, 1);

  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .16 0 0 0 0 .12 0 0 0 0 .09 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--grain), radial-gradient(120% 80% at 50% 0%, #F7F2E9 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

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

/* ---------- Vorschau-Leiste ---------- */
.preview-bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: var(--bg);
  font-size: 14px; text-align: center;
  padding: 10px 16px;
}
.preview-bar a { color: #F3C9A9; }

/* ---------- Seite ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) clamp(20px, 4vw, 48px) 64px;
}

.masthead { max-width: 640px; margin-bottom: clamp(40px, 7vh, 72px); }

.eyebrow {
  margin: 0 0 14px;
  font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}

.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 340;
  font-size: clamp(52px, 9vw, 104px);
  line-height: .95;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144, "SOFT" 50;
}
.title span { font-style: italic; color: var(--accent); font-weight: 400; }

.lede {
  margin: 22px 0 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2.2vw, 22px);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 34ch;
  font-variation-settings: "opsz" 24;
}

.status {
  margin: 18px 0 0;
  font-size: 15px;
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 10px;
}
.status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}
.status:empty { display: none; }

/* ---------- Briefe-Brett ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-flow: dense;
  gap: clamp(22px, 3vw, 38px) clamp(16px, 2.4vw, 30px);
  padding-top: 12px;
}

.env {
  --c: var(--c-kraft);
  --tilt: 0deg;
  position: relative;
  aspect-ratio: 4 / 3;
  border: 0; padding: 0; margin: 0;
  background: none;
  cursor: pointer;
  container-type: inline-size;
  transform: rotate(var(--tilt));
  transition: transform .24s var(--ease-ui);
  perspective: 900px;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  animation: drop .7s var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}
.env--wide { grid-column: span 2; aspect-ratio: auto; }
.env--big  { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }

@keyframes drop {
  from { opacity: 0; transform: rotate(var(--tilt)) translateY(10px); }
  to   { opacity: 1; transform: rotate(var(--tilt)); }
}

.env:hover { transform: rotate(var(--tilt)) translateY(-3px); }
.env:active { transform: rotate(var(--tilt)) scale(.985); }
.env.is-shaking { animation: shake .42s var(--ease-ui); opacity: 1; }
@keyframes shake {
  0%, 100% { transform: rotate(var(--tilt)); }
  25% { transform: rotate(calc(var(--tilt) - 2.2deg)); }
  60% { transform: rotate(calc(var(--tilt) + 1.6deg)); }
}

.env__back, .env__front, .env__flap, .env__letter { position: absolute; display: block; }

.env__back {
  inset: 0; border-radius: 3px;
  background: color-mix(in oklab, var(--c) 78%, #2a160c);
  box-shadow:
    0 1px 2px rgba(60, 38, 20, .18),
    0 12px 22px -14px rgba(60, 38, 20, .55);
}

.env__letter {
  left: 7%; right: 7%; top: 7%; bottom: 8%;
  z-index: 1;
  background:
    repeating-linear-gradient(to bottom, transparent 0 13px, rgba(42,33,28,.07) 13px 14px) 0 22px / 100% calc(100% - 30px) no-repeat,
    var(--sheet);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  transition: transform .6s var(--ease-out) .18s;
}

.env__front {
  inset: 0; z-index: 2; border-radius: 3px;
  background-color: var(--c);
  background-image: var(--grain), linear-gradient(170deg, rgba(255,255,255,.14), rgba(0,0,0,.04));
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}

.env__flap {
  left: 0; right: 0; top: 0; height: 58%;
  z-index: 3;
  background-color: color-mix(in oklab, var(--c) 90%, #2a160c);
  background-image: var(--grain);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .55s var(--ease-out), z-index 0s linear .2s;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.12));
}

.env__seal {
  position: absolute; z-index: 4;
  left: 50%; top: 58%;
  width: clamp(16px, 11cqi, 38px); aspect-ratio: 1;
  translate: -50% -55%;
  border-radius: 46% 54% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 34% 30%, #D2645A 0%, #A8322D 45%, #7A1E1A 100%);
  box-shadow: inset 0 0 0 2px rgba(122, 30, 26, .55), 0 2px 3px rgba(60, 20, 10, .35);
  transition: opacity .25s, transform .35s var(--ease-out);
}
.env__seal::after {
  content: ""; position: absolute; inset: 26%;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 210, .35);
}

.env--locked .env__seal { display: none; }

.env__stamp {
  --s: clamp(30px, 24cqi, 92px);
  position: absolute; z-index: 4;
  right: 7%; bottom: 10%;
  width: var(--s); aspect-ratio: 5 / 6;
  padding: 5px;
  background: #FBF6EC;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 2.3px, #0000 96%, #000) -3.5px -3.5px / 7px 7px;
          mask:
    linear-gradient(#000 0 0) content-box,
    radial-gradient(circle 2.3px, #0000 96%, #000) -3.5px -3.5px / 7px 7px;
  rotate: 2deg;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}
.env__stamp span {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border: 1px solid color-mix(in oklab, var(--stamp, var(--accent)) 55%, transparent);
  font-family: var(--serif);
  font-weight: 500;
  font-size: calc(var(--s) * .46);
  line-height: 1;
  color: var(--stamp, var(--accent));
  font-variation-settings: "opsz" 72;
  font-feature-settings: "lnum";
}

.env__label {
  position: absolute; z-index: 4;
  left: 8%; bottom: 11%;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(18px, 9cqi, 46px);
  line-height: 1;
  color: #F7E8D8;
  font-variation-settings: "opsz" 144;
}
.env__label small {
  display: block; margin-bottom: 6px;
  font-family: var(--sans); font-style: normal;
  font-size: clamp(10px, 2.6cqi, 13px);
  letter-spacing: .16em; text-transform: uppercase; opacity: .75;
}

.env__today {
  position: absolute; z-index: 5;
  left: -6px; top: -12px;
  padding: 3px 9px 4px;
  background: var(--ink); color: var(--bg);
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  border-radius: 2px;
  rotate: -4deg;
}

/* geöffnet */
.env.is-open .env__flap { transform: rotateX(180deg); z-index: 0; }
.env.is-open .env__letter { transform: translateY(-26%); }
.env.is-open .env__seal { opacity: 0; transform: scale(.6); }

/* ---------- Brief (Dialog) ---------- */
.letter {
  border: 0; padding: 0; margin: auto;
  background: transparent;
  width: min(660px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow: visible;
}
.letter::backdrop {
  background: rgba(36, 26, 20, .52);
  backdrop-filter: blur(3px);
}
.letter[open] .letter__paper { animation: rise .6s var(--ease-out); }
.letter[open]::backdrop { animation: fade .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(28px) rotate(.6deg); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.letter__paper {
  position: relative;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: var(--sheet);
  background-image: var(--grain);
  border-radius: 3px;
  padding: clamp(36px, 6vw, 64px) clamp(24px, 6vw, 64px) clamp(36px, 5vw, 56px);
  box-shadow: 0 30px 60px -20px rgba(30, 18, 10, .5), 0 2px 4px rgba(30, 18, 10, .12);
}

.letter__close {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
  transition: background .2s var(--ease-ui), color .2s;
}
.letter__close:hover { background: rgba(42, 33, 28, .07); color: var(--ink); }

.l-date {
  margin: 0 0 10px;
  font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
.l-title {
  margin: 0 0 26px;
  font-family: var(--serif); font-weight: 380;
  font-size: clamp(32px, 5vw, 44px); line-height: 1.08;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}
.l-text p {
  margin: 0 0 1em;
  font-family: var(--serif);
  font-size: 19px; line-height: 1.6;
  font-variation-settings: "opsz" 18;
  max-width: 60ch;
}
.letter mark {
  background: #F6E3A6; color: inherit; padding: 0 3px; border-radius: 2px;
}
.l-sign {
  margin: 28px 0 0;
  font-family: var(--serif); font-style: italic;
  font-size: 24px; color: var(--accent);
}

.l-block { margin: 30px 0; }
.l-block:last-child { margin-bottom: 0; }

/* Polaroids */
.polaroids {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.polaroids--single { grid-template-columns: 1fr; max-width: 440px; margin-inline: auto; }
.polaroid {
  margin: 0;
  background: #fff;
  padding: 10px 10px 0;
  box-shadow: 0 10px 20px -12px rgba(40, 25, 15, .5), 0 1px 2px rgba(40, 25, 15, .15);
  rotate: var(--r, 0deg);
}
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #EEE6DA; }
.polaroid figcaption {
  min-height: 38px; padding: 8px 2px 10px;
  font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink-soft);
  text-align: center;
}

.media { display: block; width: 100%; border-radius: 4px; background: #1d1612; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; background: #1d1612; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.audio {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(255, 255, 255, .5);
}
.audio__btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: var(--accent); color: #FBF3E8;
  display: grid; place-items: center; cursor: pointer;
  transition: transform .2s var(--ease-ui), background .2s;
}
.audio__btn:hover { background: var(--accent-deep); }
.audio__btn:active { transform: scale(.96); }
.audio__meta { flex: 1; min-width: 0; }
.audio__label { font-family: var(--serif); font-style: italic; font-size: 18px; }
.audio__bar { margin-top: 8px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.audio__bar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }

.l-list { margin: 0; padding: 0; list-style: none; counter-reset: li; }
.l-list li {
  counter-increment: li;
  display: grid; grid-template-columns: 2.4em 1fr; gap: 6px;
  padding: 12px 0; border-top: 1px solid var(--line);
  font-family: var(--serif); font-size: 18px; line-height: 1.5;
}
.l-list li:last-child { border-bottom: 1px solid var(--line); }
.l-list li::before {
  content: counter(li, decimal-leading-zero);
  font-family: var(--sans); font-size: 13px; color: var(--accent); padding-top: 5px; font-weight: 600;
}

.l-link {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  background: var(--ink); color: var(--bg);
  border-radius: 999px; text-decoration: none; font-weight: 500;
  transition: transform .2s var(--ease-ui), background .2s;
}
.l-link:hover { background: #000; transform: translateY(-1px); }

/* Gutschein */
.voucher {
  position: relative;
  display: grid; grid-template-columns: auto 1fr;
  background-color: var(--accent);
  background-image: var(--grain);
  color: #FBF1E4;
  border-radius: 6px;
  -webkit-mask:
    radial-gradient(circle 12px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 12px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
          mask:
    radial-gradient(circle 12px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 12px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
}
.voucher__side {
  writing-mode: vertical-rl; rotate: 180deg;
  padding: 22px 16px;
  font-size: 12px; letter-spacing: .3em; text-transform: uppercase; font-weight: 600;
  border-left: 1.5px dashed rgba(251, 241, 228, .45);
  text-align: center;
}
.voucher__main { padding: 26px 28px 24px; }
.voucher__title {
  margin: 0 0 8px;
  font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.1;
  font-variation-settings: "opsz" 144;
}
.voucher__text { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.5; opacity: .92; }
.voucher__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; font-size: 13px; opacity: .9; }
.voucher__btn {
  border: 1px solid rgba(251, 241, 228, .7); background: transparent; color: inherit;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background .2s;
}
.voucher__btn:hover { background: rgba(251, 241, 228, .14); }
.voucher__used {
  font-family: var(--serif); font-style: italic; font-size: 16px;
  border: 1.5px solid currentColor; padding: 4px 12px; border-radius: 3px; rotate: -3deg;
}

/* Quiz */
.quiz__q { margin: 0 0 22px; }
.quiz__q h3 { margin: 0 0 10px; font-family: var(--serif); font-weight: 500; font-size: 20px; }
.quiz__opts { display: flex; flex-wrap: wrap; gap: 8px; }
.quiz__opt {
  border: 1px solid var(--line); background: rgba(255,255,255,.6);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 15px;
  transition: border-color .2s, background .2s;
}
.quiz__opt:hover:not(:disabled) { border-color: var(--ink-soft); }
.quiz__opt:disabled { cursor: default; }
.quiz__opt.is-right { background: #DCE5CC; border-color: #7D8F63; }
.quiz__opt.is-wrong { background: #F0D3CD; border-color: #B5675C; text-decoration: line-through; }
.quiz__result { font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--accent); min-height: 1.5em; }

.missing {
  display: grid; place-items: center; text-align: center;
  min-height: 140px; padding: 18px;
  border: 1.5px dashed #C9B394; border-radius: 4px;
  background: #FBF3DF; color: #7A6447; font-size: 14px;
}
.missing code { font-size: 13px; background: rgba(0,0,0,.05); padding: 2px 6px; border-radius: 3px; }

/* ---------- Footer & Toast ---------- */
.foot {
  margin-top: clamp(64px, 10vh, 112px);
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--serif); font-style: italic; font-size: 18px;
  color: var(--ink-soft);
}
.foot p { margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  translate: -50% 0;
  max-width: calc(100vw - 32px);
  padding: 14px 20px;
  background: var(--ink); color: var(--bg);
  border-radius: 8px;
  font-size: 15px; line-height: 1.4;
  box-shadow: 0 14px 30px -12px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(12px);
  pointer-events: none;
  transition: opacity .25s var(--ease-ui), transform .3s var(--ease-out);
}
.toast.is-on { opacity: 1; transform: none; }

/* ---------- Responsiv ---------- */
@media (max-width: 900px) {
  .board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  .board { gap: 22px 14px; }
  .env__today { font-size: 10px; padding: 2px 7px 3px; }
  .voucher__main { padding: 22px 20px 20px; }
  .voucher__title { font-size: 26px; }
  .l-text p { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .env { animation: none; opacity: 1; }
  .env, .env__flap, .env__letter, .env__seal { transition-duration: .01ms; transition-delay: 0s; }
  .env.is-shaking { animation: none; }
  .letter[open] .letter__paper { animation: fade .2s ease; }
  .toast { transform: none; }
}
