/* ScanBoard Reader — high contrast first. Themes swap the variables; brand navy/red are accents only. */
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('fonts/atkinson-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('fonts/atkinson-bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root { --navy: #3C3B6E; --red: #B22234; --bar-h: 112px; --head-h: 64px; }
.theme-yellow { --bg: #000; --fg: #FFE600; --text: #FFE600; --btn-bg: #000; --btn-fg: #FFE600; --line: #FFE600; --pri-bg: #FFE600; --pri-fg: #000; --focus: #00E5FF; --hl-bg: #FFE600; --hl-fg: #000; }
.theme-white  { --bg: #000; --fg: #FFF; --text: #FFF; --btn-bg: #000; --btn-fg: #FFF; --line: #FFF; --pri-bg: #FFF; --pri-fg: #000; --focus: #FFE600; --hl-bg: #FFF; --hl-fg: #000; }
.theme-light  { --bg: #FFF; --fg: #000; --text: #000; --btn-bg: #FFF; --btn-fg: #000; --line: #000; --pri-bg: #000; --pri-fg: #FFF; --focus: #B22234; --hl-bg: #000; --hl-fg: #FFF; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body.size-2 { font-size: 1.2rem; } body.size-3 { font-size: 1.4rem; }
body.size-1 { font-size: 1rem; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; line-height: 1.35; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
[hidden], .hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 2em; } h2 { font-size: 1.6em; }
h1:focus { outline: none; }
p { margin: .5em 0; }

button, .link-btn, select { font: inherit; font-weight: 700; color: var(--btn-fg); background: var(--btn-bg); border: 4px solid var(--line); border-radius: 18px; cursor: pointer; touch-action: manipulation; }
button:focus-visible, .link-btn:focus-visible, select:focus-visible, input:focus-visible + *, .choice:focus-within { outline: 6px solid var(--focus); outline-offset: -14px; }
.read-btn:focus-visible, .fill:focus-visible { outline-offset: -18px; outline-width: 8px; }
button:active { filter: invert(1); }
button[disabled], button[aria-disabled="true"] { opacity: 1; border-style: dashed; }
.big { min-height: 96px; font-size: 1.6em; padding: 10px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; }
.big .ico { font-size: 1.1em; line-height: 1; }
.wide { width: 100%; }
.primary { background: var(--pri-bg); color: var(--pri-fg); border-color: var(--pri-bg); }
.link-btn { display: flex; align-items: center; justify-content: center; text-decoration: underline; text-underline-offset: 6px; margin: 16px 0; }

#app { height: 100%; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); gap: 12px; background: var(--bg); overflow-y: auto; }
.brandbar { flex: 0 0 auto; background: var(--navy); color: #fff; border-bottom: 6px solid var(--red); margin: -12px -14px 0; padding: max(10px, env(safe-area-inset-top)) 16px 10px; }
.brandbar h1 { font-size: 1.4em; color: #fff; }
.brandbar .byline { font-size: .7em; font-weight: 400; color: #fff; white-space: nowrap; }
.brandbar.tall { padding-top: max(28px, env(safe-area-inset-top)); padding-bottom: 22px; }
.brandbar.tall h1 { font-size: 2.1em; }
.brandbar.tall .byline { display: block; font-size: .5em; margin-top: 6px; }

/* Start + tutorial: one giant button */
.fill { flex: 1 1 auto; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; font-size: 1em; }
.start-label { font-size: 3em; line-height: 1.1; }
.start-note { font-size: 1.4em; font-weight: 400; }
#tutorial .fill { font-size: 2.4em; flex: 0 0 auto; min-height: 30vh; }
.tut-line { font-size: 1.9em; font-weight: 700; flex: 1 1 auto; margin: 0; }
.step { font-size: 1.3em; margin: 0; }

/* Home: the camera shows through the giant Read button */
#home { background: transparent; padding-left: 0; padding-right: 0; padding-bottom: 0; gap: 0; }
#home .brandbar { margin: -12px 0 0; }
#camera-layer { position: fixed; left: 0; right: 0; top: var(--head-h); bottom: var(--bar-h); background: #000; }
#video { width: 100%; height: 100%; object-fit: contain; display: block; }
#outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#live-quad { fill: rgba(255, 230, 0, .12); stroke: #FFE600; stroke-width: 6; stroke-linejoin: round; }
.read-wrap { position: relative; flex: 1 1 auto; display: flex; margin: 8px; }
.read-btn { position: relative; flex: 1 1 auto; margin: 0; border: 8px solid var(--line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 18px 12px; border-radius: 26px; min-height: 300px; }
.read-label { font-size: 4.4em; line-height: 1; background: var(--bg); color: var(--fg); padding: 8px 32px; border-radius: 18px; border: 4px solid var(--line); }
.hint { position: absolute; left: 22px; right: 22px; bottom: 22px; margin: 0; pointer-events: none; font-weight: 700; font-size: 1.9em; background: var(--bg); color: var(--fg); padding: 10px 16px; border-radius: 14px; max-width: 100%; text-align: center; border: 3px solid var(--line); }
.level { position: absolute; top: 50%; left: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 6px solid #fff; box-shadow: 0 0 0 4px #000, inset 0 0 0 4px #000; pointer-events: none; }
.level .bubble { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; border-radius: 50%; background: var(--red); border: 4px solid #fff; transform: translate(var(--bx, 0), var(--by, 0)); }
.level.ok { border-color: #00E676; } .level.ok .bubble { background: #00E676; border-color: #000; }
.bottombar { flex: 0 0 var(--bar-h); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px max(8px, env(safe-area-inset-bottom)); background: var(--bg); }
.bottombar .big { min-height: 0; height: calc(var(--bar-h) - 8px); font-size: min(1.5em, 7.2vw); line-height: 1.1; padding: 6px; white-space: nowrap; }
.bottombar .sub { font-size: .8em; }
#btn-hands[aria-pressed="true"] { background: var(--pri-bg); color: var(--pri-fg); border-color: var(--pri-bg); }

.big-text { font-size: 1.5em; }
.bar { height: 36px; border: 4px solid var(--line); border-radius: 18px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--fg); transition: width .2s; }
#working { justify-content: center; }
#working h1 { font-size: 2.4em; }

/* Reader */
.reader-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.reader-top h1 { font-size: 1.6em; }
.pos { font-size: 1.3em; margin: 0; }
.surface { flex: 0 0 auto; min-height: 30vh; border: 4px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; justify-content: center; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.sentence { font-size: 2em; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.gesture-tip { font-size: 1em; margin: 10px 0 0; }
.hf-note { font-size: 1.2em; font-weight: 700; margin: 0; padding: 8px 12px; border: 3px dashed var(--line); border-radius: 12px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls .wide { grid-column: 1 / -1; }
.controls #btn-play { min-height: 120px; font-size: 2.2em; }
.rate { grid-column: 1 / -1; text-align: center; font-size: 1.4em; font-weight: 700; margin: 0; }
.controls #btn-repeat { grid-column: 1 / -1; }
.fulltext { border-top: 4px solid var(--line); padding-top: 12px; }
#full p { font-size: 1.4em; }
#full p.now { background: var(--hl-bg); color: var(--hl-fg); }
#full mark { background: var(--hl-bg); color: var(--hl-fg); }

/* Lists + menus */
.stack { display: flex; flex-direction: column; gap: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.list button { width: 100%; text-align: left; align-items: flex-start; }
.list .when { font-size: .7em; font-weight: 400; }
.help-list { margin: 0; padding-left: 1.4em; font-size: 1.35em; }
.help-list li { margin: 0 0 .7em; }
.help-list b { display: block; }
.back { margin-top: auto; }

/* Settings */
.group { border: 4px solid var(--line); border-radius: 18px; padding: 10px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend, .field-label { font-size: 1.5em; font-weight: 700; padding: 0 6px; }
.choice { display: flex; align-items: center; gap: 16px; min-height: 72px; font-size: 1.4em; font-weight: 700; padding: 8px 12px; border: 3px solid var(--line); border-radius: 14px; cursor: pointer; }
.choice input { width: 40px; height: 40px; flex: 0 0 40px; accent-color: var(--fg); margin: 0; }
.choice:has(input:checked) { background: var(--pri-bg); color: var(--pri-fg); }
.note { font-size: 1.1em; margin: 0; }
select { min-height: 80px; font-size: 1.3em; padding: 8px 12px; width: 100%; }
.about-icon { width: 120px; height: 120px; border-radius: 24px; }
.small-print { font-size: 1em; }
.byline { font-weight: 400; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
body.size-2 { --bar-h: 132px; } body.size-3 { --bar-h: 156px; }
