/* ==========================================================
   Accessibility Suite Austria – Public Styles
   WCAG 2.1 AA / WACA konform
   ========================================================== */

/* ---- Skip Links ---- */
.asa-skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 999999;
    padding: .5rem 1rem;
    background: #1a56db;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    transition: top .15s;
}
.asa-skip-link:focus {
    top: 0;
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

/* ---- Screen Reader Only ---- */
.asa-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ---- Widget Container ---- */
:root {
    --asa-primary: #1a56db;
    --asa-primary-dark: #1341a3;
    --asa-bg: #ffffff;
    --asa-surface: #f8fafc;
    --asa-border: #e2e8f0;
    --asa-text: #1e293b;
    --asa-text-muted: #64748b;
    --asa-radius: 12px;
    --asa-shadow: 0 8px 32px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
    --asa-font-scale: 1;
    --asa-line-height-scale: 1;
}

#asa-widget {
    position: fixed;
    z-index: 99998;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.asa-pos-bottom-right { bottom: 1.5rem; right: 1.5rem; }
.asa-pos-bottom-left  { bottom: 1.5rem; left: 1.5rem; }
.asa-pos-top-right    { top: 5rem;      right: 1.5rem; }
.asa-pos-top-left     { top: 5rem;      left: 1.5rem; }

/* ---- Toggle Button ---- */
.asa-toggle-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1rem;
    background: var(--asa-primary);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(26,86,219,.35);
    transition: background .2s, transform .15s, box-shadow .2s;
}
.asa-toggle-btn:hover  { background: var(--asa-primary-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,86,219,.4); }
.asa-toggle-btn:focus-visible { outline: 3px solid #f59e0b; outline-offset: 3px; }
.asa-toggle-btn svg    { flex-shrink: 0; }
.asa-toggle-label      { white-space: nowrap; }

/* ---- Panel ---- */
.asa-panel {
    position: absolute;
    bottom: calc(100% + .75rem);
    right: 0;
    width: 340px;
    max-height: 80vh;
    background: var(--asa-bg);
    border: 1px solid var(--asa-border);
    border-radius: var(--asa-radius);
    box-shadow: var(--asa-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: asa-slide-in .2s ease;
}
.asa-pos-bottom-left .asa-panel { right: auto; left: 0; }
.asa-pos-top-right   .asa-panel { bottom: auto; top: calc(100% + .75rem); }
.asa-pos-top-left    .asa-panel { bottom: auto; top: calc(100% + .75rem); right: auto; left: 0; }

/* Ensure panel shows regardless of theme [hidden] overrides */
#asa-panel[hidden] { display: none !important; }
#asa-panel:not([hidden]) { display: flex !important; }

@keyframes asa-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.asa-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--asa-primary);
    color: #fff;
    flex-shrink: 0;
}
.asa-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}
.asa-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.85);
    cursor: pointer;
    padding: .25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color .15s;
}
.asa-close-btn:hover         { color: #fff; }
.asa-close-btn:focus-visible  { outline: 2px solid #f59e0b; outline-offset: 2px; }

.asa-panel-body {
    overflow-y: auto;
    padding: .75rem 0;
    flex: 1;
    overscroll-behavior: contain;
}

/* ---- Sections ---- */
.asa-section { padding: .75rem 1.25rem; border-bottom: 1px solid var(--asa-border); }
.asa-section:last-child { border-bottom: none; }

.asa-section-title {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .75rem;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--asa-text-muted);
}
.asa-controls { display: flex; flex-direction: column; gap: .6rem; }

/* ---- Control Group ---- */
.asa-control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.asa-control-group.asa-control-col { flex-direction: column; align-items: flex-start; }
.asa-control-label {
    font-size: .875rem;
    color: var(--asa-text);
    flex: 1;
    line-height: 1.3;
}

/* ---- Toggle Switch ---- */
.asa-toggle-ctrl {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.asa-toggle-ctrl:focus-visible .asa-switch-track { outline: 3px solid #f59e0b; outline-offset: 2px; }
.asa-switch-track {
    display: flex;
    align-items: center;
    width: 44px;
    height: 24px;
    background: #cbd5e1;
    border-radius: 50px;
    padding: 2px;
    transition: background .2s;
    position: relative;
}
.asa-switch-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: transform .2s;
}
.asa-toggle-ctrl[aria-checked="true"] .asa-switch-track  { background: var(--asa-primary); }
.asa-toggle-ctrl[aria-checked="true"] .asa-switch-thumb  { transform: translateX(20px); }
.asa-toggle-ctrl.active[aria-checked="true"] .asa-switch-track { background: var(--asa-primary); }

/* ---- Stepper ---- */
.asa-stepper {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.asa-step-btn {
    width: 28px;
    height: 28px;
    background: var(--asa-surface);
    border: 1px solid var(--asa-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--asa-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
    line-height: 1;
}
.asa-step-btn:hover         { background: #e2e8f0; border-color: #94a3b8; }
.asa-step-btn:focus-visible  { outline: 2px solid var(--asa-primary); outline-offset: 2px; }
.asa-step-value {
    min-width: 56px;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--asa-text);
}

/* ---- Button Group (Filters/Cursor) ---- */
.asa-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    width: 100%;
}
.asa-filter-btn,
.asa-cursor-btn {
    padding: .3rem .6rem;
    background: var(--asa-surface);
    border: 1px solid var(--asa-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: .75rem;
    color: var(--asa-text);
    transition: background .15s, border-color .15s, color .15s;
}
.asa-filter-btn:hover,
.asa-cursor-btn:hover { background: #e2e8f0; border-color: #94a3b8; }
.asa-filter-btn:focus-visible,
.asa-cursor-btn:focus-visible { outline: 2px solid var(--asa-primary); outline-offset: 2px; }
.asa-filter-btn.active,
.asa-cursor-btn.active {
    background: var(--asa-primary);
    border-color: var(--asa-primary);
    color: #fff;
}

/* ---- TTS Bar ---- */
.asa-tts-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
    background: var(--asa-surface);
    border-radius: 8px;
    border: 1px solid var(--asa-border);
}
.asa-tts-btn {
    width: 32px;
    height: 32px;
    background: var(--asa-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    transition: background .15s;
}
.asa-tts-btn:hover         { background: var(--asa-primary-dark); }
.asa-tts-btn:focus-visible  { outline: 2px solid #f59e0b; outline-offset: 2px; }
.asa-tts-hint { font-size: .7rem; color: var(--asa-text-muted); flex: 1; }

/* ---- Panel Footer ---- */
.asa-panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--asa-border);
    background: var(--asa-surface);
    flex-shrink: 0;
}
.asa-reset-btn {
    background: none;
    border: 1px solid var(--asa-border);
    border-radius: 6px;
    padding: .35rem .7rem;
    font-size: .8rem;
    color: var(--asa-text-muted);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.asa-reset-btn:hover         { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.asa-reset-btn:focus-visible  { outline: 2px solid var(--asa-primary); outline-offset: 2px; }
.asa-statement-link {
    font-size: .75rem;
    color: var(--asa-primary);
    text-decoration: underline;
}
.asa-statement-link:focus-visible { outline: 2px solid var(--asa-primary); outline-offset: 2px; }

/* ---- Reading Guide ---- */
.asa-reading-guide {
    position: fixed;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(26,86,219,.4);
    pointer-events: none;
    z-index: 99997;
    box-shadow: 0 0 0 9999px rgba(26,86,219,.04);
}

/* ==========================================================
   ACTIVE STATES – Applied to <html> or <body>
   ========================================================== */

/* High Contrast */
html.asa-contrast * {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
html.asa-contrast a         { color: #ff0 !important; }
html.asa-contrast img       { filter: grayscale(100%) contrast(200%) !important; }
html.asa-contrast button    { background: #000 !important; color: #fff !important; border: 2px solid #fff !important; }

/* Color Filters */
html.asa-filter-protanopia  { filter: url('#asa-protanopia'); }
html.asa-filter-deuteranopia { filter: url('#asa-deuteranopia'); }
html.asa-filter-tritanopia  { filter: url('#asa-tritanopia'); }
html.asa-filter-grayscale   { filter: grayscale(100%); }

/* Font Scale */
html.asa-font-scaled * { font-size: calc(1em * var(--asa-font-scale)) !important; }

/* Line Height */
html.asa-lh-scaled p,
html.asa-lh-scaled li,
html.asa-lh-scaled td { line-height: calc(1.6 * var(--asa-line-height-scale)) !important; }

/* Cursor Size */
html.asa-cursor-large  * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M8,2L8,26L14,20L18,30L21,29L17,19L24,19Z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 8 2, auto !important; }
html.asa-cursor-xlarge * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M10,3L10,38L20,28L26,44L30,42L24,26L36,26Z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 10 3, auto !important; }

/* Focus Indicators – Enhanced */
html.asa-focus-enhanced *:focus,
html.asa-focus-enhanced *:focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(245,158,11,.25) !important;
}

/* Touch Optimization */
html.asa-touch a,
html.asa-touch button,
html.asa-touch input,
html.asa-touch select,
html.asa-touch textarea { min-height: 44px !important; min-width: 44px !important; }

/* Distraction Free */
html.asa-distraction-free aside,
html.asa-distraction-free .widget-area,
html.asa-distraction-free .sidebar,
html.asa-distraction-free .advertisement,
html.asa-distraction-free [class*="ad-"],
html.asa-distraction-free [id*="ad-"],
html.asa-distraction-free .social-share,
html.asa-distraction-free .popup { display: none !important; }

/* Mute Sounds */
html.asa-muted video,
html.asa-muted audio { volume: 0 !important; }

/* ---- SVG Color Filters (hidden) ---- */
.asa-svg-filters { display: none; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .asa-panel { width: calc(100vw - 2rem); right: 0; left: 0; margin: 0 auto; }
    .asa-pos-bottom-left .asa-panel { left: 0; right: 0; }
}
