:root {
  --cream: #f4e9d8;
  --cream-2: #efe3cf;
  --paper: #ece0ca;
  --paper-shade: #dcc9ab;
  --rose: #d98c86;
  --rose-deep: #c4674f;
  --sage: #a8b89a;
  --sage-deep: #7f9272;
  --ink: #382a24;
  --ink-soft: #6c5648;
  --gold: #c9a44c;
  --sky: #cbdde0;
  --shadow: rgba(74, 52, 36, 0.28);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 15% -10%, #f8efe1 0%, transparent 60%),
    radial-gradient(900px 600px at 95% 10%, #e7d6bd 0%, transparent 55%),
    linear-gradient(160deg, var(--cream) 0%, var(--cream-2) 60%, #e6d5bd 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* бумажное зерно */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 92, 60, 0.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(120, 92, 60, 0.04) 0 1px, transparent 1px 5px),
    radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(96, 70, 44, 0.16) 100%);
}

/* ------------------------------------------------------------------ обложка */

.cover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  perspective: 1400px;
  transition: opacity 0.7s ease, visibility 0.7s;
}

body.opened .cover {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.cover__shadow {
  position: absolute;
  width: min(78vw, 520px);
  height: min(70vh, 460px);
  border-radius: 26px;
  background: radial-gradient(closest-side, rgba(74, 52, 36, 0.35), transparent 70%);
  filter: blur(18px);
  transform: translateY(28px) rotate(-1deg);
}

.cover__card {
  position: relative;
  width: min(92vw, 560px);
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(170deg, #f7eddc, #e8d8bd);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 0 0 1px rgba(120, 92, 60, 0.18),
    0 26px 50px -28px rgba(74, 52, 36, 0.55),
    0 3px 0 #d6c2a1;
  transform: rotate(-0.6deg);
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cover__card:hover { transform: rotate(0deg) translateY(-3px); }

.cover__frame {
  position: relative;
  border: 1.5px dashed rgba(160, 120, 74, 0.45);
  border-radius: 16px;
  padding: 30px 26px 26px;
  text-align: center;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, #f6ecda, #eddfc7);
}

.cover__eyebrow,
.eyebrow {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cover__title {
  font-size: clamp(46px, 12vw, 64px);
  line-height: 1;
  margin: 14px 0 12px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cover__hint {
  margin: 0 auto 22px;
  max-width: 30ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.cover__foot {
  display: block;
  margin-top: 18px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(108, 86, 72, 0.75);
}

/* сургучная печать-кнопка */
.seal {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 0 auto;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff6ea;
  background: radial-gradient(circle at 34% 28%, #d97a63, #b5533f 62%, #94402f 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 0 0 3px rgba(255, 246, 234, 0.35),
    0 14px 22px -14px rgba(120, 50, 34, 0.85);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.seal:hover { transform: translateY(-2px) scale(1.02); }
.seal:active { transform: translateY(1px) scale(0.99); }

.seal__ring {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 226, 0.55);
}

.seal__text {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------- сцена */

.scene {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 44px 18px 96px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease 0.15s, transform 0.9s cubic-bezier(0.2, 0.9, 0.2, 1) 0.1s;
}

body.opened .scene {
  opacity: 1;
  transform: none;
}

.masthead { text-align: center; }

.title {
  margin: 10px 0 8px;
  font-size: clamp(34px, 8vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.lede {
  margin: 0 auto;
  max-width: 44ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.thread {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 4px;
}

.thread span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: thread-bob 3.6s ease-in-out infinite;
}

.thread span:nth-child(2) { animation-delay: 0.2s; background: var(--gold); }
.thread span:nth-child(3) { animation-delay: 0.4s; }
.thread span:nth-child(4) { animation-delay: 0.6s; background: var(--gold); }
.thread span:nth-child(5) { animation-delay: 0.8s; }

@keyframes thread-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ---------------------------------------------------------------- диорама */

.diorama {
  position: relative;
  margin: 30px 0 8px;
  padding: 26px 14px 34px;
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(80% 60% at 50% 0%, #e9f1f0 0%, transparent 70%),
    linear-gradient(180deg, #dfeaea 0%, #efe4cf 44%, #e7d6bb 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 0 0 1px rgba(120, 92, 60, 0.16),
    0 30px 50px -34px rgba(74, 52, 36, 0.6);
}

.paper-sun {
  position: absolute;
  top: 8%;
  right: 8%;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, #f6d98a, #e3b45c 70%, #c9944a);
  box-shadow: 0 0 0 12px rgba(233, 196, 120, 0.18), 0 14px 24px -14px rgba(148, 108, 44, 0.6);
  opacity: 0.9;
}

.cloud {
  position: absolute;
  height: 34px;
  border-radius: 999px;
  background: #f7f1e6;
  box-shadow: 0 10px 18px -14px rgba(74, 52, 36, 0.6), 0 1px 0 #fff inset;
  opacity: 0.85;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before { width: 44px; height: 44px; left: 18px; top: -20px; }
.cloud::after { width: 30px; height: 30px; left: 58px; top: -12px; }

.cloud--1 { width: 140px; top: 15%; left: 6%; animation: drift 26s linear infinite; }
.cloud--2 { width: 108px; top: 26%; right: 22%; animation: drift 34s linear infinite reverse; }

@keyframes drift {
  0% { transform: translateX(-10px); }
  50% { transform: translateX(16px); }
  100% { transform: translateX(-10px); }
}

.hill {
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.hill--far {
  height: 44%;
  background: linear-gradient(180deg, #b9c9ad, #a2b596);
  opacity: 0.55;
  bottom: 18%;
}

.hill--mid {
  height: 38%;
  background: linear-gradient(180deg, #a8b89a, #93a684);
  opacity: 0.8;
  bottom: 8%;
}

.hill--near {
  height: 30%;
  background: linear-gradient(180deg, #95a684, #7f9272);
  bottom: 0;
}

/* фотографии-карточки */
.gallery {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 86px;
  max-width: 900px;
  margin-inline: auto;
}

.photo {
  position: relative;
  margin: 0;
  padding: 10px 10px 30px;
  background: linear-gradient(180deg, #fbf5ea, #f2e7d4);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(120, 92, 60, 0.18),
    0 16px 26px -18px rgba(74, 52, 36, 0.7),
    0 3px 0 rgba(214, 194, 161, 0.9);
  transform: rotate(var(--r, 0deg));
  cursor: zoom-in;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.2, 1), box-shadow 0.35s ease;
  opacity: 0;
  translate: 0 26px;
}

body.opened .photo {
  animation: rise 0.85s cubic-bezier(0.18, 1.34, 0.34, 1) forwards;
  animation-delay: calc(0.22s + var(--i) * 0.09s);
}

@keyframes rise {
  0% { opacity: 0; translate: 0 30px; }
  70% { opacity: 1; translate: 0 -4px; }
  100% { opacity: 1; translate: 0 0; }
}

.photo:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(120, 92, 60, 0.24),
    0 26px 36px -22px rgba(74, 52, 36, 0.75);
}

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 3px;
  filter: saturate(0.92) contrast(0.98) sepia(0.06);
  background: #e3d6c1;
}

.photo figcaption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  text-align: center;
  font-size: 13px;
  line-height: 1.2;
  color: #6a5341;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo { padding-bottom: 10px; }

.photo--captioned { padding-bottom: 30px; }

.subhead {
  position: relative;
  z-index: 3;
  margin: 38px 0 4px;
  text-align: center;
  font-size: clamp(20px, 4.4vw, 26px);
  font-style: italic;
  color: #6b5342;
}

.gallery--more { margin-top: 18px; }

.gallery--more .photo img { aspect-ratio: 1 / 1; }

.photo--wide { grid-column: span 2; }
.photo--wide img { aspect-ratio: 16 / 10; }

/* сердечки-конфетти */
.hearts { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

.heart {
  position: absolute;
  bottom: 18%;
  left: calc(8% + var(--i) * 19%);
  width: 16px;
  height: 16px;
  background: var(--rose);
  transform: rotate(45deg);
  border-radius: 3px 0 3px 0;
  opacity: 0;
  box-shadow: 0 3px 6px -4px rgba(120, 50, 34, 0.8);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: inherit;
}

.heart::before { left: -8px; top: 0; }
.heart::after { top: -8px; left: 0; }

body.opened .heart {
  animation: float-up 7s ease-in infinite;
  animation-delay: calc(1.2s + var(--i) * 0.8s);
}

@keyframes float-up {
  0% { opacity: 0; translate: 0 0; }
  12% { opacity: 0.9; }
  100% { opacity: 0; translate: 0 -280px; }
}

/* ------------------------------------------------------------------ письмо */

.sheet {
  position: relative;
  margin: 26px 0 0;
  padding: 34px 28px;
  border-radius: 18px;
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(196, 103, 79, 0.12) 31px 32px),
    linear-gradient(180deg, #fbf4e6, #f1e5d0);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(120, 92, 60, 0.16),
    0 26px 44px -32px rgba(74, 52, 36, 0.6);
  transform: rotate(-0.35deg);
}

.sheet h2 {
  margin: 8px 0 14px;
  font-size: clamp(26px, 6vw, 34px);
}

.sheet p {
  margin: 0 0 16px;
  font-size: 15.5px;
  line-height: 1.75;
  color: #4c3a30;
}

.sheet--dark {
  background:
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(255, 255, 255, 0.05) 31px 32px),
    linear-gradient(160deg, #3d423c, #2f3531);
  color: #f2e8d8;
  transform: rotate(0.4deg);
}

.sheet--dark .eyebrow { color: rgba(242, 232, 216, 0.6); }
.sheet--dark h2 { color: #fdf6e8; }

.sheet--dark ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: #e7dccb;
}

.signature {
  font-style: italic;
  text-align: right;
  font-size: 17px;
  color: var(--rose-deep);
  margin: 6px 0 0;
}

/* ------------------------------------------------------------------- ноты */

.notes {
  display: grid;
  gap: 16px;
  margin-top: 26px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.note {
  padding: 22px 20px;
  border-radius: 14px;
  background: linear-gradient(180deg, #faf3e5, #f0e4cf);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(120, 92, 60, 0.16),
    0 18px 30px -24px rgba(74, 52, 36, 0.65);
  transform: rotate(var(--r, 0deg));
}

.note h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--rose-deep);
}

.note p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: #54402f;
}

/* --------------------------------------------------------------- финал */

.ending {
  margin-top: 34px;
  text-align: center;
  color: var(--ink-soft);
}

.ending p { font-size: 15.5px; line-height: 1.7; }

/* -------------------------------------------------------------- музыка */

.music {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 12px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fbf5e9, #e9dcc6);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 1px rgba(120, 92, 60, 0.2),
    0 16px 24px -18px rgba(74, 52, 36, 0.8);
  transition: transform 0.2s ease;
}

.music:hover { transform: translateY(-2px); }

.music__icon {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 16px;
}

.music__icon .bar {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--rose-deep);
  transition: height 0.2s ease;
}

.music[aria-pressed="true"] .bar { animation: eq 0.9s ease-in-out infinite; }
.music[aria-pressed="true"] .bar:nth-child(2) { animation-delay: 0.15s; }
.music[aria-pressed="true"] .bar:nth-child(3) { animation-delay: 0.3s; }
.music[aria-pressed="true"] .bar:nth-child(4) { animation-delay: 0.45s; }

@keyframes eq {
  0%, 100% { height: 6px; }
  50% { height: 16px; }
}

/* ------------------------------------------------------------ просмотр */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(38, 26, 20, 0.72);
  backdrop-filter: blur(6px);
}

.lightbox[hidden] { display: none; }

.lightbox img {
  max-width: min(92vw, 760px);
  max-height: 84vh;
  border-radius: 8px;
  padding: 10px;
  background: #faf4e7;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
}

.lightbox__close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  background: #f8f1e3;
}

/* ------------------------------------------------------------ адаптив */

@media (min-width: 640px) {
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo--wide { grid-column: span 1; }
  .photo--wide img { aspect-ratio: 4 / 5; }
}

@media (min-width: 900px) {
  .scene { padding-top: 56px; }
  .diorama { padding: 34px 26px 40px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}


body.closed .music {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}


.cover__frame::before,
.cover__frame::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-top: 1.5px solid rgba(201, 164, 76, 0.75);
  border-left: 1.5px solid rgba(201, 164, 76, 0.75);
  top: 12px;
  left: 12px;
}

.cover__frame::after {
  top: auto;
  left: auto;
  bottom: 12px;
  right: 12px;
  transform: rotate(180deg);
}
