/* ==========================================================================
   fonts
   ========================================================================== */
@font-face {
  font-family: 'TitleFont';
  src: url('fonts/title.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'TextFont';
  src: url('fonts/text.otf') format('opentype');
  font-display: swap;
}

/* ==========================================================================
   tokens — strictly black, white, and neutral gray. no hues anywhere.
   ========================================================================== */
:root {
  --ink: #000000;
  --white: #ffffff;
  --gray-100: #f6f6f6;
  --gray-200: #ebebeb;
  --gray-300: #d6d6d6;
  --gray-400: #9a9a9a;

  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 34px;
  --radius-pill: 999px;

  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.12);
  --shadow-tiny: 0 3px 8px rgba(0, 0, 0, 0.10);
  --shadow-pressed: 0 2px 4px rgba(0, 0, 0, 0.14);

  --font-head: 'TitleFont', system-ui, sans-serif;
  --font-body: 'TextFont', system-ui, sans-serif;

  --ease-soft: cubic-bezier(.34, 1.56, .64, 1);
}

/* ==========================================================================
   reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--white);
  font-family: var(--font-body);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; color: var(--ink); }
a { color: inherit; }
h1, h2, h3, p { margin: 0; color: var(--ink); }
ul { margin: 0; padding: 0; list-style: none; }
textarea, input { font-family: inherit; color: var(--ink); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   page shell + transitions
   ========================================================================== */
.page {
  position: relative;
  min-height: 100vh;
  padding-bottom: 7rem;
  opacity: 0;
  transform: translateY(10px) scale(.995);
  animation: page-in .7s var(--ease-soft) forwards;
}
@keyframes page-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
body.leaving .page {
  animation: page-out .35s ease forwards;
}
@keyframes page-out {
  to { opacity: 0; transform: translateY(-8px) scale(.98); }
}

/* ==========================================================================
   decorative stickers (/bg) — always confined to the outer edges
   ========================================================================== */
.sticker {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.10));
}
.float-a { animation: float-a 6s ease-in-out infinite; }
.float-b { animation: float-b 7.5s ease-in-out infinite; }
.float-c { animation: float-c 5.5s ease-in-out infinite; }
.spin-wiggle { animation: wiggle 8s ease-in-out infinite; }

@keyframes float-a { 0%,100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-10px) rotate(calc(var(--rot, 0deg) + 3deg)); } }
@keyframes float-b { 0%,100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(8px) rotate(calc(var(--rot, 0deg) - 4deg)); } }
@keyframes float-c { 0%,100% { transform: translateY(0) scale(1) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-6px) scale(1.05) rotate(var(--rot, 0deg)); } }
@keyframes wiggle { 0%, 92%, 100% { transform: rotate(var(--rot, 0deg)); } 96% { transform: rotate(calc(var(--rot, 0deg) + 6deg)); } }

/* ==========================================================================
   /photos — larger hand-placed accents, always in their own strip so
   they can never touch the corner-dwelling /bg stickers. width/height
   are both fixed (object-fit: cover) so a tall source photo can never
   grow past its box and spill into whatever section follows.
   ========================================================================== */
