/* Pixel Creative - Accessibilità : toolbar utente + filtri reversibili.
   Tutte le regole sono namespaced (.pc-a11y*) per non collidere col tema. */

:root { --pc-a11y-accent: #172C84; }

/* ---------------------------------------------------------------------------
 * SKIP LINK
 * ------------------------------------------------------------------------- */
.pc-a11y-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100001;
    background: var(--pc-a11y-accent);
    color: #fff;
    padding: 12px 18px;
    border-radius: 0 0 6px 0;
    font: 600 15px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    text-decoration: none;
}
.pc-a11y-skip-link:focus {
    left: 0;
    outline: 3px solid #fff;
    outline-offset: -3px;
}

/* ---------------------------------------------------------------------------
 * FONT OpenDyslexic (caricato solo se i file sono presenti in views/fonts/)
 * ------------------------------------------------------------------------- */
@font-face {
    font-family: "PcOpenDyslexic";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/OpenDyslexic-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "PcOpenDyslexic";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/OpenDyslexic-Bold.woff2") format("woff2");
}

/* ---------------------------------------------------------------------------
 * LAUNCHER (bottone flottante)
 * ------------------------------------------------------------------------- */
.pc-a11y-launcher {
    position: fixed;
    z-index: 100000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--pc-a11y-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.28);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}
.pc-a11y-launcher:hover { transform: scale(1.06); }
.pc-a11y-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.pc-a11y-launcher svg { width: 30px; height: 30px; fill: currentColor; }

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

/* ---------------------------------------------------------------------------
 * PANNELLO
 * ------------------------------------------------------------------------- */
.pc-a11y-panel {
    position: fixed;
    z-index: 100000;
    width: 340px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: #fff;
    color: #1d2327;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.32);
    font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: none;
}
.pc-a11y-panel[data-open="true"] { display: block; }

.pc-a11y-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 18px;
    background: var(--pc-a11y-accent);
    color: #fff;
    border-radius: 12px 12px 0 0;
    position: sticky;
    top: 0;
}
.pc-a11y-panel__head h2 { margin: 0; font-size: 17px; font-weight: 700; color: #fff; }
.pc-a11y-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}
.pc-a11y-close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.pc-a11y-panel__body { padding: 14px; }

/* Gruppo dimensione testo */
.pc-a11y-textsize {
    display: flex; align-items: center; gap: 8px;
    padding: 10px; border: 1px solid #e3e5e8; border-radius: 10px; margin-bottom: 12px;
}
.pc-a11y-textsize span { flex: 1; font-weight: 600; }
.pc-a11y-textsize button {
    width: 38px; height: 38px; border-radius: 8px; border: 1px solid #ccd0d4;
    background: #f6f7f7; font-size: 20px; cursor: pointer; line-height: 1;
}
.pc-a11y-textsize button:focus-visible { outline: 3px solid var(--pc-a11y-accent); outline-offset: 2px; }

/* Griglia toggle */
.pc-a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pc-a11y-toggle {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 8px; border: 1px solid #e3e5e8; border-radius: 10px;
    background: #fff; cursor: pointer; text-align: center; min-height: 84px;
    font-size: 13px; font-weight: 600; color: #1d2327;
}
.pc-a11y-toggle svg { width: 26px; height: 26px; fill: var(--pc-a11y-accent); }
.pc-a11y-toggle:hover { background: #f6f7f7; }
.pc-a11y-toggle:focus-visible { outline: 3px solid var(--pc-a11y-accent); outline-offset: 2px; }
.pc-a11y-toggle[aria-pressed="true"] {
    background: var(--pc-a11y-accent); color: #fff; border-color: var(--pc-a11y-accent);
}
.pc-a11y-toggle[aria-pressed="true"] svg { fill: #fff; }

.pc-a11y-reset {
    width: 100%; margin-top: 12px; padding: 11px; border-radius: 10px;
    border: 1px solid #d63638; background: #fff; color: #d63638; font-weight: 700; cursor: pointer;
}
.pc-a11y-reset:hover { background: #d63638; color: #fff; }
.pc-a11y-reset:focus-visible { outline: 3px solid #d63638; outline-offset: 2px; }

.pc-a11y-disclaimer {
    margin: 12px 0 0; padding-top: 10px; border-top: 1px solid #e3e5e8;
    font-size: 11px; line-height: 1.4; color: #666;
}

/* ---------------------------------------------------------------------------
 * FILTRI APPLICATI AL DOCUMENTO (classi su <html>)
 * Reversibili: rimuovere la classe ripristina tutto.
 * ------------------------------------------------------------------------- */

/* Dimensione testo: gestita via variabile + scala su root */
html.pc-a11y-textscale body {
    zoom: var(--pc-a11y-textscale, 1) !important;
}

/* Alto contrasto */
html.pc-a11y-contrast,
html.pc-a11y-contrast body { background: #000 !important; }
html.pc-a11y-contrast body * {
    background-color: transparent !important;
    color: #fff !important;
    border-color: #fff !important;
}
html.pc-a11y-contrast a,
html.pc-a11y-contrast a * { color: #ffe100 !important; }
html.pc-a11y-contrast img,
html.pc-a11y-contrast video { filter: none !important; }
html.pc-a11y-contrast :is(input,select,textarea,button) {
    background: #000 !important; color: #fff !important; border: 1px solid #fff !important;
}

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

/* Font leggibile (OpenDyslexic con fallback) */
html.pc-a11y-dyslexia body,
html.pc-a11y-dyslexia body :not(.pc-a11y-panel):not(.pc-a11y-panel *):not(.pc-a11y-launcher) {
    font-family: "PcOpenDyslexic", "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif !important;
    letter-spacing: .03em !important;
}

/* Evidenzia link */
html.pc-a11y-links body a:not(.pc-a11y-launcher):not(.pc-a11y-skip-link) {
    text-decoration: underline !important;
    text-underline-offset: 2px !important;
    background: #fff8c4 !important;
    color: #0a3cff !important;
    box-shadow: 0 0 0 1px #0a3cff;
}

/* Focus rafforzato */
html.pc-a11y-focus body *:focus,
html.pc-a11y-focus body *:focus-visible {
    outline: 4px solid #ff6a00 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(255,106,0,.35) !important;
}

/* Interlinea / spaziatura (WCAG 1.4.12) */
html.pc-a11y-spacing body :not(.pc-a11y-panel):not(.pc-a11y-panel *) {
    line-height: 1.8 !important;
    letter-spacing: .12em !important;
    word-spacing: .16em !important;
}
html.pc-a11y-spacing body p { margin-bottom: 1.6em !important; }

/* Stop animazioni */
html.pc-a11y-stop-anim *,
html.pc-a11y-stop-anim *::before,
html.pc-a11y-stop-anim *::after {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
}

/* Cursore ingrandito */
html.pc-a11y-big-cursor,
html.pc-a11y-big-cursor * {
    cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4Ij48cGF0aCBkPSJNMTAgNGwyOCAxNi0xMiAzIDcgMTQtNiAzLTctMTQtMTAgOXoiIGZpbGw9IiNmZmYiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLXdpZHRoPSIyIi8+PC9zdmc+"), auto !important;
}


@media print {
    .pc-a11y-launcher, .pc-a11y-panel, .pc-a11y-skip-link { display: none !important; }
}
