/* ==========================================================================
   Cyber Falak v3 — accessibility panel and tools (js/access.js)
   Colours come from the shared variables, so the panel follows the space
   theme, Simple dark view and High contrast automatically.
   ========================================================================== */

/* ---------- The panel: a drawer from the right ---------- */
.dialog.ax-panel {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; width: min(440px, 100vw); max-width: none; height: 100vh; height: 100dvh; max-height: none;
  border: 0; border-radius: 24px 0 0 24px; background: var(--surface); color: var(--text); box-shadow: -30px 0 80px rgba(2, 6, 25, .5);
}
.dialog.ax-panel[open] { animation: ax-in .45s cubic-bezier(.2, .7, .1, 1); }
@keyframes ax-in { from { transform: translateX(48px); opacity: 0; } }
.dialog.ax-panel::backdrop { background: rgba(2, 6, 25, .45); backdrop-filter: blur(3px); }
.ax-inner { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 28px; }
.ax-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 20px 0 12px; background: var(--surface); }
.ax-kicker { margin: 0; font: 600 .75rem/1 "DM Sans", var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--blue-700); }
.ax-head h2 { margin: .3rem 0 0; font: 500 1.75rem/1.1 "DM Sans", var(--font-head); letter-spacing: -.02em; color: var(--text); }
.dialog .ax-close { position: static; flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--text); font-size: 1.5rem; line-height: 1; }
.dialog .ax-close:hover { background: var(--bg-tint); }
.ax-panel .a11y-intro { margin: 0 0 1.25rem; color: var(--text-muted); font-size: .9375rem; }

.ax-sec { margin-bottom: 14px; padding: 18px 16px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-tint); }
.ax-h { display: flex; flex-direction: column; gap: 2px; margin: 0 0 12px; font: 600 1.0625rem/1.3 "DM Sans", var(--font-head); color: var(--text); }
.ax-h span { font: 400 .8125rem/1.4 var(--font-body); color: var(--text-muted); }