.photo-strip {
  position: relative;
  width: min(980px, 92vw);
  margin: 1rem auto;
  min-height: clamp(280px, 40vw, 380px);
}
.photo-scatter {
  position: absolute;
  top: var(--pt, 0);
  left: var(--pl, 0);
  width: var(--pw, 220px);
  height: var(--ph, 170px);
  z-index: 5;
  object-fit: cover;
  border: 7px solid var(--white);
  border-radius: 6px;
  background: var(--white);
  box-shadow: var(--shadow-soft);
  transform: rotate(var(--rot, 0deg));
  transition: transform .25s var(--ease-soft), box-shadow .25s ease;
  opacity: 0;
  animation: photo-in .6s var(--ease-soft) forwards;
  animation-delay: var(--delay, 0s);
}
.photo-scatter:hover {
  transform: rotate(0deg) scale(1.05) translateY(-4px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, .25);
  z-index: 30;
}
@keyframes photo-in {
  from { opacity: 0; transform: rotate(var(--rot, 0deg)) translateY(14px) scale(.94); }
  to { opacity: 1; transform: rotate(var(--rot, 0deg)) translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .photo-strip {
    position: static;
    width: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    padding: .5rem 0 1rem;
  }
  .photo-scatter {
    position: static;
    top: auto;
    left: auto;
    width: min(82vw, 340px);
    height: auto;
    max-height: 62vw;
  }
}

/* ==========================================================================
   buttons — solid black, white text. no exceptions.
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .9em 1.6em;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  box-shadow: var(--shadow-tiny);
  transition: transform .2s var(--ease-soft), box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(0) scale(.97); box-shadow: var(--shadow-pressed); }
.btn.secondary {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
}
.btn.secondary:hover { background: var(--gray-100); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: var(--shadow-tiny); }

/* ==========================================================================
   floating navigation
   ========================================================================== */
.site-nav {
  position: fixed;
  left: 50%;
  bottom: clamp(.9rem, 3vh, 1.6rem);
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .6rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  border: 2px solid var(--ink);
}
.nav-step {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform .2s var(--ease-soft), background .2s ease;
}
.nav-step:hover { transform: scale(1.1) rotate(-6deg); background: var(--gray-200); }
.nav-step svg { width: 18px; height: 18px; }

.nav-dots { display: flex; gap: .4rem; padding: 0 .3rem; align-items: center; }
.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  padding: 0;
  background: var(--white);
  opacity: .5;
  transition: all .25s var(--ease-soft);
  display: inline-block;
}
.nav-dot:hover { opacity: .85; transform: scale(1.2); }
.nav-dot.active {
  opacity: 1;
  width: 26px;
  border-radius: var(--radius-pill);
  background: var(--ink);
}

/* ==========================================================================
   music controls — fixed top-right on every unlocked page
   ========================================================================== */
.music-dock {
  position: fixed;
  top: clamp(.7rem, 3vh, 1.1rem);
  right: clamp(.7rem, 3vw, 1.1rem);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: .35rem;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  padding: .35rem .55rem;
}
.music-control {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  display: grid;
  place-items: center;
  font-size: .95rem;
  transition: transform .2s var(--ease-soft), background .2s ease;
}
.music-control:hover { transform: scale(1.08); background: var(--gray-200); }
.music-control:active { transform: scale(.92); }
.music-volume {
  width: 72px;
  accent-color: var(--ink);
  cursor: pointer;
}
@media (max-width: 560px) {
  .music-volume { width: 44px; }
  .music-dock { gap: .25rem; padding: .3rem .5rem; }
  .music-control { width: 28px; height: 28px; font-size: .82rem; }
}

/* ==========================================================================
   GATE — password screen
   ========================================================================== */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  position: relative;
}
.gate-card {
  position: relative;
  z-index: 5;
  width: min(420px, 92vw);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.8rem, 5vw, 2.6rem);
  text-align: center;
}
.gate-card.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.gate-card .kicker {
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: .06em;
}
.gate-card h1 {
  font-family: var(--font-head);
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  margin-top: .3rem;
}
.gate-card p.lede { margin-top: .7rem; }
.gate-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  align-items: stretch;
}
.gate-input {
  width: 100%;
  padding: .8em 1.1em;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  font-size: 1rem;
  font-family: var(--font-body);
  text-align: center;
  background: var(--gray-100);
}
.gate-input:focus { outline: none; background: var(--white); }
.gate-error {
  font-size: .88rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity .2s ease, max-height .2s ease;
}
.gate-error.show { opacity: 1; max-height: 3rem; }

