/* Display & accessibility (a11y.js): UI scale, larger text, high contrast, colour-blind palettes,
   reduce motion, easy-read font; the settings block; the offline banner and update notice. */

/* ---------- interface size ----------
   The map canvas is never zoomed (its maths is in screen pixels); the chrome around it is. */
html.a11y-scaled #topbar,
html.a11y-scaled #toolbar,
html.a11y-scaled #side,
html.a11y-scaled #windows > .win,
html.a11y-scaled .modal,
html.a11y-scaled #toasts,
html.a11y-scaled #toolopts,
html.a11y-scaled #macrobar,
html.a11y-scaled #turnbanner,
html.a11y-scaled #stagehint,
html.a11y-scaled #hand-tray,
html.a11y-scaled #m-tabs,
html.a11y-scaled #menu .wrap,
html.a11y-scaled #offline-banner,
html.a11y-scaled #app-update { zoom: var(--ui-scale, 1); }
html.a11y-scaled #windows > .win { max-width: calc(100vw / var(--ui-scale, 1) - 16px); max-height: calc((100vh - 24px) / var(--ui-scale, 1)); }
/* menus and hover cards sit at the pointer, so they grow by font size instead of zoom */
html.a11y-scaled .ctx-item { font-size: calc(12px * var(--ui-scale, 1)); padding-top: calc(6px * var(--ui-scale, 1)); padding-bottom: calc(6px * var(--ui-scale, 1)); }
html.a11y-scaled .ctx { min-width: calc(190px * var(--ui-scale, 1)); }
html.a11y-scaled .hover-card { font-size: calc(12px * var(--ui-scale, 1)); max-width: calc(260px * var(--ui-scale, 1)); }

/* ---------- larger text ---------- */
html.a11y-big body { font-size: 15px; }
html.a11y-big .msg, html.a11y-big .msg .text { font-size: 15px; }
html.a11y-big .desc { font-size: 16px; }
html.a11y-big .chat-name { font-size: 14px; }
html.a11y-big .chat-time { font-size: 10.5px; }
html.a11y-big .system, html.a11y-big .roll-detail { font-size: 12.5px; }
html.a11y-big .roll-line, html.a11y-big .ooc { font-size: 13.5px; }
html.a11y-big .tpl-title { font-size: 19px; }
html.a11y-big .tpl-sub, html.a11y-big .tpl-label { font-size: 10.5px; }
html.a11y-big .tpl-desc { font-size: 13.5px; }
html.a11y-big label { font-size: 10.5px; }
html.a11y-big label.inline { font-size: 14px; }
html.a11y-big button, html.a11y-big .go { font-size: 12.5px; }
html.a11y-big button.small { font-size: 12px; }
html.a11y-big button.primary, html.a11y-big .go { font-size: 11px; }
html.a11y-big input, html.a11y-big select, html.a11y-big textarea { font-size: 14.5px; }
html.a11y-big .small, html.a11y-big .muted.small, html.a11y-big p.small { font-size: 12.5px; }
html.a11y-big h3 { font-size: 22px; }
html.a11y-big h4 { font-size: 10.5px; }
html.a11y-big .tag { font-size: 9.5px; }
html.a11y-big .j-name { font-size: 15px; }
html.a11y-big .side-tab { font-size: 11px; }
html.a11y-big .win-title { font-size: 18px; }
html.a11y-big .ctx-item { font-size: 14px; }
html.a11y-big .hover-card { font-size: 14px; }
html.a11y-big .section-kicker, html.a11y-big .home-kicker, html.a11y-big .choice-no { font-size: 10px; }
html.a11y-big .home-copy, html.a11y-big .section-head p { font-size: 15px; }
html.a11y-big .page-tab, html.a11y-big .page-name { font-size: 11px; }
html.a11y-big .th-cap-text { font-size: clamp(17px, 2vw, 26px); }

