:root {
  --sky-top: #3a2f8f;
  --sky: #1a1648;
  --sky-low: #120f3a;
  --moon: #f4efff;
  --dim: #aaa3dc;
  --me: #ffc36b;
  --her: #ff6fa8;
  --text: var(--moon);
  --thread: rgba(244, 239, 255, 0.55);
  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}

/* When we're together the whole sky turns pink. */
body.together {
  --sky-top: #ffa3c8;
  --sky: #ff6fa8;
  --sky-low: #f2508f;
  --text: #1a1648;
  --dim: #4a2560;
  --me: #1a1648;
  --her: #1a1648;
  --thread: rgba(26, 22, 72, 0.7);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, var(--sky-top), var(--sky) 55%, var(--sky-low));
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: color 0.8s;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--me); outline-offset: 4px; border-radius: 4px; }

.sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.sky circle { fill: var(--moon); }
body.together .sky { opacity: 0; }

section { position: relative; z-index: 1; }
[hidden] { display: none !important; }

/* ── enter screen ─────────────────────────────────────── */

.door {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 40px;
  padding: 32px max(16px, 6vw);
}

.title {
  margin: 0;
  font-size: clamp(64px, 21vw, 200px);
  font-weight: 800;
  font-variation-settings: "wdth" 75;
  line-height: 0.82;
  letter-spacing: -0.035em;
}

.login { display: grid; gap: 10px; width: min(100%, 360px); }
.login label { color: var(--dim); font-size: 17px; }
.row { display: flex; gap: 8px; }
.login input, .note-out textarea, .adding input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  font-size: 18px;
  background: rgba(244, 239, 255, 0.08);
  border: 1px solid rgba(244, 239, 255, 0.25);
  border-radius: 10px;
}
.solid {
  padding: 12px 22px;
  font-size: 18px;
  font-weight: 700;
  background: var(--her);
  color: #1a1648;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.solid:disabled { opacity: 0.45; cursor: default; }
/* --her turns navy when we're together, so flip the label to stay readable. */
body.together .solid { color: var(--moon); }
.enter { font-size: 22px; padding: 16px 32px; }
.error { margin: 0; min-height: 1.4em; color: var(--me); font-size: 16px; }

/* ── main view ────────────────────────────────────────── */

.room {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, 5vw) max(20px, env(safe-area-inset-bottom));
}

.top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.greeting {
  margin: 0;
  font-size: clamp(22px, 3.4vw, 34px);
  font-weight: 700;
  font-variation-settings: "wdth" 85;
}

.quiet {
  background: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  color: var(--dim);
  cursor: pointer;
}

.stage { margin: 4vh -5vw 0; height: clamp(110px, 20vh, 200px); }
#string { width: 100%; height: 100%; overflow: visible; }
#thread { fill: none; stroke: var(--thread); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 2 6; stroke-linecap: round; }
#dot-me { fill: var(--me); color: var(--me); filter: drop-shadow(0 0 10px var(--me)); }
#dot-her { fill: var(--her); color: var(--her); filter: drop-shadow(0 0 10px var(--her)); }
.dot-label { fill: var(--sky); font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

main { display: grid; justify-items: center; align-content: center; text-align: center; gap: 20px; padding-bottom: 6vh; }

.reading {
  display: grid;
  justify-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  max-width: 100%;
}
.number {
  font-size: clamp(60px, 23vw, 230px);
  font-weight: 800;
  font-variation-settings: "wdth" 75;
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.unit {
  font-size: clamp(19px, 2.8vw, 30px);
  font-weight: 400;
  color: var(--dim);
  max-width: 28ch;
}
.fact {
  margin: 12px 0 0;
  max-width: 30ch;
  font-size: clamp(21px, 2.8vw, 32px);
  font-weight: 500;
  line-height: 1.25;
  text-wrap: balance;
}
.share { margin-top: 8px; }

.bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  padding-top: 32px;
  color: var(--dim);
  font-size: 15px;
}
.bottom p { margin: 0; }

/* ── incoming note ────────────────────────────────────── */

.note-in {
  max-width: 34ch;
  padding: 18px 22px;
  background: rgba(244, 239, 255, 0.1);
  border: 1px solid rgba(255, 111, 168, 0.5);
  border-radius: 18px 18px 18px 4px;
  text-align: left;
  display: grid;
  gap: 8px;
  justify-items: start;
}
.note-from { margin: 0; color: var(--dim); font-size: 15px; }
.note-unread { display: grid; gap: 8px; }
.note-text { margin: 0; font-size: 21px; font-weight: 500; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── below the fold ───────────────────────────────────── */

.below { padding: 8vh 0 12vh; }
.column { width: min(100% - 32px, 640px); margin: 0 auto; }
.below h2 {
  margin: 64px 0 18px;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 800;
  font-variation-settings: "wdth" 75;
  line-height: 0.9;
  letter-spacing: -0.03em;
}
.below .column:first-child h2:first-child { margin-top: 0; }

.records { display: grid; grid-template-columns: auto 1fr; gap: 12px 24px; margin: 0; font-size: 19px; }
.records dt { color: var(--dim); }
.records dd { margin: 0; font-weight: 700; }

.note-out { display: grid; gap: 12px; }
.note-out label { color: var(--dim); font-size: 17px; }
.note-out textarea { resize: vertical; min-height: 90px; line-height: 1.4; }
.note-history { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 18px; }
.history-text { margin: 4px 0 0; font-size: 18px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.status { margin: 0; color: var(--dim); font-size: 16px; align-self: center; }
.hint { margin: 0; color: var(--dim); font-size: 17px; }

.globe-wrap { position: relative; width: min(100% - 32px, 720px); margin: 24px auto; aspect-ratio: 1; }
/* A round porthole, so zooming in still looks like a globe and not a square map. */
#globe { width: 100%; height: 100%; border-radius: 50%; touch-action: none; cursor: grab; display: block; }
#globe:active { cursor: grabbing; }
.zoom { position: absolute; right: 0; bottom: 0; display: grid; gap: 8px; }
.round { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; background: rgba(26, 22, 72, 0.6); }

.add-photo { display: inline-block; }
.adding { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.adding img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; flex: none; }
.adding-fields { display: grid; gap: 10px; flex: 1; min-width: 0; }

.photo-view {
  width: min(100% - 32px, 720px);
  max-height: calc(100dvh - 32px);
  padding: 16px;
  border: 0;
  border-radius: 20px;
  background: #241e66;
  color: var(--moon);
}
.photo-view::backdrop { background: rgba(10, 8, 40, 0.75); }
.photo-view img { display: block; width: 100%; max-height: 65dvh; object-fit: contain; border-radius: 12px; }
.photo-caption { margin: 14px 0 0; font-size: 22px; font-weight: 600; }
.photo-meta { margin: 6px 0 14px; color: var(--dim); font-size: 15px; }
.photo-flip { align-items: center; justify-content: space-between; margin-bottom: 14px; color: var(--dim); }

/* ── together confetti ────────────────────────────────── */

.confetti {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  z-index: 2;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  body { transition: none; }
}
