/* Acton Reader, styled after actonacademynb.com:
   navy #13406b, cyan #62b6cb, gold #ddb42f, ink #14251d, grays #f3f4f6 / #e4e4e4,
   Libre Baskerville headings, DM Sans body, pill buttons, rounded cards. */
@font-face { font-family: "DM Sans"; src: url("fonts/dm-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: "Libre Baskerville"; src: url("fonts/libre-baskerville-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Libre Baskerville"; src: url("fonts/libre-baskerville-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "OpenDyslexic"; src: url("fonts/opendyslexic-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --navy: #13406b;
  --navy-dark: #0e3154;
  --navy-ink: #0b2a47;
  --cyan: #62b6cb;
  --cyan-soft: #e3f2f6;
  --gold: #ddb42f;
  --gold-soft: #f8edc4;
  --ink: #14251d;
  --muted: #4b5563;
  --gray: #f3f4f6;
  --line: #e4e4e4;
  --red: #e40014;
  --red-dark: #9f0712;
  --white: #fff;
  --text-size: 22px;
  --body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --heading: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --read-font: var(--body);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--white); line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column; }
body.font-easy { --read-font: "Atkinson Hyperlegible", var(--body); }
body.font-dyslexic { --read-font: "OpenDyslexic", "Comic Sans MS", sans-serif; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 999px; z-index: 20; font-weight: 600; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }

/* Header like the main site: white bar with the horizontal logo, then a navy bar */
.site-head { background: var(--white); border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.logo { height: 52px; width: auto; display: block; }
.logo-link { border-radius: 6px; }
.app-name { text-align: right; }
.app-title { display: block; font-family: var(--heading); font-weight: 700; color: var(--navy); font-size: 1.45rem; line-height: 1.2; }
.app-sub { display: block; color: var(--muted); font-size: .95rem; }

.modebar { background: var(--navy); }
.tabs { display: flex; justify-content: center; gap: 6px; }
.tab {
  font: inherit; font-weight: 600; font-size: .95rem; text-transform: uppercase; letter-spacing: .6px;
  color: #fff; background: transparent; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 20px 11px; border-bottom: 3px solid transparent; min-height: 50px;
}
.tab svg { width: 18px; height: 18px; fill: currentColor; opacity: .9; }
.tab:hover { background: var(--navy-dark); }
.tab[aria-selected="true"] { border-bottom-color: var(--gold); background: var(--navy-dark); }
.tab:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }

main.wrap { flex: 1; padding-top: 24px; padding-bottom: 10px; }
.notice { background: #fef2f2; border: 2px solid #ffcaca; color: var(--red-dark); border-radius: 16px; padding: 12px 16px; margin-bottom: 14px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.buttons { display: flex; gap: 10px; align-items: center; }
.btn {
  font: inherit; font-weight: 600; font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid transparent; border-radius: 999px; cursor: pointer;
  padding: 0 28px; min-height: 56px;
  box-shadow: 0 4px 10px rgba(19, 64, 107, .18);
  transition: transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); box-shadow: 0 2px 4px rgba(19, 64, 107, .18); }
.btn svg { width: 24px; height: 24px; fill: currentColor; }
.btn.play { background: var(--navy); color: #fff; min-width: 150px; }
.btn.play:hover { background: var(--navy-dark); }
body.playing .btn.play { background: var(--gold); color: var(--ink); }
.btn.stop { background: #fff; color: var(--navy); border-color: var(--navy); box-shadow: none; }
.btn.stop:hover { background: var(--cyan-soft); }
.btn.round { width: 50px; min-height: 50px; height: 50px; padding: 0; background: var(--cyan); color: var(--navy-ink); box-shadow: none; }
.btn.round:hover { background: #4fa9bf; }
.btn.small-pill { min-height: 44px; font-size: 1rem; background: var(--cyan); color: var(--navy-ink); box-shadow: none; padding: 0 22px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ic-pause { display: none; }
body.playing .ic-play { display: none; }
body.playing .ic-pause { display: inline; }

.settings { display: flex; flex-wrap: wrap; gap: 12px 22px; align-items: flex-end; }
.settings.shared { background: var(--gray); border-radius: 18px; padding: 12px 18px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); font-weight: 600; border: none; margin: 0; padding: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
.field output { color: var(--navy); font-weight: 700; margin-left: 4px; }
.field input[type=range] { width: 170px; accent-color: var(--navy); height: 28px; }
.field select { font: inherit; font-size: .98rem; padding: 8px 12px; border-radius: 12px; border: 1px solid #cfd4da; background: #fff; color: var(--ink); max-width: 260px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: .98rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.toggles { gap: 4px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .88rem; font-weight: 600; border-radius: 999px; border: 1px solid var(--cyan); background: #fff; color: var(--navy-ink); padding: 4px 12px; cursor: pointer; min-height: 32px; }
.chip:hover { background: var(--cyan-soft); }
.chip[aria-pressed="true"] { background: var(--cyan); }
.seg-row { display: inline-flex; border: 1px solid var(--cyan); border-radius: 999px; overflow: hidden; }
.seg-row label { cursor: pointer; }
.seg-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-row span { display: inline-block; min-width: 48px; text-align: center; padding: 8px 0; color: var(--navy-ink); font-weight: 700; font-size: 1rem; background: #fff; }
.seg-row label + label span { border-left: 1px solid var(--cyan); }
.seg-row input:checked + span { background: var(--cyan); }
.seg-row input:focus-visible + span { outline: 3px solid var(--navy); outline-offset: -3px; }

/* Text card */
.paper { background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 10px 30px rgba(19, 64, 107, .08); overflow: hidden; }
.paper-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--gray); }
.status { color: var(--muted); font-size: .95rem; }
.bar-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.link { font: inherit; font-size: .95rem; background: none; border: none; color: var(--navy); font-weight: 600; cursor: pointer; padding: 6px 10px; border-radius: 999px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { background: var(--cyan-soft); }

textarea, .reader {
  position: relative; display: block; width: 100%;
  font-family: var(--read-font); font-size: var(--text-size); line-height: 1.7; color: var(--ink);
  padding: 22px 28px; height: min(60vh, 660px); min-height: 260px; overflow-y: auto;
  border: none; background: #fff;
}
body.font-dyslexic textarea, body.font-dyslexic .reader { line-height: 1.9; word-spacing: .12em; }
textarea { resize: vertical; }
textarea:focus-visible, .reader:focus-visible { outline: 3px solid var(--navy); outline-offset: -3px; }
textarea::placeholder { color: #6b7280; }
.reader p { margin: 0 0 .9em; max-width: 68ch; }
.reader .s { cursor: pointer; border-radius: 6px; padding: 1px 0; transition: background-color .15s; }
.reader .s:hover { background: var(--cyan-soft); }
.reader .s.read { color: #5b6670; }
.reader .s.current { background: var(--gold-soft); color: var(--ink); box-shadow: 0 0 0 3px var(--gold-soft); }
.reader .s .w { background: var(--gold); border-radius: 4px; box-shadow: 0 0 0 2px var(--gold); }

/* Speed trainer stage: the focal point never moves */
.stage { height: min(60vh, 660px); min-height: 300px; display: flex; flex-direction: column; justify-content: center; align-items: stretch; padding: 18px 22px; background: #fff; position: relative; }
.focus { position: relative; margin: 0 auto; width: 100%; max-width: 860px; }
.guide { position: relative; height: 2px; background: var(--navy); opacity: .85; margin: 0 6%; }
.guide .tick { position: absolute; left: 50%; width: 2px; height: 14px; background: var(--navy); transform: translateX(-1px); }
.guide.top .tick { top: 2px; }
.guide.bottom .tick { bottom: 2px; }
.rsvp-word {
  display: flex; align-items: baseline; white-space: pre; overflow: hidden;
  font-family: var(--read-font); font-weight: 500; color: var(--ink);
  font-size: calc(var(--text-size) * 2.2); line-height: 1.25; padding: .35em 0;
  min-height: calc(var(--text-size) * 2.2 * 1.25 + .7em);
}
.rsvp-word .l { flex: 1 1 0; text-align: right; overflow: hidden; }
.rsvp-word .r { flex: 1 1 0; text-align: left; overflow: hidden; }
.rsvp-word .o { color: var(--red); font-weight: 700; flex: none; }
.rsvp-word.idle { color: #6b7280; }
.context {
  margin: 28px auto 0; max-width: 760px; text-align: center; color: #5b6670;
  font-family: var(--read-font); font-size: calc(var(--text-size) * .85); line-height: 1.6;
  height: calc(var(--text-size) * .85 * 1.6 * 3); overflow: hidden;
}
.context mark { background: var(--gold-soft); color: var(--ink); border-radius: 4px; box-shadow: 0 0 0 2px var(--gold-soft); }
.stage-meta { position: absolute; left: 22px; right: 22px; bottom: 14px; display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; font-weight: 600; }

.progress { height: 6px; background: var(--line); }
#progressBar { height: 100%; width: 0; background: var(--cyan); transition: width .3s; }

.paper { position: relative; }
.summary {
  position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92%, 560px); background: #fff; border-radius: 24px; padding: 22px 26px;
  border-top: 6px solid var(--gold); box-shadow: 0 18px 50px rgba(19, 64, 107, .25);
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
}
.summary h2 { font-family: var(--heading); color: var(--navy); font-size: 1.3rem; margin: 0; }
.summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; margin: 0; width: 100%; }
.summary dt { font-size: .85rem; color: var(--muted); font-weight: 600; }
.summary dd { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--navy); }

.voice-note { flex-basis: 100%; margin: 2px 0 0; color: var(--navy); font-size: .92rem; font-weight: 600; }
.hint { color: var(--muted); font-size: .92rem; margin: 14px 4px; }
kbd { font-family: inherit; background: #fff; border: 1px solid #cfd4da; border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-size: .9em; }
.site-foot { background: var(--navy); color: #fff; font-size: .9rem; padding: 18px 0 22px; margin-top: 18px; text-align: center; }
.site-foot a { color: #fff; font-weight: 600; }
.site-foot a:focus-visible { outline-color: var(--gold); }

@media (max-width: 760px) {
  .head-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .logo { height: 40px; }
  .app-name { text-align: left; }
  .app-title { font-size: 1.2rem; }
  .tab { padding: 12px 12px 9px; font-size: .85rem; letter-spacing: .3px; }
  .buttons { width: 100%; justify-content: center; }
  .settings { width: 100%; }
  .field { flex: 1 1 150px; }
  .field input[type=range] { width: 100%; }
  .field select { max-width: none; width: 100%; }
  .btn { font-size: 1.05rem; padding: 0 20px; }
  .btn.play { min-width: 128px; }
  textarea, .reader { padding: 16px 18px; height: 56vh; }
  .stage { height: 56vh; padding: 14px; }
  .rsvp-word { font-size: calc(var(--text-size) * 1.7); min-height: calc(var(--text-size) * 1.7 * 1.25 + .7em); }
  .stage-meta { left: 14px; right: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
