/*
 * Global Website Read Aloud / Voice Reader accessibility widget.
 *
 * Loaded once from templates/base.html (the single template every public
 * page/layout extends), so this widget appears on every page without any
 * per-layout or per-page duplication. This file only styles the buttons
 * themselves -- positioning/dragging is handled by the wrapping
 * #evitoA11yToolbar (see static/assets/css/a11y-toolbar.css), which this
 * widget sits inside as one of three control groups.
 */

.evito-voice-reader {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.evito-vr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: #f2f2f2;
    color: #222;
    cursor: pointer;
    border-radius: 999px;
    padding: 8px 12px;
    min-width: 40px;
    min-height: 40px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s ease-out, color 0.15s ease-out, opacity 0.15s ease-out;
}

.evito-vr-btn .evito-vr-icon {
    font-size: 16px;
    line-height: 1;
}

.evito-vr-btn:hover:not(:disabled) {
    background: #37C2CC;
    color: #fff;
}

.evito-vr-btn:focus-visible {
    outline: 3px solid #37C2CC;
    outline-offset: 2px;
}

.evito-vr-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Icon-only "Stop" control (Listen/Pause/Resume keeps its text label). */
.evito-vr-stop {
    padding: 8px;
    width: 40px;
}

/* Active/speaking state — gives a clear visual "state change" as required,
   beyond just the label text swap. */
.evito-voice-reader[data-vr-state="speaking"] .evito-vr-toggle,
.evito-voice-reader[data-vr-state="paused"] .evito-vr-toggle {
    background: #1C5E91;
    color: #fff;
}

/* Visually-hidden label -- the select carries its own aria-label too, this
   just gives assistive tech a slightly more descriptive accessible name. */
.evito-vr-sr-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accent/voice picker -- same custom-arrow treatment as .evito-tr-select
   in translate-widget.css (appearance:none replaces the native dropdown
   arrow, which looked broken combined with this pill shape/background). */
.evito-vr-accent-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    background-color: #f2f2f2;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23333333' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
    color: #222;
    cursor: pointer;
    border-radius: 999px;
    padding: 8px 26px 8px 10px;
    min-height: 40px;
    font-size: 13px;
    font-weight: 700;
}

.evito-vr-accent-select:focus-visible {
    outline: 3px solid #37C2CC;
    outline-offset: 2px;
}

/* Scoped to real hover-capable pointers only, so a tap on a touchscreen
   doesn't leave the control looking "stuck" highlighted (no mouse ever
   leaves to un-hover it). */
@media (hover: hover) and (pointer: fine) {
    .evito-vr-accent-select:hover {
        background-color: #37C2CC;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
        color: #fff;
    }
}

/* Visually-hidden live region: only for screen readers, never shown. */
.evito-vr-sr-status {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 576px) {
    .evito-voice-reader {
        gap: 3px;
    }

    .evito-vr-btn {
        padding: 8px 10px;
        font-size: 0;
        /* hide text label on very small screens, icon + aria-label remain */
        min-width: 40px;
    }

    .evito-vr-btn .evito-vr-icon {
        font-size: 17px;
    }

    .evito-vr-stop {
        width: 40px;
    }

    .evito-vr-accent-select {
        font-size: 12px;
        padding: 8px 22px 8px 8px;
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .evito-vr-btn {
        transition: none;
    }
}