/* ===== Accessibility toolbar ===== */
html { font-size: calc(100% * var(--a11y-scale, 1)); }

.skip-link {
  position: fixed; top: 10px; right: 10px; z-index: 1000; padding: 12px 20px; border-radius: 12px;
  background: var(--ink); color: var(--cream); font-weight: 600; transform: translateY(-200%); transition: transform .2s;
}
.skip-link:focus { transform: none; outline: 3px solid var(--gold); }

.a11y { position: fixed; bottom: 24px; right: 24px; z-index: 95; font-family: var(--sans); font-size: 16px; }
.a11y-toggle {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: #1d4ed8; color: #fff; box-shadow: 0 12px 28px -10px rgba(29, 78, 216, .7);
  transition: transform .3s var(--ease);
}
.a11y-toggle:hover { transform: scale(1.08); }
.a11y-toggle svg { width: 30px; height: 30px; stroke-width: 2; }
.a11y-panel {
  position: absolute; bottom: 70px; right: 0; width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 120px); overflow: auto;
  background: #fff; color: #111; border-radius: 22px; padding: 20px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
}
.a11y-panel.open { opacity: 1; transform: none; }
.a11y-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.a11y-head h2 { font-family: var(--sans); font-size: 1.2em; font-weight: 700; }
.a11y-close { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #f1f1f1; }
.a11y-close:hover { background: #e2e2e2; }
.a11y-size { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #f4f4f6; margin-bottom: 12px; }
.a11y-size span { flex: 1; font-weight: 600; }
.a11y-size button { width: 44px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid #ccc; font-weight: 700; }
.a11y-size button:hover { border-color: #1d4ed8; color: #1d4ed8; }
.a11y-size output { min-width: 48px; text-align: center; font-weight: 600; }
.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 14px;
  background: #f4f4f6; border: 2px solid transparent; font-size: .92em; font-weight: 500; color: #111; transition: .2s;
}
.a11y-opt svg { width: 26px; height: 26px; }
.a11y-opt:hover { border-color: #93a8e8; }
.a11y-opt[aria-pressed="true"] { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.a11y-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid #e5e5e5; }
.a11y-reset { padding: 10px 16px; border-radius: 10px; background: #111; color: #fff; font-weight: 600; }
.a11y-foot a { color: #1d4ed8; text-decoration: underline; font-weight: 600; }
.a11y button:focus-visible, .a11y a:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

/* ===== Modes ===== */
/* high contrast: black background, white text, yellow links */
html.a11y-contrast body, html.a11y-contrast body *:not(.a11y):not(.a11y *):not(svg):not(svg *):not(img) {
  background-color: #000 !important; color: #fff !important; border-color: #fff !important;
  background-image: none !important; box-shadow: none !important; text-shadow: none !important;
  -webkit-text-fill-color: currentColor !important;
}
html.a11y-contrast body a:not(.a11y *), html.a11y-contrast body a:not(.a11y *) * { color: #ffeb3b !important; }
html.a11y-contrast .grain, html.a11y-contrast .blob, html.a11y-contrast .cursor { display: none !important; }

html.a11y-invert body > *:not(.a11y) { filter: invert(1) hue-rotate(180deg); }
html.a11y-invert body > *:not(.a11y) img, html.a11y-invert body > *:not(.a11y) iframe { filter: invert(1) hue-rotate(180deg); }
html.a11y-grayscale body > *:not(.a11y) { filter: grayscale(1); }

html.a11y-links a:not(.a11y *) { text-decoration: underline !important; text-underline-offset: 3px; outline: 2px dashed #1d4ed8; outline-offset: 2px; }
html.a11y-headings :is(h1, h2, h3, h4, h5, h6):not(.a11y *) { outline: 2px solid #f59e0b; outline-offset: 4px; background: rgba(245, 158, 11, .08); }

html.a11y-readable body *:not(.a11y *):not(svg):not(svg *) { font-family: Arial, "Heebo", sans-serif !important; font-style: normal !important; letter-spacing: normal; }
html.a11y-readable em { -webkit-text-fill-color: currentColor; color: var(--rose-deep) !important; background: none !important; }

html.a11y-spacing body *:not(.a11y *) { line-height: 1.9 !important; letter-spacing: .06em !important; word-spacing: .16em !important; }
html.a11y-spacing p:not(.a11y *) { margin-bottom: 1.2em; }

html.a11y-motion *, html.a11y-motion *::before, html.a11y-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html.a11y-motion .reveal { opacity: 1 !important; transform: none !important; }
html.a11y-motion .cursor { display: none !important; }

html.a11y-cursor, html.a11y-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M5 3l14 8-6 2-2 6z' fill='%23000' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") 4 2, auto !important;
}
html.a11y-cursor .cursor { display: none !important; }

html.a11y-focus *:focus, html.kbd-nav *:focus-visible { outline: 3px solid #f59e0b !important; outline-offset: 3px !important; }

@media (max-width: 720px) {
  .a11y { bottom: calc(96px + env(safe-area-inset-bottom)); right: 16px; }
  .a11y-toggle { width: 50px; height: 50px; }
}
@media print { .a11y, .skip-link { display: none; } }
