/* WCAG Widget — Frontend panel & trigger */

.wcag-trigger,
.wcag-panel,
.wcag-reading-line,
.wcag-reading-mask-top,
.wcag-reading-mask-bottom {
    box-sizing: border-box;
}

.wcag-trigger *,
.wcag-panel *,
.wcag-panel *::before,
.wcag-panel *::after {
    box-sizing: border-box;
}

/* ====== Trigger Button ====== */
.wcag-trigger {
    position: fixed;
    z-index: 99999;
    width: var(--wcag-trigger-size, 56px);
    height: var(--wcag-trigger-size, 56px);
    background: var(--wcag-brand, #40a639);
    color: #fff;
    border: none;
    border-radius: var(--wcag-trigger-radius, 50%);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.wcag-trigger:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.wcag-trigger:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px var(--wcag-brand, #40a639);
}

.wcag-trigger svg {
    width: 60%;
    height: 60%;
    fill: currentColor;
}

/* ====== Panel ====== */
.wcag-panel[hidden] {
    display: none !important;
}

.wcag-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    color: #1a1a1a;
    z-index: 100000;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.22);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
}

.wcag-panel.wcag-anchor-right {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.22);
}

.wcag-panel.is-open {
    transform: translateX(0);
}

.wcag-panel-inner {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 80px;
    scrollbar-width: thin;
}

.wcag-panel-inner::-webkit-scrollbar {
    width: 8px;
}
.wcag-panel-inner::-webkit-scrollbar-thumb {
    background: #c3c4c7;
    border-radius: 4px;
}

/* Header */
.wcag-panel-header {
    position: sticky;
    top: 0;
    background: var(--wcag-brand, #40a639);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
}

.wcag-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
}

.wcag-panel-close {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}

.wcag-panel-close:hover { background: rgba(255, 255, 255, 0.28); }
.wcag-panel-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Sections */
.wcag-section {
    padding: 16px 20px;
    border-bottom: 1px solid #efefef;
}

.wcag-section-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #50575e;
}

/* Grid of feature buttons */
.wcag-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.wcag-feature {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 14px 10px;
    background: #f6f7f8;
    border: 2px solid transparent;
    border-radius: 10px;
    color: #1a1a1a;
    cursor: pointer;
    font: inherit;
    min-height: 74px;
    transition: background 0.15s, border-color 0.15s;
}

.wcag-feature:hover {
    background: #eef1f3;
}

.wcag-feature:focus-visible {
    outline: 2px solid var(--wcag-brand, #40a639);
    outline-offset: 2px;
}

.wcag-feature[aria-pressed="true"],
.wcag-feature.is-active {
    background: var(--wcag-brand, #40a639);
    color: #fff;
    border-color: var(--wcag-brand, #40a639);
}

.wcag-feature-label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}

.wcag-feature-desc {
    font-size: 11px;
    opacity: 0.75;
    line-height: 1.3;
}

/* Stepped controls (font size, line height) span full row */
.wcag-feature-stepped {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px;
    background: #f6f7f8;
    border-radius: 10px;
    cursor: default;
}

.wcag-feature-stepped .wcag-feature-label {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
}

.wcag-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wcag-step-up,
.wcag-step-down {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--wcag-brand, #40a639);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wcag-step-up:hover,
.wcag-step-down:hover { filter: brightness(1.1); }

.wcag-step-up:focus-visible,
.wcag-step-down:focus-visible {
    outline: 2px solid var(--wcag-brand);
    outline-offset: 2px;
}

.wcag-step-value {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #1a1a1a;
}

.wcag-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.wcag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    transition: background 0.15s;
}

.wcag-feature-stepped[data-level="1"] .wcag-dot:nth-child(1),
.wcag-feature-stepped[data-level="2"] .wcag-dot:nth-child(-n+2),
.wcag-feature-stepped[data-level="3"] .wcag-dot:nth-child(-n+3) {
    background: var(--wcag-brand, #40a639);
}

/* Reset */
.wcag-reset {
    padding: 16px 20px;
    text-align: center;
}

.wcag-reset-btn {
    background: transparent;
    color: #b91c1c;
    border: 2px solid #b91c1c;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

.wcag-reset-btn:hover {
    background: #b91c1c;
    color: #fff;
}

.wcag-reset-btn:focus-visible {
    outline: 2px solid #b91c1c;
    outline-offset: 2px;
}

/* Panel footer */
.wcag-panel-footer {
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid #efefef;
}

.wcag-badge {
    font-size: 11px;
    color: #50575e;
}

/* Reading aids (hidden by default, shown via JS classes) */
.wcag-reading-line {
    position: fixed;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--wcag-brand, #40a639);
    opacity: 0.85;
    pointer-events: none;
    z-index: 99998;
}

.wcag-reading-line[hidden] { display: none !important; }

.wcag-reading-mask-top,
.wcag-reading-mask-bottom {
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.75);
    pointer-events: none;
    z-index: 99998;
}

.wcag-reading-mask-top[hidden],
.wcag-reading-mask-bottom[hidden] { display: none !important; }

.wcag-reading-mask-top { top: 0; }
.wcag-reading-mask-bottom { bottom: 0; }

/* Keyboard-nav focus indicator (JS-applied class on body) */
html.wcag-keyboard-nav *:focus-visible {
    outline: 4px solid var(--wcag-brand, #40a639) !important;
    outline-offset: 3px !important;
}

/* Responsive: panel becomes wider on desktop */
@media (min-width: 768px) {
    .wcag-panel { width: 400px; }
}

@media (max-width: 479px) {
    .wcag-panel { width: 100vw; }
    .wcag-grid { grid-template-columns: 1fr 1fr; }
    .wcag-trigger {
        width: 48px !important;
        height: 48px !important;
    }
}

/* TTS unavailable notice */
.wcag-tts-notice {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 100002;
    max-width: 90vw;
    width: 420px;
    background: #1f2937;
    color: #fff;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    animation: wcag-notice-in 0.2s ease-out;
}
@keyframes wcag-notice-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Visually hidden helper */
.wcag-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;
}