/* ==========================================================================
   PAGE 1 — flowers / entrance
   ========================================================================== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.25rem;
}
.hero-eyebrow {
  font-family: var(--font-head);
  font-size: .95rem;
  letter-spacing: .08em;
  background: var(--white);
  border: 1px solid var(--ink);
  padding: .35em 1em;
  border-radius: var(--radius-pill);
  margin-bottom: 1.1rem;
}
.hero h1 {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  line-height: 1.05;
}
.hero p.lede {
  margin-top: 1rem;
  max-width: 34rem;
  font-size: clamp(1rem, 2vw, 1.2rem);
}
.hero .actions {
  margin-top: 2.2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mascot-wrap {
  position: relative;
  margin-top: 2.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mascot-btn {
  position: relative;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 50%;
  padding: 1.1rem;
  box-shadow: var(--shadow-soft);
  transition: transform .18s var(--ease-soft);
  line-height: 0;
}
.mascot-btn img { width: clamp(110px, 18vw, 160px); }
.mascot-btn:hover { transform: scale(1.06) rotate(-3deg); }
.mascot-btn:active { transform: scale(.94) rotate(2deg); }
.mascot-btn.bounce { animation: mascot-bounce .5s var(--ease-soft); }
@keyframes mascot-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(.88, 1.12) rotate(-4deg); }
  70% { transform: scale(1.08, .94) rotate(3deg); }
  100% { transform: scale(1); }
}

.speech-bubble {
  position: relative;
  margin-bottom: .9rem;
  padding: .7em 1.2em;
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: var(--radius-md);
  font-family: var(--font-head);
  font-size: 1.05rem;
  box-shadow: var(--shadow-tiny);
  opacity: 0;
  transform: translateY(6px) scale(.9);
  transition: all .28s var(--ease-soft);
}
.speech-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -8px;
  width: 16px; height: 16px;
  background: var(--white);
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 3px;
}

.pop-heart {
  position: absolute;
  width: 26px;
  opacity: 0;
  pointer-events: none;
}
.pop-heart.pop { animation: pop-up 1.1s ease-out forwards; }
@keyframes pop-up {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.4) rotate(0deg); }
  15% { opacity: 1; transform: translate(calc(-50% + var(--dx, 0px) * .2), -10px) scale(1) rotate(-8deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -90px) scale(.8) rotate(12deg); }
}

.hint { margin-top: .6rem; font-size: .85rem; }

.entry-star-fall {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.falling-star {
  position: absolute;
  top: -10vh;
  color: var(--ink);
  font-size: var(--fsize, 20px);
  opacity: var(--fop, .85);
  animation: star-fall var(--fdur, 8s) linear forwards, star-sway var(--sdur, 3s) ease-in-out infinite;
}
@keyframes star-fall {
  to { transform: translateY(120vh); }
}
@keyframes star-sway {
  0%, 100% { margin-left: 0; }
  50% { margin-left: 26px; }
}

/* ==========================================================================
   PAGE 2 — random phrases
   ========================================================================== */
.board-head {
  position: relative;
  text-align: center;
  padding: 4.5rem 1.25rem 1rem;
}
.board-head .kicker {
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: .06em;
}
.board-head h1 {
  font-family: var(--font-head);
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  margin-top: .3rem;
}
.board-head p { margin-top: .6rem; max-width: 32rem; margin-inline: auto; }

