/* ============ Grundlagen ============ */
:root {
  --paper: #f7f0e1;
  --paper-dark: #efe5d0;
  --ink: #3c332a;
  --ink-soft: #6b5d4d;
  --accent: #8c2f2f;
  --gold: #c8a24b;
  --leather: #35502f;
  --leather-dark: #24371f;
  --page-radius: 8px;
  --flip-time: 1.25s;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 244, 214, 0.10), transparent 60%),
    linear-gradient(180deg, #201a15 0%, #2b241d 55%, #1c1712 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.handwritten {
  font-family: "Caveat", "Comic Sans MS", cursive;
}

/* ============ Kopfbereich ============ */
.site-header {
  text-align: center;
  color: #e9dcc3;
  margin: 28px 0 8px;
}

.site-header h1 {
  font-weight: 500;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  margin: 0;
}

.site-header p {
  margin: 6px 0 0;
  font-style: italic;
  letter-spacing: 0.08em;
  color: #b7a888;
  font-size: 1rem;
}

/* ============ Bühne & Buch ============ */
.book-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 28px;
}

.book-wrap {
  perspective: 2600px;
  width: min(92vw, 1100px);
}

.book {
  position: relative;
  margin: 0 auto;
  height: min(72vh, 620px);
  aspect-ratio: 3 / 2;           /* zwei Seiten à 3:4 */
  max-width: 100%;
  transform-style: preserve-3d;
  transition: transform var(--flip-time) ease;
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.55));
}

.book.closed { transform: translateX(-25%); }

/* Buch nach links rücken, solange die Ausklapptafel offen ist */
.book.fold-open { transform: translateX(-16%); }

/* Buchrücken-Schatten unter allem */
.book::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 1%;
  bottom: 1%;
  width: 3px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
}

/* ============ Blätter ============ */
.sheet {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform var(--flip-time) cubic-bezier(0.645, 0.045, 0.355, 1);
}

.sheet.flipped { transform: rotateY(-180deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.5), transparent 55%),
    var(--paper);
  box-shadow: inset 0 0 60px rgba(160, 130, 80, 0.18);
}

.face.front {
  border-radius: 0 var(--page-radius) var(--page-radius) 0;
}
.face.front::after {          /* Falzschatten links */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 9%;
  background: linear-gradient(90deg, rgba(90, 60, 20, 0.22), transparent);
  pointer-events: none;
}

.face.back {
  transform: rotateY(180deg);
  border-radius: var(--page-radius) 0 0 var(--page-radius);
}
.face.back::after {           /* Falzschatten rechts */
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 9%;
  background: linear-gradient(-90deg, rgba(90, 60, 20, 0.22), transparent);
  pointer-events: none;
}

