/* ==========================================================================
   Anchor Accessibility Widget — Frontend Styles
   ========================================================================== */

/* --- Widget container --- */
.anchor-a11y-widget {
    --aa-color: #0073aa;
    --aa-accent: #005177;
    --aa-size: 56px;
    --aa-radius: 12px;
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    direction: ltr;
}

.anchor-a11y-bottom-right {
    bottom: 20px;
    right: 20px;
}

.anchor-a11y-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* --- Toggle button --- */
.anchor-a11y-toggle {
    width: var(--aa-size);
    height: var(--aa-size);
    border-radius: 50%;
    background: var(--aa-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 2;
}

.anchor-a11y-toggle:hover,
.anchor-a11y-toggle:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.anchor-a11y-toggle:focus-visible {
    outline: 3px solid var(--aa-accent);
    outline-offset: 3px;
}

.anchor-a11y-toggle svg {
    pointer-events: none;
}

/* --- Panel --- */
.anchor-a11y-panel {
    position: absolute;
    bottom: calc(var(--aa-size) + 12px);
    width: 300px;
    max-height: 70vh;
    background: #fff;
    border-radius: var(--aa-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.anchor-a11y-panel[hidden] {
    display: none;
}

.anchor-a11y-bottom-right .anchor-a11y-panel {
    right: 0;
}

.anchor-a11y-bottom-left .anchor-a11y-panel {
    left: 0;
}

/* Header */
.anchor-a11y-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--aa-color);
    color: #fff;
    font-size: 16px;
}

.anchor-a11y-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.85;
}

.anchor-a11y-close:hover,
.anchor-a11y-close:focus-visible {
    opacity: 1;
}

/* Body */
.anchor-a11y-body {
    padding: 10px 16px;
    overflow-y: auto;
    flex: 1;
}

/* Feature items */
.anchor-a11y-item {
    margin-bottom: 6px;
}

.anchor-a11y-feature {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: 2px solid #e2e2e2;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.anchor-a11y-feature:hover {
    border-color: var(--aa-color);
    background: #f0f7fc;
}

.anchor-a11y-feature:focus-visible {
    outline: 3px solid var(--aa-accent);
    outline-offset: 1px;
}

.anchor-a11y-feature[aria-pressed="true"] {
    background: var(--aa-color);
    border-color: var(--aa-color);
    color: #fff;
}

/* Font size button group */
.anchor-a11y-font-size {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.anchor-a11y-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.anchor-a11y-btn-group {
    display: flex;
    gap: 4px;
}

.anchor-a11y-btn-group button {
    padding: 6px 12px;
    border: 2px solid #e2e2e2;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    transition: background 0.15s, border-color 0.15s;
}

.anchor-a11y-btn-group button:hover {
    border-color: var(--aa-color);
    background: #f0f7fc;
}

.anchor-a11y-btn-group button:focus-visible {
    outline: 3px solid var(--aa-accent);
    outline-offset: 1px;
}

/* Footer */
.anchor-a11y-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid #eee;
    gap: 10px;
}

.anchor-a11y-reset {
    padding: 6px 14px;
    border: 2px solid #e2e2e2;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    transition: background 0.15s, border-color 0.15s;
}

.anchor-a11y-reset:hover {
    border-color: #c00;
    color: #c00;
    background: #fff5f5;
}

.anchor-a11y-statement {
    font-size: 12px;
    color: var(--aa-color);
    text-decoration: underline;
    white-space: nowrap;
}

/* ==========================================================================
   Body-level classes applied by the widget JS
   ========================================================================== */

/* High contrast */
.aa-contrast {
    filter: contrast(1.5) !important;
}

/* Grayscale */
.aa-grayscale {
    filter: grayscale(1) !important;
}

/* Contrast + grayscale combined */
.aa-contrast.aa-grayscale {
    filter: contrast(1.5) grayscale(1) !important;
}

/* Underline links */
.aa-underline a {
    text-decoration: underline !important;
}

/* Readable font */
.aa-readable,
.aa-readable * {
    font-family: "OpenDyslexic", "Comic Sans MS", "Arial", sans-serif !important;
    letter-spacing: 0.05em;
}

/* Text spacing */
.aa-spacing,
.aa-spacing * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
    line-height: 1.8 !important;
}

/* Hide images */
.aa-hide-images img,
.aa-hide-images svg,
.aa-hide-images [role="img"],
.aa-hide-images picture {
    visibility: hidden !important;
}

/* Big cursor */
.aa-big-cursor,
.aa-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M4 4l14 32 5-14 14-5z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Pause animations */
.aa-pause-anim,
.aa-pause-anim * {
    animation-play-state: paused !important;
    transition: none !important;
}

/* Don't freeze the widget itself */
.aa-pause-anim .anchor-a11y-widget,
.aa-pause-anim .anchor-a11y-widget * {
    animation-play-state: running !important;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Keyboard focus highlight */
.aa-highlight *:focus-visible {
    outline: 3px solid var(--aa-accent, #005177) !important;
    outline-offset: 3px !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
    .anchor-a11y-panel {
        width: calc(100vw - 40px);
        max-height: 60vh;
    }
}
