/* ---------- Tokens: light = dusk, dark = moonlit night ---------- */
:root {
  --sky-top: #f6c3cf;
  --sky-mid: #f1d6e6;
  --sky-low: #bfb0e6;
  --ink: #2c1a3c;
  --muted: #5e4470;
  --paper: rgba(255, 251, 253, 0.9);
  --paper-edge: rgba(255, 255, 255, 0.95);
  --paper-shadow: 0 24px 60px -24px rgba(90, 30, 80, 0.38), 0 2px 8px -2px rgba(90, 30, 80, 0.12);
  --rule: rgba(94, 68, 112, 0.18);
  --rose: #d93d74;
  --rose-soft: rgba(217, 61, 116, 0.1);
  --rose-ink: #ffffff;
  --butter: #b9822a;
  --star-opacity: 0.35;
  --display: "Sniglet", "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-top: #0f0b26;
    --sky-mid: #22184a;
    --sky-low: #4a2a5e;
    --ink: #fbeff5;
    --muted: #d9c6e4;
    --paper: rgba(30, 20, 58, 0.88);
    --paper-edge: rgba(255, 233, 176, 0.18);
    --paper-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6), 0 2px 8px -2px rgba(0, 0, 0, 0.3);
    --rule: rgba(217, 198, 228, 0.18);
    --rose: #ff7aa2;
    --rose-soft: rgba(255, 122, 162, 0.13);
    --rose-ink: #2a0f22;
    --butter: #ffe3a3;
    --star-opacity: 1;
  }
}
:root[data-theme="dark"] {
  --sky-top: #0f0b26;
  --sky-mid: #22184a;
  --sky-low: #4a2a5e;
  --ink: #fbeff5;
  --muted: #d9c6e4;
  --paper: rgba(30, 20, 58, 0.88);
  --paper-edge: rgba(255, 233, 176, 0.18);
  --paper-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6), 0 2px 8px -2px rgba(0, 0, 0, 0.3);
  --rule: rgba(217, 198, 228, 0.18);
  --rose: #ff7aa2;
  --rose-soft: rgba(255, 122, 162, 0.13);
  --rose-ink: #2a0f22;
  --butter: #ffe3a3;
  --star-opacity: 1;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--sky-mid);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Fixed background layers ---------- */
.sky {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
}
#scene {
  position: fixed; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  display: block;
  touch-action: pan-y;
}

/* ---------- Content ---------- */
main { pointer-events: none; }
main a, main button, .note, .counter { pointer-events: auto; }

section { padding: 0 clamp(1rem, 5vw, 4.5rem); }

/* Shared card look */
.note, .counter, .hint, .sound {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow: var(--paper-shadow);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding-top: clamp(3rem, 10vh, 6.5rem);
}
.names {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.8rem, 9vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: 0;
  margin: 0;
  color: var(--ink);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 0 0.3em;
}
.names .amp { color: var(--rose); }

.eyebrow {
  margin: 1.4rem 0 0.6rem;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.counter {
  display: flex;
  border-radius: 22px;
  padding: 0.7rem 0.4rem;
}
.unit {
  min-width: 4.6rem;
  padding: 0 0.6rem;
  display: flex; flex-direction: column; align-items: center;
}
.unit + .unit { border-left: 1px solid var(--rule); }
.unit b {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.7rem, 4.4vw, 2.3rem);
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.unit span {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.since-tail {
  margin: 0.7rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

.hint {
  margin-top: auto;
  margin-bottom: 4.75rem;
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--display);
  font-size: 1rem;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
}
.hint svg { width: 1rem; height: 1rem; color: var(--rose); animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }

/* ---------- Story panels ---------- */
.panel {
  min-height: 100svh;
  display: flex; align-items: center;
  padding-top: 4rem; padding-bottom: 4rem;
}
.note {
  width: min(100%, 33rem);
  border-radius: 28px 28px 28px 8px;
  padding: clamp(1.4rem, 3.5vw, 2.4rem);
}
.panel.right { justify-content: flex-end; }
.panel.right .note { border-radius: 28px 28px 8px 28px; }

h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.1;
  margin: 0 0 1.5rem;
  text-wrap: balance;
}

/* Timeline: a trail of paw prints, one per week */
.trail { list-style: none; margin: 0; padding: 0; }
.trail li {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0 1rem;
  position: relative;
  padding-bottom: 1.6rem;
}
.trail li:last-child { padding-bottom: 0; }
.trail li:not(:last-child)::after {
  content: "";
  position: absolute; left: 1.2rem; top: 2.8rem; bottom: 0.5rem;
  border-left: 2px dotted var(--rose);
  opacity: 0.35;
}
.trail .print {
  width: 2.4rem; height: 2.4rem;
  color: var(--rose);
  margin-top: 0.15rem;
}
.trail li:nth-child(even) .print { transform: rotate(14deg); }
.trail li:nth-child(odd) .print { transform: rotate(-10deg); }
.trail .when {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rose);
  background: var(--rose-soft);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
.trail h3 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  margin: 0.35rem 0 0.3rem;
  line-height: 1.2;
}
.trail p { margin: 0; max-width: 60ch; }