.page-inner {
  position: relative;
  height: 100%;
  padding: 7% 9%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

/* ============ Einband ============ */
.cover-front {
  background:
    radial-gradient(circle at 25% 15%, rgba(255, 255, 255, 0.12), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(0, 0, 0, 0.35), transparent 60%),
    linear-gradient(135deg, var(--leather), var(--leather-dark));
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.cover-border {
  position: absolute;
  inset: 6%;
  border: 2px solid rgba(200, 162, 75, 0.85);
  outline: 1px solid rgba(200, 162, 75, 0.35);
  outline-offset: 6px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.cover-ornament { font-size: 1.4rem; opacity: 0.9; }
.cover-ornament.flip { transform: rotate(180deg); }

.cover-title {
  font-size: clamp(3rem, 7vw, 4.6rem);
  font-weight: 500;
  letter-spacing: 0.32em;
  margin: 6px 0 0 0.32em;
  text-transform: uppercase;
}

.cover-years {
  margin: 2px 0 10px;
  letter-spacing: 0.35em;
  font-size: 1.05rem;
}

.cover-sub {
  margin: 0;
  font-style: italic;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: #d9c48b;
}

.cover-hint {
  position: absolute;
  bottom: 3.5%;
  width: 100%;
  text-align: center;
  margin: 0;
  color: rgba(233, 220, 195, 0.55);
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

/* ============ Vorsatz / Zitatseiten ============ */
.endpaper {
  background:
    repeating-linear-gradient(45deg, rgba(140, 47, 47, 0.05) 0 14px, transparent 14px 28px),
    var(--paper-dark);
}

.quote-page { gap: 18px; }

.big-quote {
  font-size: clamp(1.05rem, 1.9vw, 1.45rem);
  font-style: italic;
  line-height: 1.55;
  margin: 0;
  color: var(--ink);
  max-width: 34ch;
}

.big-quote.chinese {
  font-style: normal;
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  color: var(--ink-soft);
}

.quote-source {
  margin: -8px 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.quote-divider {
  color: var(--accent);
  font-size: 1.3rem;
  opacity: 0.75;
}

.closing-note {
  margin: 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.6;
}

/* ============ Titelseite ============ */
.small-caps {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.page-heading { margin-bottom: 6px; }

.oval-frame {
  width: clamp(120px, 46%, 210px);
  aspect-ratio: 4 / 5;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid #fff;
  outline: 1px solid rgba(120, 90, 40, 0.4);
  box-shadow: 0 10px 24px rgba(60, 40, 10, 0.35);
  margin: 8px 0;
}

.oval-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-name {
  margin: 4px 0 0;
  font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: 0.08em;
}

.title-dates {
  margin: 2px 0 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.title-note {
  margin: 8px 0 0;
  font-size: 1.35rem;
  color: var(--accent);
}

/* ============ Fotoseiten ============ */
.photo-page .page-inner { gap: 14px; }

.taped-photo {
  position: relative;
  margin: 0;
  width: 88%;
  background: #fff;
  padding: 3.5%;
  box-shadow: 0 12px 26px rgba(60, 40, 10, 0.35);
  transform: rotate(-1.2deg);
  cursor: zoom-in;
}

.taped-photo img {
  display: block;
  width: 100%;
  height: auto;
}

.tape {
  position: absolute;
  width: 78px;
  height: 26px;
  background: rgba(222, 205, 160, 0.75);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  z-index: 2;
}

.tape-tl { top: -12px; left: -22px; transform: rotate(-40deg); }
.tape-br { bottom: -12px; right: -22px; transform: rotate(-40deg); }
.tape-top { top: -13px; left: 50%; transform: translateX(-50%) rotate(-3deg); }

.caption {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
  color: var(--ink);
}

.caption-small {
  font-size: 1.1rem;
  color: var(--ink-soft);
}

/* ============ Polaroid-Seite ============ */
.polaroid-board {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.polaroid {
  position: absolute;
  margin: 0;
  width: 44%;
  background: #fdfdfa;
  padding: 4% 4% 2%;
  box-shadow: 0 10px 22px rgba(60, 40, 10, 0.35);
  cursor: zoom-in;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.polaroid:hover, .polaroid:focus-visible {
  transform: scale(1.06) rotate(0deg) !important;
  box-shadow: 0 16px 32px rgba(60, 40, 10, 0.45);
  z-index: 5;
}

.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.polaroid figcaption {
  text-align: center;
  font-size: 1.25rem;
  padding: 4px 0 2px;
  color: var(--ink);
}

.polaroid.p1 { top: 2%; left: 3%; transform: rotate(-5deg); }
.polaroid.p2 { top: 8%; right: 2%; transform: rotate(4deg); }
.polaroid.p3 { bottom: 2%; left: 26%; transform: rotate(-2deg); }

/* ============ Ausklappseite (Gatefold) ============ */
.gatefold-face { overflow: visible; }

.gatefold-inner { gap: 14px; }

.gatefold {
  position: relative;
  width: 92%;
  flex: 1;
  min-height: 0;
  transform-style: preserve-3d;
  perspective: 1800px;
}

.pano-under {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 24px rgba(60, 40, 10, 0.3);
}

.pano-under img,
.flap-open-face img {
  position: absolute;
  top: 0;
  height: 100%;
  width: 200%;
  object-fit: cover;
}

.pano-under img { left: 0; }

.flap {
  position: absolute;
  top: 0;
  left: 100%;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(-180deg);
  transition: transform 1.1s cubic-bezier(0.645, 0.045, 0.355, 1);
  cursor: pointer;
}

.gatefold.open .flap { transform: rotateY(0deg); }
.gatefold.open ~ .caption { opacity: 1; }

.flap-open-face,
.flap-closed-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.flap-open-face {
  background: #fff;
  box-shadow: 6px 10px 24px rgba(0, 0, 0, 0.35);
}

.flap-open-face img { left: -100%; }

.flap-closed-face {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.55), transparent 55%),
    var(--paper);
  box-shadow: inset 0 0 40px rgba(160, 130, 80, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.flap-teaser {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10%;
}

.flap-teaser img {
  width: 62%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 8px 18px rgba(60, 40, 10, 0.35);
  transform: rotate(2deg);
}

.flap-teaser .handwritten {
  margin: 0;
  font-size: 1.5rem;
}

.fold-hint {
  margin: 0;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* ============ Briefseite / Umschlag ============ */
.letter-page .page-inner { gap: 12px; }

.envelope-area {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.envelope {
  position: relative;
  width: min(78%, 320px);
  aspect-ratio: 8 / 5;
  cursor: pointer;
  transform: rotate(-2deg);
  filter: drop-shadow(0 12px 20px rgba(60, 40, 10, 0.35));
  outline: none;
}

.env-back {
  position: absolute;
  inset: 0;
  background: #e8dbc0;
  border-radius: 4px;
}

.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 52%;
  background: linear-gradient(180deg, #dfd0b0, #d4c29d);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s cubic-bezier(0.645, 0.045, 0.355, 1);
  z-index: 4;
  border-radius: 4px 4px 0 0;
}

.envelope.open .env-flap {
  transform: rotateX(180deg);
  z-index: 1;
  transition-delay: 0s;
}

.env-front {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(200deg, rgba(255, 255, 255, 0.35), transparent 45%),
    #efe3c8;
  clip-path: polygon(0 0, 50% 46%, 100% 0, 100% 100%, 0 100%);
  border-radius: 4px;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.env-address {
  margin: 0 0 14%;
  font-size: 1.7rem;
  color: var(--ink);
}

.env-stamp {
  position: absolute;
  top: 54%;
  right: 6%;
  width: 34px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--accent);
  font-size: 1.1rem;
  border: 1px dashed rgba(140, 47, 47, 0.6);
  transform: rotate(4deg);
}

.env-letter {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 8%;
  height: 84%;
  background: #fffdf6;
  border: 1px solid rgba(120, 90, 40, 0.25);
  box-shadow: 0 4px 14px rgba(60, 40, 10, 0.25);
  z-index: 2;
  padding: 10px 12px;
  text-align: left;
  transform: translateY(6%);
  transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1) 0.15s;
  cursor: pointer;
  overflow: hidden;
}

.envelope.open .env-letter { transform: translateY(-58%); }

.env-letter-line {
  margin: 0 0 4px;
  font-family: "Caveat", cursive;
  font-size: 1.15rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.env-letter-line.small {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.env-letter-more {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.8rem;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--accent);
  border-bottom: 1px solid rgba(140, 47, 47, 0.5);
}

.env-caption { font-size: 1.3rem; }

.page-hint {
  margin: 0;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-soft);
  opacity: 0.85;
}

/* ============ Traueranzeige ============ */
.memorial-page .page-inner { gap: 12px; }

.framed-notice {
  margin: 0;
  width: 74%;
  max-height: 72%;
  background: #fff;
  padding: 10px;
  border: 1px solid #2b2b2b;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  cursor: zoom-in;
  overflow: hidden;
}

.framed-notice img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============ Navigation ============ */
.book-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 30px;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(233, 220, 195, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: #e9dcc3;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.15s ease;
}

.nav-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); transform: scale(1.06); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

.dots { display: flex; gap: 10px; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(233, 220, 195, 0.6);
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
}

.dot.active { background: var(--gold); border-color: var(--gold); transform: scale(1.25); }

.key-hint {
  margin: 12px 0 0;
  color: rgba(233, 220, 195, 0.45);
  font-style: italic;
  font-size: 0.85rem;
  text-align: center;
}

/* ============ Overlays ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay[hidden] { display: none; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 9, 0.78);
  backdrop-filter: blur(3px);
}

.overlay-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(60, 51, 42, 0.1);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.overlay-close:hover { background: rgba(60, 51, 42, 0.22); }

.letter-sheet {
  position: relative;
  width: min(680px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(120, 90, 40, 0.08) 31px 32px),
    #fffdf4;
  padding: clamp(28px, 5vw, 56px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  animation: letter-in 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  font-size: clamp(1.02rem, 1.6vw, 1.18rem);
  line-height: 1.7;
}

@keyframes letter-in {
  from { transform: translateY(60px) rotate(1.5deg); opacity: 0; }
  to   { transform: translateY(0) rotate(0); opacity: 1; }
}

.letter-sheet p { margin: 0 0 1em; }

.letter-place {
  text-align: right;
  font-style: italic;
  color: var(--ink-soft);
}

.letter-salute { font-size: 1.9rem; margin-bottom: 0.6em !important; }

.letter-sign {
  font-size: 1.7rem;
  margin-top: 1.4em !important;
  line-height: 1.3;
}

.lightbox-frame {
  position: relative;
  margin: 0;
  max-width: min(900px, 94vw);
  max-height: 88vh;
  background: #fff;
  padding: 16px 16px 8px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
  animation: letter-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
}

.lightbox-frame img {
  max-width: 100%;
  max-height: calc(88vh - 90px);
  object-fit: contain;
}

.lightbox-frame figcaption {
  text-align: center;
  font-size: 1.35rem;
  padding: 8px 0 4px;
}

/* ============ Kleine Bildschirme ============ */
@media (max-width: 720px) {
  .book { height: min(58vh, 480px); }
  .site-header h1 { letter-spacing: 0.2em; }
  .key-hint { display: none; }
}
