/* =============================================================
   KSS Accessibility Panel – Sonnensystem-Design
   BFSG 2025 – Barrierefreiheitsstärkungsgesetz
   ============================================================= */

/* ── Custom Properties ────────────────────────────────────── */
:root {
    --kss-a11y-color:        #334155;
    --kss-a11y-color-light:  #475569;
    --kss-a11y-orbit-r:      90px;
    --kss-a11y-sun-w:        58px;
    --kss-a11y-sun-h:        116px;
    --kss-a11y-planet-size:  46px;
    --kss-a11y-z:            9999;
    --kss-a11y-transition:   0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Panel Container ──────────────────────────────────────── */
.kss-a11y-panel {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--kss-a11y-z);
    /* "orbit center" – the virtual center of the half-circle full circle */
    display: flex;
    align-items: center;
}

.kss-a11y-panel--left {
    left: 0;
}

.kss-a11y-panel--right {
    right: 0;
    left: auto;
    /* Mirror entire panel */
    flex-direction: row-reverse;
}

/* ── Toggle Button (die Sonne / der Halbkreis) ────────────── */
.kss-a11y-toggle {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    width: var(--kss-a11y-sun-w);
    height: var(--kss-a11y-sun-h);
    background: var(--kss-a11y-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    transition:
        box-shadow 0.25s ease,
        transform  0.25s ease;
    outline: none;
}

/* Left side: D-shape (right half of circle) */
.kss-a11y-panel--left .kss-a11y-toggle {
    border-radius: 0 calc(var(--kss-a11y-sun-h) / 2) calc(var(--kss-a11y-sun-h) / 2) 0;
    margin-left: -2px; /* flush with viewport edge */
}

/* Right side: mirror D-shape */
.kss-a11y-panel--right .kss-a11y-toggle {
    border-radius: calc(var(--kss-a11y-sun-h) / 2) 0 0 calc(var(--kss-a11y-sun-h) / 2);
    justify-content: flex-start;
    padding-right: 0;
    padding-left: 10px;
    margin-right: -2px;
}

.kss-a11y-toggle:hover,
.kss-a11y-toggle:focus-visible {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.35);
    transform: translateX(4px);
}

.kss-a11y-panel--right .kss-a11y-toggle:hover,
.kss-a11y-panel--right .kss-a11y-toggle:focus-visible {
    transform: translateX(-4px);
}

.kss-a11y-toggle:focus-visible {
    outline: 3px solid white;
    outline-offset: -4px;
}

.kss-a11y-panel.is-open .kss-a11y-toggle {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25),
                4px 0 24px rgba(0, 0, 0, 0.4);
}

/* Icon in toggle */
.kss-a11y-toggle__icon {
    width: 24px;
    height: 24px;
    transition: transform 0.35s ease;
    pointer-events: none;
}

.kss-a11y-panel.is-open .kss-a11y-toggle__icon {
    transform: scale(0.85) rotate(360deg);
}

/* ── Orbit Container ──────────────────────────────────────── */
/*
   Position: absolute center of the virtual full circle.
   For a 58×116px half-circle the full-circle center is at
   (58px from left edge, 58px from top/bottom midpoint).
   We place this div AT that "center" so planets can use
   rotate(A) translateX(r) to fly out.
*/
.kss-a11y-orbit {
    position: absolute;
    /* sits at center of the half-circle */
    top:  50%;
    left: calc(var(--kss-a11y-sun-w) - 2px);
    width: 0;
    height: 0;
    pointer-events: none;
}

.kss-a11y-panel--right .kss-a11y-orbit {
    left: auto;
    right: calc(var(--kss-a11y-sun-w) - 2px);
}

