/* Homepage. Colours follow the app: the stage is the Sleep night sky (Background Depth in dark mode), the page is Background App. */
.home { --depth: #0b0a14; --page: #f9f9fb; --ink: #111114; --ink2: #5f5f66; --ink3: #8e8e93; --alt: #ffffff; --alt2: rgba(255, 255, 255, 0.78); --button: #6b5cff; background: var(--page); }

.stage { position: relative; overflow: hidden; background: var(--depth); color: var(--alt); padding: 0 20px 72px; }
.sky { position: absolute; inset: 0; pointer-events: none; }
.glow { position: absolute; border-radius: 50%; }
.glow.far { width: 180%; height: 120%; left: -10%; top: -55%; background: radial-gradient(ellipse at center, rgba(136, 108, 254, 0.55) 0%, rgba(136, 108, 254, 0.2) 40%, rgba(136, 108, 254, 0) 70%); }
.glow.mid { width: 100%; height: 80%; left: 35%; top: -15%; background: radial-gradient(ellipse at center, rgba(210, 108, 254, 0.3) 0%, rgba(210, 108, 254, 0) 70%); }
.glow.near { width: 90%; height: 70%; left: -30%; top: 15%; background: radial-gradient(ellipse at center, rgba(113, 185, 233, 0.2) 0%, rgba(113, 185, 233, 0) 70%); }
.stars { position: absolute; inset: 0 0 140px; }
.star { position: absolute; border-radius: 50%; background: #fafafa; }

.stage-nav { position: relative; display: flex; justify-content: space-between; align-items: baseline; max-width: 1200px; margin: 0 auto; padding: 24px 0 8px; }
.stage-nav .wordmark { color: var(--alt); }
.stage-nav nav a { color: var(--alt2); margin: 0; }
.hero { position: relative; max-width: 1200px; margin: 0 auto; padding-top: 40px; display: grid; gap: 48px; }
.hero h1 { font-size: 40px; line-height: 48px; letter-spacing: 0.37px; margin: 0 0 14px; color: var(--alt); }
.hero-line { font-size: 18px; line-height: 24px; letter-spacing: -0.44px; color: var(--alt2); margin: 0 0 24px; }
.store-button { display: inline-block; width: 100%; max-width: 360px; box-sizing: border-box; text-align: center; padding: 16px 24px; border-radius: 28px; background: var(--button); color: #fff; font-weight: 400; font-size: 17px; line-height: 22px; letter-spacing: -0.43px; text-decoration: none; }
.qr { display: none; }

.phone { position: relative; width: 270px; margin: 0 auto; aspect-ratio: 450 / 920; }
.phone::before { content: ""; position: absolute; left: -30%; right: -30%; top: 10%; bottom: 10%; border-radius: 50%; background: radial-gradient(ellipse at center, rgba(157, 170, 255, 0.34) 0%, rgba(157, 170, 255, 0.12) 38%, rgba(157, 170, 255, 0) 70%); z-index: -1; }
.phone-bezel { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.phone-screen { position: absolute; left: 5.378%; top: 2.517%; width: 89.244%; height: 94.966%; border-radius: 13.5% / 6.2%; overflow: hidden; background: #000; }
.phone-screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.home-main { max-width: 1280px; box-sizing: border-box; margin: 0 auto; padding: 24px 20px 64px; color: var(--ink); }
.home-main h2 { font-size: 30px; line-height: 36px; letter-spacing: 0.39px; margin: 0 0 12px; }
.home-main h3 { font-size: 18px; line-height: 24px; letter-spacing: -0.44px; margin: 0 0 6px; }
.faq-grid p { font-size: 14px; line-height: 20px; letter-spacing: -0.14px; }
.three p { font-size: 15px; line-height: 20px; letter-spacing: -0.23px; }
.home-main p { color: var(--ink2); }
.day { display: grid; gap: 24px; margin-bottom: 72px; }
.day-words p { font-size: 18px; max-width: 30rem; }
.feed-fit { width: 100%; }
.three { display: grid; gap: 32px; margin-bottom: 72px; }
.three h3 { font-size: 30px; line-height: 36px; letter-spacing: 0.39px; }
.faq-grid { display: grid; gap: 20px; margin-top: 20px; }
.closing { text-align: center; margin: 64px 0 0; }
.home-footer { max-width: 1280px; box-sizing: border-box; margin: 0 auto; padding: 20px 20px 40px; border-top: 1px solid rgba(127, 127, 140, 0.25); color: var(--ink3); font-size: 13px; }
.home-footer a { color: var(--ink2); margin-right: 16px; text-decoration: none; }

/* The feed: rows cropped from the app's own LifeStream render (1134 × 3090 at 3×, 378 pt wide). */
.feed { position: relative; width: 378px; }
.feed .row { position: absolute; left: 0; width: 378px; height: 48px; z-index: 1; }
.feed .part { position: absolute; top: 0; height: 48px; background-size: 378px auto; background-repeat: no-repeat; }
.feed-light .part, .feed-light .card { background-image: url("/assets/feed-light.png?v=3132fcbd48"); }
.feed-dark .part, .feed-dark .card { background-image: url("/assets/feed-dark.png?v=54ee304271"); }
.feed .time { left: 0; width: 34px; }
.feed .words { left: 84px; width: 294px; }
.feed .icon { left: 36px; top: 0; width: 48px; height: 48px; }
.feed .card { position: absolute; left: 0; width: 378px; height: 150px; background-size: 378px auto; background-repeat: no-repeat; }
/* One lifeline from the first icon down to the now marker, as in Today. */
.feed .lifeline { position: absolute; left: 58.75px; top: 24px; width: 2.5px; height: 0; border-radius: 2px; background: #d9d9de; z-index: 0; }
.feed .now-marker { position: absolute; left: 0; top: 0; width: 378px; height: 12px; z-index: 2; }
.feed .now-time { position: absolute; left: 0; top: -2px; font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; color: #8e8e93; }
.feed .now-dot { position: absolute; left: 56px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: #7b6cf6; }
.feed .now-rule { position: absolute; left: 70px; right: 0; top: 5.5px; height: 1px; background: #d1d1d6; }
.feed:not(.playing) .now-marker { opacity: 0; }
.feed.playing .row:not(.in), .feed.playing .card:not(.in) { visibility: hidden; }

@media (min-width: 900px) {
  .stage { padding: 0 40px 120px; }
  .hero { grid-template-columns: 1fr 340px; align-items: center; gap: 80px; padding-top: 72px; }
  .hero h1 { font-size: 60px; line-height: 68px; letter-spacing: 0.28px; max-width: 620px; }
  .hero-line { font-size: 18px; }
  .store-button { width: auto; min-width: 320px; }
  .qr { display: flex; gap: 12px; align-items: center; margin-top: 28px; }
  .qr img { box-sizing: content-box; width: 76px; height: 76px; border-radius: 16px; background: #fff; padding: 10px; image-rendering: pixelated; }
  .qr p { color: var(--alt2); font-size: 14px; max-width: 16rem; margin: 0; }
  .phone { width: 330px; margin: 0; }
  .home-main { padding: 72px 40px 96px; }
  .home-main h2 { font-size: 40px; line-height: 48px; letter-spacing: 0.37px; }
  .day { grid-template-columns: 1fr 440px; gap: 96px; align-items: start; }
  .three { grid-template-columns: repeat(3, 1fr); gap: 48px; }
  .faq-grid { grid-template-columns: 1fr 1fr; gap: 24px 48px; }
  .home-footer { display: flex; justify-content: space-between; padding: 24px 40px 48px; }
}

/* Polish: rhythm, hierarchy, one grid. */
.home h1, .home h2, .home h3 { text-wrap: balance; }
.home p { text-wrap: pretty; }
.stage { padding: 0 20px 72px; }
.hero { padding-top: 48px; }
.home-main { padding: 96px 20px 64px; }
.home-main h2 { font-size: 40px; line-height: 48px; letter-spacing: 0.37px; }
.day { margin-bottom: 96px; }
.three { gap: 40px; margin-bottom: 96px; }
.three h3 { font-size: 22px; line-height: 28px; letter-spacing: -0.26px; font-weight: 500; }
.faq-grid p { font-size: 15px; line-height: 20px; letter-spacing: -0.23px; color: var(--ink2); }
.closing { text-align: center; margin: 96px 0 0; }
.closing h2 { margin-bottom: 24px; }
.home-footer p:last-child { font-size: 12px; line-height: 16px; }
@media (min-width: 900px) {
  .phone-only { display: none; }
  .stage { padding: 0 40px 120px; }
  .hero { padding-top: 64px; }
  .qr { margin-top: 32px; }
  .home-main { padding: 160px 40px 120px; }
  .home-main h2 { font-size: 60px; line-height: 68px; letter-spacing: 0.28px; }
  .day { grid-template-columns: minmax(0, 1fr) 440px; gap: 120px; margin-bottom: 160px; }
  .day-words { position: sticky; top: 140px; align-self: start; }
  .three { grid-template-columns: repeat(3, 1fr); gap: 48px; margin-bottom: 160px; }
  .faq { display: grid; grid-template-columns: 368px 1fr; gap: 48px; }
  .faq-grid { margin-top: 0; grid-template-columns: 1fr 1fr; gap: 40px 48px; }
  .closing { margin-top: 200px; }
  .closing h2 { margin-bottom: 32px; }
}

/* The night runs under the status bar and Safari's toolbar: the page's canvas is the sky's colour, and the
   sections below carry their own light background. */
html:has(body.home) { background: #0b0a14; }
.home { background: transparent; }
.home-main, .home-footer { background: var(--page); }
.home-footer { max-width: none; padding-left: max(20px, calc((100% - 1200px) / 2)); padding-right: max(20px, calc((100% - 1200px) / 2)); border-top: none; box-shadow: inset 0 1px 0 rgba(127, 127, 140, 0.25); }
.home-main { max-width: none; padding-left: max(20px, calc((100% - 1240px) / 2)); padding-right: max(20px, calc((100% - 1240px) / 2)); }
.home-main > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.stage { padding-top: env(safe-area-inset-top); }

/* Stars twinkle as in the app's sky: each dips at its own pace, harder and quicker near the horizon. */
.star { opacity: var(--o); animation: twinkle var(--t) ease-in-out infinite; animation-delay: var(--delay); }
@keyframes twinkle {
  0%, 100% { opacity: var(--o); }
  25% { opacity: calc(var(--o) * (1 - var(--d))); }
  50% { opacity: var(--o); }
  75% { opacity: calc(var(--o) * (1 - var(--d) * 0.5)); }
}
/* Shooting stars: a short bright streak whose tail fades behind it. */
.shooting { position: absolute; width: 70px; height: 1.5px; border-radius: 1px; background: linear-gradient(to right, rgba(250, 250, 250, 0), rgba(250, 250, 250, 0.95)); transform-origin: 100% 50%; pointer-events: none; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .star { animation: none; } }
@media (min-width: 900px) { .home-footer { display: flex; justify-content: space-between; padding-top: 24px; padding-bottom: 48px; } }
/* Safari tints the status bar with the canvas colour; the sky fades up into that colour so there is no seam. */
.sky::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 120px; background: linear-gradient(to bottom, #0b0a14, rgba(11, 10, 20, 0)); z-index: 1; }
.stage-nav, .hero { z-index: 2; }

/* The hero video never shows Safari's play button. */
/* The video stays invisible until it really plays, so Safari's play button, drawn when Low Power Mode blocks autoplay, never shows. The still sits under it. */
.phone-screen .phone-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.phone-screen video { opacity: 0; transition: opacity 0.3s; }
.phone-screen.playing video { opacity: 1; }
/* Stars drift slower than the page, driven by the scroll itself so they never lag it. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .stars { animation: star-drift linear both; animation-timeline: scroll(root block); animation-range: 0 1000px; }
    @keyframes star-drift { from { transform: translateY(0); } to { transform: translateY(300px); } }
  }
}
/* Safari fills the bars' edges with the canvas colour: night while the sky is on screen, the page once past it. */
html.past-sky:has(body.home) { background: #f9f9fb; }
