/* A Little Museum for Jaya — mobile-first */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/CormorantGaramond.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/CormorantGaramond-Italic.ttf") format("truetype");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Outfit";
  src: url("fonts/Outfit.ttf") format("truetype");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #140b0f;
  --bg-2: #1d1016;
  --cream: #f7efe6;
  --cream-dim: #e8dcd0;
  --pink: #e8a0b0;
  --pink-deep: #c45b76;
  --pink-btn: #e07a94;
  --gold: #c9a05a;
  --gold-soft: #e8d5a3;
  --ink: #2a161c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Outfit", system-ui, sans-serif;
}

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

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body { min-height: 100dvh; }

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.screen {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.85s ease, visibility 0.85s ease;
  z-index: 1;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.eyebrow {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 0.9rem;
}

.gold-rule {
  width: 72px;
  height: 1px;
  margin: 1.1rem auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.from-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--cream-dim);
  letter-spacing: 0.02em;
}

/* ---------- Loading ---------- */

#screen-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(2rem + var(--safe-top)) 1.4rem calc(2rem + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 55% at 50% 30%, rgba(196, 91, 118, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(201, 160, 90, 0.1), transparent 55%),
    var(--bg);
}

.loading-inner {
  width: min(36rem, 100%);
  text-align: center;
}

.museum-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.15rem, 9vw, 4rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: #fff;
  text-wrap: balance;
}

.countdown {
  margin: 2.2rem auto 2.4rem;
  padding: 1.15rem 0.8rem 1.25rem;
  border: 1px solid rgba(201, 160, 90, 0.28);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 0 40px rgba(201, 160, 90, 0.06) inset;
}

.countdown-label {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.9rem;
}

.countdown-units {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.unit-num {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.45rem, 6.2vw, 2.35rem);
  color: #fff;
  line-height: 1;
}

.unit-name {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim);
  opacity: 0.85;
}

.today-banner {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  color: var(--gold-soft);
  padding: 0.4rem 0 0.1rem;
}

.countdown.is-today .countdown-units,
.countdown.is-today .countdown-label { display: none; }

.countdown.is-today .today-banner { display: block; }

.progress-wrap { margin-top: 0.4rem; }

.progress-track {
  height: 3px;
  background: rgba(247, 239, 230, 0.12);
  overflow: hidden;
  border-radius: 99px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink-deep), var(--gold-soft));
  box-shadow: 0 0 12px rgba(232, 213, 163, 0.55);
  transition: width 0.16s linear;
}

.progress-label {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream-dim);
  opacity: 0.8;
}

/* ---------- Gallery ---------- */

#screen-gallery {
  background:
    radial-gradient(ellipse 90% 70% at 50% 40%, #2a161c 0%, transparent 60%),
    linear-gradient(#1a0e12, #0c0709);
  display: flex;
  flex-direction: column;
}

.gallery-top {
  position: relative;
  z-index: 4;
  text-align: center;
  padding: calc(1rem + var(--safe-top)) 1.2rem 0.4rem;
  flex: 0 0 auto;
}

.gallery-heading {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 5.5vw, 2.2rem);
  color: #fff;
}

.gallery-hint {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.hall-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(ellipse 55% 70% at 50% 48%, transparent 30%, rgba(8, 4, 6, 0.55) 100%),
    linear-gradient(90deg, rgba(8, 4, 6, 0.72), transparent 18%, transparent 82%, rgba(8, 4, 6, 0.72)),
    linear-gradient(180deg, rgba(8, 4, 6, 0.15), transparent 20%, transparent 75%, rgba(8, 4, 6, 0.55));
}

.hall {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  perspective: 90rem;
  scrollbar-width: none;
  cursor: grab;
}

.hall::-webkit-scrollbar { display: none; }
.hall.is-dragging { cursor: grabbing; }

.hall-track {
  height: 100%;
  display: flex;
  align-items: center;
  gap: clamp(1.4rem, 4vw, 3rem);
  padding: 1rem 12vw 5.5rem;
  width: max-content;
  transform-style: preserve-3d;
}

