/* sleeptraining.org · Night Light
   Layout: app shell. Top bar, sticky filter rail, dense data grid; details slide
   in from the right; compare is a full-screen sheet. Dark-first, with a light
   "lights on" theme. */
:root {
  color-scheme: dark;
  --bg: #0d1322;
  --panel: #121a2d;
  --raised: #182239;
  --hover: #1a2440;
  --line: #253050;
  --line-soft: #1b2541;
  --text: #e7eaf3;
  --text-2: #b0b8cc;
  --text-3: #7f89a5;
  --lamp: #f4b860;
  --lamp-ink: #20160a;
  --lamp-soft: rgb(244 184 96 / 0.12);
  --lamp-line: rgb(244 184 96 / 0.45);
  --good: #8ad6b3;
  --bad: #f29a86;
  --shadow: 0 0 0 1px var(--line), -24px 0 48px rgb(0 0 0 / 0.45);
  --display: 'Young Serif', 'Iowan Old Style', Georgia, serif;
  --body: 'Atkinson Hyperlegible', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --bar-h: 60px;
  /* Type scale. Floor: 13px for any text; 12px only for all-caps labels. */
  --fs-xl: 40px;    /* Young Serif: method page title */
  --fs-l: 28px;     /* Young Serif: page titles, drawer title */
  --fs-m: 20px;     /* Young Serif: section headings, column names, wordmark */
  --fs-lede: 18px;  /* lede under a title */
  --fs-read: 16px;  /* reading text, program names, stat values */
  --fs-ui: 14px;    /* default UI text */
  --fs-small: 13px; /* metadata, buttons, links, counts */
  --fs-label: 12px; /* all-caps labels, bold, 0.08em tracking */
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f1f3f8;
  --panel: #ffffff;
  --raised: #ffffff;
  --hover: #f4f6fb;
  --line: #dde2ec;
  --line-soft: #eceff5;
  --text: #141a2c;
  --text-2: #465069;
  --text-3: #6f7993;
  --lamp: #a8670c;
  --lamp-ink: #ffffff;
  --lamp-soft: rgb(196 125 24 / 0.1);
  --lamp-line: rgb(168 103 12 / 0.4);
  --good: #1d7653;
  --bad: #b2452d;
  --shadow: 0 0 0 1px var(--line), -24px 0 48px rgb(20 26 44 / 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--bar-h) + 50px); }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-ui)/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--lamp); text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 4px; }
h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; letter-spacing: 0.005em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input[type='checkbox'], input[type='radio'] { accent-color: var(--lamp); width: 15px; height: 15px; margin: 0; cursor: pointer; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 60; height: var(--bar-h);
  display: flex; align-items: center; gap: 24px; padding-inline: 20px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; width: 228px; color: var(--text); text-decoration: none; font: 400 var(--fs-m)/1 var(--display); }
.brand-mark { fill: var(--lamp); filter: drop-shadow(0 0 6px rgb(244 184 96 / 0.45)); }
:root[data-theme='light'] .brand-mark { filter: none; }
.tld { color: var(--text-3); }
.search { position: relative; flex: 0 1 520px; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--text-3); }
.search input {
  width: 100%; height: 38px; padding: 0 40px 0 38px; font: inherit; font-size: var(--fs-ui); color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: none; border-color: var(--lamp-line); box-shadow: 0 0 0 3px var(--lamp-soft); }
