/* accessibility layer: loaded last. focus, contrast, motion, touch targets and the user's own contrast and
   forced colour settings. nothing here changes layout, it only makes what is there reachable and readable */

/* ---------- landmarks ---------- */
/* #content is the skip link target, it takes focus from script and shows no ring for it */
#content:focus, #content:focus-visible { outline: none; }
/* the channel stamp over a title is decoration, keep it out of the heading's spoken name */
h1[data-code]::before { content: attr(data-code) / ""; }

/* ---------- contrast: text colours that fell under 4.5:1 on their own theme's background and panel ---------- */
:root { --paper-red: #c0202f; }
html[data-theme="fog"] { --chi: #086278; --red: #b50e2a; --amber: #795300; --green: #106840; --violet: #5440d5; }
html[data-theme="petal"] { --chi: #b91e63; --amber: #855800; --green: #127146; }
html[data-theme="redroom"] { --ink-3: #8e776e; }
html[data-theme="flipnote"] { --chi: #b33a0a; --green: #1d7236; }
html[data-theme="peach"] { --chi: #b33528; --green: #1c7044; }
html[data-theme="mint"] { --chi: #c02963; --green: #0e7547; }
html[data-theme="psx"] { --red: #a20d25; --amber: #6e4900; --green: #0f5d39; --violet: #712baa; }
html[data-theme="pocket"] { --chi: #2f602f; --amber: #724f00; --green: #1c6052; }
html[data-theme="blueprint"] { --red: #ff9797; }
html[data-theme="ice"] { --amber: #8c5d00; --green: #127648; }
html[data-theme="matcha"] { --amber: #875800; --green: #1c7035; }
html[data-theme="dsi"] { --chi: #0a6ca8; --red: #c91e3a; --amber: #915b00; --green: #107648; }
html[data-theme="rust"] { --chi: #d06742; }
html[data-theme="aqua"] { --chi: #1e7398; }
html[data-theme="vhs"] { --chi: #5981f4; }
html[data-theme="zine"] { --chi: #cb2638; }
html[data-theme="lime"] { --chi: #458113; }
html[data-theme="quartz"] { --chi: #bb4363; }
html[data-theme="sepia"] { --chi: #845629; --amber: #855800; --green: #116f44; }

/* ---------- focus ---------- */
/* a clipped (chamfered) key cuts any outline that sits outside it, so rings are drawn just inside the edge */
:is(button, a[href], summary, [role="button"], [role="tab"], [role="switch"], [role="checkbox"], [role="radio"], [role="menuitem"], [role="option"], label.chip, .chip, .pill, .key, .tile, .opt, .seg-option, .switch-option, [tabindex="0"]):focus-visible { outline-offset: -3px !important; }
/* inputs keep the ring outside, and a filled key shows its ring in the ink that sits on it */
.pill.accent:focus-visible, .key.accent:focus-visible, .view-key.accent:focus-visible { outline-color: var(--chi-ink); }
.pill.danger:focus-visible { outline-color: #fff; }
/* a keyboard user always gets a ring, whatever a look pack does to cursors */
:focus-visible { cursor: auto; }
html[data-focus="bold"] :focus-visible { outline-offset: -4px !important; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation-delay: 0s !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
  .fx-ripple, .fx-spark, .grain, .tween-pulse, .tween-dots { animation: none !important; }
  .fx-ripple, .fx-spark { display: none; }
  }
html.calm { scroll-behavior: auto !important; }
html.calm *, html.calm *::before, html.calm *::after { animation-delay: 0s !important; transition-delay: 0s !important; }

/* ---------- touch targets: 44 css px on a finger, 24 is the floor everywhere else ---------- */
@media (pointer: coarse) {
  .pill.small, .seg-option, .switch-option, .chip, .tag-rail .chip, .perm-row .seg-option, .feed-tag, .board-key, .job-link-title, .task-col-head, .section-head > button { min-height: 44px; }
  .pill.icon-only.small, .key-mini[data-act="hide"], .tile-remove, .scrap-index, .routine-check, .slice-swatch, .slice-step, .slice-colour, .job-link-drop, .job-preview-pic button { min-width: 44px; min-height: 44px; }
  .tile-remove, .scrap-index { width: 44px; height: 44px; }
  .routine-check { width: 44px; height: 44px; }
  .key-mini[data-act="hide"] { width: 44px; height: 44px; }
  .slice-swatch, .slice-step, .slice-colour { width: 44px; height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; min-width: 24px; }
  .toggle { min-height: 48px; }
  .wb-chip, .wb-key { min-height: 40px; }
}

/* ---------- people who ask for more contrast ---------- */
@media (prefers-contrast: more) {
  html:root { --ink-2: var(--ink); --ink-3: var(--ink); --line: color-mix(in srgb, var(--ink) 50%, transparent); --line-2: color-mix(in srgb, var(--ink) 75%, transparent); --panel: var(--panel-solid); }
  html:root .pattern, html:root .ambient, html:root .fog, html:root .grain, html:root .vignette { display: none; }
  .hint, .empty, input::placeholder, textarea::placeholder { opacity: 1; }
  :focus-visible { outline-width: 3px; }
}

/* ---------- forced colours (windows high contrast) ---------- */
@media (forced-colors: active) {
  :focus-visible { outline: 3px solid Highlight !important; }
  .pill, .chip, .seg-option, .switch-option, .key, .tile, .card, .panel, .modal-sheet, button, input, select, textarea, summary { border: 1px solid ButtonText; forced-color-adjust: auto; }
  .pill.accent, .chip.active, .seg-option.active, .key.active, [aria-pressed="true"], [aria-selected="true"], [aria-current="page"] { border-color: Highlight; outline: 2px solid Highlight; outline-offset: -3px; }
  .pill:disabled, button:disabled { border-color: GrayText; color: GrayText; }
  .pattern, .ambient, .fog, .grain, .vignette { display: none; }
}
