/* ==========================================================================
   a11y-pill.css — floating accessibility-settings pill (bottom-left) + panel
   --------------------------------------------------------------------------
   Houses the motion + readable-font controls (relocated out of the crowded nav
   keycaps) and a link to /accessibility. Injected by js/a11y-pill.js on every
   page. Styling uses the shared tokens so it themes with the rest of the site;
   the switches drive the same localStorage / html-attribute state motion.js and
   readable-font.css already react to (no motion-system rebuild).
   ========================================================================== */

/* --- Footer clearance ----------------------------------------------------
   The pill is position:fixed and floats over everything, including the footer
   when scrolled to the bottom. Reserve space under the footer so the pill never
   covers the last links. */
.site-footer { padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 84px)); }

/* --- The pill ------------------------------------------------------------- */
.a11y-pill {
    position: fixed;
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 12px));
    left: max(16px, calc(env(safe-area-inset-left) + 12px));
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 13px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-bottom-width: 3px;
    border-radius: 999px;
    box-shadow: 0 6px 20px var(--card-shadow, rgba(0, 0, 0, 0.15));
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
[data-mode="gremlin"] .a11y-pill { font-family: 'Nunito', sans-serif; }
[data-mode="pro"] .a11y-pill { font-family: 'DM Sans', sans-serif; border-radius: 10px; }
.a11y-pill:hover { transform: translateY(-2px); border-color: var(--accent); }
.a11y-pill:active { transform: translateY(0); }
.a11y-pill:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[data-mode="gremlin"][data-theme="light"] .a11y-pill:hover { border-color: #9C2D63; }
[data-mode="gremlin"][data-theme="light"] .a11y-pill:focus-visible { outline-color: #9C2D63; }

.a11y-pill-icon { flex: 0 0 auto; width: 18px; height: 18px; color: var(--accent); }
[data-mode="gremlin"][data-theme="light"] .a11y-pill-icon { color: #9C2D63; }
.a11y-pill-label { white-space: nowrap; }

/* --- The panel ------------------------------------------------------------ */
.a11y-panel {
    position: fixed;
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 62px));
    left: max(16px, calc(env(safe-area-inset-left) + 12px));
    z-index: 1001;
    width: min(280px, calc(100vw - 32px));
    padding: 16px 18px 18px;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 40px var(--card-shadow, rgba(0, 0, 0, 0.22));
    transform-origin: bottom left;
}
[data-mode="pro"] .a11y-panel { border-radius: 10px; }
.a11y-panel[hidden] { display: none; }

/* Entrance (motion-gated below). */
.a11y-panel { animation: a11yPanelIn 0.18s cubic-bezier(0.3, 1.2, 0.5, 1) both; }
@keyframes a11yPanelIn {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
[data-motion="off"] .a11y-panel { animation: none; }
@media (prefers-reduced-motion: reduce) { .a11y-panel { animation: none; } }

.a11y-panel-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--text-2);
    margin: 0 0 12px;
}

.a11y-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
}
.a11y-row-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.a11y-row-note { display: block; font-size: 0.72rem; font-weight: 400; color: var(--text-2); margin-top: 2px; }

/* --- The switches (role="switch") ---------------------------------------- */
.a11y-switch {
    flex: 0 0 auto;
    position: relative;
    width: 46px;
    height: 26px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 999px;
    background: var(--bg-2, rgba(127, 127, 127, 0.15));
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.a11y-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-2);
    transition: transform 0.18s ease, background 0.18s ease;
}
.a11y-switch[aria-checked="true"] {
    background: var(--accent);
    border-color: var(--accent);
}
.a11y-switch[aria-checked="true"]::after {
    transform: translateX(20px);
    background: #ffffff;
}
[data-mode="gremlin"][data-theme="light"] .a11y-switch[aria-checked="true"] {
    background: #9C2D63;
    border-color: #9C2D63;
}
.a11y-switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[data-mode="gremlin"][data-theme="light"] .a11y-switch:focus-visible { outline-color: #9C2D63; }
[data-motion="off"] .a11y-switch, [data-motion="off"] .a11y-switch::after { transition: none; }
@media (prefers-reduced-motion: reduce) { .a11y-switch, .a11y-switch::after { transition: none; } }

/* --- The statement link --------------------------------------------------- */
.a11y-panel-link {
    display: inline-block;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    width: 100%;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
[data-mode="gremlin"][data-theme="light"] .a11y-panel-link { color: #9C2D63; }
.a11y-panel-link:hover { text-decoration: underline; }
.a11y-panel-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[data-mode="gremlin"][data-theme="light"] .a11y-panel-link:focus-visible { outline-color: #9C2D63; }

/* Narrow phones: let the pill shrink to just the icon if space is tight. */
@media (max-width: 380px) {
    .a11y-pill { padding: 10px 13px; }
    .a11y-pill-label { font-size: 0.8rem; }
}
