/* =========================================================================
   RonRov accessibility widget — professional redesign (v2)
   Compliance target: IS 5568 / WCAG 2.0 AA.
   Key architecture note:
   - Color FILTERS (contrast/invert/grayscale) are applied to the page
     content wrapper  #a11y-content  (opened in inc/header.php, closed in
     inc/footer.php) — NOT to <html>. Applying a CSS filter to an ancestor
     of a position:fixed element makes that element scroll with the page
     (iOS Safari bug on long pages). The widget lives OUTSIDE #a11y-content,
     so the floating button always stays fixed and un-filtered.
   - All other helpers (font scale, links, focus, motion, readable font,
     spacing, big cursor) stay on <html>; none of them create a containing
     block, so they are safe there.
   ========================================================================= */

:root{
  --a11y-font-scale: 1;
  --a11y-accent: #1e63d6;       /* AA on white (4.7:1) */
  --a11y-accent-ink: #ffffff;
  --a11y-ink: #14181f;
  --a11y-surface: #ffffff;
  --a11y-muted: #f1f3f6;
  --a11y-border: rgba(0,0,0,.14);
  --a11y-focus: 3px solid #14181f;
  --a11y-radius: 16px;
}

/* ---- Skip link (kept; works with #main-content) ---- */
.a11y-skip-link{
  position: fixed;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 2147483647;
  background: #14181f;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  transform: translateY(-150%);
  transition: transform .15s ease;
}
.a11y-skip-link:focus{ transform: translateY(0); outline: none; }

/* =========================================================================
   Widget shell — insulated from page-level font/spacing helpers so the
   toolbar UI itself never distorts when "readable font" / "text spacing"
   are enabled on <html>.
   ========================================================================= */
.a11y-root,
.a11y-root *{
  font-family: system-ui, -apple-system, "Segoe UI", "Heebo", Arial, sans-serif !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
  box-sizing: border-box;
}
.a11y-root{
  position: fixed;
  z-index: 2147483646;
  color-scheme: light;           /* block iOS private-browsing dark coercion */
}
.a11y-root[dir="rtl"]{ direction: rtl; }
.a11y-root[dir="ltr"]{ direction: ltr; }

/* ---- Four admin-controlled FAB positions ---- */
.a11y-root.rr-accessibility-pos-bottom-right{ bottom: 18px; right: 18px; left: auto; top: auto; }
.a11y-root.rr-accessibility-pos-bottom-left { bottom: 18px; left: 18px; right: auto; top: auto; }
.a11y-root.rr-accessibility-pos-middle-right{ top: 50%; transform: translateY(-50%); right: 18px; left: auto; bottom: auto; }
.a11y-root.rr-accessibility-pos-middle-left { top: 50%; transform: translateY(-50%); left: 18px; right: auto; bottom: auto; }

/* legacy 2-value fallback */
.a11y-root[data-a11y-position="right"]{ bottom: 18px; inset-inline-end: 18px; }
.a11y-root[data-a11y-position="left"]{ bottom: 18px; inset-inline-start: 18px; }

@media (max-width: 600px){
  .a11y-root.rr-accessibility-pos-bottom-right,
  .a11y-root.rr-accessibility-pos-bottom-left{ bottom: 84px; }
  .a11y-root.rr-accessibility-pos-middle-right,
  .a11y-root.rr-accessibility-pos-middle-left{ top: max(50%, 120px); }
}

/* ---- Floating button (FAB) ---- */
.a11y-fab{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;                 /* >= 44px touch target */
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: var(--a11y-accent);
  color: var(--a11y-accent-ink);
  box-shadow: 0 10px 28px rgba(20,24,31,.32);
  transition: transform .12s ease, box-shadow .12s ease;
}
.a11y-fab:hover{ transform: scale(1.05); box-shadow: 0 12px 34px rgba(20,24,31,.4); }
.a11y-fab:focus-visible{ outline: var(--a11y-focus); outline-offset: 3px; }
.a11y-fab svg{ width: 30px; height: 30px; display: block; }

