/* Undersleep — undersleep.app */

/* Tokens: Open Air Navy, the app's own colours. The site is dark only: the navy night is
   :root, whatever the visitor's device prefers. */
:root {
  color-scheme: dark;
  --bg-top: #0A0F1E;
  --bg-bottom: #121C38;
  --surface: #0E152B;
  --ink: #F0F3F9;
  --ink2: #A6AFBF;
  --ink3: #8A94A6;
  --rule: rgba(240, 243, 249, .10);
  --rule-strong: rgba(240, 243, 249, .18);
  --link: #9BB0D9;
  --deficit: #F3B36E;
  --surplus: #8AC79A;
  --pretty: #E8836B;
  --zone-ontrack: rgba(138, 199, 154, .22);
  --zone-abit: rgba(240, 160, 84, .22);
  --zone-pretty: rgba(232, 131, 107, .22);
  --card: rgba(240, 243, 249, .04);
  --card-edge: rgba(240, 243, 249, .09);
  --screen-fill: rgba(240, 243, 249, .04);
  --screen-edge: rgba(240, 243, 249, .14);
  --screen-shadow: rgba(0, 0, 0, .6);
  --glow: rgba(240, 160, 84, .10);

  --font-text: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --gutter: 24px;
}

/* Warm paper, kept for a return to light: nothing sets data-theme, so this block is dormant. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg-top: #FAF7F0;
  --bg-bottom: #FAF7F0;
  --surface: #FAF7F0;
  --ink: #22303C;
  --ink2: #5F6975;
  --ink3: #68717B;
  --rule: rgba(34, 48, 60, .10);
  --rule-strong: rgba(34, 48, 60, .18);
  --link: #3F5F95;
  --deficit: #9E6118;
  --surplus: #2F7247;
  --pretty: #B04E33;
  --zone-ontrack: #A9D1B5;
  --zone-abit: #F0C384;
  --zone-pretty: #E6A891;
  --card: rgba(255, 255, 255, .55);
  --card-edge: rgba(34, 48, 60, .09);
  --screen-fill: rgba(34, 48, 60, .04);
  --screen-edge: rgba(34, 48, 60, .12);
  --screen-shadow: rgba(34, 48, 60, .28);
  --glow: rgba(240, 160, 84, .16);
}

/* Base */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100% }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) no-repeat;
  background-color: var(--bg-bottom);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none }
a:hover { text-decoration: underline; text-underline-offset: 3px }
a:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 6px;
}
summary::-webkit-details-marker { display: none }
.page { overflow-x: clip }
.page--fill { min-height: 100vh; display: flex; flex-direction: column }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header */
.site-header {
  width: min(1128px, 100%);
  margin: 0 auto;
  padding: 18px var(--gutter);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 2;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none }
.mark { display: block; width: 28px; height: 28px; flex-shrink: 0 }
.nav { display: flex; align-items: center; gap: 22px; font-size: 15px }
.nav a { color: var(--ink2); white-space: nowrap }
.nav a:hover { color: var(--ink); text-decoration: none }

/* Hero — shared */
.hero { position: relative; padding: 48px var(--gutter) 0; text-align: center }
.hero::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 760px;
  height: 620px;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none;
}
.hero > * { position: relative }
.hero-copy { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 18px }
h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 62px);
  line-height: 1.06;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.hero-sub {
  margin: 0;
  max-width: 620px;
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.5;
  color: var(--ink2);
  text-wrap: balance;
}
.cta { display: flex; flex-direction: column; align-items: center; gap: 10px }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
a.pill:hover { text-decoration: none; border-color: var(--ink3) }
.cta-note { margin: 0; font-size: 14px; color: var(--ink3) }
/* Apple's badge, as supplied: 48 px tall (its floor is 40), the width its own */
.store-badge { display: inline-block; line-height: 0 }
.store-badge img { height: 48px; width: auto; display: block }

/* The hero: the app's headline set in type, under the H1 */
.hero .specimen { margin: 52px auto 0 }
.hero .cta { margin-top: 44px }

/* The app's headline at web size. Every length is in em of the premise's size, so the
   proportions are the app's: 74 over 15, units at 0.55, the space at 0.4,
   the ladder's 6 pt track and 16 pt marker. */