/* ---------- high contrast ---------- */
html.a11y-hc {
  --ink: #ffffff; --ink-2: #f2eee4; --dim: #c9d1e1; --dim-2: #aab4c8;
  --rule: #5f6f90; --rule-2: #8a9ac0; --gold: #ffd36b;
  --plate-a: #121826; --plate-b: #05070b;
}
html.a11y-hc body, html.a11y-hc #table { background: #000; }
html.a11y-hc #side, html.a11y-hc #toolbar, html.a11y-hc #topbar { background: #05070b; }
html.a11y-hc .win, html.a11y-hc .modal, html.a11y-hc .ctx, html.a11y-hc .hover-card { background: #070a10 !important; border-color: var(--rule-2) !important; }
html.a11y-hc button, html.a11y-hc .go, html.a11y-hc input, html.a11y-hc select, html.a11y-hc textarea { border-color: var(--rule-2); }
html.a11y-hc button { color: #fff; }
html.a11y-hc input, html.a11y-hc select, html.a11y-hc textarea { background: #000; color: #fff; }
html.a11y-hc button:focus-visible, html.a11y-hc input:focus-visible, html.a11y-hc select:focus-visible, html.a11y-hc textarea:focus-visible, html.a11y-hc a:focus-visible, html.a11y-hc [tabindex]:focus-visible { outline: 2px solid var(--gold) !important; outline-offset: 2px; }
html.a11y-hc .muted, html.a11y-hc label, html.a11y-hc .chat-time, html.a11y-hc .tpl-sub, html.a11y-hc .roll-line, html.a11y-hc .ooc, html.a11y-hc .tag,
html.a11y-hc .home-copy, html.a11y-hc .section-head p, html.a11y-hc .choice-no, html.a11y-hc .home-choice small, html.a11y-hc .side-tab, html.a11y-hc .page-tab { color: #d4dbe8; }
html.a11y-hc label.inline, html.a11y-hc .msg .text, html.a11y-hc .j-name { color: #fff; }
html.a11y-hc .side-tab.on, html.a11y-hc .page-tab.on, html.a11y-hc h4 { color: var(--gold); }
html.a11y-hc .j-row:hover, html.a11y-hc .ctx-item:focus, html.a11y-hc .ctx-item:hover { background: #1a2338; }
html.a11y-hc .tpl, html.a11y-hc .roll, html.a11y-hc .system { border-color: var(--rule-2); background: #070a10; }
html.a11y-hc .desc { color: #fff; border-left-color: var(--gold); }
html.a11y-hc .hp-bar { border-color: #8a9ac0; }
html.a11y-hc .road-motes { opacity: .45; }

/* ---------- colour-blind palettes (DOM side; canvases are remapped in a11y.js) ---------- */
html.a11y-cb-deut { --cb-good: #4aa3ff; --cb-mid: #d6d6d6; --cb-bad: #ff9a1f; }
html.a11y-cb-prot { --cb-good: #3d9bff; --cb-mid: #d6d6d6; --cb-bad: #ffc21a; }
html.a11y-cb-trit { --cb-good: #20c6c6; --cb-mid: #f0f0f0; --cb-bad: #ff4d6a; }
html[class*="a11y-cb-"] { --ok: var(--cb-good); --blood: var(--cb-bad); }
html[class*="a11y-cb-"] .hp-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--cb-good) 60%, #000), var(--cb-good)); }
html[class*="a11y-cb-"] .hp-bar[data-state=bloodied] .hp-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--cb-mid) 55%, #000), var(--cb-mid)); }
html[class*="a11y-cb-"] .hp-bar[data-state=down] .hp-fill { background: var(--cb-bad); }
html[class*="a11y-cb-"] .disp-friendly { color: var(--cb-good); }
html[class*="a11y-cb-"] .disp-neutral { color: var(--cb-mid); }
html[class*="a11y-cb-"] .disp-hostile { color: var(--cb-bad); }
html[class*="a11y-cb-"] .roll.crit, html[class*="a11y-cb-"] .inline-roll.crit { border-color: color-mix(in srgb, var(--cb-good) 60%, #000); }
html[class*="a11y-cb-"] .roll.crit .roll-total, html[class*="a11y-cb-"] .die.crit, html[class*="a11y-cb-"] .inline-roll.crit { color: var(--cb-good); }
html[class*="a11y-cb-"] .roll.fumble, html[class*="a11y-cb-"] .inline-roll.fumble { border-color: color-mix(in srgb, var(--cb-bad) 60%, #000); }
html[class*="a11y-cb-"] .roll.fumble .roll-total, html[class*="a11y-cb-"] .die.fail, html[class*="a11y-cb-"] .inline-roll.fumble { color: var(--cb-bad); }
/* seat colours on the people strip (the eight colours seats pick from) */
html.a11y-cb-deut .person[style*="#e05252"] { --c: #ff9a1f !important; }
html.a11y-cb-deut .person[style*="#e0a030"] { --c: #f0e442 !important; }
html.a11y-cb-deut .person[style*="#5bbf5b"] { --c: #4aa3ff !important; }
html.a11y-cb-deut .person[style*="#4aa8e0"] { --c: #1d5fd1 !important; }
html.a11y-cb-deut .person[style*="#9a6ee0"] { --c: #cc79a7 !important; }
html.a11y-cb-deut .person[style*="#e06bb5"] { --c: #f6c6e0 !important; }
html.a11y-cb-deut .person[style*="#40c4b0"] { --c: #ffffff !important; }
html.a11y-cb-deut .person[style*="#c8c050"] { --c: #9a9a9a !important; }
html.a11y-cb-prot .person[style*="#e05252"] { --c: #ffc21a !important; }
html.a11y-cb-prot .person[style*="#e0a030"] { --c: #fff27a !important; }
html.a11y-cb-prot .person[style*="#5bbf5b"] { --c: #3d9bff !important; }
html.a11y-cb-prot .person[style*="#4aa8e0"] { --c: #1d5fd1 !important; }
html.a11y-cb-prot .person[style*="#9a6ee0"] { --c: #b58cff !important; }
html.a11y-cb-prot .person[style*="#e06bb5"] { --c: #f6c6e0 !important; }
html.a11y-cb-prot .person[style*="#40c4b0"] { --c: #ffffff !important; }
html.a11y-cb-prot .person[style*="#c8c050"] { --c: #9a9a9a !important; }
html.a11y-cb-trit .person[style*="#e05252"] { --c: #ff4d6a !important; }
html.a11y-cb-trit .person[style*="#e0a030"] { --c: #ff9ec0 !important; }
html.a11y-cb-trit .person[style*="#5bbf5b"] { --c: #20c6c6 !important; }
html.a11y-cb-trit .person[style*="#4aa8e0"] { --c: #0f7f86 !important; }
html.a11y-cb-trit .person[style*="#9a6ee0"] { --c: #ffffff !important; }
html.a11y-cb-trit .person[style*="#e06bb5"] { --c: #b8346a !important; }
html.a11y-cb-trit .person[style*="#40c4b0"] { --c: #9aa3b0 !important; }
html.a11y-cb-trit .person[style*="#c8c050"] { --c: #d98c8c !important; }

/* ---------- reduce motion (master switch) ---------- */
html.a11y-rm *, html.a11y-rm *::before, html.a11y-rm *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
  transition-duration: .12s !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}
html.a11y-rm .road-motes { display: none; }

/* ---------- easy-read font ---------- */
html.a11y-dys {
  --sans: "Atkinson Hyperlegible", "Atkinson Hyperlegible Next", "Lexend", "OpenDyslexic", Verdana, Tahoma, sans-serif;
  --serif: "Atkinson Hyperlegible", "Atkinson Hyperlegible Next", "Lexend", Verdana, Tahoma, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", "Atkinson Hyperlegible", Verdana, Tahoma, sans-serif;
}
html.a11y-dys body { word-spacing: .06em; }
html.a11y-dys .msg, html.a11y-dys .md, html.a11y-dys .desc, html.a11y-dys textarea { line-height: 1.65; letter-spacing: .01em; }
html.a11y-dys .desc, html.a11y-dys .th-cap-text, html.a11y-dys .thd-caption { font-style: normal; }

/* ---------- the settings block ---------- */
.ds { display: flex; flex-direction: column; gap: 10px; }
.ds h4 { margin: 14px 0 0; }
.ds h4:first-child { margin-top: 4px; }
.ds-range { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }
.ds-range input { flex: 1; }
.ds-out { min-width: 44px; font: 700 11px var(--mono); color: var(--accent); text-align: right; }
.ds-checks { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
.ds-check { align-items: flex-start; }
.ds-check input { margin-top: 2px; flex: none; }
.ds-check span { display: flex; flex-direction: column; gap: 1px; }
.ds-check small { font-size: 10.5px; color: var(--dim-2); line-height: 1.35; }
.ds-swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 4px; background: rgba(5, 8, 13, .5); }
.ds-swl { font: 700 7.5px var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--dim); margin: 0 2px 0 6px; }
.ds-swl:first-child { margin-left: 0; }
.ds-sw { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35); }
.ds-hp { width: 40px; height: 6px; border-radius: 3px; background: #070a10; border: 1px solid #1c2537; overflow: hidden; }
.ds-hp i { display: block; height: 100%; }
.ds-app { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ds-note { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.5; }
.ds-install { padding: 8px 16px; }

/* ---------- offline banner, update notice ---------- */
#offline-banner, #app-update {
  position: fixed; left: 50%; z-index: 1200; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px);
  padding: 9px 14px; border: 1px solid var(--rule-2); border-radius: 5px; background: linear-gradient(150deg, rgba(29, 37, 52, .97), rgba(9, 13, 21, .98));
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55); font-size: 12px; color: var(--ink-2);
}
#offline-banner { top: 56px; transform: translate(-50%, -14px); opacity: 0; transition: opacity .3s, transform .3s var(--ease); border-color: #6a5420; pointer-events: none; }
#offline-banner.on { opacity: 1; transform: translate(-50%, 0); }
#offline-banner b { font: 700 9px var(--mono); letter-spacing: .2em; text-transform: uppercase; color: #e0b050; white-space: nowrap; }
.ob-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #e0b050; box-shadow: 0 0 10px #e0b050; animation: pulse 1.2s ease-in-out infinite; }
#app-update { bottom: 64px; transform: translateX(-50%); border-color: var(--accent-dim); animation: viewIn .35s var(--ease); }
.au-kick { font: 700 8px var(--mono); letter-spacing: .3em; text-transform: uppercase; color: var(--accent); }

@media (max-width: 700px) {
  .ds-checks { grid-template-columns: 1fr; }
  #offline-banner { top: 50px; font-size: 11px; }
  #offline-banner span:last-child { display: none; }
}

/* hover-card bars (extras.js) use the same colours as the map bars */
html[class*="a11y-cb-"] .hc-bar[style*="#c94a4a"], html[class*="a11y-cb-"] .hc-bar[style*="#d64545"] { --c: var(--cb-bad) !important; }
html[class*="a11y-cb-"] .hc-bar[style*="#3fb45a"] { --c: var(--cb-good) !important; }
html[class*="a11y-cb-"] .hc-bar[style*="#3b82d6"] { --c: var(--cb-mid) !important; }
.ds-win .ds > h4:first-child { display: none; }