.search kbd { position: absolute; right: 10px; font: var(--fs-small)/1 var(--body); color: var(--text-3); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
.topbar-back { color: var(--text-2); text-decoration: none; font-size: var(--fs-ui); }
.topbar-back:hover { color: var(--text); }
.page-nav { display: none; } /* phones only: see src/mobile/site.css */
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; font: 700 var(--fs-small)/1 var(--body);
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.tb-btn:hover { border-color: var(--text-3); }
.tb-count { font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tb-btn.is-ready { background: var(--lamp); color: var(--lamp-ink); border-color: var(--lamp); }
.tb-btn.is-ready .tb-count { color: inherit; opacity: 0.75; }
.tb-icon[aria-pressed='true'] { color: var(--lamp); }
.compare-group { display: flex; }
.compare-group.has-picks #open-compare { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tb-clear { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; color: var(--text-2); font-weight: 400; padding: 0 12px; }
.tb-clear:hover { color: var(--text); }
.tb-clear span[aria-hidden] { font-size: var(--fs-read); line-height: 1; }

/* ---- Shell ---- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - var(--bar-h)); }
.rail { border-right: 1px solid var(--line); }
.rail-inner { position: sticky; top: var(--bar-h); max-height: calc(100vh - var(--bar-h)); overflow-y: auto; padding: 16px 16px 32px 20px; display: grid; gap: 22px; align-content: start; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; min-height: 20px; margin-bottom: -6px; font: 400 var(--fs-m)/1.2 var(--display); color: var(--text); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 2px; }
legend { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; padding: 0; }
.opt { display: flex; align-items: center; gap: 9px; padding: 6px 8px; margin-inline: -8px; border-radius: 7px; cursor: pointer; font-size: var(--fs-ui); color: var(--text-2); }
.opt > span:not(.n):not(.dots) { flex: 1; }
.opt:hover { background: var(--hover); color: var(--text); }
.opt:has(input:checked) { color: var(--text); }
.opt .n { font-size: var(--fs-small); color: var(--text-3); font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; padding: 0; font: 400 var(--fs-small)/1.5 var(--body); color: var(--lamp); cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; justify-self: start; }

.main { padding: 22px 28px 0; min-width: 0; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.main-head h1 { font-size: var(--fs-l); line-height: 1.15; }
.purpose { max-width: 74ch; margin-top: 10px; color: var(--text-2); font-size: var(--fs-read); line-height: 1.6; }
.sub { color: var(--text-2); font-size: var(--fs-ui); margin-top: 4px; }
.purpose em { color: var(--text-3); }
.purpose + .sub { margin-top: 12px; color: var(--text-3); }
.count { font-size: var(--fs-small); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Grid ---- */
.grid-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: var(--fs-ui); }
.w-sel { width: 40px; } .w-rank { width: 38px; } .w-name { width: 250px; }
.w-start { width: 140px; } .w-results { width: 132px; } .w-cry { width: 92px; } .w-ev { width: 104px; }
.grid thead th {
  position: sticky; top: var(--bar-h); z-index: 3; background: var(--panel); text-align: left;
  font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3);
  padding: 12px 10px; border-bottom: 1px solid var(--line);
}
.grid thead th:first-child { border-top-left-radius: 12px; }
.grid thead .c-sel { padding-left: 14px; }
.grid thead .c-sel input:disabled { opacity: 0.35; cursor: default; }
.grid thead th:last-child { border-top-right-radius: 12px; }
.grid thead button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.grid thead button:hover { color: var(--text); }
.grid thead button:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }
.sort-ind::after { content: '↕'; opacity: 0.4; }
[aria-sort='ascending'] .sort-ind::after { content: '↑'; opacity: 1; color: var(--lamp); }
[aria-sort='descending'] .sort-ind::after { content: '↓'; opacity: 1; color: var(--lamp); }
.grid tbody td, .grid tbody th { padding: 13px 10px; text-align: left; vertical-align: top; font-weight: 400; border-bottom: 1px solid var(--line-soft); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover > * { background: var(--hover); }
.grid tbody tr.is-open > * { background: var(--lamp-soft); }
.grid tbody tr.is-open > .c-sel { box-shadow: inset 3px 0 0 var(--lamp); }
.grid tbody tr:last-child > * { border-bottom: 0; }
.c-sel { padding-left: 14px !important; }
.c-sel input { margin-top: 2px; }
.c-rank { color: var(--text-3); font-variant-numeric: tabular-nums; }
.c-name a { color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--fs-read); }
.c-name a:hover { color: var(--lamp); }
.c-name .creator { display: block; margin-top: 2px; font-size: var(--fs-small); color: var(--text-3); }
.flag { display: block; margin-top: 4px; font-size: var(--fs-small); color: var(--lamp); }
/* Approaches that reject sleep training */
.stance { display: inline-block; margin-top: 6px; padding: 2px 8px; border: 1px solid var(--text-3); border-radius: 999px; color: var(--text); font: 700 var(--fs-small)/1.4 var(--body); white-space: nowrap; }
.c-name .stance { display: table; }
.stance-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--text-2); font-size: var(--fs-ui); }
.stance-note .stance { margin-top: 0; }
.cmp-card .stance { justify-self: start; margin-top: 2px; }
.c-sum { color: var(--text-2); }
.grid tbody tr:has(.cmp-check:checked) > .c-sel { box-shadow: inset 3px 0 0 var(--lamp-line); }
.c-start small { display: block; color: var(--text-3); font-size: var(--fs-small); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cry, .ev { display: inline-flex; align-items: center; gap: 8px; }
/* Icon-only cells: the label shows on hover (and stays in the accessible name). */
.grid .c-cry, .grid .c-ev { text-align: center; }
.hint { position: relative; display: inline-flex; align-items: center; min-height: 22px; padding: 3px 6px; margin: -3px -6px; border-radius: 6px; }
.hint .meter { width: 24px; height: 16px; }
.hint .dots i { width: 7px; height: 7px; }
.hint::after {
  content: attr(data-hint); position: absolute; z-index: 10; left: 50%; bottom: calc(100% + 6px); transform: translate(-50%, 4px);
  padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: var(--fs-small); font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.12s, transform 0.12s;
}
.grid tbody tr:hover .hint:hover { background: var(--lamp-soft); }
.hint:hover::after { opacity: 1; transform: translate(-50%, 0); }
.empty { padding: 48px; text-align: center; color: var(--text-3); display: grid; gap: 8px; justify-items: center; }
.note { font-size: var(--fs-small); color: var(--text-3); margin-top: 12px; }
.foot { margin-top: 48px; padding-block: 24px 32px; border-top: 1px solid var(--line); font-size: var(--fs-small); color: var(--text-3); }

/* Widgets */
.meter { flex: none; }
.meter .bar { fill: var(--line); }
.meter .bar-on { fill: var(--lamp); }
.meter .bar-maybe { fill: var(--lamp); opacity: 0.45; }
.meter .bar-any { fill: none; stroke: var(--text-3); stroke-width: 0.8; stroke-dasharray: 1.6 1.2; }
.dots { display: inline-flex; gap: 3px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--text); }

