/* Night-sky birthday page. Mobile first: base styles are for phones,
   the media queries at the bottom add room on bigger screens. */
:root {
  --sky: #04071a;
  --ink: #ece6d3;
  --mute: #8f97b4;
  --gold: #f3d58a;
  --gold-ink: #1d1a12;
  --card: rgba(11, 17, 40, 0.86);
  --line: rgba(243, 213, 138, 0.24);

  --f-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  font-family: var(--f-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

/* ---------- top bar ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 5;
  padding: calc(var(--safe-t) + 14px) max(18px, var(--safe-r)) 0 max(18px, var(--safe-l));
  display: grid;
  gap: 6px;
  pointer-events: none;
  transition: opacity 0.8s;
}
body.intro .hud { opacity: 0; }
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow, .kicker, .coords {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}
.coords { display: none; letter-spacing: 0.06em; }
.hud-right { position: relative; flex: none; }
.dots { display: flex; gap: 6px; }
/* mute toggle: small, faded, tucked under the dots; doesn't change the bar's height */
.sound {
  position: absolute;
  top: 100%;
  right: -9px;
  margin-top: 4px;
  padding: 7px;
  border: 0;
  background: none;
  color: var(--mute);
  opacity: 0.4;
  pointer-events: auto;
  line-height: 0;
  transition: opacity 0.3s;
}
.sound:focus-visible { opacity: 0.8; }
@media (hover: hover) { .sound:hover { opacity: 0.8; } }
.sound svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound .spk { fill: currentColor; stroke: none; }
.sound .off, .sound.muted .on { display: none; }
.sound.muted .off { display: inline; }
.dots i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--gold); opacity: 0.55; transition: background 0.4s, opacity 0.4s; }
.dots i.on { background: var(--gold); opacity: 1; }
.hint {
  margin: 0;
  font-style: italic;
  font-size: 18px;
  line-height: 1.25;
  max-width: 30ch;
  text-wrap: balance;
}
.hint.flash { animation: rise 0.6s both; }

/* ---------- intro ---------- */
.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(var(--safe-t) + 24px) max(24px, var(--safe-r)) calc(var(--safe-b) + 44px) max(24px, var(--safe-l));
  background: linear-gradient(180deg, rgba(4, 7, 26, 0) 0%, rgba(4, 7, 26, 0.5) 40%, rgba(4, 7, 26, 0.94) 100%);
  transition: opacity 1.4s, visibility 0s 1.4s;
}
.intro-screen.gone { opacity: 0; visibility: hidden; }
.intro-in { width: 100%; max-width: 520px; margin: 0 auto; display: grid; gap: 12px; }
/* stay hidden until the fonts have loaded, so the title never jumps from 2 lines to 1 */
.intro-in > * { opacity: 0; }
.fonts-ready .intro-in > * { animation: rise 1.1s both; }
.fonts-ready .intro-in > :nth-child(2) { animation-delay: 0.25s; }
.fonts-ready .intro-in > :nth-child(3) { animation-delay: 0.5s; }
.fonts-ready .intro-in > :nth-child(4) { animation-delay: 0.9s; }
.intro-in .kicker { color: var(--gold); }
h1 {
  margin: 0;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(46px, 13vw, 76px);
  line-height: 0.96;
  text-wrap: balance;
}
.intro-text { margin: 0; font-size: 20px; line-height: 1.35; color: #cfcbd0; max-width: 28ch; }

/* ---------- buttons ---------- */
.btn {
  justify-self: start;
  margin-top: 10px;
  padding: 12px 26px 13px;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(243, 213, 138, 0.08);
  color: var(--gold);
  font-style: italic;
  font-size: 21px;
  line-height: 1.1;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); background: rgba(243, 213, 138, 0.2); }
.btn.solid { background: var(--gold); color: var(--gold-ink); }
.btn.quiet { border-color: transparent; background: none; color: var(--mute); }
.pill {
  position: fixed;
  z-index: 10;
  bottom: calc(var(--safe-b) + 16px);
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(11, 17, 40, 0.7);
  color: var(--gold);
  font-family: var(--f-mono);
  font-size: 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.reread { left: 50%; transform: translateX(-50%); font-family: var(--f-display); font-style: italic; font-size: 18px; padding: 9px 20px; animation: rise 0.8s both; }
.skip { left: max(16px, var(--safe-l)); color: var(--mute); }

/* ---------- memory card (slides up after each shape) ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 0 max(12px, var(--safe-r)) calc(var(--safe-b) + 12px) max(12px, var(--safe-l));
  transform: translateY(calc(100% + 24px));
  visibility: hidden;
  transition: transform 0.65s cubic-bezier(0.2, 0.85, 0.25, 1), visibility 0s 0.65s;
}
.sheet.open { transform: none; visibility: visible; transition: transform 0.65s cubic-bezier(0.2, 0.85, 0.25, 1); }
.card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--card);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}
.card .kicker { color: var(--gold); }
.card h2 {
  margin: 0;
  font-style: italic;
  font-weight: 500;
  font-size: 36px;
  line-height: 1;
  color: var(--gold);
  text-wrap: balance;
}
.card p { margin: 0; font-size: 19px; line-height: 1.38; }
.card img { width: 100%; max-height: 30dvh; object-fit: cover; border-radius: 14px; margin-block: 4px; }
.card .btn { justify-self: stretch; text-align: center; }

/* ---------- the letter ---------- */
.letter {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--safe-t) + 20px) max(12px, var(--safe-r)) calc(var(--safe-b) + 12px) max(12px, var(--safe-l));
  background: rgba(4, 7, 26, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s, visibility 0s 1s;
}
.letter.open { opacity: 1; visibility: visible; transition: opacity 1s; }
.letter .card {
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-user-select: text;
  user-select: text;
  gap: 12px;
  padding: 24px 24px 18px;
}
.letter.open .card { animation: rise 1.1s 0.2s both; }
.letter h2 { color: var(--ink); font-size: clamp(26px, 7.6vw, 44px); }
.letter-body { display: grid; gap: 12px; }
.letter-body p { font-size: 20px; line-height: 1.42; color: #ddd8d0; }
.sig { font-style: italic; font-size: 23px !important; color: var(--gold); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.actions .btn { justify-self: auto; }

.oops { position: fixed; inset: auto 0 0; padding: 24px; margin: 0; font-size: 20px; color: var(--ink); z-index: 50; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- bigger screens ---------- */
@media (min-width: 700px) {
  .hud { padding-top: calc(var(--safe-t) + 22px); padding-left: max(28px, var(--safe-l)); padding-right: max(28px, var(--safe-r)); }
  .eyebrow { font-size: 11.5px; }
  .coords { display: block; }
  .hint { font-size: 22px; }
  .sheet { padding-bottom: calc(var(--safe-b) + 28px); }
  .card { padding: 26px 28px; }
  .letter { align-items: center; }
  .letter .card { max-width: 540px; padding: 34px 36px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
