/* Edgery reading comfort (see a11y.js). Attributes on <html>: data-rfont, data-rsize, data-rcolor. */

/* ---- font ---- */
html[data-rfont="easy"] body, html[data-rfont="easy"] body *:not(svg):not(svg *) {
  font-family: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif !important;
  letter-spacing: normal !important; font-variant-numeric: tabular-nums;
}
html[data-rfont="system"] body, html[data-rfont="system"] body *:not(svg):not(svg *) {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  letter-spacing: normal !important; font-variant-numeric: tabular-nums;
}
html[data-rfont="easy"] body, html[data-rfont="system"] body { line-height: 1.55; }

/* ---- text size: the whole page scales, so nothing overlaps ---- */
html[data-rsize="l"] body { zoom: 1.12; }
html[data-rsize="xl"] body { zoom: 1.25; }

/* ---- colours: soft (dark themes) ---- */
html[data-rcolor="soft"]:not(.light) {
  --bg: #16181e !important; --ink: #cfd3dc !important; --cream: #cfd3dc !important; --muted: #9ba2b2 !important;
  --gold: #d6ad69 !important; --acc-rgb: 214,173,105 !important; --goldsoft: #d9bf93 !important; --acc-ink: #d6ad69 !important;
  --teal: #7fbfb3 !important; --sky: #8fb4cf !important; --violet: #ad9fd0 !important; --green: #7cc59b !important; --red: #e08c84 !important;
  --green-rgb: 124,197,155 !important; --red-rgb: 224,140,132 !important;
  --surf: #1d2027 !important; --surf-top: #20232b !important; --surf-deep: #181a20 !important; --card: #1d2027 !important;
  --bg-a: #16181e !important; --bg-b: #16181e !important; --bg-c: #16181e !important;
  --line: rgba(255,255,255,.10) !important; --glass: rgba(255,255,255,.04) !important;
}
html[data-rcolor="soft"] .aurora, html[data-rcolor="high"] .aurora { display: none !important; }
html[data-rcolor="soft"]:not(.light) body { background: #16181e !important; }
html[data-rcolor="soft"] .grad { background: none !important; -webkit-text-fill-color: currentColor !important; color: var(--gold) !important; }
html[data-rcolor="soft"] body *, html[data-rcolor="high"] body * { text-shadow: none !important; }

/* ---- colours: soft (light theme in the app) ---- */
html.light[data-rcolor="soft"] { --cream: #33363e !important; --muted: #5d6370 !important; --bg-a: #ecebe6 !important; --bg-b: #ecebe6 !important; --bg-c: #ecebe6 !important; }

/* ---- colours: high contrast ---- */
html[data-rcolor="high"]:not(.light) {
  --bg: #000 !important; --ink: #fff !important; --cream: #fff !important; --muted: #e4e6eb !important;
  --gold: #ffcc66 !important; --acc-rgb: 255,204,102 !important; --goldsoft: #ffd98a !important; --acc-ink: #ffcc66 !important;
  --green: #5ff59d !important; --red: #ff8a80 !important; --green-rgb: 95,245,157 !important; --red-rgb: 255,138,128 !important;
  --surf: #0b0b0b !important; --surf-top: #0b0b0b !important; --surf-deep: #000 !important; --card: #0b0b0b !important;
  --bg-a: #000 !important; --bg-b: #000 !important; --bg-c: #000 !important;
  --border: rgba(255,255,255,.55) !important; --line: rgba(255,255,255,.45) !important; --glass: #0b0b0b !important; --ink-rgb: 255,255,255 !important;
}
html[data-rcolor="high"]:not(.light) body { background: #000 !important; }
html[data-rcolor="high"] .grad { background: none !important; -webkit-text-fill-color: currentColor !important; color: #fff !important; }
html[data-rcolor="high"] a { text-decoration: underline !important; text-underline-offset: 3px; }
html.light[data-rcolor="high"] { --cream: #000 !important; --muted: #222 !important; --border: rgba(0,0,0,.6) !important; --bg-a: #fff !important; --bg-b: #fff !important; --bg-c: #fff !important; }

/* ---- the "Aa" button ---- */
.rd-aa { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.04); color: inherit; font: 600 14px/1 inherit; cursor: pointer; }
.rd-aa:hover { border-color: rgba(253,177,64,.7); }
.rd-aa:focus-visible, .rd-opt:focus-visible, .rd-x:focus-visible, .rd-done:focus-visible, .rd-link:focus-visible { outline: 3px solid #ffcc66; outline-offset: 2px; }

/* ---- the panel: fixed, readable colours whatever mode is chosen ---- */
.rd-bg { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.rd-bg[hidden] { display: none; }
.rd-card { position: relative; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; background: #15171d; color: #f1f2f5;
  border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 24px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
html[data-rsize="l"] .rd-card { zoom: .893; } html[data-rsize="xl"] .rd-card { zoom: .8; }   /* the panel keeps one size */
.rd-x { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: transparent; color: #f1f2f5; cursor: pointer; }
.rd-h { margin: 0 44px 4px 0; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: normal; }
.rd-sub { margin: 0 0 16px; font-size: 14px; line-height: 1.5; color: #c3c7d0; }
.rd-g { margin-top: 14px; }
.rd-gt { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #c3c7d0; margin-bottom: 8px; }
.rd-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rd-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 11px 12px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.18); background: #1d2028; color: #f1f2f5; min-height: 52px; }
.rd-opt.on { border-color: #ffcc66; background: #2a2416; box-shadow: inset 0 0 0 1px #ffcc66; }
.rd-ot { font-size: 15px; font-weight: 700; color: #fff; }
.rd-od { font-size: 12px; line-height: 1.35; color: #b8bdc8; }
.rd-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.rd-link { background: none; border: 0; padding: 6px 0; color: #ffcc66; font-size: 14px; text-decoration: underline; cursor: pointer; }
.rd-done { height: 42px; padding: 0 26px; border-radius: 10px; border: 0; background: #ffcc66; color: #14141c; font-size: 14px; font-weight: 700; cursor: pointer; }
@media (max-width: 560px) { .rd-row { grid-template-columns: 1fr; } .rd-row.rd-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .rd-card { padding: 20px 16px; } }
html[data-rfont] .rd-card, html[data-rfont] .rd-card *:not(.rd-ot) { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif !important; letter-spacing: normal !important; }
html[data-rfont] .rd-card .rd-ot.f-default { font-family: 'Space Grotesk', Arial, sans-serif !important; }
html[data-rfont] .rd-card .rd-ot.f-easy { font-family: 'Atkinson Hyperlegible', sans-serif !important; }
html[data-rfont] .rd-card .rd-ot.f-system { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif !important; }

/* ---- larger text: keep everything reachable ---- */
html[data-rsize="l"] .psside, html[data-rsize="xl"] .psside { position: static !important; max-height: none !important; }   /* pinned side panels would push buttons off screen */
@media (max-width: 1250px) { html[data-rsize="l"] header.top .nav { display: none !important; } }   /* website header links: also in the footer */
@media (max-width: 1440px) { html[data-rsize="xl"] header.top .nav { display: none !important; } }
@media (max-width: 600px) {   /* phones have their own text size setting: scale gently so nothing is cut off */
  html[data-rsize="l"] body { zoom: 1.05; }
  html[data-rsize="xl"] body { zoom: 1.1; }
  html[data-rsize="l"] .rd-card { zoom: .952; } html[data-rsize="xl"] .rd-card { zoom: .909; }
}
