/* Sleep Tools — site.css
   One stylesheet for the home page and, later, every tool page.
   A sibling of habit-tools.com: same fonts, same layout pieces, same class
   names. The look is a bedroom at night: dark blue room, lamplit text,
   and moon yellow for everything that means "asleep". */

/* Fonts are hosted here, not on Google, so the page needs no third-party
   request. Both are variable fonts (one file covers every weight), Latin
   only. Licence: assets/fonts/OFL.txt */
@font-face {
  font-family: "Big Shoulders Display";
  src: url("/assets/fonts/big-shoulders-display.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("/assets/fonts/public-sans.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --night: #10182E;    /* page background */
  --panel: #19233F;    /* the spotlight band */
  --text: #F2EDE1;     /* text */
  --muted: #AAB3CB;    /* secondary text */
  --moon: #FFE15A;     /* asleep: the dial arc, buttons, tags, Storey band */
  --moon-light: #FFEE9E; /* button hover */
  --line: #33406A;     /* rules, dashed lines, the unlit part of the dial */
  --ink: #10182E;      /* text on moon yellow */

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --body: "Public Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.55;
}

h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
a { color: var(--text); }
a:hover { color: var(--moon); }
:focus-visible { outline: 3px solid var(--moon); outline-offset: 3px; }

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: clamp(20px, 4vw, 40px); }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: .5rem; z-index: 2; background: var(--panel); padding: .5rem .8rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Shared pieces ──────────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 24px;
  background: var(--moon);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.button:hover { color: var(--ink); background: var(--moon-light); }
.button-big { min-height: 58px; padding: 0 34px; font-size: 1.1875rem; }

.tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--moon);
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 800;
  line-height: 1.3;
}
/* A tool that has no page yet */
.tag-soon { background: none; color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }

.display-2 {
  font-family: var(--display);
  font-size: clamp(3rem, 6vw, 5.5rem);
  font-weight: 900;
  line-height: .9;
  max-width: 14em;
}
.display-3 {
  font-family: var(--display);
  font-size: clamp(2.5rem, 4.6vw, 4.25rem);
  font-weight: 900;
  line-height: .92;
}
.section-lede { margin-top: 18px; max-width: 600px; font-size: 1.1875rem; color: var(--muted); }

/* ── Header and footer ──────────────────────────────────────── */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 32px;
  padding-block: 24px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Big Shoulders Display", "Arial Narrow", sans-serif;
  font-size: 1.875rem;
  font-weight: 900;
  text-decoration: none;
}
.wordmark:hover { color: var(--text); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 8px 28px; font-weight: 600; }
.site-header nav a { text-decoration: none; }
.site-header nav a:hover { text-decoration: underline; }

.site-footer { padding-block: 88px 56px; font-size: .9375rem; color: var(--muted); }
.site-footer p + p { margin-top: 6px; }

