/* TOGOPEPTIDE — accessibility hardening (cluster 16, items 551-600).
 *
 * Loaded sitewide AFTER all design CSS so its rules win on tie.
 *
 * What this provides:
 *   1. Strong, brand-coloured :focus-visible outline on every interactive
 *      element (>= 3:1 contrast on dark + light themes). Item 554.
 *   2. A reinforced .skip-link / .skip-to-content rule that survives
 *      conflicting framework styles. Item 556.
 *   3. Global prefers-reduced-motion fallback that disables animations
 *      and transitions for every element. Item 567.
 *   4. forced-colors mode polish (Windows High Contrast). Item 568.
 *
 * Compatible with the existing :focus-visible rule in glowup.css —
 * this file simply hardens the contract (3px outline + 2px offset).
 */

/* ─── Focus visible (item 554) ─────────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--tgp-brand-red, var(--accent, #D31E27));
  outline-offset: 2px;
  border-radius: 4px;
}

/* Some legacy buttons re-declare outline:none — we always re-assert. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--tgp-brand-red, var(--accent, #D31E27));
  outline-offset: 2px;
}

/* Mouse-only focus stays clean. */
:focus:not(:focus-visible) { outline: none; }

/* ─── Skip-to-content reinforcement (item 556) ─────────────────── */

.skip-link,
.skip-to-content {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-120%);
  padding: 12px 16px;
  background: var(--tgp-brand-red, var(--accent, #D31E27));
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  /* z-index: was 100000 (magic) → --z-skiplink (900). A11y skiplink moet
     boven alles staan zodra keyboard-focus arriveert. */
  z-index: var(--z-skiplink, 900);
  border-radius: 0 0 6px 0;
}

.skip-link:focus,
.skip-link:focus-visible,
.skip-to-content:focus,
.skip-to-content:focus-visible {
  top: 0;
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* ─── Forced-colors / Windows High-Contrast (item 568) ─────────── */

@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid CanvasText;
    outline-offset: 2px;
  }
  .skip-link,
  .skip-to-content {
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
  }
}

/* ─── Reduced motion (item 567) ────────────────────────────────── */
/* Global override — wins because it's loaded last, AND each rule
   uses !important to defeat any inline animation from JS. */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto !important; }
}

/* ─── Zero-specificity safety nets (cluster 16, items 554/566) ──── */
/* These use :where() so existing per-component CSS always wins.    */
/* They only kick in when nothing else has set the property.        */

/* 554 — focus-visible last-resort fallback (zero specificity).     */
/* Ensures every interactive thing has SOME visible focus ring even */
/* if a future component CSS sets outline:none without replacement. */
:where(a, button, input, textarea, select, summary,
       [role="button"], [role="link"], [role="tab"], [role="menuitem"],
       [tabindex]):focus-visible {
  outline: 3px solid var(--tgp-brand-red, var(--accent, #D31E27));
  outline-offset: 2px;
}

/* 566 — reduced-motion zero-spec safety net.                        */
/* The earlier @media block above uses !important; this :where()     */
/* fallback is for the rare case where a component author wants to   */
/* OVERRIDE motion deliberately (e.g. an essential carousel).        */
@media (prefers-reduced-motion: reduce) {
  :where(*, *::before, *::after) {
    animation: none;
    transition: none;
  }
}

/* ─── Body-text link underline (item 586) ─────────────────────── */
/* Inside long-form prose (legal, blog, articles, glossary) links   */
/* must be distinguishable by more than colour alone — WCAG 1.4.1.  */
/* Using :where() so individual components can still opt out.       */

:where(.prose, .article__body, .legal__section, .blog__body,
       .glossary__body, .help__body, .faq__body) a:not(.btn):not(.button):not([class*="badge"]) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

:where(.prose, .article__body, .legal__section, .blog__body,
       .glossary__body, .help__body, .faq__body) a:not(.btn):not(.button):not([class*="badge"]):hover,
:where(.prose, .article__body, .legal__section, .blog__body,
       .glossary__body, .help__body, .faq__body) a:not(.btn):not(.button):not([class*="badge"]):focus-visible {
  text-decoration-thickness: 2px;
}

/* ─── Skip-link offscreen → focused slide-in (item 556 reinforce) ─ */
/* Belt-and-braces version using transform so we don't fight the    */
/* existing top:-40px rule above. .skip-link is the canonical class. */
:where(.skip-link):not(:focus):not(:focus-visible) {
  /* clip the link from sighted users without removing it from the  */
  /* accessibility tree */
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}

:where(.skip-link):focus,
:where(.skip-link):focus-visible {
  clip-path: none;
  width: auto;
  height: auto;
  overflow: visible;
  white-space: normal;
}