/* ---- Panel ---- */
.a11y-panel{
  position: fixed;
  width: min(384px, calc(100vw - 24px));
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--a11y-surface);
  color: var(--a11y-ink);
  border-radius: var(--a11y-radius);
  box-shadow: 0 18px 70px rgba(20,24,31,.32);
  overflow: hidden;
  color-scheme: light;
}
/* Restore the HTML [hidden] behaviour: our display:flex above would otherwise
   override the UA `display:none`, leaving the panel permanently open. */
.a11y-panel[hidden]{ display: none !important; }
.a11y-root.rr-accessibility-pos-bottom-right .a11y-panel{ bottom: 84px; right: 18px; left: auto; top: auto; }
.a11y-root.rr-accessibility-pos-bottom-left  .a11y-panel{ bottom: 84px; left: 18px;  right: auto; top: auto; }
.a11y-root.rr-accessibility-pos-middle-right .a11y-panel{ top: 50%; transform: translateY(-50%); right: 84px; left: auto; bottom: auto; }
.a11y-root.rr-accessibility-pos-middle-left  .a11y-panel{ top: 50%; transform: translateY(-50%); left: 84px;  right: auto; bottom: auto; }
.a11y-root[data-a11y-position="left"] .a11y-panel{ inset-inline-end: auto; inset-inline-start: 18px; }

