/* ==========================================================================
   Listen to this blog — text-to-speech player widget
   Shared across all blog posts. Paired with js/listen-player.js.
   ========================================================================== */

.listen-player {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    margin: 0 0 2rem 0;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #ffffff;
}

/* The widget stays hidden until JS confirms the browser supports speech
   synthesis. `.listen-player` sets display:flex, which would otherwise beat
   the [hidden] attribute's user-agent display:none. */
.listen-player[hidden] {
    display: none;
}

/* -------------------------------------------------------------- head row */

.listen-player__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.listen-player__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    color: #f97316;
    flex-shrink: 0;
}

.listen-player__icon svg {
    width: 100%;
    height: 100%;
}

.listen-player__title {
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #111827;
    line-height: 1.2;
}

.listen-player__hint {
    margin-left: auto;
    font-size: 0.6875rem;
    color: #9ca3af;
    line-height: 1.2;
    white-space: nowrap;
}

/* ---------------------------------------------------------- controls row */

.listen-player__controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.listen-player__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    background: #ffffff;
    color: #4b5563;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.listen-player__btn svg {
    width: 1rem;
    height: 1rem;
    pointer-events: none;
}

.listen-player__btn:hover {
    border-color: #111827;
    color: #111827;
}

.listen-player__btn:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

.listen-player__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Play / pause is the primary action */
.listen-player__btn--play {
    width: 2.75rem;
    height: 2.75rem;
    border-color: #111827;
    background: #111827;
    color: #ffffff;
}

.listen-player__btn--play svg {
    width: 1.125rem;
    height: 1.125rem;
}

.listen-player__btn--play:hover {
    border-color: #000000;
    background: #000000;
    color: #ffffff;
}

/* Wrappers that let JS swap the play/pause glyph without touching the button */
.listen-player__icon-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.listen-player__icon-slot[hidden] {
    display: none;
}

/* Speed and language toggles are text, not icons */
.listen-player__btn--speed,
.listen-player__btn--lang {
    width: auto;
    min-width: 2.75rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
}

.listen-player__btn--speed {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- progress */

/* global.css applies `input:not([type=checkbox]):not([type=radio])` padding and
   a 44px min-height to every input. That selector scores 0,2,1, so this one is
   deliberately scored 0,3,1 to win no matter which stylesheet loads last. */
.listen-player input[type="range"].listen-player__range {
    -webkit-appearance: none;
    appearance: none;
    flex: 1 1 auto;
    min-width: 3rem;
    width: auto;
    height: 4px;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 9999px;
    background: #e5e7eb;
    cursor: pointer;
}

.listen-player input[type="range"].listen-player__range:focus {
    outline: none;
}

.listen-player input[type="range"].listen-player__range:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 4px;
}

/* Filled portion is painted via a gradient the JS updates */
.listen-player__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 9999px;
    background: #111827;
    cursor: pointer;
}

.listen-player__range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 9999px;
    background: #111827;
    cursor: pointer;
}

.listen-player__range::-moz-range-track {
    height: 4px;
    border-radius: 9999px;
    background: transparent;
}

.listen-player__time {
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 640px) {
    .listen-player__hint {
        display: none;
    }

    .listen-player__time {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .listen-player__btn {
        transition: none;
    }
}