/* Running tally of tools, built by scripts/build-footer.py */
.tally {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 18px 48px;
  margin-bottom: 40px;
  padding-top: 32px;
  border-top: 3px solid var(--text);
  color: var(--text);
}
.tally-head { display: flex; align-items: baseline; gap: 10px; font-size: 1.125rem; font-weight: 800; line-height: 1.2; }
.tally-num { font-family: "Big Shoulders Display", "Arial Narrow", sans-serif; font-size: 4rem; font-weight: 900; line-height: .8; color: var(--moon); }
.tally-marks { grid-column: 1; margin-top: -6px; }
.tally-list { grid-column: 2; grid-row: 1 / span 2; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); column-gap: 32px; }
.tally-list li { padding-block: 7px; border-bottom: 2px dashed var(--line); }
.tally-list a { font-weight: 700; text-decoration-color: var(--moon); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.tally-list a[aria-current="page"] { text-decoration: none; color: var(--muted); }
@media (max-width: 720px) {
  .tally { grid-template-columns: minmax(0, 1fr); }
  .tally-list { grid-column: 1; grid-row: auto; }
}

/* ── Opening ────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-block: clamp(56px, 8vw, 88px) clamp(80px, 10vw, 120px);
}
.hero h1 {
  max-width: 1000px;
  font-family: var(--display);
  font-size: clamp(4rem, 9vw, 9.25rem);
  font-weight: 900;
  line-height: .86;
  text-wrap: balance;
}
.lede { margin-top: 28px; max-width: 560px; font-size: 1.3125rem; color: var(--muted); text-wrap: pretty; }
.hero .button { margin-top: 36px; }

/* ── Cards and previews ─────────────────────────────────────── */

.card { padding: clamp(20px, 3vw, 32px); background: var(--panel); }
.spotlights .card { background: var(--night); }
.card-label { font-size: .875rem; font-weight: 700; color: var(--muted); }
.card-note { margin-top: 18px; font-size: .875rem; color: var(--muted); }

/* Wake-up time buttons */
.cues { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cue {
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 700;
  cursor: pointer;
}
.cue:hover { border-color: var(--text); }
.cue[aria-pressed="true"] { border-color: var(--moon); background: var(--moon); color: var(--ink); }
/* The five wake-up times share one row, on a phone too. */
.bedtime .cues { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.bedtime .cue { padding: 0 4px; }

/* Bedtime preview: a 24-hour dial, midnight at the top. The yellow arc is
   the night's sleep. It is always the same length (7 hours 45 minutes);
   the script turns it so that it ends at the chosen wake-up time. */
.dial { display: block; width: 100%; max-width: 340px; height: auto; margin: 24px auto 0; }
.dial-ring { fill: none; stroke: var(--line); stroke-width: 28; }
.dial-arc {
  fill: none;
  stroke: var(--moon);
  stroke-width: 28;
  transform-origin: 170px 170px;
  transition: transform .5s ease;
}
.dial-notches { fill: none; stroke: var(--night); stroke-width: 30; }   /* the card's own colour */
.dial-hour { fill: var(--muted); font-family: var(--body); font-size: 13px; font-weight: 700; }
.dial-label { fill: var(--muted); font-family: var(--body); font-size: 14px; font-weight: 700; }
.dial-time { fill: var(--text); font-family: var(--display); font-size: 44px; font-weight: 900; }

.result {
  margin-top: 28px;
  font-family: var(--display);
  font-size: clamp(2.25rem, 3.6vw, 3.25rem);
  font-weight: 900;
  line-height: .95;
  text-wrap: balance;
}
.result-sub { margin-top: 12px; font-size: 1.125rem; font-weight: 700; }
.bedtime .result-sub { margin-top: 20px; }

/* Caffeine cutoff preview */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { margin-top: 6px; padding: 12px 14px; border: 2px solid var(--line); background: var(--panel); font-weight: 700; }

/* Sleep debt preview: one column per night. The dashed box is the target,
   the yellow fill is the sleep you got (its height is set in the HTML). */
.nights { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(6px, 1.4vw, 12px); margin-top: 14px; list-style: none; }
.nights li { text-align: center; }
.night-col {
  display: flex;
  align-items: flex-end;
  height: 136px;
  border: 2px dashed var(--line);
  border-bottom: 2px solid var(--text);
}
.night-fill { width: 100%; background: var(--moon); }
.night-day { display: block; margin-top: 8px; font-size: .8125rem; font-weight: 700; color: var(--muted); }
.night-hours { display: block; font-weight: 800; }

/* ── Spotlight ──────────────────────────────────────────────── */

.spotlights { background: var(--panel); padding-block: 96px 32px; }
.spotlights .display-2 { margin-bottom: 40px; }

.spot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 40px 72px;
  padding-block: 72px;
  border-top: 3px solid var(--text);
}
.spot-flip { flex-direction: row-reverse; }
.spot-text { flex: 1 1 380px; min-width: 0; }
.spot-preview { flex: 1 1 480px; min-width: 0; }

.spot h3 {
  margin-top: 14px;
  font-family: var(--display);
  font-size: clamp(2.75rem, 4.6vw, 4.25rem);
  font-weight: 900;
  line-height: .9;
}
.spot-what { margin-top: 16px; max-width: 460px; font-size: 1.1875rem; color: var(--muted); }
.spot-gets { list-style: none; margin-top: 20px; max-width: 460px; border-bottom: 1px solid var(--line); }
.spot-gets li { padding-block: 10px; border-top: 1px solid var(--line); }
.spot .button { margin-top: 26px; }

/* ── All the tools ──────────────────────────────────────────── */

.all { padding-top: 104px; scroll-margin-top: 16px; }
.all .section-lede { margin-bottom: 40px; }

.step {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 48px;
  padding-block: 40px;
  border-top: 3px solid var(--text);
}
.step-head { flex: 1 1 240px; min-width: 0; }
/* The time of day the tools in this group are for */
.step-time { font-family: "Big Shoulders Display", "Arial Narrow", sans-serif; font-size: 4.5rem; font-weight: 900; line-height: .8; color: var(--moon); }
.step-head h3 { margin-top: 12px; font-family: var(--display); font-size: 2.25rem; font-weight: 800; line-height: 1; }
.step-head p:last-child { margin-top: 8px; font-size: 1rem; color: var(--muted); }

.tool-list { flex: 3 1 560px; min-width: 0; list-style: none; }
.tool-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding-block: 20px;
  border-bottom: 2px dashed var(--line);
}
/* A tool's name: a link once its page exists, plain text until then. */
.tool-name { flex: 1 1 250px; font-size: 1.3125rem; font-weight: 800; }
a.tool-name { text-decoration-color: var(--moon); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.tool-desc { flex: 2 1 300px; font-size: 1rem; color: var(--muted); }
.tool-list .tag { flex: 0 0 auto; min-width: 108px; text-align: center; white-space: nowrap; }

/* ── Storey ─────────────────────────────────────────────────── */

.storey {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px 56px;
  margin-top: 104px;
  padding: clamp(32px, 5vw, 48px) clamp(24px, 5vw, 52px);
  background: var(--moon);
  color: var(--ink);
}
.storey > div { flex: 1 1 440px; min-width: 0; }
.storey p { margin-top: 14px; max-width: 540px; font-size: 1.125rem; }
.storey .button { background: var(--ink); color: var(--text); }
.storey .button:hover { background: #000; color: #fff; }
.storey :focus-visible { outline-color: var(--ink); }

/* ── Questions ──────────────────────────────────────────────── */

.faq { padding-top: 104px; scroll-margin-top: 16px; }
.faq .display-3 { margin-bottom: 28px; }
.faq-grid { display: flex; flex-wrap: wrap; gap: 0 48px; }
.faq-grid > div { flex: 1 1 440px; min-width: 0; padding-block: 24px; border-top: 2px solid var(--text); }
.faq-grid h3 { font-size: 1.25rem; font-weight: 800; }
.faq-grid p { margin-top: 8px; color: var(--muted); }

/* ── Small screens ──────────────────────────────────────────── */

@media (max-width: 560px) {
  .spot { padding-block: 56px; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .night-col { height: 112px; }
  .night-hours { font-size: .9375rem; }
  .button { width: 100%; justify-content: center; text-align: center; }
  .hero .button, .storey .button { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dial-arc { transition: none; }
}