.frame-card {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: min(78vw, 22rem);
  transform: rotateY(var(--tilt, 0deg)) rotateX(2deg);
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.frame-card.is-center { --tilt: 0deg; }

.frame {
  background:
    linear-gradient(145deg, #ead7a0, #8a6a2e 40%, #f0e0b0 52%, #6d5220 80%, #d4b56a);
  padding: 12px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 230, 170, 0.25) inset,
    0 0 50px rgba(201, 160, 90, 0.12);
}

.frame-mat {
  background: #f3e8d8;
  padding: 10px 10px 36px;
}

.frame-mat img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #2a161c;
  filter: saturate(1.05) contrast(1.04);
}

.plaque {
  margin-top: 8px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: #4a3420;
}

.continue-btn {
  position: absolute;
  left: 50%;
  bottom: calc(1.1rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 5;
  appearance: none;
  border: 1px solid rgba(201, 160, 90, 0.55);
  background: rgba(20, 11, 15, 0.78);
  color: var(--cream);
  padding: 0.7rem 1.3rem 0.75rem;
  min-width: 13rem;
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.continue-btn span {
  display: block;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.continue-btn small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.continue-btn:hover,
.continue-btn:active {
  background: rgba(42, 22, 28, 0.95);
  border-color: var(--gold-soft);
  transform: translateX(-50%) translateY(-1px);
}

/* ---------- Board ---------- */

#screen-board {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1.2rem + var(--safe-top)) 1.1rem calc(1.2rem + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(196, 91, 118, 0.2), transparent 62%),
    var(--bg);
}

.board-card {
  width: min(34rem, 100%);
  text-align: center;
  padding: 1.6rem 1.15rem 1.4rem;
  border: 1px solid rgba(201, 160, 90, 0.32);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015)),
    rgba(20, 11, 15, 0.6);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.board-question {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.55rem, 6.4vw, 2.35rem);
  line-height: 1.25;
  text-wrap: balance;
  color: #fff;
}

.tease {
  min-height: 1.4em;
  margin: 0.85rem 0 1.15rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--pink);
  transition: opacity 0.2s ease;
}

.btn-stage {
  position: relative;
  min-height: 13.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.85rem;
  padding: 0.4rem 0.2rem 0.6rem;
  overflow: hidden;
  touch-action: none;
}

.btn {
  appearance: none;
  border: 0;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, font-size 0.22s ease, width 0.22s ease, height 0.22s ease, padding 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
}

.btn-yes {
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, #f094a8, var(--pink-btn) 45%, var(--pink-deep));
  color: #fff;
  padding: 0.85rem 1.7rem;
  min-width: 6.4rem;
  font-size: 1rem;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(196, 91, 118, 0.4);
}

.btn-yes:hover { filter: brightness(1.05); }

.btn-no {
  position: relative;
  z-index: 3;
  background: #f7efe6;
  color: var(--ink);
  padding: 0.85rem 1.7rem;
  min-width: 6.4rem;
  font-size: 1rem;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  will-change: transform, left, top;
}

.btn-no.is-fleeing {
  position: absolute;
  z-index: 4;
}

/* ---------- Celebrate ---------- */

#screen-celebrate {
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(196, 91, 118, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(201, 160, 90, 0.14), transparent 50%),
    var(--bg);
}

.fx-canvas, .petals, .balloons {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.petals, .balloons { overflow: hidden; }

.celebrate-inner {
  position: relative;
  z-index: 7;
  width: min(40rem, 100%);
  margin: 0 auto;
  padding: calc(2rem + var(--safe-top)) 1.3rem calc(3rem + var(--safe-bottom));
  text-align: center;
}

.celebrate-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 9vw, 3.6rem);
  line-height: 1.15;
  color: #fff;
  text-wrap: balance;
}

.birthday-message {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 3.6vw, 1.35rem);
  line-height: 1.65;
  color: var(--cream-dim);
  white-space: pre-line;
  margin: 0.3rem 0 1rem;
}

.cake-scene { margin-top: 1.6rem; }

.cake-hint {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.9rem;
}

