@font-face { font-family: "Nunito"; src: url(assets/Nunito-SemiBold.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: "Nunito"; src: url(assets/Nunito-Bold.ttf); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url(assets/Nunito-Black.ttf); font-weight: 900; font-display: swap; }
@font-face { font-family: "Caveat"; src: url(assets/Caveat-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  /* night palette, pulled from the app's navy/mint/lilac/gold */
  --dusk: #2a3378;
  --night: #151b4d;
  --deep: #0a0d2a;
  --cream: #f7f0e0;
  --cream-dim: #c9c4d9;
  --muted: #9a98bd;
  --mint: #6fcfa8;
  --lilac: #a79ce8;
  --gold: #e9b820;
  --line: rgba(247, 240, 224, .12);
  --card: rgba(247, 240, 224, .05);
  --stitch: rgba(210, 192, 148, .45);
  --p: 0; /* scroll progress 0..1, set by app.js */
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--night);
  color: var(--cream);
  font: 600 18px/1.6 "Nunito", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }
.hand { font-family: "Caveat", cursive; font-weight: 700; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--cream); color: var(--night); padding: 8px 12px; border-radius: 8px; }

/* The sky darkens as you scroll down the page */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 70% at 75% 0%, color-mix(in srgb, var(--dusk) calc((1 - var(--p)) * 100%), var(--deep)) 0%, transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--night) calc((1 - var(--p)) * 100%), var(--deep)), var(--deep));
}
.stars { position: absolute; inset: 0; opacity: calc(.35 + var(--p) * .65); }
.stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--cream); opacity: .7; }
.stars i.big { width: 3px; height: 3px; box-shadow: 0 0 6px rgba(247,240,224,.7); }
[data-motion="on"] .stars i { animation: twinkle var(--d, 4s) ease-in-out var(--delay, 0s) infinite; }
@keyframes twinkle { 50% { opacity: .15; } }

/* Nav */
.nav { display: flex; align-items: center; justify-content: space-between; padding: 22px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; text-decoration: none; letter-spacing: -.01em; }
.brand img { border-radius: 10px; }
.nav nav { display: flex; gap: 28px; font-size: 15px; }
.nav nav a { text-decoration: none; color: var(--cream-dim); }
.nav nav a:hover { color: var(--cream); }

/* Shared type */
.kicker { margin: 0 0 14px; font-size: 13px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--mint); }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.025em; line-height: 1.02; }
h2 { font-size: clamp(36px, 5vw, 60px); }
.body { color: var(--cream-dim); max-width: 34em; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 24px; border-radius: 16px; border: 0;
  background: var(--cream); color: var(--night);
  font: 900 16px "Nunito", sans-serif; text-decoration: none; cursor: pointer;
  outline: 2px dashed rgba(21, 27, 77, .25); outline-offset: -6px;
  transition: transform .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(233, 184, 32, .18); }
.btn.ghost { background: transparent; color: var(--cream); border: 1.5px solid var(--line); outline-color: var(--stitch); }
:focus-visible { outline: 2px solid var(--gold) !important; outline-offset: 3px !important; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 40px; min-height: calc(100svh - 90px); padding-bottom: 60px; }
.clock { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 28px; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 15px; color: var(--cream-dim); }
.clock .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px var(--gold); }
h1 { font-size: clamp(48px, 7.4vw, 96px); }
h1 .soft { color: var(--lilac); }
.lede { margin: 28px 0 36px; font-size: 20px; color: var(--cream-dim); max-width: 30em; }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.status span { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }

.hero-art { position: relative; aspect-ratio: 1; }
.moon {
  position: absolute; inset: 8%; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fbf6ea, #efe6d2 55%, #d9cba6);
  box-shadow: 0 0 80px rgba(247, 240, 224, .25), 0 0 200px rgba(167, 156, 232, .25);
}
.moon::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; border: 2px dashed rgba(181, 163, 122, .5); }
.fish { position: absolute; left: 2%; right: 2%; top: 2%; aspect-ratio: 1; }
.fish-body { position: relative; z-index: 1; width: 100%; height: auto; filter: drop-shadow(0 24px 30px rgba(10, 13, 42, .45)); }
.pompom { position: absolute; width: 18.18%; left: 70.02%; top: 19.62%; transform-origin: 11.84% 21.49%; }
[data-motion="on"] .fish { animation: float 7s ease-in-out infinite; }
[data-motion="on"] .pompom { animation: swing 3.5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-14px) rotate(-1.5deg); } }
@keyframes swing { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }
.zzz { position: absolute; right: 2%; top: -2%; margin: 0; font-size: 46px; color: var(--cream); display: flex; gap: 2px; }
.zzz span:nth-child(2) { font-size: .8em; transform: translateY(-20px); }
.zzz span:nth-child(3) { font-size: .6em; transform: translateY(-38px); }
[data-motion="on"] .zzz span { animation: drift 3s ease-in-out infinite; }
[data-motion="on"] .zzz span:nth-child(2) { animation-delay: .4s; }
[data-motion="on"] .zzz span:nth-child(3) { animation-delay: .8s; }
@keyframes drift { 50% { opacity: .35; } }