/* Reasons: tappable treats that open in place */
.treats { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.treat {
  font: inherit;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.2;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--rose);
  border-radius: 999px;
  min-height: 2.75rem;
  padding: 0.45rem 1rem 0.45rem 0.75rem;
  display: inline-flex; align-items: center; gap: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.treat:hover { background: var(--rose-soft); }
.treat:active { transform: scale(0.97); }
.treat svg { width: 1.15rem; height: 1.15rem; color: var(--rose); flex: none; transition: transform 0.3s ease; }
.treat[aria-expanded="true"] { background: var(--rose); color: var(--rose-ink); }
.treat[aria-expanded="true"] svg { color: var(--rose-ink); transform: rotate(-20deg) scale(1.1); }
.reveal {
  min-height: 6rem;
  margin: 1.4rem 0 0;
  padding: 1rem 1.2rem;
  border-radius: 16px;
  border-left: 4px solid var(--rose);
  background: var(--rose-soft);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--ink);
}
.reveal.show { animation: rise 0.35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.reveal:empty { display: flex; align-items: center; border-left-color: transparent; }
.reveal:empty::before {
  content: attr(data-empty);
  font-weight: 400;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- Finale: a little letter ---------- */
.finale {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding-top: clamp(2.5rem, 8vh, 5rem);
  padding-bottom: 5.5rem;
}
.letter {
  width: min(100%, 36rem);
  border-radius: 28px;
  text-align: left;
}
.finale h2 { font-size: clamp(2rem, 5vw, 2.8rem); margin-bottom: 0.9rem; text-align: center; }
.finale .letter p { margin: 0; }
.finale .sign {
  margin-top: 1rem !important;
  text-align: right;
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--rose);
}
.finale .sign::before { content: "— "; }
.finale button.big {
  margin-top: 1.6rem;
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--rose-ink);
  background: var(--rose);
  border: 0;
  border-radius: 999px;
  padding: 0.95rem 1.9rem;
  box-shadow: 0 14px 30px -12px rgba(217, 61, 116, 0.75);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.finale button.big svg { width: 1.2rem; height: 1.2rem; }
.finale button.big:hover { transform: translateY(-1px); }
.finale button.big:active { transform: scale(0.96); }

/* ---------- Sound toggle ---------- */
.sound {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 2.75rem; min-width: 2.75rem;
  justify-content: center;
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.95rem 0.45rem 0.8rem;
  cursor: pointer;
  z-index: 5;
}
.sound svg { width: 1.25rem; height: 1.25rem; color: var(--rose); flex: none; }
.sound .off { display: none; }
.sound[aria-pressed="false"] .on { display: none; }
.sound[aria-pressed="false"] .off { display: inline; }
.sound[aria-pressed="false"] svg { color: var(--muted); }

/* ---------- Speech bubbles that pop out of the cats ---------- */
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  color: #2c1a3c;
  background: #fffaf3;
  padding: 0.35rem 0.8rem;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 8px 20px -8px rgba(44, 26, 60, 0.45);
  white-space: nowrap;
  animation: pop 1.5s ease-out forwards;
}
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -80%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -100%) scale(1.05); }
  25% { transform: translate(-50%, -100%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

:focus-visible { outline: 3px solid var(--butter); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  body { font-size: 1.0625rem; }
  .panel, .panel.right { justify-content: center; align-items: flex-end; padding-bottom: 5rem; }
  .unit { min-width: 0; flex: 1; padding: 0 0.5rem; }
  .counter { width: min(100%, 22rem); }
  .sound { padding: 0; width: 2.75rem; }
  .sound .label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bubble { animation-duration: 0.9s; }
  .hint svg, .reveal.show { animation: none; }
  .treat, .treat svg { transition: none; }
}