.specimen {
  width: min(23em, 100%);
  font-size: clamp(15px, 0.9vw + 11px, 21px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.specimen p { margin: 0 }
.big-number {
  font-family: var(--font-round);
  font-size: 4.93em;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}
.big-number .u { font-size: .55em; font-weight: 700 }
.big-number .sp { font-size: .4em }
.premise { margin-top: .6em !important; color: color-mix(in srgb, var(--ink) 85%, transparent); line-height: 1.35 }
.premise b { font-weight: 600; color: var(--ink) }
.average { margin-top: .15em !important; color: var(--ink2); line-height: 1.35 }
.ladder {
  --marker: 1.067em;
  position: relative;
  width: 100%;
  height: var(--marker);
  margin-top: 1.6em;
}
.ladder-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: .4em;
  transform: translateY(-50%);
  display: flex;
  gap: 3px;
}
.zone { flex: 1; border-radius: 999px }
.zone--ontrack { background: var(--zone-ontrack); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surplus) 40%, transparent) }
.zone--abit { background: var(--zone-abit); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--deficit) 40%, transparent) }
.zone--pretty { background: var(--zone-pretty); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pretty) 40%, transparent) }
.ladder--abit .zone--abit { background: var(--deficit); box-shadow: none }
.marker {
  position: absolute;
  top: 0;
  width: var(--marker);
  height: var(--marker);
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid var(--surface);
}
/* 215 min over 13 scored nights = 16.5 min a night: the marker sits at 0.4423 of the ladder. */
.ladder--abit .marker { left: calc(0.4423 * (100% - var(--marker))); background: var(--deficit) }
.band-word { margin-top: .65em !important; font-size: 1.133em; font-weight: 600; color: var(--deficit) }

/* Screenshots: bare screens with their device's corners, a hairline and a soft shadow — the
   app's paper is the page's paper, so a light screen has no edge of its own. The <img> takes
   the <picture>'s corners, so each device's radius is set once. */
.screen { display: block; position: relative }
.screen img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: inherit;
  background: var(--screen-fill);
  box-shadow: 0 0 0 1px var(--screen-edge), 0 18px 40px -16px var(--screen-shadow);
}
.screen--iphone { border-radius: 13.7% / 6.3% }
.screen--watch { border-radius: 20% / 16.4% }
.screen--spread { border-radius: 3.5% / 5% }

/* Sections */
.section {
  width: min(1128px, 100%);
  margin: 0 auto;
  padding: 128px var(--gutter) 0;
  box-sizing: border-box;
  scroll-margin-top: 16px;
}
.section-head { max-width: 660px; display: flex; flex-direction: column; gap: 14px }
.section-head--center { margin: 0 auto; text-align: center; align-items: center }
h2 {
  margin: 0;
  font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.lede { margin: 0; font-size: clamp(17px, 1.8vw, 19px); line-height: 1.55; color: var(--ink2); text-wrap: pretty }

/* Wherever you glance */
.tiles {
  margin: 52px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 32px;
}
.tile { flex: 0 1 228px; display: flex; flex-direction: column; gap: 16px; margin: 0 }
.tile figcaption { font-size: 15px; line-height: 1.45; color: var(--ink2); text-align: center; text-wrap: pretty }
.tile figcaption b { display: block; font-weight: 600; color: var(--ink) }
.watch-pair { display: flex; flex-direction: column; align-items: center; gap: 16px }
/* Two 368 × 448 watch screens at 86 % of the tile stack to a phone's height, so the captions line up. */
.watch-pair .screen--watch { width: 86% }

/* How the number works: the About sheet's strip, then the rules */
.how { margin-top: 52px }
.strip-card {
  margin: 0 auto;
  max-width: 820px;
  padding: 32px 40px 28px;
  box-sizing: border-box;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--card-edge);
}
.strip-caption { margin: 0; text-align: center; font-size: 14px; font-weight: 600; color: var(--ink2) }
.strip svg { display: block; width: 100%; height: auto; margin-top: 10px; overflow: visible }
.strip-ends { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--ink3) }
.strip-sum { margin: 14px 0 0; text-align: center; font-size: 19px; color: var(--ink2) }
.strip-sum b { color: var(--ink); font-weight: 700 }
.strip-note { margin: 20px auto 0; max-width: 600px; padding-top: 18px; border-top: 1px solid var(--rule); text-align: center; font-size: 14.5px; line-height: 1.55; color: var(--ink3); text-wrap: pretty }
.s-rule { stroke: var(--rule-strong); stroke-width: 1 }
.s-axis { fill: var(--rule-strong) }
.s-deficit { fill: var(--deficit) }
.s-pretty { fill: var(--pretty) }
.s-surplus { fill: var(--surplus) }
.s-tail { opacity: .35 }
.s-dot { fill: var(--ink3) }
.s-pending { stroke: var(--ink3); stroke-width: 1 }
.s-leaving { opacity: .35 }

.rules {
  margin: 56px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 40px;
}
.rule-item { padding: 22px 0 26px; border-top: 1px solid var(--rule) }
.rules dt { font-size: 17px; font-weight: 600; letter-spacing: -0.01em }
.rules dd { margin: 6px 0 0; font-size: 16px; line-height: 1.55; color: var(--ink2); text-wrap: pretty }

/* Your sleep history */
.ledger-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 56px;
  align-items: center;
}
.ledger-copy { display: flex; flex-direction: column; gap: 16px }
.ledger-copy p { margin: 0 }
.phone-pair { display: flex; justify-content: center; gap: 24px }
.phone-pair .screen--iphone { flex: 0 1 236px }
/* iPhone Duo open: Today on the left page, the ledger on the right — this section's two halves
   on one screen. The open inner display's proportions, 951 × 669 pt. */