.cake {
  --cake-w: min(220px, 70vw);
  width: var(--cake-w);
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.candles {
  display: flex;
  justify-content: center;
  gap: 14px;
  height: 64px;
  align-items: flex-end;
  position: relative;
  z-index: 2;
}

.candle {
  width: 10px;
  height: 42px;
  background: linear-gradient(90deg, #f4e7c3, #fffaf0 45%, #e6d3a0);
  border-radius: 2px 2px 0 0;
  position: relative;
  border: 0;
  padding: 0;
  appearance: none;
  box-shadow: 1px 0 0 rgba(0,0,0,0.08);
}

.candle .wick {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 2px;
  height: 7px;
  background: #3a2a20;
  transform: translateX(-50%);
}

.candle .flame {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 12px;
  height: 20px;
  margin-left: -6px;
  background: radial-gradient(circle at 50% 70%, #fff6c8 0 25%, #ffb347 45%, #ff6b3d 80%, transparent 81%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform-origin: 50% 100%;
  animation: flicker 0.7s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 8px #ffb347);
}

.candle.is-out .flame { display: none; }

.candle .smoke {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 8px;
  height: 28px;
  margin-left: -4px;
  background: radial-gradient(ellipse at 50% 80%, rgba(220,220,220,0.45), transparent 70%);
  border-radius: 50%;
  animation: smoke 1.4s ease-out forwards;
}

.candle.is-out .smoke { display: block; }

.frosting {
  width: 100%;
  height: 22px;
  background: radial-gradient(circle at 20% 0, #fff, transparent 30%),
              linear-gradient(180deg, #f7c9d4, #e07a94);
  border-radius: 40% 40% 8px 8px;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 0 #c45b76;
}

.frosting::before,
.frosting::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  background: #f3b6c4;
  border-radius: 50%;
  top: 8px;
}

.frosting::before { left: 12%; }
.frosting::after { right: 12%; box-shadow: -50px 2px 0 #f3b6c4, -100px 0 0 #f3b6c4; }

.layer {
  width: 100%;
  height: 58px;
  background:
    repeating-linear-gradient(90deg, #5a321c 0 14px, #4a2816 14px 28px),
    linear-gradient(180deg, #6a3a22, #3e2114);
  background-blend-mode: multiply, normal;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 14px 20px rgba(0,0,0,0.35);
  position: relative;
}

.layer::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 12px;
  height: 8px;
  background: repeating-linear-gradient(90deg, #f3b6c4 0 10px, transparent 10px 18px);
  border-radius: 4px;
  opacity: 0.9;
}

.plate {
  width: 122%;
  height: 12px;
  margin-top: -4px;
  background: linear-gradient(180deg, #f0e4d0, #c9b496);
  border-radius: 50%;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.wish {
  margin-top: 1.1rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--gold-soft);
}

/* petals + balloons */

.petal {
  position: absolute;
  top: -10%;
  width: 14px;
  height: 18px;
  background: radial-gradient(circle at 30% 30%, #f6c2cd, #c45b76);
  border-radius: 80% 0 80% 0;
  opacity: 0.85;
  animation: fall linear forwards;
}

.petal:nth-child(odd) {
  background: radial-gradient(circle at 30% 30%, #f8d9a8, #c9a05a);
  border-radius: 0 80% 0 80%;
}

.balloon {
  position: absolute;
  bottom: -20%;
  width: 42px;
  height: 54px;
  border-radius: 50% 50% 48% 48%;
  animation: float-up linear forwards;
}

.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 70px;
  background: rgba(247, 239, 230, 0.45);
}

.balloon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: inherit;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

@keyframes flicker {
  from { transform: scaleY(0.92) rotate(-6deg); }
  to { transform: scaleY(1.08) rotate(6deg); }
}

@keyframes smoke {
  from { opacity: 0.6; transform: translateY(0) scaleX(1); }
  to { opacity: 0; transform: translateY(-28px) scaleX(1.6); }
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.9; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0.15; }
}

@keyframes float-up {
  0% { transform: translateY(0) rotate(-4deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-130vh) rotate(6deg); opacity: 0.7; }
}

@media (min-width: 768px) {
  .board-card { padding: 2.4rem 2.2rem 2rem; }
  .btn-stage { min-height: 16rem; }
  .frame-card { width: min(28vw, 24rem); }
  .hall-track { padding: 1.5rem 18vw 6rem; }
  .countdown { margin-top: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { transition-duration: 0.2s; }
  .candle .flame { animation: none; }
  .petal, .balloon { animation-duration: 8s !important; }
}
