/*
 * PS Speakeasy player.
 * Container contract: <div class="ps-speakeasy-player"
 *   data-radius="sharp|soft|rounded"
 *   data-density="compact|comfy|spacious">
 * Mirror these data attributes from PHP renderers and JS init.
 */

@font-face {
    font-family: "PS Speakeasy EB Garamond";
    src: url("../fonts/EBGaramond-VariableFont_wght.ttf") format("truetype-variations"),
         url("../fonts/EBGaramond-VariableFont_wght.ttf") format("truetype");
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "PS Speakeasy EB Garamond";
    src: url("../fonts/EBGaramond-Italic-VariableFont_wght.ttf") format("truetype-variations"),
         url("../fonts/EBGaramond-Italic-VariableFont_wght.ttf") format("truetype");
    font-weight: 400 800;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "PS Speakeasy Figtree";
    src: url("../fonts/Figtree-VariableFont_wght.ttf") format("truetype-variations"),
         url("../fonts/Figtree-VariableFont_wght.ttf") format("truetype");
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "PS Speakeasy Figtree";
    src: url("../fonts/Figtree-Italic-VariableFont_wght.ttf") format("truetype-variations"),
         url("../fonts/Figtree-Italic-VariableFont_wght.ttf") format("truetype");
    font-weight: 300 900;
    font-style: italic;
    font-display: swap;
}

.ps-speakeasy-player {
    --p-paper:        #FFFDF8;
    --p-paper-warm:   #F9F6EF;
    --p-paper-deep:   #F2EDE3;
    --p-stone:        #E5DFD3;
    --p-stone-strong: #C9C1B0;
    --p-ink:          #1A1714;
    --p-ink-muted:    rgba(26, 23, 20, 0.62);
    --p-ink-subtle:   rgba(26, 23, 20, 0.42);

    --ps-font-serif:   "PS Speakeasy EB Garamond", "EB Garamond", "Source Serif Pro", Georgia, "Times New Roman", serif;
    --ps-font-ui:      "PS Speakeasy Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ps-font-display: var(--ps-font-serif);

    --lc-pad-y: 12px;
    --lc-pad-x: 16px;
    --lc-r-card: 4px;
    --lc-r-btn: 3px;
    --lc-gap: 16px;

    box-sizing: border-box;
    background: var(--p-paper);
    border: 1px solid var(--p-stone-strong);
    border-radius: var(--lc-r-card);
    color: var(--p-ink);
    font-family: var(--ps-font-ui);
    font-size: 14px;
    line-height: 1.4;
    overflow: visible;
    position: relative;
    width: 100%;
    container-type: inline-size;
    container-name: ps-speakeasy-player;
}

.ps-speakeasy-player *,
.ps-speakeasy-player *::before,
.ps-speakeasy-player *::after {
    box-sizing: border-box;
}

.ps-speakeasy-player[data-radius="sharp"]   { --lc-r-card: 0;    --lc-r-btn: 0; }
.ps-speakeasy-player[data-radius="soft"]    { --lc-r-card: 4px;  --lc-r-btn: 3px; }
.ps-speakeasy-player[data-radius="rounded"] { --lc-r-card: 12px; --lc-r-btn: 8px; }

.ps-speakeasy-player[data-density="compact"]  { --lc-pad-y: 8px;  --lc-pad-x: 12px; --lc-gap: 12px; }
.ps-speakeasy-player[data-density="comfy"]    { --lc-pad-y: 12px; --lc-pad-x: 16px; --lc-gap: 16px; }
.ps-speakeasy-player[data-density="spacious"] { --lc-pad-y: 18px; --lc-pad-x: 22px; --lc-gap: 22px; }

.entry-content .ps-speakeasy-player:first-child {
    margin-bottom: 20px;
}

.ps-speakeasy-player__inner {
    display: flex;
    align-items: center;
    gap: var(--lc-gap);
    padding: var(--lc-pad-y) var(--lc-pad-x);
}

.ps-speakeasy-player__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--ps-font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--p-ink-muted);
    flex-shrink: 0;
}

