/* Accessibility layer v17 — WCAG 2.2-oriented enhancements */
:root{
  --a11y-focus:#ffbf47;
  --a11y-focus-shadow:0 0 0 3px #fff,0 0 0 6px var(--a11y-focus);
  --a11y-link:#004f9e;
  --a11y-danger:#9f1239;
  --a11y-success:#166534;
  --a11y-warning:#854d0e;
}
html{scroll-padding-top:7rem}
body{font-size:16px;line-height:1.65}
main:focus{outline:none}
.sr-only,.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
.sr-only-focusable:focus{position:fixed!important;z-index:100000!important;top:8px!important;left:8px!important;width:auto!important;height:auto!important;padding:12px 16px!important;margin:0!important;overflow:visible!important;clip:auto!important;white-space:normal!important;background:#fff!important;color:#111!important;border:3px solid #111!important;border-radius:8px!important}
.skip-links{position:relative;z-index:100000}
.skip-link{position:fixed;top:-120px;left:12px;z-index:100001;background:#111;color:#fff!important;padding:12px 18px;border-radius:0 0 10px 10px;font-weight:800;text-decoration:none;transition:top .15s ease}
.skip-link:focus{top:0}
:where(a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])):focus-visible{outline:3px solid var(--a11y-focus)!important;outline-offset:3px!important;box-shadow:var(--a11y-focus-shadow)!important}
:where(button,.btn,input,select,textarea){min-height:44px}
:where(a.btn,button,.nav-toggle,.admin-menu-toggle,.role-menu-toggle,.main-nav a,.quick-list a,.quick-grid a){min-width:44px;min-height:44px}
a{text-decoration-thickness:.1em;text-underline-offset:.2em}
body.a11y-underline-links a:not(.btn):not(.brand):not(.badge){text-decoration:underline!important}
body.a11y-strong-focus :where(a,button,input,select,textarea,[tabindex]):focus-visible{outline-width:5px!important;outline-offset:4px!important}
body.a11y-readable-font{font-family:Tahoma,"Noto Sans Thai","Leelawadee UI",sans-serif!important;letter-spacing:.015em;word-spacing:.04em}
body.a11y-reading-guide::after{content:"";position:fixed;z-index:99990;left:0;right:0;top:var(--reading-guide-y,-100px);height:3px;background:#ffbf47;box-shadow:0 0 0 2px #111;pointer-events:none}
.a11y-live-region{position:fixed;left:-9999px;top:auto;width:1px;height:1px;overflow:hidden}
.a11y-search{display:flex;align-items:center;gap:6px;min-width:min(320px,40vw)}
.a11y-search label{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important}
.a11y-search input{width:100%;min-width:160px;min-height:42px;border:2px solid rgba(15,23,42,.2);border-radius:999px;padding:8px 44px 8px 14px;background:#fff;color:#111}
.a11y-search button{margin-left:-48px;width:42px;height:42px;border:0;background:transparent;color:#111;border-radius:999px;font-size:1.1rem}
.topbar-inner{gap:12px}.topbar-links{flex-wrap:wrap}
.accessibility-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;margin:20px 0}
.accessibility-card{padding:20px;border:2px solid #dbeafe;border-radius:16px;background:#fff}
.accessibility-card h2,.accessibility-card h3{margin-top:0}
.keyboard-key{display:inline-block;min-width:2em;padding:.15em .45em;border:2px solid #475569;border-bottom-width:4px;border-radius:6px;background:#f8fafc;color:#111;font-family:monospace;text-align:center}
.a11y-checklist li{margin:.65em 0}
.a11y-checklist li::marker{font-weight:800}
.status-badge,.badge,.alert{border:1px solid currentColor}
.status-success::before,.alert.success::before{content:"✓ ";font-weight:900}
.status-danger::before,.alert.error::before{content:"! ";font-weight:900}
.status-warning::before{content:"⚠ ";font-weight:900}
.status-info::before{content:"● ";font-weight:900}
[aria-current="page"],.main-nav a.active,.admin-sidebar a.active{font-weight:900;text-decoration:underline;text-decoration-thickness:3px;text-underline-offset:5px}
img{max-width:100%;height:auto}
img[alt=""]{pointer-events:none}
figure img{display:block}
.video-caption-note,.transcript-box{margin-top:14px;padding:16px;border-left:5px solid var(--blue);background:#f8fafc;border-radius:8px}
.transcript-box summary{cursor:pointer;font-weight:800;min-height:44px;display:flex;align-items:center}
.slider-controls-accessible{position:absolute;right:16px;bottom:16px;z-index:5;display:flex;gap:8px}
.slider-pause{background:#fff;color:#111;border:2px solid #111;border-radius:999px;padding:8px 14px;font-weight:800}
.home-slider[data-paused="true"] .slider-pause::before{content:"▶ "}.home-slider[data-paused="false"] .slider-pause::before{content:"⏸ "}
.display-tools-panel{max-height:min(80vh,680px);overflow:auto}
.display-tools-panel .tool-section{border-top:1px solid #cbd5e1;padding-top:10px;margin-top:10px}
.display-tools-panel button[aria-pressed="true"]{outline:3px solid #111;background:#fde68a;color:#111}
.table-wrap:focus-visible,.school-calendar-wrap:focus-visible{outline:4px solid var(--a11y-focus);outline-offset:3px}
.a11y-table-hint{display:block;margin:.25rem 0 .75rem;color:#334155;font-size:.925rem}
.required-hint{font-size:.925rem;color:#475569}
[aria-invalid="true"]{border-color:#b91c1c!important;border-width:3px!important}
.form-error{color:#991b1b;font-weight:700;margin-top:4px}

/* High contrast that does not rely on theme colors */
body.high-contrast{--blue:#003366;--blue2:#6b004f;--gold:#ffd400;--bg:#fff;background:#fff!important;color:#000!important}
body.high-contrast :where(.card,.content-box,.admin-card,.student-panel,.parent-panel,.teacher-panel,.executive-panel,.site-header,.site-footer,.topbar){background:#fff!important;color:#000!important;border-color:#000!important;background-image:none!important}
body.high-contrast :where(a){color:#003a8c!important}
body.high-contrast :where(.btn,button,.badge,.status-badge){border:2px solid #000!important;box-shadow:none!important}
body.high-contrast :where(.btn-primary,.btn-gold,.active,[aria-current="page"]){background:#000!important;color:#fff!important}
body.high-contrast input,body.high-contrast select,body.high-contrast textarea{background:#fff!important;color:#000!important;border:2px solid #000!important}
body.high-contrast .page-hero,body.high-contrast .hero,body.high-contrast .slide{background:#111!important;color:#fff!important;background-image:none!important}

/* Reduce motion on request and by operating-system preference */
body.a11y-reduce-motion *,body.a11y-reduce-motion *::before,body.a11y-reduce-motion *::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
body.a11y-reduce-motion .home-slider .slide{transition:none!important}
@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
  *,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
}

@media (max-width:980px){
 .a11y-search{order:20;width:100%;min-width:0;margin-top:8px}.a11y-search input{min-width:0}
 .topbar-inner>span{width:100%}
}
@media (max-width:640px){
 body{font-size:16px}.a11y-search{display:flex}.display-tools-panel{font-size:1rem}
 .skip-link{left:4px;right:4px;text-align:center}
}
@media print{
 .skip-links,.display-tools,.a11y-search,.slider-controls-accessible{display:none!important}
}

/* Color-safe interactive defaults */
.btn-primary{background:#1d4ed8!important;color:#fff!important;border-color:#1e3a8a!important}
.btn-primary:hover{background:#1e40af!important}
.btn-danger,.link-danger{color:#fff!important;background:#b91c1c!important;border-color:#7f1d1d!important}
.btn-gold{background:#facc15!important;color:#111827!important;border-color:#854d0e!important}
.btn-outline{background:#fff!important;color:#1e3a8a!important;border:2px solid #1e3a8a!important}
.badge{background:#dbeafe;color:#1e3a8a}
.status-success{background:#dcfce7!important;color:#14532d!important}.status-warning{background:#fef3c7!important;color:#713f12!important}.status-danger{background:#fee2e2!important;color:#7f1d1d!important}.status-info{background:#dbeafe!important;color:#1e3a8a!important}
.alert.success{background:#dcfce7!important;color:#14532d!important}.alert.error{background:#fee2e2!important;color:#7f1d1d!important}
