@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-latin.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-cyrl.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
  unicode-range: U+0400-045F, U+2116;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-cyrl-ext.woff2') format('woff2');
  font-weight: 500 600;
  font-display: swap;
  unicode-range: U+0460-052F;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-latin.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-cyrl.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0400-045F, U+2116;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-cyrl-ext.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0460-052F;
}

:root {
  color-scheme: light;
  --paper: #f8f3eb;
  --ink: #49372f;
  --muted: #715c54;
  --pink: #c48b91;
  --rose: #784b54;
  --line: #ddc7bd;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
  --left: max(20px, env(safe-area-inset-left));
  --right: max(20px, env(safe-area-inset-right));
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --page-height: 100vh;
}

@supports (height: 100dvh) {
  :root { --page-height: 100dvh; }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { color: var(--ink); background: var(--paper); font-family: var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 4px; }
h1:focus, h2:focus { outline: none; }
h1, h2, p { margin: 0; }

.masthead {
  position: fixed;
  z-index: 4;
  inset: calc(var(--top) + 13px) var(--right) auto var(--left);
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  font: 600 1.4rem/1 var(--serif);
  pointer-events: none;
}

.masthead::after { content: ''; flex: 1; height: 1px; margin-left: 9px; background: var(--line); opacity: .68; }
.masthead-heart { display: grid; place-items: center; width: 27px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; font: 1.02rem/1 var(--sans); color: var(--rose); }

.entrance {
  height: var(--page-height);
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 26% 50%, #efdacb72 0%, transparent 57%),
    radial-gradient(ellipse at 90% 0%, #eed6d138 0%, transparent 53%),
    var(--paper);
}

.gate-layout {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(23px, 4.2vh, 40px);
  width: min(100%, 1200px);
  min-height: 100%;
  margin-inline: auto;
  padding: calc(var(--top) + 72px) var(--right) calc(var(--bottom) + 26px) var(--left);
}

.gate-art { width: min(82%, 340px); height: clamp(173px, 35vh, 328px); height: clamp(173px, 35dvh, 328px); display: grid; place-items: center; }
.arch {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px solid #e1c8ba;
  border-radius: 49% 49% 10px 10px / 44% 44% 10px 10px;
  background:
    repeating-linear-gradient(94deg, #fff8 0 1px, transparent 1px 4px),
    linear-gradient(146deg, #f6e8db 18%, #efd9cb 62%, #e9cdbe);
  box-shadow: 0 25px 47px -31px #8959438a, inset 0 0 45px #fdf6ec7d;
}

.arch-line { position: absolute; inset: 10px; border: 1px solid #b47c7561; border-radius: inherit; pointer-events: none; }
.arch::before { content: ''; position: absolute; inset: -11px -8px -8px 8px; z-index: -1; border: 1px solid #b47c7536; border-radius: inherit; transform: rotate(2.5deg); }
.glint { position: absolute; color: #a56c74; font-family: Georgia, serif; }
.glint-one { top: 17%; left: 25%; font-size: clamp(20px, 3vw, 35px); }
.glint-two { bottom: 20%; right: 18%; font-size: clamp(12px, 1.8vw, 20px); }
.glint-three { top: 29%; right: 19%; font-size: clamp(13px, 2vw, 23px); }

.envelope {
  position: relative;
  width: 68%;
  max-width: 308px;
  aspect-ratio: 1.52;
  transform: translateY(7%) rotate(-8deg);
  border-radius: 5px;
  background: #f5e5d8;
  box-shadow: 2px 21px 28px -13px #764a3e9c, 0 0 0 1px #b88e7f54;
}

.envelope::before { content: ''; position: absolute; inset: 0; transform: translate(5%, 0) rotate(14deg); z-index: -1; border-radius: 5px; background: #d5a6a2; box-shadow: 0 0 0 1px #a5676d41, 0 12px 22px -18px #663e32; }
.envelope-back { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(35deg, #f1dccc 49.6%, #d9b7a9 50%, transparent 50.55%) left / 50% 100% no-repeat, linear-gradient(-35deg, #f3dfd0 49.6%, #d9b7a9 50%, transparent 50.55%) right / 50% 100% no-repeat, #f9ebe0; }
.envelope-fold { position: absolute; inset: 0; border-radius: inherit; clip-path: polygon(0 0, 100% 0, 55% 64%, 50% 67%, 45% 64%); background: linear-gradient(#fdf2e7, #efdbcd); }

.seal {
  position: absolute;
  display: grid;
  place-items: center;
  top: 60%;
  left: 50%;
  translate: -50% -50%;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 45% 53% 49% 46%;
  color: #fff5e9;
  background: radial-gradient(circle at 35% 24%, #ba8287, #8a525e 80%);
  box-shadow: inset 0 0 0 2px #ad757d, inset 0 0 0 4px #915664, 0 4px 10px #794e4669;
}

.lock { position: relative; width: 33%; height: 26%; margin-top: 13%; border: 1.4px solid currentColor; border-radius: 3px; animation: lock-breathe 3.7s ease-in-out infinite; }
.lock::before { content: ''; position: absolute; width: 64%; height: 79%; left: 18%; bottom: 99%; border: 1.4px solid currentColor; border-radius: 55% 55% 0 0; border-bottom: 0; transform-origin: right bottom; transition: transform .65s cubic-bezier(.18,.64,.32,1); }
.lock i { position: absolute; width: 13%; height: 33%; top: 32%; left: 44%; border-radius: 4px; background: currentColor; }
[data-state='welcome'] .lock::before { transform: rotate(34deg) translateY(-3px); }

.gate-panel { display: grid; justify-items: center; width: min(100%, 480px); text-align: center; }
.gate-title, .quiz-title, .slide-title { font-family: var(--serif); font-weight: 600; line-height: .99; letter-spacing: -.03em; overflow-wrap: anywhere; }
.gate-title { font-size: clamp(3.15rem, 11vw, 5.85rem); }
.gate-text { max-width: 36ch; margin-top: 16px; color: var(--muted); font-size: .95rem; line-height: 1.68; text-wrap: pretty; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  min-height: 51px;
  margin-top: 23px;
  padding: 12px 24px;
  border: 1px solid #784b54;
  border-radius: 5px;
  background: var(--rose);
  color: #fff9f3;
  box-shadow: 0 8px 20px -12px #76424cbd;
  font-size: .9rem;
  font-weight: 600;
  transition: background-color .2s ease, transform .2s ease;
}

.primary-button:hover { background: #693e47; transform: translateY(-1px); }
.button-arrow { position: relative; width: 16px; height: 1px; background: currentColor; }
.button-arrow::after { position: absolute; top: -2.5px; right: 0; content: ''; width: 6px; height: 6px; border-right: 1px solid; border-top: 1px solid; transform: rotate(45deg); }
.quiz-title { font-size: clamp(2.02rem, 7vw, 3.5rem); margin: 13px 0 16px; }
.quiz-count { font-size: .78rem; font-weight: 600; color: var(--rose); }
progress { appearance: none; display: block; border: 0; border-radius: 3px; overflow: hidden; background: #e8d8d0; color: var(--rose); }
progress::-webkit-progress-bar { background: #e8d8d0; }
progress::-webkit-progress-value { border-radius: 3px; background: var(--rose); transition: width .25s ease; }
progress::-moz-progress-bar { border-radius: 3px; background: var(--rose); }
.quiz-progress { width: min(100%, 186px); height: 3px; margin-top: 6px; }
.quiz-answers { display: grid; gap: 8px; width: 100%; }
.quiz-answer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 8px 13px; background: #fdf9f3be; border: 1px solid var(--line); border-radius: 6px; text-align: left; font-size: .9rem; line-height: 1.4; }
.quiz-answer:hover, .quiz-answer:active { background: #f0dfda; border-color: #ae7b80; }
.choice-dot { flex: 0 0 13px; width: 13px; aspect-ratio: 1; border: 1px solid #a37377; border-radius: 50%; }
.quiz-answer:hover .choice-dot { background: var(--pink); box-shadow: inset 0 0 0 2px var(--paper); }
[data-state='quiz'] .gate-art { height: clamp(116px, 24dvh, 245px); width: min(66%, 270px); }

.hearts { position: absolute; inset: 0; pointer-events: none; }
.hearts span { position: absolute; left: 19%; bottom: 21%; color: #a16372; opacity: 0; font-size: 1.35rem; }
.hearts span:nth-child(2) { left: 64%; bottom: 28%; animation-delay: .35s !important; font-size: .95rem; }
.hearts span:nth-child(3) { left: 76%; bottom: 41%; animation-delay: .6s !important; }
.hearts span:nth-child(4) { left: 31%; bottom: 47%; animation-delay: .9s !important; font-size: .92rem; }
.hearts span:nth-child(5) { left: 51%; bottom: 40%; animation-delay: 1.1s !important; font-size: .9rem; }
[data-state='welcome'] .hearts span, .is-active .hearts span { animation: float-heart 3.8s ease-out both; }
[data-state='welcome'] .gate-panel { animation: arrive .7s ease both; }

.story, .slide-scroll { height: var(--page-height); }
.slide-scroll { position: relative; overflow: hidden auto; overscroll-behavior-y: contain; scroll-snap-type: y mandatory; scrollbar-width: none; }
.slide-scroll::-webkit-scrollbar { display: none; }
.slide { position: relative; isolation: isolate; display: grid; width: 100%; height: 100%; overflow: hidden; scroll-snap-align: start; scroll-snap-stop: always; background: var(--paper); }
.slide-backdrop { display: none; }

.slide-layout {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(14px, 3.2dvh, 27px);
  min-width: 0;
  min-height: 0;
  width: 100%;
  margin-inline: auto;
  padding: calc(var(--top) + 64px) var(--right) calc(var(--bottom) + 71px) var(--left);
}

.media-stage { position: relative; display: grid; place-items: center; container-type: size; min-height: 0; min-width: 0; }
.media-frame { --frame-ratio: var(--mobile-ratio); position: relative; isolation: isolate; width: min(100cqw, calc(100cqh * var(--frame-ratio))); aspect-ratio: var(--frame-ratio); max-height: 100%; border-radius: clamp(9px, 1.4vw, 19px); background: #ebd8cc; box-shadow: 0 18px 29px -20px #60423998, 0 0 0 1px #b39b8c44; }
.media-visual { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.media-element { display: block; width: 100%; height: 100%; object-fit: cover; object-position: var(--photo-position); transform: scale(var(--photo-zoom)); transform-origin: var(--photo-position); }
.media-element:is(video) { object-fit: contain; background: #332923; }
.is-active img.media-element { animation: photo-move 15s ease-out both; }
.is-active .media-visual { animation: photo-in .5s ease both; }
.nostalgic img { filter: sepia(.17) saturate(.83) contrast(.94) brightness(1.035); }
.nostalgic .media-visual::before, .nostalgic .media-visual::after { content: ''; position: absolute; z-index: 1; inset: 0; pointer-events: none; }
.nostalgic .media-visual::before { background: url('media/grain.webp') repeat; opacity: .34; mix-blend-mode: soft-light; }
.nostalgic .media-visual::after { background: radial-gradient(ellipse at 51% 54%, transparent 47%, #6e402c4a 100%); }
.media-stage .media-frame.video-frame { width: min(100cqw, calc((100cqh - 48px) * var(--frame-ratio))); translate: 0 -24px; }
.sound-button { position: absolute; top: calc(100% + 4px); left: 50%; translate: -50% 0; min-height: 44px; border-radius: 6px; border: 1px solid var(--line); color: var(--rose); background: #fbf6ef; padding: 7px 11px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.sound-button:hover { background: #efdfd9; }
.missing-media { position: absolute; inset: auto 6% 8%; z-index: 2; margin: auto; width: fit-content; padding: 8px 12px; border-radius: 6px; background: var(--paper); color: var(--muted); font-size: .82rem; text-align: center; }
.gallery-nav { position: absolute; display: flex; align-items: center; gap: 6px; left: 50%; bottom: 10px; translate: -50%; padding: 3px; border: 1px solid #d9bdb3; border-radius: 24px; background: #f9f2eafb; box-shadow: 0 2px 12px #3b252944; }
.gallery-count { white-space: nowrap; color: var(--rose); font-size: .76rem; font-variant-numeric: tabular-nums; }
.gallery-arrow.icon-button { width: 44px; height: 44px; border-color: transparent; }
.media-stage:has(.gallery-nav) .media-frame { width: min(100cqw, calc((100cqh - 54px) * var(--frame-ratio))); align-self: start; }
.media-stage:has(.gallery-nav) .media-frame.video-frame { width: min(100cqw, calc((100cqh - 102px) * var(--frame-ratio))); translate: none; }
.media-stage:has(.gallery-nav) .gallery-nav { bottom: 0; }

.caption { min-width: 0; min-height: 0; }
.slide-period { margin-bottom: 8px; font-size: .8rem; font-weight: 600; letter-spacing: .14em; color: var(--rose); }
.slide-title { font-size: clamp(2.15rem, 9.2vw, 3.55rem); text-wrap: balance; }
.caption-rule { width: 32px; height: 1px; margin: 11px 0; background: #b87d81; }
.slide-text, .letter-body { color: var(--muted); font-size: clamp(.88rem, 3.75vw, 1.02rem); line-height: 1.59; text-wrap: pretty; }
.letter-body p + p { margin-top: .7em; }
.is-active .caption { animation: arrive .52s ease-out both; }
.text-button { display: inline-flex; gap: 10px; align-items: center; min-height: 43px; padding: 4px 0; border: 0; background: transparent; text-align: left; color: var(--rose); font-size: .8rem; font-weight: 600; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.slide-hint { margin-top: 10px; }
.slide-hint .chevron { flex-shrink: 0; margin-inline-end: 3px; animation: hint 2.8s ease-in-out infinite; }

.book-art { display: grid; place-items: center; width: min(100cqw, 440px); height: min(100cqh, 480px); border: 1px solid #e1c8ba; border-radius: 49% 49% 10px 10px / 44% 44% 10px 10px; background: repeating-linear-gradient(88deg, #fff6 0 1px, transparent 1px 4px), linear-gradient(138deg, #f6e8dc, #e8cabc); }
.book { position: relative; display: grid; place-items: center; width: min(59cqw, 48cqh, 224px); aspect-ratio: .78; border-radius: 5px 10px 10px 5px; border-left: 7px solid #704851; background: repeating-linear-gradient(0deg, #ffffff07 0 1px, transparent 1px 4px), linear-gradient(145deg, #a96f7b, #82545b); transform: rotate(-9deg); box-shadow: 4px 3px 0 2px #f5e3ce, 7px 5px 0 3px #814e55, 15px 18px 25px -10px #704b46aa; color: #f2d2b8; }
.book-line { position: absolute; inset: 9%; border: 1px solid #e9cead9c; border-radius: 4px; }
.book-heart { font-size: clamp(37px, 14cqh, 65px); font-family: Georgia, serif; }

.finale .slide-layout { grid-template-rows: minmax(0, .82fr) minmax(0, 1fr); }
.finale .caption { display: flex; flex-direction: column; }
.finale .slide-title { flex-shrink: 0; }
.finale .caption-rule { flex-shrink: 0; }
.letter-body { min-height: 0; overflow-y: auto; scrollbar-color: #b78688 #ede1d6; scrollbar-width: thin; padding-right: 8px; }
.replay-button { align-self: flex-start; flex-shrink: 0; margin-top: 4px; }

.slide-nav { position: fixed; z-index: 3; left: 50%; bottom: calc(var(--bottom) + 9px); translate: -50% 0; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.slide-nav button:enabled { pointer-events: auto; }
.music-toggle { position: fixed; z-index: 3; right: var(--right); bottom: calc(var(--bottom) + 9px); }
.music-toggle span { position: relative; font-size: 1.13rem; line-height: 1; }
.music-toggle.is-muted span::after { content: ''; position: absolute; left: -3px; right: -3px; top: 50%; height: 1px; background: currentColor; box-shadow: 0 1px var(--paper); transform: rotate(-43deg); }
.slide-indicator { display: grid; gap: 5px; text-align: center; font-variant-numeric: tabular-nums; color: var(--rose); white-space: nowrap; font-size: .72rem; font-weight: 600; }
.slide-indicator progress { width: 67px; height: 3px; }
.icon-button { display: grid; width: 45px; height: 45px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fbf6efeb; color: var(--rose); transition: background-color .2s ease; }
.icon-button:enabled:hover { background: #efdfd9; }
.icon-button:disabled { opacity: .38; }
.chevron { display: block; width: 9px; height: 9px; border-bottom: 1.5px solid currentColor; border-right: 1.5px solid currentColor; }
.chevron.up { transform: translateY(2px) rotate(225deg); }
.chevron.down { transform: translateY(-2px) rotate(45deg); }
.chevron.left { transform: translateX(2px) rotate(135deg); }
.chevron.right { transform: translateX(-2px) rotate(-45deg); }

@media (max-height: 665px) and (max-width: 849px) {
  .gate-layout { gap: 19px; padding-top: calc(var(--top) + 62px); }
  .slide-layout { gap: 13px; padding-top: calc(var(--top) + 55px); padding-bottom: calc(var(--bottom) + 63px); }
  .slide-title { font-size: clamp(1.94rem, 8.35vw, 2.7rem); }
  .slide-text, .letter-body { line-height: 1.48; }
  .caption-rule { margin-block: 8px; }
}

@media (min-width: 850px) {
  :root { --left: max(clamp(34px, 5vw, 80px), env(safe-area-inset-left)); --right: max(clamp(34px, 5vw, 80px), env(safe-area-inset-right)); }
  .masthead { inset-block-start: calc(var(--top) + 25px); font-size: 1.6rem; }
  .masthead-heart { width: 33px; }
  .masthead::after { margin-left: 18px; }
  .gate-layout { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); align-items: center; gap: clamp(58px, 8vw, 117px); padding-block: calc(var(--top) + 84px) calc(var(--bottom) + 52px); }
  .gate-art, [data-state='quiz'] .gate-art { width: 100%; height: min(64vh, 560px); height: min(64dvh, 560px); }
  .arch-line { inset: 16px; }
  .gate-panel { justify-items: start; text-align: left; }
  .gate-title { font-size: clamp(3.7rem, 6.55vw, 6.2rem); }
  .gate-text { font-size: 1.02rem; line-height: 1.72; margin-top: 19px; }
  .primary-button { margin-top: 30px; }
  .quiz-title { margin-top: 18px; }
  .quiz-answer { min-height: 51px; padding-inline: 17px; }

  .slide-layout { max-width: 1370px; grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: center; gap: clamp(43px, 7vw, 103px); padding-block: calc(var(--top) + 93px) calc(var(--bottom) + 72px); }
  .slide-backdrop { display: block; position: absolute; z-index: -1; inset: 8% 45% 8% 0; background: var(--backdrop) center / cover; opacity: 0; filter: blur(69px) saturate(.75); transform: scale(1.1); mask-image: radial-gradient(ellipse, #000 5%, transparent 74%); transition: opacity .55s ease; pointer-events: none; }
  .is-active .slide-backdrop { opacity: .26; }
  .media-stage { align-self: stretch; }
  .media-frame { --frame-ratio: var(--ratio); }
  .caption { max-width: 520px; }
  .slide-title { font-size: clamp(2.75rem, 5.1vw, 5.6rem); }
  .slide-period { margin-bottom: 13px; font-size: .82rem; }
  .caption-rule { width: 46px; margin-block: 16px; }
  .slide-text, .letter-body { font-size: clamp(.97rem, 1.32vw, 1.16rem); line-height: 1.69; }
  .slide-hint { margin-top: 18px; }
  .finale .slide-layout { grid-template-rows: minmax(0, 1fr); }
  .finale .caption { max-height: 100%; }
  .finale .slide-title { font-size: clamp(2.48rem, 4.2vw, 4.55rem); }
  .slide-nav { left: auto; right: var(--right); bottom: calc(var(--bottom) + 19px); translate: none; }
  .music-toggle { left: var(--left); right: auto; bottom: calc(var(--bottom) + 19px); }
  .slide-indicator progress { width: 82px; }
}

@media (max-height: 545px) and (orientation: landscape) {
  .gate-layout { grid-template-columns: minmax(0, .75fr) minmax(0, 1fr); align-items: center; gap: 22px; }
  .gate-title { font-size: clamp(2.5rem, 7vw, 4rem); }
  .slide-layout, .finale .slide-layout { grid-template-columns: minmax(0, .85fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: center; }
  .media-stage { align-self: stretch; }
  .caption { max-height: 100%; overflow-y: auto; }
  .slide-title { font-size: clamp(1.86rem, 5vw, 3.4rem); }
}

@keyframes arrive { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes photo-in { from { opacity: .62; } to { opacity: 1; } }
@keyframes photo-move { from { transform: scale(var(--photo-zoom)); } to { transform: scale(calc(var(--photo-zoom) * 1.025)); } }
@keyframes lock-breathe { 50% { opacity: .72; } }
@keyframes float-heart { 0% { transform: translateY(15px) rotate(-7deg); opacity: 0; } 25% { opacity: .8; } 100% { transform: translateY(-92px) rotate(17deg); opacity: 0; } }
@keyframes hint { 50% { transform: translateY(1px) rotate(45deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