.ps-speakeasy-player__label-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--p-ink);
}

.ps-speakeasy-player__divider {
    width: 1px;
    align-self: stretch;
    background: var(--p-stone);
    margin: 4px 0;
    flex-shrink: 0;
}

.ps-speakeasy-player__controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ps-speakeasy-player__head,
.ps-speakeasy-player__mobile-row {
    display: none;
}

.ps-speakeasy-player__btn-primary,
.ps-speakeasy-player__btn-ghost {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: var(--p-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms cubic-bezier(0.2, 0, 0, 1),
                color 120ms cubic-bezier(0.2, 0, 0, 1),
                transform 100ms cubic-bezier(0.2, 0, 0, 1);
    flex-shrink: 0;
    padding: 0;
    line-height: 0;
}

.ps-speakeasy-player__btn-primary {
    width: 36px;
    height: 36px;
    background: var(--p-ink);
    color: var(--p-paper);
    border-radius: var(--lc-r-btn);
}

.ps-speakeasy-player__btn-primary:focus { outline: none; }
.ps-speakeasy-player__btn-primary:active { transform: scale(0.97); }
.ps-speakeasy-player__btn-primary:focus-visible {
    outline: 2px solid var(--p-ink);
    outline-offset: 2px;
}

@media (hover: hover) {
    .ps-speakeasy-player__btn-primary:hover { background: #000; }
}

.ps-speakeasy-player__btn-ghost {
    width: 32px;
    height: 32px;
    color: var(--p-ink);
    border-radius: var(--lc-r-btn);
}

.ps-speakeasy-player__btn-ghost:focus { outline: none; }
.ps-speakeasy-player__btn-ghost:focus-visible {
    outline: 2px solid var(--p-ink);
    outline-offset: 2px;
}

@media (hover: hover) {
    .ps-speakeasy-player__btn-ghost:hover { background: var(--p-paper-deep); }
}

.ps-speakeasy-player__time {
    font-family: var(--ps-font-ui);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    letter-spacing: 0.02em;
    color: var(--p-ink-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 7ch;
    display: inline-block;
}

.speakeasy-time--approximate {
    opacity: 0.85;
    font-style: italic;
    transition: opacity 300ms ease;
    font-variant-numeric: tabular-nums;
}

.ps-speakeasy-player__seek {
    position: relative;
    width: 100%;
    height: 14px; /* enlarged hit/touch target around the 3px visual track */
    flex: 1 1 auto;
    min-width: 80px;
    cursor: pointer;
    touch-action: none;
}

.ps-speakeasy-player__seek-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 3px;
    background: var(--p-stone);
    border-radius: 999px;
}

.ps-speakeasy-player__seek-fill {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 3px;
    width: 0;
    background: var(--p-ink);
    border-radius: 999px;
}

.ps-speakeasy-player__seek-thumb {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--p-ink);
    border: 2px solid var(--p-paper);
    box-shadow: 0 1px 2px rgba(26, 23, 20, 0.18);
    transform: translate(-50%, -50%);
    top: 50%;
    left: 0;
}

.ps-speakeasy-player__speed {
    position: relative;
    flex-shrink: 0;
}

.ps-speakeasy-player__speed-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--p-stone);
    background: var(--p-paper);
    border-radius: var(--lc-r-btn);
    height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--ps-font-ui);
    cursor: pointer;
    color: var(--p-ink);
    transition: background 120ms cubic-bezier(0.2, 0, 0, 1),
                border-color 120ms cubic-bezier(0.2, 0, 0, 1);
}

.ps-speakeasy-player__speed-btn:focus { outline: none; }

.ps-speakeasy-player__speed-btn:focus-visible {
    outline: 2px solid var(--p-ink);
    outline-offset: 2px;
}

@media (hover: hover) {
    .ps-speakeasy-player__speed-btn:hover {
        background: var(--p-paper-deep);
        border-color: var(--p-stone-strong);
    }
}

.ps-speakeasy-player__speed-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--p-ink-muted);
}