/* ---- Mobile: full-width bottom sheet ---- */
@media (max-width: 600px){
  .a11y-root .a11y-panel,
  .a11y-root.rr-accessibility-pos-bottom-right .a11y-panel,
  .a11y-root.rr-accessibility-pos-bottom-left  .a11y-panel,
  .a11y-root.rr-accessibility-pos-middle-right .a11y-panel,
  .a11y-root.rr-accessibility-pos-middle-left  .a11y-panel{
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 86vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.a11y-panel-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--a11y-accent);
  color: var(--a11y-accent-ink);
  flex: 0 0 auto;
}
.a11y-title{ font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.a11y-title svg{ width: 22px; height: 22px; }
.a11y-close{
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px;
  background: rgba(255,255,255,.16);
  color: #fff; cursor: pointer; font-size: 18px; line-height: 1;
}
.a11y-close:hover{ background: rgba(255,255,255,.28); }
.a11y-close:focus-visible{ outline: 2px solid #fff; outline-offset: 2px; }

.a11y-panel-body{ padding: 14px 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- Grouped sections ---- */
.a11y-group{ margin: 0 0 14px; }
.a11y-group:last-of-type{ margin-bottom: 6px; }
.a11y-group-title{
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: .2px;
  color: #5a6472;
}
.a11y-row{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.a11y-row.a11y-row-2{ grid-template-columns: repeat(2, 1fr); }

/* ---- Buttons ---- */
.a11y-btn{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 56px;             /* >= 44px touch target */
  padding: 8px 6px;
  border: 1px solid var(--a11y-border);
  background: var(--a11y-muted);
  border-radius: 12px;
  color: var(--a11y-ink);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}
.a11y-btn svg{ width: 22px; height: 22px; flex: 0 0 auto; }
.a11y-glyph{ font-size: 19px; font-weight: 800; line-height: 1; }
.a11y-btn:hover{ background: #e8ebf0; }
.a11y-btn[aria-pressed="true"]{
  background: var(--a11y-accent);
  color: var(--a11y-accent-ink);
  border-color: var(--a11y-accent);
}
.a11y-btn:focus-visible{ outline: var(--a11y-focus); outline-offset: 2px; }

a.a11y-btn, a.a11y-btn-link{ text-decoration: none; color: inherit; }
a.a11y-btn:hover, a.a11y-btn-link:hover{ text-decoration: none; }

.a11y-danger{ border-color: rgba(176,0,0,.35); color: #b00000; }
.a11y-danger svg{ color: #b00000; }
.a11y-danger[aria-pressed="true"]{ color: #fff; }

/* ---- Note / footer text ---- */
.a11y-note{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--a11y-border);
  font-size: 12px;
  color: #5a6472;
  line-height: 1.5;
}

/* =========================================================================
   GLOBAL PAGE TRANSFORMATIONS
   ========================================================================= */

/* Font scale — on <html>; widget uses px so it is unaffected. */
html.a11y-font{ font-size: calc(100% * var(--a11y-font-scale)); }

/* Color filters — on the CONTENT WRAPPER only (see header note). */
#a11y-content.a11y-contrast{ filter: contrast(1.3); }
#a11y-content.a11y-invert{ filter: invert(1) hue-rotate(180deg); }
#a11y-content.a11y-grayscale{ filter: grayscale(1); }
#a11y-content.a11y-contrast.a11y-invert{ filter: invert(1) hue-rotate(180deg) contrast(1.3); }
#a11y-content.a11y-contrast.a11y-grayscale{ filter: grayscale(1) contrast(1.3); }
#a11y-content.a11y-invert.a11y-grayscale{ filter: invert(1) hue-rotate(180deg) grayscale(1); }
#a11y-content.a11y-contrast.a11y-invert.a11y-grayscale{ filter: invert(1) hue-rotate(180deg) grayscale(1) contrast(1.3); }

/* Fallback: if the wrapper is missing (older header cached), the JS applies
   the same classes to <html> instead, so the feature still works. These rules
   only match in that fallback case — when the wrapper exists the class lives on
   it, not on <html>. */
html.a11y-contrast{ filter: contrast(1.3); }
html.a11y-invert{ filter: invert(1) hue-rotate(180deg); }
html.a11y-grayscale{ filter: grayscale(1); }

/* Readable font — high-legibility stack + small tracking; widget insulated above. */
html.a11y-readable-font,
html.a11y-readable-font :where(p, li, a, span, h1, h2, h3, h4, h5, h6, label, button, input, textarea, select, td, th, dd, dt, figcaption, blockquote){
  font-family: Verdana, Tahoma, "Segoe UI", Arial, "Heebo", sans-serif !important;
  letter-spacing: .02em;
}

/* Text spacing — WCAG 1.4.12 generous spacing. */
html.a11y-text-spacing :where(p, li, a, span, h1, h2, h3, h4, h5, h6, label, td, th, dd, dt, blockquote){
  line-height: 1.8 !important;
  letter-spacing: .12em !important;
  word-spacing: .16em !important;
}
html.a11y-text-spacing :where(p, li, blockquote){ margin-bottom: 1.6em !important; }

/* Links emphasis */
html.a11y-underline-links a{ text-decoration: underline !important; text-underline-offset: 3px; }
html.a11y-highlight-links a{
  background: #fff2a8 !important;
  color: #14181f !important;
  -webkit-text-fill-color: #14181f !important;
  border-radius: 6px;
  padding-inline: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}

/* Strong focus outline */
html.a11y-focus-outline :where(a, button, input, textarea, select, [tabindex]):focus{
  outline: 3px solid #14181f !important;
  outline-offset: 3px !important;
}

/* Motion */
html.a11y-reduce-motion *{
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
html.a11y-stop-anim *,
html.a11y-stop-anim *::before,
html.a11y-stop-anim *::after{
  animation: none !important;
  transition: none !important;
}

/* Big cursor */
html.a11y-big-cursor, html.a11y-big-cursor *{
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='14' cy='14' r='10' fill='white' stroke='black' stroke-width='3'/%3E%3C/svg%3E") 14 14, auto !important;
}

/* Reading guide (mouse + touch driven; see JS) */
.a11y-reading-guide{
  position: fixed;
  inset-inline: 0;
  height: 52px;
  top: 0;
  z-index: 2147483645;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.16), rgba(0,0,0,0));
  mix-blend-mode: multiply;
}

/* Photo-page license-credit button reset (kept from previous build). */
button.ph-license-credit{
  font: inherit; color: inherit; background: none; border: 0;
  margin: 0; padding: 0; text-align: inherit; cursor: pointer;
}
button.ph-license-credit:focus-visible{ outline: 2px solid currentColor; outline-offset: 2px; }

/* Respect users who already asked the OS for reduced motion. */
@media (prefers-reduced-motion: reduce){
  .a11y-fab{ transition: none; }
}
