/* ==========================================================================
   Pixel Creative Accessibility - Toolbar CSS
   ========================================================================== */

/* Font OpenDyslexic (Local) */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('../fonts/OpenDyslexic-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --pc-a11y-primary: #1d4ed8;
    --pc-a11y-primary-hover: #1e40af;
    --pc-a11y-bg: #ffffff;
    --pc-a11y-text: #111827;
    --pc-a11y-border: #e5e7eb;
    --pc-a11y-textscale: 1;
}

/* ==========================================================================
   Accessibility Modifiers (Applied to HTML or Body)
   ========================================================================== */

/* Zoom - Applied to body but isolated from the widget */
html.pc-a11y-textscale body {
    zoom: var(--pc-a11y-textscale) !important;
}

/* Evita che il widget venga zoomato insieme al resto */
html.pc-a11y-textscale #pc-a11y-widget {
    zoom: calc(1 / var(--pc-a11y-textscale)) !important;
}

/* Alto Contrasto (Invert filter) */
html.pc-a11y-contrast {
    filter: invert(100%) hue-rotate(180deg) !important;
    background-color: #000 !important;
}
/* Revert images and videos back to normal */
html.pc-a11y-contrast img,
html.pc-a11y-contrast video,
html.pc-a11y-contrast iframe,
html.pc-a11y-contrast #pc-a11y-widget {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* Scala di Grigi */
html.pc-a11y-grayscale {
    filter: grayscale(100%) !important;
}
html.pc-a11y-grayscale #pc-a11y-widget {
    filter: none !important;
}

/* Font Dislessia */
html.pc-a11y-dyslexic body,
html.pc-a11y-dyslexic body * {
    font-family: 'OpenDyslexic', sans-serif !important;
}

/* Evidenzia Link */
html.pc-a11y-links a {
    text-decoration: underline !important;
    text-decoration-color: var(--pc-a11y-primary) !important;
    text-decoration-thickness: 3px !important;
    background-color: rgba(29, 78, 216, 0.1) !important;
    color: var(--pc-a11y-text) !important;
}

/* Focus Visibile */
html.pc-a11y-focus *:focus,
html.pc-a11y-focus *:focus-within {
    outline: 4px solid var(--pc-a11y-primary) !important;
    outline-offset: 2px !important;
}

/* Spaziatura Testo */
html.pc-a11y-spacing body,
html.pc-a11y-spacing body * {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

/* Stop Animazioni */
html.pc-a11y-animations *,
html.pc-a11y-animations *::before,
html.pc-a11y-animations *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Cursore Grande */
html.pc-a11y-cursor,
html.pc-a11y-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="black" stroke="white" stroke-width="2" d="M4 2v20l6-6h10z"/></svg>'), auto !important;
}

/* ==========================================================================
   Widget UI
   ========================================================================== */

.pc-a11y-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.pc-a11y-pos-bottom-right { bottom: 20px; right: 20px; }
.pc-a11y-pos-bottom-left { bottom: 20px; left: 20px; }
.pc-a11y-pos-top-right { top: 20px; right: 20px; }
.pc-a11y-pos-top-left { top: 20px; left: 20px; }

.pc-a11y-pos-bottom-left .pc-a11y-panel,
.pc-a11y-pos-top-left .pc-a11y-panel { right: auto; left: 0; }
.pc-a11y-pos-top-right .pc-a11y-panel,
.pc-a11y-pos-top-left .pc-a11y-panel { bottom: auto; top: 80px; }

/* Screen reader text only */
.pc-a11y-widget .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}

.pc-a11y-toggle {
    background-color: var(--pc-a11y-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, background-color 0.2s;
}

.pc-a11y-toggle:hover, .pc-a11y-toggle:focus {
    background-color: var(--pc-a11y-primary-hover);
    transform: scale(1.05);
}

.pc-a11y-toggle svg {
    width: 32px;
    height: 32px;
}

.pc-a11y-panel {
    box-sizing: border-box !important;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--pc-a11y-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--pc-a11y-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--pc-a11y-text);
}

#pc-a11y-widget,
#pc-a11y-widget *,
#pc-a11y-widget *::before,
#pc-a11y-widget *::after {
    box-sizing: border-box !important;
}

.pc-a11y-panel[hidden] {
    display: none !important;
}

.pc-a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--pc-a11y-border);
    background-color: #f9fafb;
}

.pc-a11y-panel-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.pc-a11y-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.pc-a11y-close:hover, .pc-a11y-close:focus {
    background-color: #e5e7eb;
    color: #111827;
}

.pc-a11y-panel-body {
    padding: 16px !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    max-height: 60vh;
    overflow-y: auto;
    box-sizing: border-box !important;
}

/* Specificità rinforzata e box-sizing espliciti: i temi/page builder (Elementor, ecc.)
   applicano stili globali ai <button> con priorità più alta, che altrimenti rompono
   la larghezza delle celle della grid e fanno traboccare il testo dal pannello. */
#pc-a11y-widget .pc-a11y-btn,
#pc-a11y-widget button.pc-a11y-btn {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    background: #f3f4f6 !important;
    border: 1px solid var(--pc-a11y-border) !important;
    border-radius: 8px !important;
    padding: 12px 6px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    color: var(--pc-a11y-text) !important;
    cursor: pointer !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    gap: 8px !important;
    transition: all 0.2s !important;
}

.pc-a11y-btn:hover, .pc-a11y-btn:focus {
    background: #e5e7eb;
}

.pc-a11y-btn[aria-pressed="true"] {
    background: rgba(29, 78, 216, 0.1);
    border-color: var(--pc-a11y-primary);
    color: var(--pc-a11y-primary);
}

.pc-a11y-btn .pc-a11y-icon {
    font-size: 20px;
    line-height: 1;
}

.pc-a11y-btn.pc-a11y-reset {
    grid-column: span 2;
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
    flex-direction: row;
    justify-content: center;
}

.pc-a11y-btn.pc-a11y-reset:hover, .pc-a11y-btn.pc-a11y-reset:focus {
    background: #fecaca;
}

.pc-a11y-panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--pc-a11y-border);
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    background-color: #f9fafb;
}

.pc-a11y-panel-footer a {
    color: var(--pc-a11y-primary);
    text-decoration: none;
}

.pc-a11y-panel-footer a:hover {
    text-decoration: underline;
}

/* Utility per skip link */
.pc-a11y-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--pc-a11y-primary);
    color: white;
    padding: 8px;
    z-index: 1000000;
    transition: top 0.2s;
}

.pc-a11y-skip-link:focus {
    top: 0;
}
