/**
 * Blog Voice Player Styles
 * Free Web Speech API powered audio reader
 */

/* ===========================================================
   Disable sticky/fixed header ONLY on single blog post pages
   so the voice player can occupy the sticky position cleanly.
   =========================================================== */
body.single-post .site-header,
body.single-post .site-header.header-fixed {
    position: static !important;
    top: auto !important;
    box-shadow: none !important;
    transform: none !important;
}

body.single-post.header-scrolled {
    padding-top: 0 !important;
}

.voice-player {
    background: #ffffff;
    border-radius: 25px;
    padding: 24px 28px;
    margin-bottom: 50px;
    box-shadow: 0 15px 50px rgba(0, 40, 104, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 15px;
    z-index: 99;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.96);
}

.voice-player::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, #BF0A30 0%, #002868 100%);
}

.voice-player__header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.voice-player__icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #BF0A30 0%, #002868 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(191, 10, 48, 0.25);
    animation: voice-pulse 2.5s ease-in-out infinite;
}

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(191, 10, 48, 0.25); }
    50% { box-shadow: 0 8px 30px rgba(0, 40, 104, 0.4); }
}

.voice-player__title {
    flex: 1;
    min-width: 0;
}

.voice-player__title h4 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 2px 0;
    color: #002868;
    letter-spacing: -0.3px;
}

.voice-player__title p {
    margin: 0;
    font-size: 0.82rem;
    color: #86868b;
    font-weight: 500;
}

.voice-player__time {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1d1d1f;
    background: #f5f5f7;
    padding: 6px 14px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
}

.voice-player__controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.voice-player__btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.voice-player__btn--primary {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #BF0A30 0%, #8B0824 100%);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 8px 20px rgba(191, 10, 48, 0.3);
}

.voice-player__btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(191, 10, 48, 0.4);
}

.voice-player__btn--secondary {
    background: #f5f5f7;
    color: #002868;
}

.voice-player__btn--secondary:hover {
    background: #002868;
    color: #fff;
    transform: translateY(-2px);
}

.voice-player__btn--secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.voice-player__progress-wrap {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.voice-player__progress {
    width: 100%;
    height: 6px;
    background: #e5e5ea;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transition: height 0.2s ease;
}

.voice-player__progress:hover {
    height: 10px;
}

.voice-player__progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #BF0A30, #002868);
    border-radius: 10px;
    transition: width 0.2s linear;
    pointer-events: none;
}

/* Hover scrubber dot */
.voice-player__progress::after {
    content: '';
    position: absolute;
    top: 50%;
    left: var(--vp-hover-x, 0%);
    transform: translate(-50%, -50%) scale(0);
    width: 16px;
    height: 16px;
    background: #fff;
    border: 3px solid #BF0A30;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    transition: transform 0.2s ease;
}

.voice-player__progress:hover::after {
    transform: translate(-50%, -50%) scale(1);
}

/* YouTube-style preview tooltip */
.voice-player__preview {
    position: absolute;
    bottom: 100%;
    margin-bottom: 14px;
    left: 0;
    transform: translateX(-50%);
    background: #1d1d1f;
    color: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    min-width: 220px;
    max-width: 320px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    z-index: 10;
}

.voice-player__preview.is-visible {
    opacity: 1;
    visibility: visible;
}

.voice-player__preview::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1d1d1f;
}

.voice-player__preview-section {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ff8b9c;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.voice-player__preview-section i {
    font-size: 0.65rem;
}

.voice-player__preview-text {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: #fff;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.voice-player__preview-time {
    font-size: 0.72rem;
    font-weight: 700;
    color: #86868b;
    font-variant-numeric: tabular-nums;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 5px;
    text-align: right;
}

.voice-player__settings {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.voice-player__select {
    appearance: none;
    -webkit-appearance: none;
    background: #f5f5f7 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23002868' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 12px center;
    border: none;
    border-radius: 20px;
    padding: 8px 30px 8px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #002868;
    cursor: pointer;
    transition: all 0.25s ease;
    max-width: 180px;
    text-overflow: ellipsis;
}

.voice-player__select:hover {
    background-color: #e5e5ea;
}

.voice-player__select:focus {
    outline: 2px solid rgba(191, 10, 48, 0.3);
}

/* Active / Speaking state */
.voice-player.is-playing .voice-player__icon {
    animation: voice-pulse-fast 1s ease-in-out infinite;
}

@keyframes voice-pulse-fast {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.voice-player.is-playing .voice-player__title p::before {
    content: '● ';
    color: #BF0A30;
    animation: voice-blink 1s ease-in-out infinite;
}

@keyframes voice-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Sentence wrapper (every sentence in article body) */
.vp-sentence {
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    border-radius: 4px;
    cursor: pointer;
}

.vp-sentence:hover {
    background-color: rgba(0, 40, 104, 0.05);
}

/* Currently spoken sentence — karaoke highlight */
.vp-sentence.is-speaking {
    background: linear-gradient(120deg, rgba(255, 235, 130, 0.85) 0%, rgba(255, 215, 90, 0.85) 100%);
    color: #1d1d1f;
    box-shadow:
        0 0 0 4px rgba(255, 215, 90, 0.4),
        0 4px 14px rgba(191, 10, 48, 0.12);
    padding: 2px 6px;
    margin: 0 -2px;
    font-weight: 600;
    animation: vp-pulse-bg 2s ease-in-out infinite;
}

@keyframes vp-pulse-bg {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 215, 90, 0.4), 0 4px 14px rgba(191, 10, 48, 0.12); }
    50%      { box-shadow: 0 0 0 6px rgba(255, 200, 50, 0.5), 0 6px 20px rgba(191, 10, 48, 0.2); }
}

/* Heading sentences look different when active */
.entry-content h1 .vp-sentence.is-speaking,
.entry-content h2 .vp-sentence.is-speaking,
.entry-content h3 .vp-sentence.is-speaking,
.entry-content h4 .vp-sentence.is-speaking {
    background: linear-gradient(120deg, #BF0A30 0%, #002868 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(191, 10, 48, 0.3);
    -webkit-background-clip: padding-box;
}

/* Unsupported browser notice */
.voice-player--unsupported {
    background: #fff5f7;
    border-left-color: #BF0A30;
}

.voice-player--unsupported .voice-player__title h4 {
    color: #BF0A30;
}

/* Responsive */
@media (max-width: 767px) {
    .voice-player {
        padding: 18px 20px;
        border-radius: 20px;
    }

    .voice-player__icon {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .voice-player__title h4 {
        font-size: 0.95rem;
    }

    .voice-player__controls {
        gap: 10px;
    }

    .voice-player__btn {
        width: 42px;
        height: 42px;
        font-size: 0.9rem;
    }

    .voice-player__btn--primary {
        width: 50px;
        height: 50px;
        font-size: 1.05rem;
    }

    .voice-player__select {
        font-size: 0.75rem;
        padding: 6px 26px 6px 12px;
    }

    .voice-player__time {
        font-size: 0.78rem;
        padding: 4px 10px;
    }
}