.ps-speakeasy-player__speed-value {
    font-family: var(--ps-font-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 15px;
    color: var(--p-ink);
    font-feature-settings: "tnum";
    line-height: 1;
}

.ps-speakeasy-player__speed.is-open .ps-speakeasy-player__speed-btn {
    background: var(--p-paper-deep);
    border-color: var(--p-ink);
}

.ps-speakeasy-player__speed-chevron {
    display: inline-flex;
    transition: transform 120ms cubic-bezier(0.2, 0, 0, 1);
}

.ps-speakeasy-player__speed.is-open .ps-speakeasy-player__speed-chevron {
    transform: rotate(180deg);
}

.ps-speakeasy-player__speed-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    min-width: 130px;
    background: var(--p-paper);
    border: 1px solid var(--p-ink);
    border-radius: var(--lc-r-btn);
    box-shadow: 0 12px 32px rgba(26, 23, 20, 0.14);
    padding: 6px;
    z-index: 20;
    margin: 0;
    list-style: none;
}

.ps-speakeasy-player__speed-menu[hidden] {
    display: none;
}

.ps-speakeasy-player__speed-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    font-family: var(--ps-font-serif);
    font-size: 15px;
    color: var(--p-ink);
    border-radius: 2px;
    cursor: pointer;
    font-feature-settings: "tnum";
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    line-height: 1.2;
}

.ps-speakeasy-player__speed-item:hover {
    background: var(--p-paper-deep);
}

.ps-speakeasy-player__speed-item.is-active {
    font-weight: 600;
}

.ps-speakeasy-player__speed-item-check {
    display: inline-flex;
    visibility: hidden;
}

.ps-speakeasy-player__speed-item.is-active .ps-speakeasy-player__speed-item-check {
    visibility: visible;
}

.ps-speakeasy-player__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--p-stone);
    border-top-color: var(--p-ink);
    border-radius: 50%;
    animation: ps-speakeasy-spin 800ms linear infinite;
    flex-shrink: 0;
}

.ps-speakeasy-player .ps-speakeasy-player__btn-primary[data-state="loading"] {
    background: var(--p-stone-strong);
    cursor: progress;
}

@keyframes ps-speakeasy-spin {
    to { transform: rotate(360deg); }
}

.ps-speakeasy-player.has-error {
    border-color: #b91c1c;
}

.ps-speakeasy-player__error {
    display: none;
    padding: 8px var(--lc-pad-x);
    color: #b91c1c;
    font-family: var(--ps-font-ui);
    font-size: 12px;
    border-top: 1px solid var(--p-stone);
}

.ps-speakeasy-player.has-error .ps-speakeasy-player__error {
    display: block;
}

@media (max-width: 560px) {
    .ps-speakeasy-player__inner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: var(--lc-pad-y) var(--lc-pad-x);
    }

    .ps-speakeasy-player__divider {
        display: none;
    }

    .ps-speakeasy-player__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .ps-speakeasy-player__mobile-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    /*
     * Desktop-layout siblings of __inner are duplicated inside __head and
     * __mobile-row on mobile; hide the originals so they don't render twice.
     */
    .ps-speakeasy-player__inner > .ps-speakeasy-player__label,
    .ps-speakeasy-player__inner > .ps-speakeasy-player__controls,
    .ps-speakeasy-player__inner > .ps-speakeasy-player__time,
    .ps-speakeasy-player__inner > .ps-speakeasy-player__speed {
        display: none;
    }

    .ps-speakeasy-player__transport {
        display: flex;
        align-items: center;
        gap: 6px;
    }
}

[dir="rtl"] .ps-speakeasy-player__speed-menu {
    right: auto;
    left: 0;
}

/*
 * When the player container itself is narrow (e.g., embedded in a sidebar),
 * drop the "Speed" word so the value + chevron still fit without spilling.
 * Container query targets the player width, independent of viewport size.
 */
@container ps-speakeasy-player (max-width: 480px) {
    .ps-speakeasy-player__speed-label {
        display: none;
    }

    .ps-speakeasy-player__speed-btn {
        padding: 0 8px;
        gap: 4px;
    }
}
