:root {
  --bg: #f7f1ea;
  --bg-soft: #f2e8df;
  --paper: #fffaf5;
  --paper-strong: #fffdfb;
  --ink: #2f2428;
  --muted: #6f6067;
  --accent: #a76573;
  --accent-deep: #7e3f4e;
  --gold: #c7a76a;
  --line: rgba(113, 92, 100, 0.18);
  --shadow: 0 16px 34px rgba(69, 47, 56, 0.08);
  --shadow-strong: 0 22px 50px rgba(69, 47, 56, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --max-content: 36rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  background: var(--bg);
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(199, 167, 106, 0.11), transparent 34%),
    radial-gradient(circle at 50% 0%, rgba(167, 101, 115, 0.08), transparent 28%),
    linear-gradient(180deg, #f8f2ec 0%, #f6efe7 28%, #f4ece3 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.12) 0,
      rgba(255, 255, 255, 0.12) 1px,
      transparent 1px,
      transparent 10px
    );
  opacity: 0.18;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  border: 0;
}

.site {
  width: 100%;
}

.hero,
.chapter {
  padding-inline: 1rem;
}

.hero {
  min-height: 100svh;
  display: grid;
  align-items: center;
  padding-block: 1rem 2rem;
}

.hero__inner,
.chapter__inner {
  width: min(100%, var(--max-content));
  margin-inline: auto;
}

.hero__inner {
  display: grid;
  gap: 1rem;
  text-align: center;
}

.hero__eyebrow {
  margin: 0;
  color: #4b3137;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.hero__description {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.9vw, 1.08rem);
  line-height: 1.75;
  text-wrap: balance;
}

.envelope-card {
  display: grid;
  gap: 1rem;
  justify-items: center;
  align-items: center;
  margin-inline: auto;
  width: min(100%, 24rem);
  transition:
    opacity 360ms var(--ease),
    transform 360ms var(--ease);
}

.envelope-card > * {
  grid-area: 1 / 1;
}

.envelope-card > * {
  grid-area: 1 / 1;
}

.envelope {
  display: grid;
  width: min(100%, 21rem);
  aspect-ratio: 1.52 / 1;
  padding: 1rem;
  border-radius: 1.75rem;
  background:
    linear-gradient(180deg, rgba(255, 253, 250, 0.88), rgba(248, 238, 231, 0.92)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent 45%);
  box-shadow: var(--shadow-strong);
  border: 1px solid rgba(122, 97, 104, 0.12);
  overflow: hidden;
  transition:
    opacity 420ms var(--ease),
    transform 420ms var(--ease);
}

.envelope > * {
  grid-area: 1 / 1;
}