/* ── Planet Buttons ───────────────────────────────────────── */
.kss-a11y-feature {
    --a11y-angle:  0deg;
    --a11y-radius: var(--kss-a11y-orbit-r);

    position: absolute;
    top:  calc(var(--kss-a11y-planet-size) / -2);
    left: calc(var(--kss-a11y-planet-size) / -2);
    width:  var(--kss-a11y-planet-size);
    height: var(--kss-a11y-planet-size);
    border-radius: 50%;
    background: var(--kss-a11y-color);
    border: 3px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;

    /* Start: collapsed at sun center */
    transform:
        rotate(var(--a11y-angle))
        translateX(0)
        rotate(calc(var(--a11y-angle) * -1))
        scale(0);
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
    outline: none;
    transition:
        transform var(--kss-a11y-transition),
        opacity   0.25s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

/* Right panel: mirror angle direction */
.kss-a11y-panel--right .kss-a11y-feature {
    left: auto;
    right: calc(var(--kss-a11y-planet-size) / -2);
    --a11y-angle: calc(var(--a11y-angle-raw) * -1);
}

/* Open: planets fly to orbit positions */
.kss-a11y-panel.is-open .kss-a11y-feature {
    transform:
        rotate(var(--a11y-angle))
        translateX(var(--a11y-radius))
        rotate(calc(var(--a11y-angle) * -1))
        scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Staggered entrance delay per planet */
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(1) { transition-delay: 0.00s; }
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(2) { transition-delay: 0.05s; }
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(3) { transition-delay: 0.10s; }
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(4) { transition-delay: 0.15s; }
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(5) { transition-delay: 0.20s; }
.kss-a11y-panel.is-open .kss-a11y-feature:nth-child(6) { transition-delay: 0.25s; }

/* Hover / Focus */
.kss-a11y-feature:hover,
.kss-a11y-feature:focus-visible {
    background: white;
    color: var(--kss-a11y-color);
    box-shadow: 0 0 0 3px var(--kss-a11y-color),
                0 4px 16px rgba(0, 0, 0, 0.25);
}

.kss-a11y-feature:focus-visible {
    outline: 2px solid var(--kss-a11y-color);
    outline-offset: 3px;
}

/* Active state: feature is ON */
.kss-a11y-feature.is-active {
    background: white;
    color: var(--kss-a11y-color);
    box-shadow: 0 0 0 3px var(--kss-a11y-color),
                0 0 12px rgba(204, 0, 0, 0.4);
}

/* Reset button */
.kss-a11y-feature--reset {
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    color: white;
    font-size: 10px;
}

.kss-a11y-feature--reset:hover {
    background: white;
    color: var(--kss-a11y-color);
}

/* ── Tooltip ──────────────────────────────────────────────── */
.kss-a11y-feature__label {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.3;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.kss-a11y-feature__label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
}

.kss-a11y-feature:hover .kss-a11y-feature__label,
.kss-a11y-feature:focus-visible .kss-a11y-feature__label {
    opacity: 1;
}

/* Feature icon */
.kss-a11y-feature__icon {
    width: 22px;
    height: 22px;
    pointer-events: none;
    flex-shrink: 0;
}

/* ── Font-Size Level badge ────────────────────────────────── */
.kss-a11y-feature[data-feature="fontsize"] .kss-a11y-feature__icon {
    font-size: 13px;
    font-weight: 700;
    font-family: Georgia, serif;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
}

/* ── Reading Guide ────────────────────────────────────────── */
#kss-a11y-reading-guide {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--kss-a11y-color);
    opacity: 0.6;
    pointer-events: none;
    z-index: calc(var(--kss-a11y-z) - 1);
    display: none;
    box-shadow: 0 0 8px var(--kss-a11y-color);
}

html.kss-a11y--reading #kss-a11y-reading-guide {
    display: block;
}

/* ── Accessibility Feature Styles ─────────────────────────── */

/*
   WICHTIG: filter auf body oder html bricht position:fixed für alle
   Kindelemente (neuer containing block). Deshalb wird der Filter auf
   body > *:not(#kss-a11y-panel) angewendet – das Panel ist direktes
   body-Kind (wp_footer) und bleibt so vom Filter unberührt.
*/

/* ── Dark Mode ─────────────────────────────────────────────── */
html.kss-a11y--dark body {
    background-color: #000 !important;
}

html.kss-a11y--dark body > *:not(#kss-a11y-panel) {
    filter: invert(1) hue-rotate(180deg);
}

/* Bilder/Videos/iframes zurück-invertieren – bleiben farbecht */
html.kss-a11y--dark body > *:not(#kss-a11y-panel) img,
html.kss-a11y--dark body > *:not(#kss-a11y-panel) video,
html.kss-a11y--dark body > *:not(#kss-a11y-panel) iframe,
html.kss-a11y--dark body > *:not(#kss-a11y-panel) canvas,
html.kss-a11y--dark body > *:not(#kss-a11y-panel) svg image,
html.kss-a11y--dark body > *:not(#kss-a11y-panel) [style*="background-image"] {
    filter: invert(1) hue-rotate(180deg);
}

/* ── Font Size ─────────────────────────────────────────────── */
html[data-kss-a11y-fontsize="large"] body {
    font-size: 118% !important;
}

html[data-kss-a11y-fontsize="x-large"] body {
    font-size: 136% !important;
}

/* ── High Contrast ─────────────────────────────────────────── */
html.kss-a11y--contrast body > *:not(#kss-a11y-panel) {
    filter: contrast(1.5) saturate(1.2);
}

/* ── Dyslexia Font (lokal, kein externer CDN-Request) ──────── */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('../fonts/OpenDyslexic-Regular.woff') format('woff'),
         url('../fonts/OpenDyslexic-Regular.otf')  format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

html.kss-a11y--dyslexia body,
html.kss-a11y--dyslexia p,
html.kss-a11y--dyslexia h1,
html.kss-a11y--dyslexia h2,
html.kss-a11y--dyslexia h3,
html.kss-a11y--dyslexia h4,
html.kss-a11y--dyslexia h5,
html.kss-a11y--dyslexia h6,
html.kss-a11y--dyslexia li,
html.kss-a11y--dyslexia a {
    font-family: 'OpenDyslexic', 'Comic Sans MS', cursive !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* ── Focus Mode ────────────────────────────────────────────── */
html.kss-a11y--focus *:focus {
    outline: 3px solid var(--kss-a11y-color, #cc0000) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(204, 0, 0, 0.2) !important;
}

html.kss-a11y--focus a:focus,
html.kss-a11y--focus button:focus,
html.kss-a11y--focus [tabindex]:focus {
    outline: 3px solid var(--kss-a11y-color, #cc0000) !important;
    outline-offset: 3px !important;
}

/* ── Reduced Motion Respect ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .kss-a11y-toggle,
    .kss-a11y-feature {
        transition-duration: 0.01ms !important;
    }
}

/* ── Mobile adjustments ────────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --kss-a11y-sun-w:     44px;
        --kss-a11y-sun-h:     88px;
        --kss-a11y-planet-size: 40px;
        --kss-a11y-orbit-r:   78px;
    }
}
