/* Sleep Calculator — sleepcalculator.in
   Night-to-dawn palette: indigo night, moonlight page, marigold accent. */

:root {
  --night: #1c2350;
  --night-2: #283071;
  --night-3: #3a438f;
  --moon: #eef0f7;
  --paper: #ffffff;
  --ink: #1f2547;
  --muted: #565d82;
  --line: #d6d9ea;
  --marigold: #f2a93b;
  --marigold-soft: #fbe3b8;
  --marigold-deep: #9a5a00;
  --dawn: #f5c3ad;
  --lavender: #c9cdf2;
  --good: #1f7a4d;
  --warn: #9a5a00;
  --bad: #a3322b;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 35, 80, .06), 0 8px 24px rgba(28, 35, 80, .07);
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --measure: 68ch;
  --wrap: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }

body {
  margin: 0;
  background: var(--moon);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "tnum" 0;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--night-3); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--marigold-deep); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--marigold); color: var(--night); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 12px; }

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.15rem); margin-top: 0; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.02rem; margin: 0 0 .35em; font-weight: 700; }
p { margin: 0 0 1em; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 60ch; }
.small { font-size: .9rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.site-header { background: var(--night); color: #fff; position: relative; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--serif); font-size: 1.25rem; }
.brand:hover { color: #fff; }
.brand svg { width: 30px; height: 30px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: #dfe2ff; text-decoration: none; font-weight: 500; font-size: .96rem; padding: 8px 12px; border-radius: 999px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--night-2); color: #fff; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--night-2); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font: 600 .95rem var(--sans); cursor: pointer; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: var(--night); flex-direction: column; align-items: stretch; padding: 8px 20px 18px; border-top: 1px solid var(--night-2); }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; border-radius: 10px; }
}

/* ---------- Hero / calculator band ---------- */
.band {
  background: var(--night);
  color: #fff;
  padding: 28px 0 56px;
  position: relative;
}
.band::after { /* thin horizon: night meets dawn */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: linear-gradient(90deg, var(--night-3), #8d7fd0 45%, var(--dawn) 80%, var(--marigold));
}
.band h1 { color: #fff; margin-bottom: .25em; }
.band .lede { color: #c8ccf0; }
.crumbs { font-size: .88rem; color: #aeb3e6; margin-bottom: 18px; }
.crumbs a { color: #d6daff; }
.band-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
@media (min-width: 980px) { .band-grid.split { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }

/* ---------- Calculator panel ---------- */
.calc {
  background: var(--night-2);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: #fff;
}
@media (min-width: 640px) { .calc { padding: 28px; } }
.tabs { display: inline-flex; background: var(--night); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; color: #c8ccf0; font: 600 .95rem var(--sans); padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--marigold); color: var(--night); }
.field-label { display: block; font-weight: 600; margin-bottom: 10px; color: #fff; font-size: 1.05rem; }
.timepick { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.timepick select, .calc select, .calc input[type="number"], .calc input[type="date"] {
  appearance: none; -webkit-appearance: none;
  background: var(--night); color: #fff; border: 1px solid var(--night-3);
  border-radius: var(--radius-sm); font: 600 1.35rem var(--sans); font-variant-numeric: tabular-nums;
  padding: 10px 34px 10px 14px; min-height: 54px;
  background-image: linear-gradient(45deg, transparent 50%, #aeb3e6 50%), linear-gradient(135deg, #aeb3e6 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.calc input[type="number"], .calc input[type="date"] { background-image: none; padding-right: 14px; width: 100%; font-size: 1.15rem; }
.calc select.sm { font-size: 1rem; min-height: 46px; }
.timepick .colon { font: 600 1.5rem var(--sans); align-self: center; color: #aeb3e6; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--marigold); color: var(--night); border: 0; border-radius: 999px;
  font: 700 1.02rem var(--sans); padding: 14px 24px; cursor: pointer; text-decoration: none; min-height: 50px;
}
.btn:hover { background: #ffbb52; color: var(--night); }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px var(--night-3); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--lavender); }
.settings { margin-top: 18px; border-top: 1px solid var(--night-3); padding-top: 14px; }
.settings summary { cursor: pointer; color: #d6daff; font-weight: 600; list-style: none; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: "+"; display: inline-block; width: 1.2em; color: var(--marigold); font-weight: 700; }
.settings[open] summary::before { content: "−"; }
.settings .grid-2 { margin-top: 14px; }
.settings label { display: block; font-size: .92rem; color: #c8ccf0; margin-bottom: 6px; }
.range-wrap { display: flex; align-items: center; gap: 12px; }
.range-wrap output { min-width: 4.5ch; font-weight: 700; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--marigold); }
.hint { font-size: .88rem; color: #aeb3e6; margin: 10px 0 0; }

/* ---------- Results ---------- */
.results { margin-top: 24px; }
.results[hidden] { display: none; }
.results-head { font-size: 1.05rem; color: #dfe2ff; margin-bottom: 14px; }
.results-head strong { color: #fff; }
.picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pick {
  text-align: left; background: var(--night); border: 1.5px solid var(--night-3); color: #fff;
  border-radius: var(--radius); padding: 14px; cursor: pointer; font: inherit;
}
.pick:hover { border-color: var(--lavender); }
.pick[aria-pressed="true"] { border-color: var(--marigold); box-shadow: 0 0 0 1px var(--marigold); }
.pick .t { display: block; font: 600 1.6rem var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pick .m { display: block; font-size: .86rem; color: #c8ccf0; margin-top: 2px; }
.pick .q { display: inline-block; margin-top: 8px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.q-best { background: var(--marigold); color: var(--night); }
.q-ok { background: var(--lavender); color: var(--night); }
.q-low { background: #4a2f55; color: #ffd9d4; }
.strip-wrap { margin-top: 18px; background: var(--night); border-radius: var(--radius); padding: 14px 14px 8px; }
.strip-cap { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; color: #c8ccf0; flex-wrap: wrap; }
.strip-cap b { color: #fff; }
.strip svg { width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: #c8ccf0; padding: 6px 2px 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.copy-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.copy-row .btn { padding: 10px 16px; min-height: 42px; font-size: .92rem; }
.stat-line { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 4px; }
.stat { background: var(--night); border-radius: var(--radius); padding: 14px; }
.stat .v { font: 600 1.55rem var(--sans); font-variant-numeric: tabular-nums; display: block; color: #fff; }
.stat .k { font-size: .85rem; color: #c8ccf0; }
.note-box { margin-top: 14px; background: rgba(242, 169, 59, .12); border: 1px solid rgba(242, 169, 59, .35); color: #ffe6bf; border-radius: var(--radius); padding: 12px 14px; font-size: .94rem; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--night-3); }
.tl li:last-child { border-bottom: 0; }
.tl .when { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--marigold); }
.tl .what { color: #e4e6ff; }

/* ---------- Side card on band ---------- */
.aside-note { color: #c8ccf0; font-size: .98rem; }
.aside-note h2 { color: #fff; font-size: 1.5rem; }
.aside-note ul { padding-left: 1.1em; margin: 0 0 1em; }
.aside-note li { margin-bottom: .4em; }

/* ---------- Content ---------- */
main { display: block; }
.section { padding: 56px 0; }
.section + .section { padding-top: 8px; }
.prose { max-width: var(--measure); }
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin-bottom: .45em; }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--marigold); color: var(--muted); }
.cols { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 56px; } }
.panel { background: var(--paper); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.panel h3 { margin-top: 0; }
.toc { position: sticky; top: 20px; }
.toc ol { padding-left: 1.2em; margin: 0; }
.toc li { margin: .3em 0; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); margin: 1.2em 0 1.6em; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .9rem; color: var(--muted); font-weight: 600; background: #f7f8fc; }
tr:last-child td { border-bottom: 0; }
td.hl { font-weight: 700; color: var(--night); }

/* Stats from India */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 1.4em 0; }
.fact { background: var(--paper); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.fact .big { font-family: var(--serif); font-size: 2.4rem; line-height: 1; color: var(--night); display: block; margin-bottom: 8px; }
.fact p { margin: 0; color: var(--muted); font-size: .95rem; }
.fact .src { display: block; margin-top: 10px; font-size: .8rem; }

/* Routine cards (real Indian schedules) */
.routines { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 1.2em; }
.routine { background: var(--paper); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.routine h3 { font-size: 1.15rem; margin-bottom: .4em; }
.routine p { color: var(--muted); font-size: .96rem; flex: 1; }
.routine .times { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--night); margin-bottom: 10px; }

/* Tool directory */
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 1.2em; }
.tool { display: block; text-decoration: none; color: var(--ink); background: var(--paper); border-radius: var(--radius); padding: 18px 20px; border: 1.5px solid transparent; box-shadow: var(--shadow); }
.tool:hover { border-color: var(--night-3); color: var(--ink); }
.tool strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.2rem; margin-bottom: 4px; color: var(--night); }
.tool span { color: var(--muted); font-size: .94rem; }

/* Time chips (wake-up-at / sleep-at pages) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: .8em 0 1.4em; }
.chip { display: inline-block; padding: 7px 14px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .92rem; font-variant-numeric: tabular-nums; }
.chip:hover, .chip[aria-current="page"] { background: var(--night); border-color: var(--night); color: #fff; }

/* FAQ */
.faq details { background: var(--paper); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); }
.faq summary { cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--marigold-deep); font-weight: 700; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq .a { padding: 0 20px 16px; color: var(--muted); }
.faq .a p:last-child { margin-bottom: 0; }

/* Guides list */
.guide-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 1em; }
.guide-card { background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); display: block; }
.guide-card:hover { color: var(--ink); box-shadow: 0 0 0 1.5px var(--night-3), var(--shadow); }
.guide-card h3 { font-size: 1.25rem; color: var(--night); }
.guide-card p { color: var(--muted); margin: 0; font-size: .96rem; }
.byline { color: #aeb3e6; font-size: .9rem; margin-top: 6px; }

.callout { background: var(--marigold-soft); border-radius: var(--radius); padding: 18px 20px; margin: 1.4em 0; }
.callout p:last-child { margin-bottom: 0; }

/* ---------- Light-surface calculator (used inside content) ---------- */
.contact-card { background: var(--paper); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow); max-width: 560px; }
.contact-card .mail { font-family: var(--serif); font-size: 1.5rem; word-break: break-all; }

/* ---------- Footer ---------- */
.site-footer { background: var(--night); color: #c8ccf0; padding: 48px 0 28px; margin-top: 40px; font-size: .94rem; }
.site-footer a { color: #e4e6ff; text-decoration: none; }
.site-footer a:hover { color: var(--marigold); text-decoration: underline; }
.foot-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.foot-grid h2 { font-family: var(--sans); font-size: .95rem; font-weight: 700; color: #fff; margin-bottom: 10px; letter-spacing: 0; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin: 6px 0; }
.foot-brand p { max-width: 32ch; }
.disclaimer { border-top: 1px solid var(--night-2); margin-top: 32px; padding-top: 20px; font-size: .85rem; color: #aeb3e6; max-width: 90ch; }
.legal-line { margin-top: 14px; font-size: .85rem; color: #aeb3e6; display: flex; flex-direction: column; gap: 4px; }

/* print: results only */
@media print {
  .site-header, .site-footer, .tabs, .settings, .copy-row, .menu-btn { display: none !important; }
  .band, .calc, .pick, .stat, .strip-wrap { background: #fff !important; color: #000 !important; }
}
.chips.dark .chip { background: var(--night-2); border-color: var(--night-3); color: #fff; }
.chips.dark .chip:hover { background: var(--marigold); border-color: var(--marigold); color: var(--night); }
@media (max-width: 979px) { .band-grid.split { grid-template-columns: minmax(0, 1fr) !important; } }
@media (max-width: 640px) {
  .tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; border-radius: 14px; }
  .tabs button { padding: 10px 8px; font-size: .88rem; border-radius: 10px; }
  .picks { grid-template-columns: 1fr 1fr; }
  .pick .t { font-size: 1.35rem; }
  .strip { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .strip svg { min-width: 600px; }
  .btn { width: 100%; }
  .copy-row .btn { width: auto; }
}
.prose > h2:first-child, .prose > h3:first-child { margin-top: 0; }

/* content protection: no text selection outside form fields */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
img, svg { -webkit-user-drag: none; }

/* back to top */
.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--marigold); color: var(--night);
  box-shadow: 0 6px 18px rgba(28, 35, 80, .3);
  display: flex; align-items: center; justify-content: center;
}
.to-top:hover { background: #ffbb52; }
.to-top[hidden] { display: none; }
@media print { .to-top { display: none !important; } }
