/*
 * KC TTS Player — mobile-first compact player
 * Must not: overflow, conflict with sticky CTA / Chatwoot bubble / floating actions
 * Must: 44px tap targets, zero layout shift, smooth transitions, corporate editorial feel
 */

.kc-tts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    margin: 0 0 24px;
    background: #ffffff;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    contain: layout style;
    /* reserve height to avoid CLS even before content paints */
    min-height: 86px;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--text-primary, #0f172a);
}

.kc-tts * { box-sizing: border-box; }

.kc-tts__head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kc-tts__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color, #2563eb);
    flex-shrink: 0;
}

.kc-tts__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    letter-spacing: 0.1px;
}

.kc-tts__controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kc-tts__btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e40af, #1d4ed8);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.kc-tts__btn:hover { transform: scale(1.04); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32); }
.kc-tts__btn:active { transform: scale(0.96); }
.kc-tts__btn[disabled] { opacity: 0.55; cursor: wait; }

.kc-tts__btn svg { display: block; transform: translateX(1px); } /* play icon visual balance */
.kc-tts__btn .kc-tts__pause-icon { transform: none; }

.kc-tts__progress {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    outline: none;
}

.kc-tts__progress-bar {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
}

.kc-tts__progress-fill {
    position: absolute;
    left: 0;
    height: 4px;
    width: 0;
    background: linear-gradient(90deg, #1e40af, #1d4ed8);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.kc-tts__progress::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    background: #ffffff;
    border: 2px solid #1e40af;
    border-radius: 50%;
    transform: translateY(-50%);
    transition: left 0.1s linear, transform 0.15s ease;
    pointer-events: none;
    opacity: 0;
}

.kc-tts.is-ready .kc-tts__progress::after { opacity: 1; }

.kc-tts__time {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.kc-tts__speed {
    min-width: 42px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: #ffffff;
    color: var(--text-secondary, #475569);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.kc-tts__speed:hover { border-color: var(--primary-color, #2563eb); color: var(--primary-color, #2563eb); }

/* Compact mobile layout — stack head + controls, larger tap targets */
@media (max-width: 520px) {
    .kc-tts {
        padding: 12px 14px;
        gap: 12px;
        margin: 0 0 20px;
    }
    .kc-tts__label { font-size: 12px; }
    .kc-tts__controls { gap: 8px; }
    .kc-tts__time { min-width: 36px; font-size: 11px; }
    .kc-tts__speed { min-width: 38px; height: 30px; padding: 0 8px; }
}

/* When sticky CTA bar is present on mobile, keep player from sitting right against it */
@media (max-width: 768px) {
    .kc-tts { margin-bottom: 28px; }
}

/* Dark/invert safety — works over light editorial theme already */
audio.kc-tts-native { display: none; }
