/* Seizure Prognosis – site styles. No framework; one file. */

/* ---------- Fonts (Sarabun, OFL, self-hosted via @fontsource/sarabun 5.3.0) ---------- */
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 400;
	src: url(../fonts/sarabun-latin-400-normal.woff2) format('woff2');
	unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 400;
	src: url(../fonts/sarabun-latin-ext-400-normal.woff2) format('woff2');
	unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 600;
	src: url(../fonts/sarabun-latin-600-normal.woff2) format('woff2');
	unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 600;
	src: url(../fonts/sarabun-latin-ext-600-normal.woff2) format('woff2');
	unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 700;
	src: url(../fonts/sarabun-latin-700-normal.woff2) format('woff2');
	unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-display: swap; font-weight: 700;
	src: url(../fonts/sarabun-latin-ext-700-normal.woff2) format('woff2');
	unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

/* ---------- Tokens ---------- */
:root {
	--navy: #001957;
	--navy-2: #1d3a7a;
	--navy-soft: #e8ecf5;
	--navy-line: #c9d1e3;
	--amber: #b86a00;       /* COSY; darker than the old #ffa200 for contrast on white */
	--amber-soft: #fbefdc;
	--ink: #1b2233;
	--muted: #5d6679;
	--line: #e3e6ec;
	--bg: #f6f7fa;
	--card: #fff;
	--warn-bg: #fff6e0;
	--warn-line: #f0d48a;
	--radius: 10px;
	--focus: 0 0 0 3px rgba(29, 58, 122, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
	font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg);
	min-height: 100vh; display: flex; flex-direction: column;
}
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
a { color: var(--navy-2); text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
sub, sup { line-height: 0; }

.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 24px 28px; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.link-btn, .inline-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--navy-2); text-decoration: underline; text-underline-offset: 2px; }
.link-btn { font-size: .88rem; }