.spread { margin: 72px auto 0; max-width: 640px; display: flex; flex-direction: column; gap: 16px }
.spread figcaption { font-size: 15px; line-height: 1.45; color: var(--ink2); text-align: center; text-wrap: pretty }

/* Quiet by design */
.never {
  margin: 52px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 40px;
}
.never li { padding: 22px 0; border-top: 1px solid var(--rule) }
.never b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -0.01em }
.never span { display: block; margin-top: 4px; font-size: 16px; line-height: 1.5; color: var(--ink2) }
.privacy-line {
  margin: 36px 0 0;
  font-size: 16px;
  color: var(--ink2);
  text-align: center;
}

/* FAQ */
.section--faq { width: min(768px, 100%) }
.faq { margin-top: 32px }
.faq details { border-top: 1px solid var(--rule) }
.faq details:last-of-type { border-bottom: 1px solid var(--rule) }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.faq summary:hover { color: var(--link) }
.faq summary svg { flex-shrink: 0; color: var(--ink3); transition: transform .2s ease }
.faq details[open] > summary svg { transform: rotate(90deg) }
.faq-answer { margin: 0; padding: 0 28px 22px 2px; font-size: 16px; line-height: 1.6; color: var(--ink2); text-wrap: pretty }

/* Support */
.support {
  margin: 72px auto 0;
  width: min(640px, 100%);
  box-sizing: border-box;
  padding: 40px 32px;
  border-radius: 24px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.support h2 { font-size: clamp(24px, 3.4vw, 32px) }
.support p { margin: 0; max-width: 440px; font-size: 16px; line-height: 1.55; color: var(--ink2) }
.support-email { font-size: clamp(18px, 2.6vw, 21px); font-weight: 600 }

/* Footer */
.site-footer {
  width: min(1128px, 100%);
  margin: 128px auto 0;
  padding: 28px var(--gutter) 48px;
  box-sizing: border-box;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 24px;
  font-size: 14px;
  color: var(--ink3);
}
.page--fill .site-footer { margin-top: auto; padding-top: 28px }
.page--fill main { margin-bottom: 96px }
.site-footer p { margin: 0 }
.footer-links { display: flex; flex-wrap: wrap; gap: 20px }
.footer-links a { color: var(--ink2) }
.footer-links a:hover { color: var(--ink) }

/* Privacy policy */
.legal-head { width: min(720px, 100%); margin: 0 auto; padding: 56px var(--gutter) 0; box-sizing: border-box }
.legal-head h1 { font-size: clamp(32px, 5vw, 46px) }
.legal-date { margin: 12px 0 0; font-size: 15px; color: var(--ink3) }
.legal { width: min(720px, 100%); margin: 0 auto; padding: 0 var(--gutter); box-sizing: border-box }
.legal-lede { margin: 32px 0 0; font-size: 19px; line-height: 1.6; text-wrap: pretty }
.legal h2 { margin: 44px 0 0; font-size: 21px; letter-spacing: -0.015em }
.legal h2 + p, .legal p + p { margin: 10px 0 0; font-size: 16.5px; line-height: 1.7; color: var(--ink2); text-wrap: pretty }
.legal-sign { margin: 48px 0 0 !important; font-size: 15px !important; color: var(--ink3) !important }

/* 404 */
.notfound {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 96px var(--gutter) 0;
  text-align: center;
}
.notfound h1 { font-size: clamp(32px, 5vw, 44px) }
.notfound p { margin: 0; color: var(--ink2) }

/* Narrow screens */
@media (max-width: 900px) {
  .ledger-grid { grid-template-columns: minmax(0, 1fr); gap: 40px }
  .never, .rules { grid-template-columns: repeat(2, minmax(0, 1fr)) }
}
@media (max-width: 720px) {
  :root { --gutter: 16px }
  .site-header { padding-top: 14px; padding-bottom: 14px }
  .brand { font-size: 17px }
  .mark { width: 26px; height: 26px }
  .nav { gap: 16px; font-size: 15px }
  .hero { padding-top: 32px }
  .hero .specimen { margin-top: 40px }
  .hero .cta { margin-top: 36px }
  .section { padding-top: 88px }
  .tiles { flex-wrap: wrap; gap: 32px 16px; margin-top: 40px }
  .tile { flex: 0 1 calc(50% - 8px) }
  .tile figcaption { font-size: 14px }
  .phone-pair { gap: 16px }
  .spread { margin-top: 48px }
  .spread figcaption { font-size: 14px }
  .never, .rules { grid-template-columns: minmax(0, 1fr); margin-top: 36px }
  .how { margin-top: 36px }
  .strip-card { padding: 22px 16px 20px; border-radius: 20px }
  .strip-sum { font-size: 17px }
  .support { padding: 32px 20px }
  .site-footer { margin-top: 88px }
}
/* Three links don't fit beside the brand on a phone; the hero's badge is a scroll away */
@media (max-width: 479px) {
  .nav-store { display: none }
}
