/* Accessibility and focus preferences for Chrome and the portal (extension/app/a11y.js puts data-a11y-* attributes
   on <html>, or on a preview box). Every rule here hangs off one of those attributes, so with nothing turned on
   nothing changes. Copied to the portal with the rest of extension/app. */

@font-face { font-family: 'OpenDyslexic'; src: url('OpenDyslexic-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('OpenDyslexic-Bold.woff2') format('woff2'); font-weight: 600 900; font-display: swap; }

/* ---- Theme: Light or Dark wins over the device's setting (the palettes match the iPhone app) ---- */
[data-a11y-theme="light"] {
  color-scheme: light;
  --bg: #f4f5fa; --surface: #fff; --surface-2: #f0f1f7; --border: #e2e4ee;
  --text: #121527; --text-2: #61697f; --text-3: #8b92a6;
  --accent: #5b4ae8; --accent-hover: #4b3bd6; --accent-soft: #edeafd; --accent-text: #fff;
  --good: #15803d; --good-soft: #e8f6ee; --warm: #b45309; --warm-soft: #fff6e6; --bad: #dc2626; --bad-soft: #fdeeee;
  --shadow: 0 1px 2px rgba(20,20,60,.04), 0 8px 24px rgba(30,27,75,.06);
}
[data-a11y-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d18; --surface: #151827; --surface-2: #1c2033; --border: #262b40;
  --text: #f3f4fa; --text-2: #99a0b8; --text-3: #747b93;
  --accent: #7c6cff; --accent-hover: #9083ff; --accent-soft: #241f4a; --accent-text: #fff;
  --good: #34d399; --good-soft: #1b2e24; --warm: #fbbf24; --warm-soft: #2b2416; --bad: #f87171; --bad-soft: #3a1f22; --shadow: none;
}

/* ---- Text size: everything scales together, like the browser's own zoom ---- */
[data-a11y-size] { --a11y-zoom: 1; }
html[data-a11y-size] body, .a11y-preview[data-a11y-size] { zoom: var(--a11y-zoom); }

/* ---- High contrast: no faded text, stronger borders, solid surfaces ---- */
[data-a11y-contrast] { --text-2: var(--text); --text-3: var(--text); --border: color-mix(in srgb, var(--text) 55%, transparent); --shadow: none; }
[data-a11y-contrast] :is(.app-panel, .card, .app-row.box, .field, .btn, .app-seg, .app-chip) { border-width: 2px; border-color: var(--border); }
[data-a11y-contrast] a { text-decoration: underline; }
[data-a11y-contrast] :focus-visible { outline: 3px solid var(--text) !important; outline-offset: 2px; }

/* ---- Reduce motion ---- */
[data-a11y-motion], [data-a11y-motion] *, [data-a11y-motion] *::before, [data-a11y-motion] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
[data-a11y-motion] .confetti, [data-a11y-motion] [data-motion] { display: none !important; }

/* ---- Reduce transparency: solid colors, no blur ---- */
[data-a11y-solid] *, [data-a11y-solid] *::before, [data-a11y-solid] *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
[data-a11y-solid] .app-sheet-back { background: color-mix(in srgb, var(--bg) 88%, #000); }
[data-a11y-solid] :is(.app-pill, .app-chip, .note, .pill) { background-color: var(--surface-2); }

/* ---- Color-blind friendly: blue and orange instead of green and red ---- */
[data-a11y-cb] { --good: #1d4ed8; --good-soft: #e6eefc; --bad: #c2410c; --bad-soft: #fff0e6; --warm: #a16207; }
@media (prefers-color-scheme: dark) { [data-a11y-cb]:not([data-a11y-theme="light"]) { --good: #60a5fa; --good-soft: #17233b; --bad: #fb923c; --bad-soft: #3a2616; --warm: #facc15; } }
[data-a11y-cb][data-a11y-theme="dark"] { --good: #60a5fa; --good-soft: #17233b; --bad: #fb923c; --bad-soft: #3a2616; --warm: #facc15; }

/* ---- Density and spacing ---- */
[data-a11y-space] :is(.app-page, .app-cols, .app-cols > *, main.wrap, .app-list, .stack) { gap: calc(16px * var(--a11y-space, 1)); }
[data-a11y-space] :is(.app-panel, .card) { padding: calc(16px * var(--a11y-space, 1)); }
[data-a11y-space] :is(.app-row, .row, .setting) { padding-block: calc(10px * var(--a11y-space, 1)); }
[data-a11y-space] :is(.app-actions, .inline, .chips, .row) { gap: calc(8px * var(--a11y-space, 1)); }

/* ---- Reading: font, line spacing, letter spacing ---- */
[data-a11y-font], [data-a11y-font] :is(body, button, input, select, textarea, h1, h2, h3, h4, p, span, a, li, td, th, label, b, strong) { font-family: 'OpenDyslexic', ui-sans-serif, system-ui, sans-serif !important; }
[data-a11y-lh] :where(p, li, dd, td, label, .note, .s, .app-row .s, textarea, .app-empty, .muted, blockquote) { line-height: var(--a11y-lh) !important; }
[data-a11y-lh] body { line-height: var(--a11y-lh); }
[data-a11y-ls], [data-a11y-ls] * { letter-spacing: var(--a11y-ls) !important; word-spacing: var(--a11y-ws) !important; }

/* ---- Reading ruler and mask (a11y.js moves them with the pointer or the keyboard focus) ---- */
.a11y-ruler { position: fixed; left: 0; right: 0; height: 2.6em; pointer-events: none; z-index: 9998; background: color-mix(in srgb, var(--accent) 14%, transparent); border-block: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.a11y-mask { position: fixed; left: 0; right: 0; pointer-events: none; z-index: 9997; background: rgba(8, 10, 20, .55); }
.a11y-mask.top { top: 0; }
.a11y-mask.bottom { bottom: 0; }

/* ---- Read aloud ---- */
::highlight(a11y-word) { background-color: #ffe066; color: #121527; }
.a11y-reader { position: fixed; right: 18px; bottom: 18px; z-index: 9999; display: flex; gap: 6px; align-items: center; padding: 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.a11y-reader button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-text, #fff); font-weight: 700; cursor: pointer; }
.a11y-reader button.ghost { background: var(--surface-2); color: var(--text); padding: 0 12px; }
.a11y-reader small { color: var(--text-2); padding: 0 6px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Simplified interface and focus ---- */
[data-a11y-simple] [data-extra] { display: none !important; }
[data-a11y-focusing] :is(.app-side, .side, #sidenav) a:not([data-essential]):not([aria-current="page"]) { display: none !important; }
[data-a11y-focusing] :is(.app-side, .side, #sidenav) h4 { display: none !important; }
.a11y-one { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-2); font-size: 14px; }

/* ---- Motor: bigger targets, voice input, keyboard ---- */
[data-a11y-targets] :is(.btn, button, .app-chip, .app-seg button, .app-icon-btn, .app-link, .app-row.click, select, input:not([type=checkbox]):not([type=radio]), a.nav-link, nav a, .side a, #sidenav a) { min-height: 56px; }
[data-a11y-targets] :is(input[type=checkbox], input[type=radio]) { width: 26px; height: 26px; }
[data-a11y-targets] .app-toggle { transform: scale(1.25); transform-origin: right center; }
.a11y-mic-wrap { position: relative; display: block; }
.a11y-mic { position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; cursor: pointer; }
.a11y-mic[aria-pressed="true"] { background: var(--bad); color: #fff; }
.a11y-mic-wrap > :is(input, textarea) { padding-right: 46px; }
.a11y-skip { position: fixed; left: 12px; top: -60px; z-index: 10000; padding: 10px 16px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; }
.a11y-skip:focus { top: 12px; }
[data-a11y-keys] :focus-visible, [data-a11y-keys] :focus { outline: 3px solid var(--accent) !important; outline-offset: 3px !important; }
.a11y-keys-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
.a11y-keys-list kbd { font: 600 13px ui-monospace, monospace; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); justify-self: start; }
.a11y-close { margin-left: auto; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; }

/* ---- The settings page ---- */
.a11y-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 22px; border-radius: var(--radius-lg, 22px); background: linear-gradient(110deg, color-mix(in srgb, var(--accent-soft) 85%, var(--surface)), var(--surface)); border: 1px solid var(--border); }
.a11y-hero .grow { flex: 1 1 320px; min-width: 0; }
.a11y-hero h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.a11y-hero p { margin: 6px 0 0; color: var(--text-2); }
.a11y-preset-btn { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; text-align: left; color: var(--text); box-shadow: var(--shadow); max-width: 100%; }
.a11y-preset-btn b { display: block; color: var(--accent); }
.a11y-preset-btn small { color: var(--text-2); }
.a11y-grid { display: grid; gap: 16px; align-items: start; }
@container (min-width: 760px) { .a11y-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 1180px) { .a11y-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.a11y-group-head { display: flex; gap: 12px; align-items: flex-start; }
.a11y-group-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.a11y-group-head h2 { font-size: 18px; font-weight: 800; }
.a11y-group-head p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.a11y-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 8px 0; }
.a11y-row > .ico { color: var(--text-2); }
.a11y-row .lab { font-weight: 600; font-size: 14.5px; }
.a11y-row .why { grid-column: 2 / -1; color: var(--text-2); font-size: 12.5px; margin: -2px 0 0; }
.a11y-row .wide { grid-column: 2 / -1; }
.a11y-row.off { opacity: .55; }
.a11y-row .sys { grid-column: 2 / -1; font-size: 12.5px; color: var(--text-2); }
.app-toggle { position: relative; width: 50px; height: 30px; border-radius: 999px; border: 0; background: var(--border); cursor: pointer; flex: none; padding: 0; }
.app-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.app-toggle[aria-checked="true"] { background: var(--accent); }
.app-toggle[aria-checked="true"]::after { transform: translateX(20px); }
[data-a11y-contrast] .app-toggle[aria-checked="false"] { background: var(--text-2); }
[data-a11y-contrast] .app-toggle[aria-checked="true"]::before, [data-a11y-cb] .app-toggle[aria-checked="true"]::before { content: 'I'; position: absolute; left: 10px; top: 5px; color: #fff; font: 700 13px system-ui; }
.a11y-size { display: flex; align-items: center; gap: 10px; }
.a11y-size input[type=range] { flex: 1; accent-color: var(--accent); min-width: 120px; }
.a11y-size output { font-weight: 700; min-width: 70px; text-align: center; padding: 4px 10px; border-radius: 10px; background: var(--surface-2); }
.a11y-preview { border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); padding: 14px; display: grid; gap: 10px; font-size: 14px; }
.a11y-preview .pv-bar { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.a11y-preview .pv-search { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.a11y-preview .pv-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.a11y-preview .pv-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.a11y-preview .pv-item.later .dot { background: var(--bad); }
.a11y-preview p { margin: 0; }
.a11y-who { display: flex; gap: 8px; flex-wrap: wrap; }
.a11y-note { padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 14px; }
.a11y-presets { display: grid; gap: 10px; }
.a11y-preset { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.a11y-preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.a11y-preset .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.a11y-preset b { display: block; }
.a11y-preset small { color: var(--text-2); }
.rot90 { transform: rotate(90deg); }
html:has(.a11y-reader) body { padding-bottom: 84px; }