/* ---- Drawer ---- */
.drawer {
  position: fixed; z-index: 50; top: var(--bar-h); right: 0; bottom: 0; width: min(620px, 52vw);
  background: var(--raised); box-shadow: var(--shadow); display: flex; flex-direction: column;
  transform: translateX(0); transition: transform 0.22s ease, visibility 0.22s;
}
.drawer.is-closing { transform: translateX(100%); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.drawer-nav { display: flex; align-items: center; gap: 4px; }
.drawer-pos { font-size: var(--fs-small); color: var(--text-3); margin-left: 6px; font-variant-numeric: tabular-nums; }
.drawer-full { margin-left: auto; font-size: var(--fs-small); }
.drawer-body { overflow-y: auto; padding: 28px 32px 48px; flex: 1; }
.drawer-body.is-loading { opacity: 0.5; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; font: 400 var(--fs-lede)/1 var(--body); }
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }

/* ---- Detail (drawer + standalone page) ---- */
.detail { max-width: 760px; }
.detail-head { display: grid; gap: 10px; }
.kicker { font-size: var(--fs-small); color: var(--text-3); letter-spacing: 0.02em; }
.detail h1 { font-size: var(--fs-l); line-height: 1.1; }
.by { color: var(--text-2); font-size: var(--fs-ui); }
.by cite { font-style: italic; }
.lede { font-size: var(--fs-lede); line-height: 1.5; color: var(--text); margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 999px; font: 700 var(--fs-small)/1 var(--body); text-decoration: none; cursor: pointer; border: 1px solid var(--lamp); background: var(--lamp); color: var(--lamp-ink); }
.pill-btn[aria-pressed='true'] { background: transparent; color: var(--lamp); }
.pill-quiet { background: transparent; color: var(--text); border-color: var(--line); }
.pill-quiet:hover { border-color: var(--text-3); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 24px 0 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stat { padding: 14px 16px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat dt { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.stat dd { margin: 0; font-weight: 700; font-size: var(--fs-read); }
.stat small { display: block; font-weight: 400; color: var(--text-3); font-size: var(--fs-small); margin-top: 2px; }
.caution { margin-top: 20px; padding: 14px 16px; border-radius: 10px; background: var(--lamp-soft); border: 1px solid var(--lamp-line); color: var(--text); font-size: var(--fs-ui); }
.block { margin-top: 32px; }
.block h2 { font-size: var(--fs-m); margin-bottom: 12px; }
.block p { color: var(--text-2); font-size: var(--fs-read); line-height: 1.65; max-width: 66ch; }
.block p + p { margin-top: 14px; }
.block p strong { color: var(--text); }
.timeline { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.timeline li { counter-increment: s; position: relative; padding: 0 0 18px 40px; color: var(--text-2); font-size: var(--fs-read); line-height: 1.55; }
.timeline li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-small); font-weight: 700; color: var(--lamp); border: 1px solid var(--lamp-line); background: var(--bg); }
.timeline li::after { content: ''; position: absolute; left: 13px; top: 26px; bottom: 2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline strong { display: block; color: var(--text); }
.pc { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pros, .cons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: var(--fs-ui); color: var(--text-2); }
.pros li, .cons li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; }
.pros li::before { content: '+'; color: var(--good); font-weight: 700; }
.cons li::before { content: '−'; color: var(--bad); font-weight: 700; }
.facts { margin: 0; display: grid; }
.facts > div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding-block: 10px; border-top: 1px solid var(--line-soft); font-size: var(--fs-ui); }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; color: var(--text-2); }
.similar { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.similar a { display: grid; gap: 4px; height: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: var(--fs-ui); }
.similar a:hover { border-color: var(--lamp-line); }
.similar small { font-weight: 400; color: var(--text-3); font-size: var(--fs-small); }

/* Standalone method page */
.index .rail-inner { gap: 18px; }
.index-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.index ul { list-style: none; margin: 0; padding: 0; display: grid; }
.index a { display: block; padding: 4px 8px; margin-inline: -8px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-size: var(--fs-ui); }
.index a:hover { background: var(--hover); color: var(--text); }
.index a[aria-current='page'] { background: var(--lamp-soft); color: var(--lamp); font-weight: 700; }
.main-detail { padding: 40px 56px 0; }
.main-detail .detail h1 { font-size: var(--fs-xl); }

/* ---- Compare ---- */
.sheet { position: fixed; z-index: 55; inset: var(--bar-h) 0 0 0; background: var(--bg); display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: var(--fs-m); }
.sheet-tools { display: flex; gap: 8px; }
.sheet-body { overflow: auto; padding: 0 28px 40px; flex: 1; }
.compare-page { padding: 28px 28px 0; }
.compare-page-head { margin-bottom: 20px; }
.compare-page-head h1 { font-size: var(--fs-l); }
.notfound { max-width: 900px; margin: 0 auto; padding-top: 56px; display: grid; gap: 18px; }
.notfound h1 { font-size: var(--fs-l); }
.notfound-list { margin: 8px 0; }
.cmp { width: 100%; min-width: 960px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: var(--fs-ui); }
.cmp col.cmp-labels { width: 160px; }
.cmp thead th { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 20px 12px 16px; text-align: left; vertical-align: top; font-weight: 400; }
.compare-inline .cmp thead th { top: var(--bar-h); }
.cmp-card { display: grid; gap: 6px; padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); min-height: 132px; }
.cmp-card .cmp-name { font: 400 var(--fs-m)/1.2 var(--display); color: var(--text); text-decoration: none; }
.cmp-card .cmp-name:hover { color: var(--lamp); }
.cmp-card .cmp-by { color: var(--text-3); font-size: var(--fs-small); }
.cmp-card-tools { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 6px; }
.cmp-card select, .cmp-add select { height: 30px; font: inherit; font-size: var(--fs-small); color: var(--text-2); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; max-width: 100%; }
.cmp-add { display: grid; gap: 10px; align-content: center; justify-items: start; min-height: 132px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--text-3); }
.cmp-add select { height: 36px; width: 100%; }
.cmp tbody th { text-align: left; font-weight: 700; font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 14px 12px; vertical-align: top; border-top: 1px solid var(--line-soft); }
.cmp tbody td { padding: 14px 12px 14px 28px; vertical-align: top; color: var(--text-2); border-top: 1px solid var(--line-soft); }
.cmp tbody td strong { color: var(--text); }
.cmp tbody td small { display: block; color: var(--text-3); font-size: var(--fs-small); margin-top: 2px; }
.cmp ol { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.cmp .lede-cell { color: var(--text); font-size: var(--fs-read); line-height: 1.45; }
.cmp .win { display: inline-block; margin-left: 8px; padding: 2px 7px; border-radius: 999px; background: var(--lamp-soft); color: var(--lamp); font-size: var(--fs-small); font-weight: 700; }

/* ---- Toast ---- */
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: var(--fs-ui); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .grid-wrap { overflow-x: auto; }
  .grid { min-width: 1060px; }
  .drawer { width: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .toast, .hint::after { transition: none; }
}