.envelope__body {
  border-radius: 1.35rem;
  background:
    linear-gradient(135deg, rgba(255, 248, 242, 0.65), rgba(255, 245, 240, 0.15)),
    linear-gradient(180deg, #f8e9de 0%, #f3ddd4 100%);
  border: 1px solid rgba(122, 97, 104, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  position: relative;
}

.envelope__body::before,
.envelope__body::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 72%;
  height: 50%;
  border-bottom: 1px solid rgba(128, 87, 94, 0.16);
  transform: translateX(-50%);
}

.envelope__body::before {
  top: 18%;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}

.envelope__body::after {
  top: 52%;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
}

.envelope__flap {
  align-self: start;
  justify-self: center;
  width: 100%;
  height: 62%;
  background: linear-gradient(180deg, #fdf5ef 0%, #f0d9cf 100%);
  clip-path: polygon(0 0, 50% 76%, 100% 0, 100% 100%, 0 100%);
  transform-origin: top center;
  transition: transform 900ms var(--ease);
  box-shadow: inset 0 -1px 0 rgba(122, 97, 104, 0.1);
}

.envelope__seal {
  align-self: center;
  justify-self: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 248, 240, 0.9), transparent 34%),
    linear-gradient(180deg, #c47a86 0%, #a76573 100%);
  box-shadow: 0 8px 18px rgba(104, 64, 76, 0.16);
  transform: translateY(0.4rem);
}

.letter {
  width: min(100%, 22rem);
  padding: 1.4rem 1.25rem 1.3rem;
  border-radius: 1.5rem;
  background: linear-gradient(180deg, var(--paper-strong), #faf4ee);
  box-shadow: var(--shadow-strong);
  border: 1px solid rgba(122, 97, 104, 0.1);
  text-align: left;
  transform: translateY(0.2rem) scale(0.98);
  opacity: 0;
  transition:
    opacity 520ms var(--ease),
    transform 900ms var(--ease);
}

.letter.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.letter__greeting,
.letter__message,
.letter__signature,
.letter__continue {
  margin: 0;
}

.letter__greeting {
  color: var(--accent-deep);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.35rem, 4.3vw, 1.7rem);
  font-weight: 600;
  line-height: 1.12;
}

.letter__message {
  margin-top: 0.75rem;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.78;
}

.letter__signature {
  margin-top: 1.05rem;
  color: var(--accent-deep);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.button {
  min-height: 48px;
  width: 100%;
  padding: 0.95rem 1.15rem;
  border-radius: 999px;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform 180ms var(--ease),
    background-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    color 180ms var(--ease),
    opacity 180ms var(--ease);
}

.button:focus-visible {
  outline: 3px solid rgba(199, 167, 106, 0.55);
  outline-offset: 4px;
}

.button:active {
  transform: translateY(1px);
}

.button[disabled] {
  cursor: progress;
  opacity: 0.72;
}

.button--primary {
  background: linear-gradient(135deg, #c98a96 0%, #a76573 100%);
  color: #fffaf8;
  box-shadow: 0 14px 24px rgba(112, 69, 79, 0.12);
}

.button--secondary {
  background: rgba(255, 251, 247, 0.96);
  color: var(--ink);
  border: 1px solid rgba(122, 97, 104, 0.12);
  box-shadow: 0 12px 18px rgba(112, 69, 79, 0.07);
}

.hero__button {
  margin-top: 0.3rem;
}

.letter__continue {
  margin-top: 1rem;
}

.chapter {
  padding-block: 2rem 4rem;
  background: linear-gradient(180deg, rgba(255, 251, 247, 0.35), rgba(244, 236, 227, 0.92));
  border-top: 1px solid rgba(122, 97, 104, 0.08);
}

.chapter__inner {
  display: grid;
  gap: 1.15rem;
}

.chapter__label {
  position: relative;
  display: grid;
  gap: 0.4rem;
  padding-left: 1rem;
}

.chapter__label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.3rem;
  bottom: 0.2rem;
  width: 1px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(167, 101, 115, 0.35), rgba(199, 167, 106, 0.3));
}

.chapter__number {
  margin: 0;
  color: var(--accent-deep);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chapter__intro {
  margin: 0;
  max-width: 30ch;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.chapter__content {
  display: grid;
  gap: 1rem;
}

.memory {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.memory__media {
  display: grid;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: 1.4rem;
  background:
    linear-gradient(180deg, #fdf9f5, #f3e6dc),
    linear-gradient(135deg, rgba(199, 167, 106, 0.12), rgba(167, 101, 115, 0.08));
  border: 1px solid rgba(122, 97, 104, 0.09);
  box-shadow: var(--shadow);
}

.memory__image,
.memory__placeholder {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
}

.memory__image {
  object-fit: cover;
  opacity: 0;
  transition: opacity 220ms ease;
}

.memory__placeholder {
  object-fit: cover;
  transition: opacity 220ms ease;
}

.memory__media.has-photo .memory__image {
  opacity: 1;
}

.memory__media.has-photo .memory__placeholder {
  opacity: 0;
}

.chapter-copy {
  display: grid;
  gap: 0.95rem;
  padding-top: 0.25rem;
}

.chapter-copy__date {
  margin: 0;
  color: var(--accent-deep);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-copy__title {
  margin: 0;
  color: #382c31;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.8rem, 6vw, 2.45rem);
  font-weight: 600;
  line-height: 1.06;
  text-wrap: balance;
}

.chapter-copy__body {
  display: grid;
  gap: 0.95rem;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.82;
}

.chapter-copy__body p {
  margin: 0;
}

.chapter-copy__closing {
  color: #46353b;
}

.final-section {
  min-height: 100svh;
  padding: 1rem 1rem 4rem;
  display: grid;
  align-items: center;
  background: linear-gradient(180deg, rgba(244, 236, 227, 0.55), rgba(243, 232, 222, 0.95));
  border-top: 1px solid rgba(122, 97, 104, 0.08);
}

.final-section__inner {
  width: min(100%, 26rem);
  margin-inline: auto;
  display: grid;
  justify-items: center;
  gap: 0.95rem;
  text-align: center;
  opacity: 0;
  transform: translateY(0.75rem);
  transition:
    opacity 700ms var(--ease),
    transform 700ms var(--ease);
}

.final-section.is-visible .final-section__inner {
  opacity: 1;
  transform: translateY(0);
}

.final-section__icon {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.final-section__title {
  margin: 0;
  color: #382c31;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.85rem, 6vw, 2.55rem);
  font-weight: 600;
  line-height: 1.08;
  text-wrap: balance;
}

.final-section__message {
  margin: 0;
  max-width: 26ch;
  color: var(--muted);
  font-size: clamp(1rem, 2.9vw, 1.08rem);
  line-height: 1.8;
  text-wrap: balance;
}

.hero.is-open .envelope__flap {
  transform: rotateX(180deg) translateY(-0.1rem);
}

.hero.is-open .envelope {
  opacity: 0;
  transform: translateY(-0.45rem) scale(0.96);
  pointer-events: none;
}

.hero.is-open .hero__button {
  opacity: 0;
  transform: translateY(0.25rem);
  pointer-events: none;
}

.chapter.is-visible .chapter-copy,
.chapter.is-visible .chapter__label,
.chapter.is-visible .memory {
  animation: fade-in 700ms var(--ease) both;
}

.chapter.is-visible .chapter-copy {
  animation-delay: 60ms;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero__inner::after {
  content: "";
  width: min(9rem, 26vw);
  height: 1px;
  margin: 0.35rem auto 0;
  background: linear-gradient(90deg, transparent, rgba(199, 167, 106, 0.45), transparent);
}

@media (min-width: 48rem) {
  .hero,
  .chapter {
    padding-inline: 1.5rem;
  }

  .hero {
    padding-block: 1.4rem 2.4rem;
  }

  .hero__inner {
    gap: 1.15rem;
  }

  .chapter {
    padding-block: 2.75rem 4.25rem;
  }

  .chapter__content {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 1.35rem;
    align-items: start;
  }

  .chapter-copy {
    padding-top: 0.2rem;
  }

  .final-section {
    padding-inline: 1.5rem;
  }
}

@media (min-width: 80rem) {
  .hero__inner,
  .chapter__inner {
    width: min(100%, 40rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .chapter.is-visible .chapter-copy,
  .chapter.is-visible .chapter__label,
  .chapter.is-visible .memory,
  .final-section.is-visible .final-section__inner,
  .hero__button,
  .letter,
  .envelope__flap {
    opacity: 1 !important;
    transform: none !important;
  }

  .hero.is-open .envelope {
    opacity: 0 !important;
  }

  .hero.is-open .hero__button {
    opacity: 0 !important;
  }
}