/* ---------- Header / footer ---------- */
.site-header { background: var(--navy); color: #fff; }
.bar { max-width: 1240px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand img { display: block; }
.brand-name { font-size: 1.2rem; font-weight: 600; letter-spacing: .01em; }
.brand-tag { font-size: .88rem; opacity: .65; }
nav { margin-left: auto; display: flex; gap: 4px; }
.nav-link { background: none; border: 0; color: #fff; opacity: .85; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: .92rem; }
.nav-link:hover { opacity: 1; background: rgba(255,255,255,.08); }

.site-footer { max-width: 1240px; width: 100%; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: .85rem; display: flex; gap: 8px 20px; flex-wrap: wrap; align-items: baseline; }
.site-footer a, .site-footer .link-btn { color: var(--muted); font-size: .85rem; }

/* ---------- Layout ---------- */
.layout { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 24px 40px; display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 28px; align-items: start; }
.content { min-width: 0; display: grid; gap: 20px; }

/* ---------- Question flow ---------- */
.flow { padding: 18px 18px 18px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.flow-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.steps { list-style: none; padding: 0; counter-reset: step; }
.step { counter-increment: step; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: start; }
.step::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font-size: .75rem; display: grid; place-items: center; margin-top: 2px; }
.step-q { font-size: .82rem; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.step-q a { color: inherit; }
.step-a { font-weight: 600; line-height: 1.35; margin-top: 2px; }
.step .link-btn { font-size: .82rem; margin-top: 2px; }

.question { padding-top: 14px; }
.question.first { padding-top: 6px; }
.q-num { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.q-text { font-weight: 600; font-size: 1.02rem; line-height: 1.4; margin: 4px 0 12px; }
.q-text [title] { text-decoration: underline dotted; cursor: help; }
.answers { display: grid; gap: 8px; }
.answer {
	display: flex; align-items: center; justify-content: space-between; gap: 10px;
	width: 100%; text-align: left; padding: 10px 14px; border-radius: 8px;
	border: 1px solid var(--navy-line); background: #fff; color: var(--navy); text-decoration: none;
	font-size: .95rem; line-height: 1.35; cursor: pointer; transition: background-color .12s, border-color .12s;
}
.answer::after { content: '›'; font-size: 1.25rem; line-height: 1; color: var(--navy-line); }
.answer:hover { background: var(--navy-soft); border-color: var(--navy-2); }
.answer:hover::after { color: var(--navy-2); }
.answer[aria-current="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

.notice { margin-top: 14px; padding: 12px 14px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; font-size: .92rem; }

/* ---------- Intro ---------- */
.intro h1 { font-size: 1.5rem; color: var(--navy); line-height: 1.25; margin-bottom: 12px; }
.intro p + p, .intro ol + p { margin-top: 12px; }
.intro ol { margin: 10px 0 0; padding-left: 1.4em; }
.intro li + li { margin-top: 4px; }

/* ---------- Result ---------- */
.result { padding: 24px 28px 28px; }
.crumbs { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.crumbs sub { font-size: .7em; }
.result h1 { font-size: 1.35rem; line-height: 1.3; margin: 6px 0 6px; color: var(--navy); font-weight: 700; }
.result .design { color: var(--muted); font-size: .95rem; margin-bottom: 18px; }

.controls { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: .9rem; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--navy); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.time { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.time label { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.time output { font-weight: 700; color: var(--navy); white-space: nowrap; min-width: 6.2em; font-variant-numeric: tabular-nums; }
.time input[type=range] { flex: 1; min-width: 0; accent-color: var(--navy); }
.stepper { flex: none; border: 1px solid var(--line); background: #fff; width: 32px; height: 32px; border-radius: 7px; font-size: 1.05rem; cursor: pointer; color: var(--navy); line-height: 1; }
.stepper:hover { border-color: var(--navy-line); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile { border-radius: var(--radius); padding: 14px 16px; border-left: 4px solid var(--navy); background: var(--navy-soft); }
.tile.cosy { border-left-color: var(--amber); background: var(--amber-soft); }
.tile-lab { font-size: .86rem; color: var(--muted); line-height: 1.35; min-height: 2.35em; }
.tile-val { font-size: 2.3rem; font-weight: 700; line-height: 1.15; color: var(--navy); font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile.cosy .tile-val { color: var(--amber); }
.tile-sub { font-size: .86rem; color: var(--muted); }
.tile.off { opacity: .6; }
.tile.off .tile-val { font-size: 1rem; font-weight: 600; padding: 12px 0 4px; }

.chart { margin-top: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 3px; border-radius: 2px; background: var(--navy); }
.sw.band { height: 10px; background: rgba(0,25,87,.14); border-radius: 2px; }
.sw.off { height: 10px; background: rgba(0,25,87,.07); border: 1px dashed var(--navy-line); }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart text { font-family: 'Sarabun', system-ui, sans-serif; }
.ax text { font-size: 12px; fill: var(--muted); }
.ax line.grid { stroke: var(--line); }
.panel-title { font-size: 13.5px; font-weight: 600; fill: var(--ink); }
.panel-note { font-size: 11.5px; fill: var(--muted); }
.hit { cursor: ew-resize; }

.sentence { margin-top: 16px; padding: 12px 14px; background: var(--bg); border-radius: 8px; font-size: .93rem; }
.sentence p + p { margin-top: 6px; }
.sentence .mk { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sentence:empty { display: none; }

.note { margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--navy-2); background: var(--navy-soft); border-radius: 0 8px 8px 0; font-size: .93rem; }

.study { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.study summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.study dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; margin-top: 12px; font-size: .93rem; }
.study dt { color: var(--muted); }

.alert { padding: 14px 16px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--warn-line); }

/* ---------- Dialogs ---------- */
.dlg { border: 0; border-radius: 12px; padding: 0; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 48px); color: var(--ink); box-shadow: 0 20px 60px rgba(0,10,40,.3); }
.dlg::backdrop { background: rgba(0, 12, 40, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.dlg-head h2 { font-size: 1.15rem; color: var(--navy); }
.dlg-x { border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.dlg-body { padding: 18px 22px 22px; font-size: .95rem; }
.dlg-body p + p, .dlg-body ul + p, .dlg-body p + ul { margin-top: 10px; }
.dlg-body ul { padding-left: 1.2em; }
.dlg-body .cols { columns: 2; column-gap: 28px; }
.dlg-body h1 { display: none; }
.dlg-body ol { padding-left: 1.4em; margin-top: 8px; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
	.layout { grid-template-columns: minmax(0, 1fr); padding: 14px 12px 28px; gap: 14px; }
	.flow { position: static; max-height: none; padding: 14px 14px; }
	.step { padding: 8px 0; }
	.pad, .result { padding: 18px 16px 20px; }
	.result h1 { font-size: 1.15rem; }
	.intro h1 { font-size: 1.25rem; }
	.bar { padding: 10px 12px; gap: 12px; }
	.brand-tag { display: none; }
	.nav-link { padding: 6px 6px; font-size: .85rem; }
	.tiles { gap: 10px; }
	.tile { padding: 10px 12px; }
	.tile-val { font-size: 1.8rem; }
	.tile-lab { font-size: .78rem; }
	.controls { gap: 12px; }
	.seg { width: 100%; }
	.seg button { flex: 1; }
	.time { flex-basis: 100%; }
	.time label { display: none; }
	.time output { min-width: 0; }
	.study dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
	.study dd { margin-bottom: 10px; }
	.dlg-body .cols { columns: 1; }
	.site-footer { padding: 4px 12px 24px; }
}
@media (max-width: 420px) {
	.brand-name { font-size: 1.05rem; }
	nav .nav-link[data-open="about"] { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
	.site-header nav, .flow-head .link-btn, .controls .stepper, .skip { display: none; }
	body { background: #fff; }
	.layout { grid-template-columns: 1fr; }
	.flow { position: static; max-height: none; }
}