/* Profiles */
.ax-profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ax-prof {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 12px 13px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .25s ease, background-color .25s ease, transform .25s ease;
}
.ax-prof:hover { transform: translateY(-2px); border-color: var(--blue-700); }
.ax-prof svg { width: 26px; height: 26px; margin-bottom: 6px; fill: none; stroke: var(--blue-700); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ax-prof b { font: 600 .9375rem/1.2 "DM Sans", var(--font-body); }
.ax-prof small { font-size: .75rem; line-height: 1.35; color: var(--text-muted); }
.ax-prof[aria-pressed="true"] { border-color: #3ccf8e; background: rgba(60, 207, 142, .12); box-shadow: inset 0 0 0 1px #3ccf8e; }
.ax-prof[aria-pressed="true"]::after {
  content: ""; position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; background: #3ccf8e
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%2304122e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat;
}

/* Listen */
.ax-panel .tour-btns { display: grid; gap: 8px; }
.ax-panel .tour-btn { border-radius: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.ax-panel .tour-btn-main { background: linear-gradient(140deg, #1f44c4, #2f5bea); border-color: transparent; color: #fff; }
.ax-row2 { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.ax-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .6rem 1.1rem; border-radius: 999px;
  border: 1px solid transparent; background: var(--text); color: var(--surface); font: 600 .9375rem/1 "DM Sans", var(--font-body); cursor: pointer;
}
.ax-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ax-btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.ax-btn-ghost:hover { background: var(--bg-tint); }
.ax-voice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; margin-top: 10px; }
.ax-voice .a11y-field { display: flex; flex-direction: column; gap: 4px; font-size: .8125rem; color: var(--text-muted); }
.ax-voice select { width: 100%; min-height: 44px; padding: 0 .75rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 .875rem/1 var(--font-body); }
.ax-voice #voice-test { grid-column: 1 / -1; }
.ax-note { margin: 10px 0 6px; font-size: .8125rem; color: var(--text-muted); }
.ax-note b { color: #3ccf8e; }
.ax-panel .transcript { margin-top: 6px; }

/* Switch rows */
.ax-switches { list-style: none; display: grid; gap: 2px; padding: 0; margin: 8px 0 0; }
.ax-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 54px; padding: 8px 8px;
  border: 0; border-radius: 12px; background: none; color: var(--text); text-align: left; cursor: pointer;
}
.ax-switch:hover { background: var(--bg-tint); }
.ax-switch b { display: block; font: 600 .9375rem/1.3 "DM Sans", var(--font-body); }
.ax-switch small { display: block; font-size: .8125rem; line-height: 1.35; color: var(--text-muted); }
.ax-switch i { position: relative; flex: none; width: 46px; height: 28px; border-radius: 999px; background: rgba(157, 182, 255, .25); transition: background-color .3s ease; }
.ax-switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .3s cubic-bezier(.2, .7, .1, 1); }
.ax-switch[aria-pressed="true"] i { background: #3ccf8e; }
.ax-switch[aria-pressed="true"] i::after { transform: translateX(18px); }
.ax-size { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 6px; padding: 4px 8px; }
.ax-size .a11y-label { margin: 0; font: 600 .9375rem/1.3 "DM Sans", var(--font-body); color: var(--text); }
.ax-size .a11y-label output { margin-left: .4rem; color: var(--blue-700); }
.ax-size .size-btns button { min-width: 46px; min-height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; }

/* Colour chips */
.ax-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ax-chip {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; padding: .45rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 .875rem/1 var(--font-body); cursor: pointer;
}
.ax-chip[aria-checked="true"] { border-color: #3ccf8e; box-shadow: inset 0 0 0 1px #3ccf8e; }
.sw { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.sw-none { background: conic-gradient(#2f5bea, #3ccf8e, #ff8fb1, #2f5bea); }
.sw-low { background: conic-gradient(#7d8fbd, #8fb3a4, #bfa3ad, #7d8fbd); }
.sw-high { background: conic-gradient(#1d4dff, #00e08a, #ff3d7f, #1d4dff); }
.sw-gray { background: conic-gradient(#555, #bbb, #888, #555); }
.sw-warm { background: conic-gradient(#d9a066, #f2c48d, #b9805a, #d9a066); }

/* Keyboard shortcuts */
.ax-keys { margin-top: 8px; padding: 4px 8px; }
.ax-keys summary { cursor: pointer; font: 600 .9375rem/1.3 "DM Sans", var(--font-body); color: var(--text); padding: 6px 0; }
.ax-keys dl { display: grid; gap: 8px; margin: 8px 0 4px; }
.ax-keys dl div { display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; }
.ax-keys dd { margin: 0; color: var(--text-muted); text-align: right; }
kbd { display: inline-block; min-width: 1.6em; padding: .1em .45em; border-radius: 6px; border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface); color: var(--text); font: 600 .75rem/1.5 ui-monospace, Menlo, Consolas, monospace; text-align: center; }

.ax-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 18px; }
.ax-foot a { color: var(--link); font-size: .875rem; }

/* High contrast: plain, bold controls */
.a11y-contrast .ax-prof[aria-pressed="true"], .a11y-contrast .ax-chip[aria-checked="true"] { border: 3px solid #ffeb3b; background: #000; box-shadow: none; }
.a11y-contrast .ax-switch i { background: #000; border: 2px solid #fff; }
.a11y-contrast .ax-switch[aria-pressed="true"] i { background: #ffeb3b; }
.a11y-contrast .ax-switch i::after { background: #fff; box-shadow: none; }
.a11y-contrast .ax-switch[aria-pressed="true"] i::after { background: #000; }
.a11y-contrast .ax-panel .tour-btn-main { background: #000; border: 2px solid #fff; }

/* ---------- Accessibility button: a small planet with a count of active options ---------- */
.a11y-fab { position: fixed; }
.a11y-fab[data-count]:not([data-count=""])::after {
  content: attr(data-count); position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: #3ccf8e; color: #04122e; font: 700 .75rem/22px "DM Sans", var(--font-body); text-align: center; box-shadow: 0 0 0 2px var(--bg, #050b26);
}
html:not(.a11y-contrast):not(.a11y-dark) .a11y-fab {
  background: radial-gradient(circle at 32% 28%, #cfdcff 0 4%, #6f95ff 24%, #2a4fd0 55%, #0b1a5c 100%); color: #fff; border: 0;
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, .45), 0 0 0 6px rgba(157, 182, 255, .14), 0 10px 30px rgba(47, 91, 234, .55);
}

/* ---------- Point & listen ---------- */
.a11y-point main :is(h1, h2, h3, h4, p, li, dt, dd, td, th, figcaption, blockquote):hover { outline: 2px dashed rgba(157, 182, 255, .75); outline-offset: 4px; border-radius: 6px; cursor: pointer; }
.a11y-contrast.a11y-point main :is(h1, h2, h3, h4, p, li, dt, dd, td, th, figcaption, blockquote):hover { outline-color: #ffeb3b; }
.ax-bubble {
  position: fixed; z-index: 96; display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .4rem .9rem; border-radius: 999px;
  border: 0; background: #fff; color: #0b1230; font: 600 .875rem/1 "DM Sans", var(--font-body); box-shadow: 0 10px 30px rgba(2, 6, 25, .45); cursor: pointer;
}
.ax-bubble svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ax-bubble[hidden] { display: none; }

/* ---------- Live captions ---------- */
.ax-captions {
  position: fixed; z-index: 81; left: 50%; bottom: 112px; transform: translateX(-50%); width: min(760px, calc(100vw - 32px));
  padding: 14px 20px; border-radius: 18px; background: rgba(4, 10, 34, .9); border: 1px solid rgba(157, 182, 255, .25);
  color: rgba(255, 255, 255, .55); font: 500 1.25rem/1.5 "DM Sans", var(--font-body); text-align: center; box-shadow: 0 20px 50px rgba(2, 6, 25, .5);
}
.ax-captions[hidden] { display: none; }
.ax-captions span { padding: 0 2px; border-radius: 6px; transition: color .15s ease, background-color .15s ease; }
.ax-captions .done { color: #fff; }
.ax-captions .on { color: #04122e; background: #3ccf8e; }
.a11y-contrast .ax-captions { background: #000; border: 2px solid #fff; color: #bbb; }
.a11y-contrast .ax-captions .done { color: #fff; }
.a11y-contrast .ax-captions .on { background: #ffeb3b; color: #000; }
@media (max-width: 640px) { .ax-captions { bottom: 150px; font-size: 1.0625rem; } }

/* ---------- Text magnifier ---------- */
.ax-lens {
  position: fixed; z-index: 97; max-width: min(560px, calc(100vw - 24px)); padding: 14px 18px; border-radius: 16px; pointer-events: none;
  background: #fff; color: #0b1230; border: 3px solid #2f5bea; font: 500 1.625rem/1.35 var(--font-body); box-shadow: 0 20px 50px rgba(2, 6, 25, .5);
}
.ax-lens[hidden] { display: none; }
.a11y-contrast .ax-lens { background: #000; color: #fff; border-color: #ffeb3b; }

/* ---------- Reading mask ---------- */
.ax-mask { position: fixed; left: 0; right: 0; z-index: 60; height: 0; pointer-events: none; background: rgba(2, 6, 20, .66); display: none; }
.a11y-mask .ax-mask { display: block; }
.a11y-mask :is(.player, .a11y-fab, .site-header) { z-index: 61; }
.ax-mask-top { top: 0; }
.ax-mask-bottom { bottom: 0; }

/* ---------- Colour filters ---------- */
html[data-a11y-filter="low"] :is(main, .site-header, .site-footer), html[data-a11y-filter="low"] body::before { filter: saturate(.45); }
html[data-a11y-filter="high"] :is(main, .site-header, .site-footer), html[data-a11y-filter="high"] body::before { filter: saturate(1.6) contrast(1.05); }
html[data-a11y-filter="gray"] :is(main, .site-header, .site-footer), html[data-a11y-filter="gray"] body::before { filter: grayscale(1); }
html[data-a11y-filter="warm"] :is(main, .site-header, .site-footer), html[data-a11y-filter="warm"] body::before { filter: sepia(.4) saturate(.9) brightness(.96); }

/* ---------- Bigger buttons & strong focus ---------- */
.a11y-targets :is(button, .btn, select, input, textarea, summary) { min-height: 52px; }
.a11y-targets :is(.btn, .ax-btn) { padding-inline: 1.5rem; font-size: 1.0625rem; }
.a11y-targets .mega-nav :is(.mega-trigger, .mega-link) { min-height: 52px; font-size: 1.0625rem; }
.a11y-targets main p a, .a11y-targets main li a { display: inline-block; padding-block: .35em; }
.a11y-focus :focus-visible { outline: 4px solid #ffd60a !important; outline-offset: 4px !important; box-shadow: 0 0 0 8px rgba(0, 0, 0, .7) !important; border-radius: 8px; }

@media print { .ax-captions, .ax-lens, .ax-mask, .ax-bubble { display: none !important; } }