.phrase-field {
  position: relative;
  width: min(1000px, 88vw);
  margin: 1rem auto 3rem;
}
.phrase {
  position: absolute;
  top: 0; left: 0;
  max-width: min(55vw, 180px);
  font-family: var(--font-head);
  text-align: center;
  line-height: 1.35;
  transform: rotate(var(--rot, 0deg));
  opacity: 0;
  animation: phrase-in .6s var(--ease-soft) forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes phrase-in {
  from { opacity: 0; transform: rotate(var(--rot, 0deg)) scale(.85); }
  to { opacity: 1; transform: rotate(var(--rot, 0deg)) scale(1); }
}

/* ==========================================================================
   PAGE 3 — secret letter
   ========================================================================== */
.wish-hero {
  position: relative;
  text-align: center;
  padding: 4.5rem 1.25rem 1rem;
}
.wish-hero .kicker { font-family: var(--font-head); letter-spacing: .08em; }
.wish-hero h1 { font-family: var(--font-head); font-size: clamp(2.1rem, 5.5vw, 3.4rem); margin-top: .3rem; }
.wish-hero p { margin-top: .6rem; max-width: 30rem; margin-inline: auto; }

.letter-progress {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-top: 1.2rem;
  background: var(--gray-100);
  border: 1px solid var(--ink);
  padding: .5em 1.1em;
  border-radius: var(--radius-pill);
  font-family: var(--font-head);
}
.letter-progress.complete {
  background: var(--ink);
  color: var(--white);
}

.star-field {
  position: relative;
  min-height: 40vh;
  margin: 1rem auto 0;
  max-width: 1100px;
}
.star-btn {
  position: absolute;
  background: none;
  border: none;
  padding: 0;
  width: clamp(34px, 6vw, 60px);
  transition: transform .2s var(--ease-soft), opacity .2s ease;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, .25));
}
.star-btn img { width: 100%; }
.star-btn:hover { transform: scale(1.2) rotate(6deg); }
.star-btn:active { transform: scale(.9); }
.star-btn.found {
  opacity: .3;
  pointer-events: none;
  animation: star-found .5s ease;
}
@keyframes star-found {
  0% { transform: scale(1); }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(1); opacity: .3; }
}

.paper {
  position: relative;
  width: min(640px, 92vw);
  margin: 2rem auto 0;
  background: var(--gray-100);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.7rem, 5vw, 2.6rem);
  scroll-margin: 6rem;
}
.paper-locked {
  font-family: var(--font-head);
  text-align: center;
  transition: opacity .3s ease;
}
.paper-locked.hide { display: none; }
.paper-text {
  font-family: var(--font-body);
  white-space: pre-line;
  line-height: 1.75;
  opacity: 0;
  animation: paper-in .8s var(--ease-soft) forwards;
}
.paper-text[hidden] { display: none; }
.paper-signature {
  display: block;
  margin-top: 1.2rem;
  font-family: var(--font-head);
  text-align: right;
}
@keyframes paper-in { to { opacity: 1; } }

/* ==========================================================================
   PAGE 4 — memories
   ========================================================================== */
.night-hero {
  position: relative;
  text-align: center;
  padding: 4.5rem 1.25rem 1rem;
}
.night-hero .kicker { font-family: var(--font-head); letter-spacing: .08em; }
.night-hero h1 { font-family: var(--font-head); font-size: clamp(2.1rem, 5.5vw, 3.4rem); margin-top: .3rem; }
.night-hero p { margin-top: .6rem; max-width: 30rem; margin-inline: auto; }

.memories-list {
  position: relative;
  width: min(720px, 90vw);
  margin: 1rem auto 3rem;
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
}
.memory {
  position: relative;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.2rem, 4vw, 1.8rem);
  transform: rotate(var(--rot, 0deg));
  opacity: 0;
  animation: memory-in .6s var(--ease-soft) forwards;
}
@keyframes memory-in {
  from { opacity: 0; transform: rotate(var(--rot, 0deg)) translateY(16px); }
  to { opacity: 1; transform: rotate(var(--rot, 0deg)) translateY(0); }
}
.memory-index {
  font-family: var(--font-head);
  font-size: .85rem;
  opacity: .6;
}
.memory-text { margin-top: .4rem; line-height: 1.65; }
.memory-media { margin-top: .9rem; }
.memory-media img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.signoff {
  text-align: center;
  margin-top: 3rem;
  padding-bottom: 2rem;
  font-size: .9rem;
}
.signoff .zzz {
  font-family: var(--font-head);
  display: block;
  margin-bottom: .4rem;
  letter-spacing: .1em;
}

/* ==========================================================================
   reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
