/* ============================================
   TTS Player — Text-to-Speech Audio Bar
   Scoped: .tts-player prefix to avoid conflicts
   ============================================ */

.tts-player {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
}

.tts-player__inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}

/* Play / Pause button */
.tts-player__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #333;
    flex-shrink: 0;
}

.tts-player__btn:hover {
    color: #1a73e8;
}

.tts-player__btn--play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f0f0;
}

.tts-player__btn--play:hover {
    background: #e0e0e0;
}

/* Progress bar */
.tts-player__progress {
    flex: 1;
    position: relative;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
}

.tts-player__progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #2e7d32;
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s linear;
}

/* Range input overlay */
.tts-player__seek {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* Seek thumb for better UX */
.tts-player__seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2e7d32;
    cursor: pointer;
}

.tts-player__progress:hover .tts-player__seek {
    opacity: 1;
}

.tts-player__progress:hover .tts-player__progress-bar {
    height: 100%;
}

/* Time display */
.tts-player__time {
    font-size: 13px;
    color: #555;
    min-width: 48px;
    text-align: center;
    flex-shrink: 0;
    font-family: 'Roboto', Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* Voice selector */
.tts-player__voice-wrap {
    position: relative;
    flex-shrink: 0;
}

.tts-player__voice-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: #fff;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Roboto', Arial, sans-serif;
}

.tts-player__voice-btn:hover {
    border-color: #999;
}

.tts-player__voice-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 10000;
}

.tts-player__voice-list li {
    padding: 8px 16px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Roboto', Arial, sans-serif;
}

.tts-player__voice-list li:hover {
    background: #f5f5f5;
}

.tts-player__voice-list li.active {
    color: #2e7d32;
    font-weight: 600;
}

/* Close button */
.tts-player__btn--close {
    width: 28px;
    height: 28px;
    color: #888;
}

.tts-player__btn--close:hover {
    color: #333;
}

/* ===== Toggle button (in _SharedTop) ===== */
.tts-toggle-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    color: #666;
    text-decoration: none;
    margin-bottom: 25px !important;
}

.tts-toggle-btn:hover {
    color: #333;
}

.tts-toggle-icon {
    width: 24px;
    height: 24px;
}

.tts-toggle-label {
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

/* Sticky header variant — icon only, no margin */
.tts-toggle-btn--sticky {
    margin-bottom: 0 !important;
}

/* ===== Longform: player fixed bottom on PC only ===== */
@media (min-width: 992px) {
    .onecmms-longform .tts-player {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin-bottom: 0;
        border: none;
        border-radius: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
        z-index: 2;
    }

    .onecmms-longform .tts-player__voice-list {
        top: auto;
        bottom: calc(100% + 6px);
    }

    .has-tts-longform .c-gotop {
        bottom: 120px !important;
    }
}

/* ===== Inline button in article header meta (mobile only) ===== */
.entry .sc-longform-header .tts-inline-btn {
    display: none !important;
}

@media (max-width: 991px) {
    .entry .sc-longform-header .tts-inline-btn {
        display: inline-flex !important;
        align-items: center;
        gap: 4px;
        margin-left: 8px;
        padding: 2px 8px;
        border: 1px solid currentColor;
        border-radius: 12px;
        font-size: 0.85em;
        color: inherit;
        text-decoration: none;
        vertical-align: middle;
        cursor: pointer;
        opacity: 0.7;
    }

    .tts-inline-btn:hover {
        opacity: 1;
    }

    .tts-inline-btn svg {
        flex-shrink: 0;
    }

    .tts-inline-btn .tts-toggle-label {
        font-size: inherit;
        line-height: 1.2;
    }
}

/* ===== Mobile: fixed bottom player ===== */
@media (max-width: 991px) {
    .tts-player {
        position: fixed;
        bottom: 52px;
        left: 0;
        right: 0;
        margin-bottom: 0;
        border: none;
        border-radius: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
        z-index:2;
    }

    .tts-player__voice-list {
        top: auto;
        bottom: calc(100% + 6px);
    }

    .c-header-sticky.has-audio {
        opacity: 1;
        z-index: 1;
        top: auto;
        bottom: 0;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.15);
    }

    .c-gotop {
        bottom: 120px !important;
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .tts-player__inner {
        gap: 8px;
        padding: 8px 12px;
    }

    .tts-player__btn--play {
        width: 32px;
        height: 32px;
    }

    .tts-player__voice-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .tts-player__time {
        font-size: 12px;
        min-width: 42px;
    }

    .tts-player__voice-list {
        right: -40px;
    }
}

@media (max-width: 480px) {
    .tts-player__inner {
        gap: 6px;
        padding: 8px 10px;
    }

    .tts-player__voice-wrap {
        flex-shrink: 1;
        min-width: 0;
    }

    .tts-player__voice-btn span {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .tts-player__inner {
        gap: 4px;
        padding: 6px 8px;
    }

    .tts-player__voice-btn span {
        display: none !important;
    }

    .tts-player__voice-btn {
        padding: 5px 8px;
    }

    .tts-player__time {
        font-size: 11px;
        min-width: 38px;
    }

    .tts-player__btn--play {
        width: 28px;
        height: 28px;
    }
}
