/* ======================================================================
   Module Accessibilité — thèmes, options d'affichage, gros caractères, panneau
   Les réglages sont posés sur <html> : data-tn-theme, data-tn-size, data-tn-font,
   data-tn-links, data-tn-spacing, data-tn-motion, data-tn-big.
   Tous les couples de couleurs ont été mesurés ≥ 4,5:1 (texte) et ≥ 3:1 (bordures de champs).
   ====================================================================== */

/* Police très lisible, hébergée sur le site (licence OFL) */
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("../fonts/atkinson-hyperlegible-latin-700-italic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: swap; }

/* ---------- Taille du texte (tout est en rem : la page se réorganise) ---------- */
html[data-tn-size="125"] { font-size: 125%; }
html[data-tn-size="150"] { font-size: 150%; }
html[data-tn-size="175"] { font-size: 175%; }
html[data-tn-size="200"] { font-size: 200%; }
html[data-tn-size="250"] { font-size: 250%; }

/* ---------- Thème clair ---------- */
html[data-tn-theme="clair"], html[data-tn-theme="clair"] body {
  --tn-bg: #f4f6fb; --tn-bg-2: #eef1f8; --tn-surface: #ffffff; --tn-border: #d5dae6; --tn-field-border: #767f92;
  --tn-text: #111827; --tn-muted: #4b5563; --tn-accent: #0f6e64; --tn-accent-2: #b4400c;
  --tn-danger: #b42318; --tn-ok: #166534; --tn-warn: #8a5a00; --tn-on-accent: #ffffff; --tn-on-danger: #ffffff;
  --tn-header-bg: rgba(255, 255, 255, .94); --tn-tabbar-bg: rgba(255, 255, 255, .97); --tn-glow: #dfe9ff;
  --tn-tint-accent: rgba(15, 110, 100, .08); --tn-tint-warn: rgba(180, 64, 12, .08); --tn-tint-danger: rgba(180, 35, 24, .08); --tn-tint-ok: rgba(22, 101, 52, .1);
  --tn-shadow: rgba(17, 24, 39, .15); --tn-focus: #1d4ed8;
  color-scheme: light;
}
html[data-tn-theme="clair"] body.tn-workspace {
  --tn-bg: #faf6f2; --tn-bg-2: #f5efe8; --tn-surface: #ffffff; --tn-border: #e3d8cd; --tn-field-border: #8a7a6c;
  --tn-text: #1c1410; --tn-muted: #5a4a3e; --tn-accent: #a8410a; --tn-on-accent: #ffffff; --tn-glow: #f6e3d2;
  --tn-header-bg: rgba(255, 255, 255, .94); --tn-tabbar-bg: rgba(255, 255, 255, .97); --tn-tint-accent: rgba(168, 65, 10, .08);
}
html[data-tn-theme="clair"] .tn-card, html[data-tn-theme="clair"] .tn-tile, html[data-tn-theme="clair"] .tn-kpi { box-shadow: 0 1px 2px var(--tn-shadow); }

/* ---------- Contraste élevé (noir / blanc / jaune) ---------- */
html[data-tn-theme="contraste"], html[data-tn-theme="contraste"] body, html[data-tn-theme="contraste"] body.tn-workspace {
  --tn-bg: #000000; --tn-bg-2: #000000; --tn-surface: #000000; --tn-border: #ffffff; --tn-field-border: #ffffff;
  --tn-text: #ffffff; --tn-muted: #f0f0f0; --tn-accent: #ffeb3b; --tn-accent-2: #ffeb3b;
  --tn-danger: #ff8a8a; --tn-ok: #7dff8a; --tn-warn: #ffeb3b; --tn-on-accent: #000000; --tn-on-danger: #000000;
  --tn-header-bg: #000000; --tn-tabbar-bg: #000000; --tn-glow: #000000;
  --tn-tint-accent: #000000; --tn-tint-warn: #000000; --tn-tint-danger: #000000; --tn-tint-ok: #000000;
  --tn-shadow: transparent; --tn-focus: #00e5ff;
  color-scheme: dark;
}
html[data-tn-theme="contraste"] body.tn-body { background: #000; }
html[data-tn-theme="contraste"] .tn-card, html[data-tn-theme="contraste"] .tn-tile, html[data-tn-theme="contraste"] .tn-kpi,
html[data-tn-theme="contraste"] .tn-tab, html[data-tn-theme="contraste"] .tn-badge, html[data-tn-theme="contraste"] .tn-btn--ghost { border: 2px solid #fff; }
html[data-tn-theme="contraste"] .tn-tab.is-active, html[data-tn-theme="contraste"] .tn-tabbar a.is-active { background: #ffeb3b; color: #000 !important; border-color: #ffeb3b; }
html[data-tn-theme="contraste"] .tn-body a:not(.tn-btn):not(.tn-tab):not(.tn-tile):not(.tn-card) { color: #ffeb3b; text-decoration: underline; }
html[data-tn-theme="contraste"] .tn-btn { border: 2px solid #ffeb3b; }
html[data-tn-theme="contraste"] .tn-brand__dot { box-shadow: none; }

/* ---------- Police très lisible ---------- */
html[data-tn-font="lisible"], html[data-tn-font="lisible"] body {
  --tn-font: "Atkinson Hyperlegible", "Verdana", system-ui, sans-serif;
}
html[data-tn-font="lisible"] body { font-family: var(--tn-font); }

/* ---------- Liens toujours soulignés ---------- */
html[data-tn-links="1"] .tn-body a:not(.tn-btn):not(.tn-tab):not(.tn-tile):not(.tn-card):not(.tn-tool):not(.tn-brand),
html[data-tn-links="1"] .tn-body .tn-tile__label, html[data-tn-links="1"] .tn-body a.tn-card h2,
html[data-tn-links="1"] .tn-body a.tn-card h3, html[data-tn-links="1"] .tn-body .tn-tool strong { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }

/* ---------- Espacement du texte (critère WCAG 1.4.12) ---------- */
html[data-tn-spacing="1"] .tn-body, html[data-tn-spacing="1"] .tn-a11y { line-height: 1.8 !important; letter-spacing: 0.12em; word-spacing: 0.16em; }
html[data-tn-spacing="1"] .tn-body p { margin-bottom: 1.2em; }
html[data-tn-spacing="1"] .tn-body h1, html[data-tn-spacing="1"] .tn-body h2, html[data-tn-spacing="1"] .tn-body h3 { letter-spacing: 0.05em; line-height: 1.4; }

/* ---------- Réduire les animations ---------- */
html[data-tn-motion="reduit"] *, html[data-tn-motion="reduit"] *::before, html[data-tn-motion="reduit"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
html[data-tn-motion="reduit"] .tn-tile:hover, html[data-tn-motion="reduit"] .tn-service-card:hover { transform: none; }

/* ---------- Gros caractères (≥ 150 %) : mise en page « une colonne » ---------- */
html[data-tn-big="1"] .tn-header { position: relative; flex-wrap: wrap; }
html[data-tn-big="1"] .tn-burger { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-left: auto; border-radius: 10px; }
html[data-tn-big="1"] .tn-header .tn-nav { display: none; order: 10; width: 100%; flex-direction: column; gap: 2px; padding: 0.5rem 0 0.25rem; border-top: 1px solid var(--tn-border); margin-top: 0.5rem; }
html[data-tn-big="1"] .tn-header .tn-nav.is-open { display: flex; }
html[data-tn-big="1"] .tn-header .tn-nav__item { padding: 0.75rem 0.625rem; font-size: 1rem; }
html[data-tn-big="1"] .tn-header .tn-nav .tn-nav__account { display: flex; }
html[data-tn-big="1"] .tn-user { display: none; }
html[data-tn-big="1"] .tn-tabbar { display: none !important; }
html[data-tn-big="1"] body.tn-body { padding-bottom: 0; }
html[data-tn-big="1"] .tn-main { max-width: 100%; }
html[data-tn-big="1"] .tn-service__body, html[data-tn-big="1"] .tn-contact__layout, html[data-tn-big="1"] .tn-agent__grid { grid-template-columns: 1fr; }
html[data-tn-big="1"] .tn-space__head .tn-kpis { min-width: 0; }
html[data-tn-big="1"] .tn-request__head, html[data-tn-big="1"] .tn-ticket__head, html[data-tn-big="1"] .tn-sig__head,
html[data-tn-big="1"] .tn-section-head, html[data-tn-big="1"] .tn-agent__head, html[data-tn-big="1"] .tn-space__head { flex-direction: column; align-items: flex-start; }
html[data-tn-big="1"] .tn-ticket__form, html[data-tn-big="1"] .tn-sig__actions { flex-direction: column; align-items: stretch; }
html[data-tn-big="1"] .tn-ticket__form input, html[data-tn-big="1"] .tn-sig__actions input { min-width: 0; }
html[data-tn-big="1"] .tn-table-wrap { border: 0; overflow: visible; }
html[data-tn-big="1"] .tn-table thead { display: none; }
html[data-tn-big="1"] .tn-table, html[data-tn-big="1"] .tn-table tbody, html[data-tn-big="1"] .tn-table tr, html[data-tn-big="1"] .tn-table td { display: block; width: 100%; box-sizing: border-box; }
html[data-tn-big="1"] .tn-table tr { background: var(--tn-bg-2); border: 1px solid var(--tn-border); border-radius: var(--tn-radius); padding: 0.625rem 0.75rem; margin-bottom: 0.625rem; }
html[data-tn-big="1"] .tn-table td { border: 0; padding: 0.25rem 0; }
html[data-tn-big="1"] .tn-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tn-muted); }
html[data-tn-big="1"] .tn-tabs { flex-wrap: wrap; }
@media (max-width: 640px) {
  html[data-tn-big="1"] .tn-tiles, html[data-tn-big="1"] .tn-kpis { grid-template-columns: 1fr; }
  html[data-tn-big="1"] .tn-tabs { margin-left: 0; margin-right: 0; padding: 0; }
  html[data-tn-big="1"] .tn-hero__title { font-size: 1.75rem; }
}
/* Les mots longs se coupent plutôt que de déborder */
html[data-tn-big="1"] .tn-body { overflow-wrap: anywhere; hyphens: auto; }

/* ======================================================================
   Bouton et panneau « Accessibilité »
   ====================================================================== */
.tn-a11y-btn { box-sizing: border-box; text-decoration: none !important; display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2.75rem; padding: 0 0.75rem; border-radius: 10px; border: 1px solid var(--tn-field-border); background: transparent; color: var(--tn-text); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.tn-a11y-btn:hover { background: var(--tn-surface); }
.tn-a11y-btn__icon { font-size: 1.125rem; line-height: 1; }
@media (max-width: 640px) { .tn-a11y-btn__label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); } }

.tn-a11y { position: fixed; inset: 0; z-index: 1000; display: flex; justify-content: flex-end; background: rgba(0, 0, 0, .55); font-family: var(--tn-font, system-ui, sans-serif); color: var(--tn-text, #e8ecf8); }
.tn-a11y[hidden] { display: none; }
.tn-a11y__box { width: min(30rem, 100%); height: 100%; overflow-y: auto; background: var(--tn-bg, #0b1020); border-left: 1px solid var(--tn-border, #2a3560); padding: 1.25rem 1.25rem calc(2rem + env(safe-area-inset-bottom)); box-sizing: border-box; }
.tn-a11y__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.tn-a11y__head h2 { margin: 0; font-size: 1.375rem; color: var(--tn-text); font-family: inherit; }
.tn-a11y__close { min-width: 2.75rem; min-height: 2.75rem; border-radius: 10px; border: 1px solid var(--tn-field-border, #6f7cae); background: transparent; color: var(--tn-text); font-size: 1.25rem; cursor: pointer; }
.tn-a11y__intro { color: var(--tn-muted, #a3aed0); margin: 0.5rem 0 1rem; font-size: 0.9375rem; }
.tn-a11y-form fieldset { border: 1px solid var(--tn-border, #2a3560); border-radius: 12px; padding: 0.875rem; margin: 0 0 0.875rem; min-width: 0; }
.tn-a11y-form legend { font-weight: 700; padding: 0 0.375rem; font-size: 1rem; }
.tn-a11y-form .tn-a11y-help { margin: 0 0 0.625rem; color: var(--tn-muted, #a3aed0); font-size: 0.875rem; }
.tn-a11y-choices { display: grid; gap: 0.5rem; }
.tn-a11y-choices--row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.5rem), 1fr)); }
.tn-a11y-choice { position: relative; display: flex; gap: 0.625rem; align-items: flex-start; padding: 0.625rem 0.75rem; border-radius: 10px; border: 1px solid var(--tn-field-border, #6f7cae); cursor: pointer; background: var(--tn-surface, #18213f); }
.tn-a11y-choice input { margin: 0.2rem 0 0; width: 1.25rem; height: 1.25rem; flex: 0 0 auto; accent-color: var(--tn-accent); }
.tn-a11y-choice strong { display: block; font-size: 0.9375rem; }
.tn-a11y-choice small { display: block; color: var(--tn-muted, #a3aed0); font-size: 0.8125rem; line-height: 1.35; }
.tn-a11y-choice:has(input:checked) { border-color: var(--tn-accent); box-shadow: inset 0 0 0 1px var(--tn-accent); }
.tn-a11y-choice:has(input:focus-visible) { outline: 3px solid var(--tn-focus, #ffd84d); outline-offset: 2px; }
.tn-a11y-choice--size { flex-direction: column; align-items: center; text-align: center; gap: 0.25rem; padding: 0.5rem 0.25rem; }
.tn-a11y-choice--size input { margin: 0; }
.tn-a11y-choice--size .tn-a11y-sample { font-weight: 700; line-height: 1; }
.tn-a11y-swatch { display: inline-block; width: 2rem; height: 1.375rem; border-radius: 6px; border: 1px solid currentColor; flex: 0 0 auto; margin-top: 0.1rem; }
.tn-a11y-swatch--sombre { background: linear-gradient(90deg, #0b1020 50%, #41e2c4 50%); }
.tn-a11y-swatch--clair { background: linear-gradient(90deg, #ffffff 50%, #0f6e64 50%); }
.tn-a11y-swatch--contraste { background: linear-gradient(90deg, #000000 50%, #ffeb3b 50%); }
.tn-a11y-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.tn-a11y-status { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--tn-muted, #a3aed0); }
.tn-a11y-inline { margin-top: 0.5rem; }
.tn-a11y-inline .tn-a11y-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 0 1rem; }
.tn-a11y-inline .tn-a11y-form .tn-a11y-actions, .tn-a11y-inline .tn-a11y-form .tn-a11y-status { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .tn-a11y__box { width: 100%; border-left: 0; }
  .tn-a11y-choices--row { grid-template-columns: repeat(3, 1fr); }
}

/* Page « Déclaration d'accessibilité » */
.tn-declaration h2 { margin-top: 1.75rem; font-size: 1.25rem; }
.tn-declaration ul { padding-left: 1.25rem; }
.tn-declaration li { margin-bottom: 0.375rem; }

/* Les champs ne dépassent jamais leur conteneur, même avec de très gros caractères */
.tn-body select, .tn-body input, .tn-body textarea { max-width: 100%; box-sizing: border-box; }
html[data-tn-big="1"] .tn-body select, html[data-tn-big="1"] .tn-body input:not([type=checkbox]):not([type=radio]), html[data-tn-big="1"] .tn-body textarea { min-width: 0; width: 100%; }
html[data-tn-big="1"] .tn-toolbar { flex-direction: column; align-items: stretch; }
html[data-tn-big="1"] .tn-toolbar > * { width: 100%; }
html[data-tn-big="1"] .tn-ticket__form select, html[data-tn-big="1"] .tn-sig__actions select { text-overflow: ellipsis; }

/* ------------------------------------------------------------------ */
/* F43 : couleurs adaptées au daltonisme (palette Okabe-Ito)          */
/* + une forme différente par état : la couleur n'est jamais seule    */
/* ------------------------------------------------------------------ */
html[data-tn-cvd="1"] { --tn-ok: #56b4e9; --tn-danger: #f0a04b; --tn-warn: #f0e442; --tn-tint-ok: rgba(86, 180, 233, .14); --tn-tint-danger: rgba(240, 160, 75, .16); --tn-tint-warn: rgba(240, 228, 66, .12); }
html[data-tn-cvd="1"][data-tn-theme="clair"] { --tn-ok: #005a8c; --tn-danger: #9e4a00; --tn-warn: #6b5a00; --tn-tint-ok: rgba(0, 114, 178, .10); --tn-tint-danger: rgba(213, 94, 0, .10); --tn-tint-warn: rgba(240, 228, 66, .25); }
html[data-tn-cvd="1"] .tn-badge { border-width: 2px; }
html[data-tn-cvd="1"] .tn-badge--ok { border-style: solid; }
html[data-tn-cvd="1"] .tn-badge--warn { border-style: dotted; }
html[data-tn-cvd="1"] .tn-badge--danger { border-style: dashed; }
html[data-tn-cvd="1"] .tn-status--danger, html[data-tn-cvd="1"] .tn-alertbar--urgent, html[data-tn-cvd="1"] .tn-alertbar--critique { border-left-style: double; border-left-width: 8px; }
html[data-tn-cvd="1"] .tn-status--warn, html[data-tn-cvd="1"] .tn-alertbar--important { border-left-style: dashed; }
html[data-tn-cvd="1"] .tn-dot { box-shadow: none; outline: 2px solid currentColor; }

/* ------------------------------------------------------------------ */
/* F41 : navigation au clavier — repère de position très visible      */
/* ------------------------------------------------------------------ */
html[data-tn-focus="1"] .tn-body :focus-visible,
html[data-tn-focus="1"] .tn-a11y :focus-visible { outline: 4px solid var(--tn-focus) !important; outline-offset: 3px !important; box-shadow: 0 0 0 8px var(--tn-bg) !important; border-radius: 6px; }
html[data-tn-big="1"] .tn-a11y-choices--row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.5rem), 1fr)) !important; }
.tn-a11y-choice { min-width: 0; }