/* Tonight timeline */
section { padding: 110px 0; }
.hero { padding-top: 0; }
.sec-head { margin-bottom: 56px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 18px; border-top: 2px dashed var(--stitch); }
.timeline time { position: relative; display: inline-block; padding: 4px 12px; margin-bottom: 26px; border-radius: 999px; background: var(--night); border: 1px solid var(--line); font-weight: 900; font-size: 17px; }
.timeline time small { font-size: 11px; color: var(--muted); }
.card { padding: 28px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); height: calc(100% - 60px); }
/* Embroidered patch icons: clip each image to its own stitched edge so no linen background shows */
.patch-icon { display: block; width: 64px; height: 64px; margin-bottom: 20px; filter: drop-shadow(0 6px 10px rgba(5, 7, 26, .5)); transition: transform .3s ease; }
.patch-icon img { width: 100%; height: 100%; object-fit: fill; }
.patch-icon.p-ring { transform: rotate(-3deg); }
.patch-icon.p-ring img { clip-path: inset(4.5% 3.5% 5% 3.5% round 22%); }
.patch-icon.p-block { transform: rotate(2deg); }
.patch-icon.p-block img { clip-path: inset(3% 4% 3.5% 3.5% round 22%); }
.patch-icon.p-moon { width: 58px; transform: rotate(-2deg); }
.patch-icon.p-moon img { clip-path: inset(4% 3.5% 4% 4.5% round 15%); }
[data-motion="on"] .card:hover .patch-icon { transform: rotate(0) scale(1.06); }
.card h3 { font-size: 24px; margin-bottom: 10px; }
.card p { margin: 0; color: var(--cream-dim); font-size: 16px; }

/* Sleep Defense */
.defense-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 64px; align-items: start; }
.defense h2 { margin-bottom: 18px; }
.modes { list-style: none; padding: 0; margin: 36px 0 0; border-top: 1px solid var(--line); }
.modes li { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.modes b { font-weight: 900; }
.modes span { color: var(--cream-dim); font-size: 16px; }
.breathe { position: sticky; top: 40px; text-align: center; padding: 36px 28px; border-radius: 32px; background: var(--card); border: 1px solid var(--line); outline: 2px dashed var(--stitch); outline-offset: -12px; }
.breathe h3 { font-size: 34px; font-weight: 700; letter-spacing: 0; color: var(--lilac); }
.orb-wrap { position: relative; display: grid; place-items: center; height: 280px; }
.orb { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, var(--mint), #3f8f8a 70%); box-shadow: 0 0 60px rgba(111, 207, 168, .35); transform: scale(1); transition: transform 4s ease-in-out; }
.orb.in { transform: scale(2.1); }
.orb.out { transition-duration: 6s; transform: scale(1); }
.orb-label { position: absolute; margin: 0; font-weight: 900; color: var(--night); font-size: 17px; }
.fine { margin: 14px 0 0; font-size: 14px; color: var(--muted); }

/* Preview */
.preview { display: grid; grid-template-columns: .8fr 1.2fr; gap: 80px; align-items: center; }
.phone { margin: 0; justify-self: center; width: min(300px, 68vw); padding: 10px; border-radius: 48px; background: #05071a; box-shadow: 0 0 0 1px var(--line), 0 40px 90px rgba(0,0,0,.5), 0 0 120px rgba(167,156,232,.15); transform: rotate(-3deg); }
.phone img { border-radius: 38px; }
.preview h2 { margin-bottom: 18px; }
.facts { margin: 36px 0 0; display: grid; gap: 14px; }
.facts div { padding: 18px 22px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.facts dt { font-weight: 900; }
.facts dd { margin: 2px 0 0; color: var(--cream-dim); font-size: 16px; }

/* Story */
.story { text-align: center; max-width: 820px; }
.story h2 { font-size: clamp(32px, 4.4vw, 52px); margin-bottom: 22px; }
.story .body { margin-inline: auto; font-size: 20px; }

/* Closing */
.closing { text-align: center; padding: 120px 16px 140px; }
.closing h2 { font-size: clamp(72px, 12vw, 150px); font-weight: 700; letter-spacing: 0; line-height: 1; margin: 0 0 40px; color: var(--cream); text-shadow: 0 0 40px rgba(247,240,224,.25); }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 28px 0 40px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.brand.small { font-size: 15px; color: var(--cream); }
.brand.small img { border-radius: 6px; }

/* Lights out */
.goodnight { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; text-align: center; gap: 24px; background: #020309; animation: fade 1.2s ease both; }
.goodnight[hidden] { display: none; }
.goodnight p { margin: 0; font-size: clamp(56px, 10vw, 110px); color: rgba(247,240,224,.18); }
.goodnight button { justify-self: center; background: none; border: 1px solid rgba(247,240,224,.12); color: rgba(247,240,224,.35); font: 700 14px "Nunito", sans-serif; padding: 10px 18px; border-radius: 999px; cursor: pointer; }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 860px) {
  .nav nav { display: none; }
  .hero, .defense-grid, .preview { grid-template-columns: 1fr; }
  .hero { min-height: 0; padding-top: 20px; gap: 24px; }
  .hero-art { order: -1; width: min(360px, 86vw); justify-self: center; }
  section { padding: 72px 0; }
  .timeline { grid-template-columns: 1fr; gap: 18px; }
  .timeline::before { display: none; }
  .timeline time { margin-bottom: 12px; }
  .card { height: auto; }
  .modes li { grid-template-columns: 1fr; gap: 2px; }
  .breathe { position: static; }
  .preview { gap: 48px; }
  .preview-copy { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .orb, .orb.out { transition-duration: .01s; }
  .goodnight { animation: none; }
}
