/* ==========================================================================
   PODCAST AUDIO PLAYER - COMPLETE STYLESHEET
   ========================================================================== */

/* ==========================================================================
   1. MAIN COMPONENT LAYOUT
   ========================================================================== */

/**
 * The main wrapper for the entire component (authors + player + transcript).
 * This is where you set the background, border, and overall padding.
 */
.podcast-wrapper {
    padding: 1rem;
    background-color: var(--theme-color, #f9cd01); /* Customizable theme color */
    border-radius: 15px;
    border-width: var(--border-width, 0);
    border-style: var(--border-style, none);
    border-color: var(--border-color, transparent);
    box-shadow: var(--wrapper-box-shadow, none);
    margin: 2em 0;
    position: relative; /* For absolute positioning of publication date */
}

/**
 * Publication date displayed in top right corner of podcast wrapper.
 */
.podcast-publication-date {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.8em;
    font-weight: 600;
    color: #333;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/**
 * The wrapper for the authors section and the right-side content.
 * This is a flex container that arranges the left and right columns.
 */
.podcast-authors-wrapper {
    display: flex;
    justify-content: space-between; /* Pushes authors left and title/right-side right */
    align-items: center;            /* Vertically aligns them in the middle */
    padding: var(--authors-padding, 0 0 25px 0);
    border-color: var(--authors-border-color, transparent);
    border-width: var(--authors-border-width, 0);
    border-style: var(--authors-border-style, none);
    box-shadow: var(--authors-box-shadow, none);
    gap: 20px; /* Adds space between left and right columns */
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
}

/* ==========================================================================
   2. LEFT SIDE: OVERLAPPING AVATARS
   ========================================================================== */

.podcast-authors {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-direction: row;
}

.podcaster {
    text-align: center;
    position: relative; /* Crucial for the z-index on hover to work */
    /* This is the magic: pull all but the first item to the left */
    margin-left: -20px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.podcaster:first-child {
    margin-left: 0;
}

.podcaster:hover {
    transform: translateY(-5px) scale(1.05);
    z-index: 10; /* Brings the hovered item to the top */
}

.podcaster-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    /* The light border is important for creating separation between the circles */
    border: 3px solid #f0f0f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.podcaster p {
    margin-top: 8px;
    margin-bottom: 0;
}

.podcaster a {
    text-decoration: none;
    font-weight: 600;
    color: var(--link-color, #333);
    font-size: 0.9em;
}

.podcaster a:hover {
    color: var(--link-hover-color, #0073aa);
}

/* Episode Image Display */
.episode-image {
    text-align: center;
}

.episode-image-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px; /* Square with slight rounding */
    object-fit: cover; /* Proportional resize to fill square */
    border: 3px solid #f0f0f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ==========================================================================
   3. RIGHT SIDE: TITLE & LIVE TRANSCRIPT
   ========================================================================== */

/**
 * Container for the right-side content (title and live transcript).
 */
.podcast-right-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0; /* Prevents this column from shrinking */
}

.podcast-title h3 {
    margin: 0; /* Removes default heading margin */
    font-size: var(--title-font-size, 1.4em);
    font-weight: 700;
    color: var(--title-color, #000000);
    text-align: right; /* Aligns the title text to the right */
}

/**
 * Container for the live transcript button and text.
 */
.podcast-live-transcript-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

/**
 * The element that displays the currently playing text.
 */
.podcast-live-text {
    font-size: 0.9em;
    font-style: italic;
    color: #555;
    max-width: 250px; /* Prevents it from getting too long */
    text-align: right;
}

.podcast-live-text[data-transcript-ready="true"] {
    color: #333;
    font-weight: 500;
}

.podcast-live-text[data-transcript-ready="true"]:after {
    content: " ●";
    color: #f9cd01;
    font-size: 8px;
    vertical-align: super;
    margin-left: 4px;
}

.podcast-live-text[data-transcript-ready="false"] {
    color: #999;
    font-style: normal;
}

.podcast-live-text[data-transcript-ready="false"]:after {
    content: " ○";
    color: #ccc;
    font-size: 8px;
    vertical-align: super;
    margin-left: 4px;
}

/* ==========================================================================
    4. AUDIO PLAYER
    ========================================================================== */

.podcast-audio-player {
    display: block;
    width: 100%;
    max-width: 600px;
    height: 40px;
    margin: 0 auto;
    outline: none;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ==========================================================================
    5. WAVEFORM VISUALIZATION
    ========================================================================== */

.podcast-waveform-container {
    width: 100%;
    max-width: 800px;
    margin: 15px auto 0;
    display: block;
}

.podcast-waveform {
    flex: 1;
    min-width: 200px;
    height: 50px;
    position: relative;
    background-color: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
}

.waveform-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 0.9em;
    font-style: italic;
}

/* Static Waveform Visualization */
.static-waveform {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 5px;
    gap: 2px;
    cursor: pointer;
}

.static-waveform-bar {
    flex: 1;
    background-color: #ddd;
    border-radius: 2px;
    transition: background-color 0.1s ease;
    min-width: 2px;
}

/* Played bars (yellow/progress color) */
.static-waveform-bar.played {
    background-color: var(--theme-color, #f9cd01);
}

/* Unplayed bars (gray) */
.static-waveform-bar.unplayed {
    background-color: #ddd;
}

/* Progress line indicator */
.waveform-progress-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--progress-line-color, #f9cd01);
    left: 0;
    transition: left 0.1s linear;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 4px rgba(249, 205, 1, 0.5);
}


/* Hover effect on waveform */
.static-waveform:hover .static-waveform-bar.unplayed {
    background-color: #c9c9c9;
}

.static-waveform:hover .static-waveform-bar.played {
    background-color: var(--waveform-hover-color, #e6b801);
}


/* ==========================================================================
     UNIFIED CONTROLS - Single Row Layout
     ========================================================================== */

.podcast-unified-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    border-color: var(--controls-border-color, transparent);
    border-width: var(--controls-border-width, 0);
    border-style: var(--controls-border-style, none);
    box-shadow: var(--controls-box-shadow, 0 2px 8px rgba(0,0,0,0.1));
}

/* Play/Pause Button */
.waveform-play-pause {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--theme-color, #f9cd01);
    border: none;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.waveform-play-pause:not([data-ready]) {
    opacity: 1;
    cursor: pointer;
    position: relative;
}

.waveform-play-pause:not([data-ready])::after {
    display: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.waveform-play-pause:hover {
    background-color: var(--button-hover-color, #e6b801);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.waveform-play-pause:active {
    transform: scale(0.95);
}

.waveform-play-pause svg {
    width: 20px;
    height: 20px;
    fill: var(--icon-color, #333333);
}

.waveform-pause-icon {
    display: none;
}

/* Time Display */
.waveform-time-display {
    flex-shrink: 0;
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
    min-width: 100px;
    text-align: center;
}

/* Volume Controls - Vertical Layout */
.waveform-volume-container {
    flex-shrink: 0;
    display: flex;
    flex-direction: column-reverse; /* Button at bottom, slider above */
    align-items: center;
    position: relative; /* For absolute positioning of slider wrapper */
    z-index: 100; /* Ensure it's above other elements */
}

/* Vertical Slider Wrapper - Hidden by default, shown on hover */
.waveform-volume-slider-wrapper {
    position: absolute;
    bottom: 100%; /* Position above the button */
    left: 50%;
    transform: translateX(-50%);
    height: 116px; /* Increased to include padding */
    width: 46px; /* Increased to include padding */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0s 0.3s, visibility 0s 0.3s; /* 0.3s delay before hiding */
    z-index: 101;
    padding: 8px; /* Padding around slider */
    margin-bottom: 0; /* No gap - connects to button */
    background-color: #ffffff; /* White background */
    border-radius: 8px; /* Rounded corners */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); /* Subtle shadow for depth */
}

/* Show slider on container hover - instant appearance */
.waveform-volume-container:hover .waveform-volume-slider-wrapper,
.waveform-volume-slider-wrapper:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0s, visibility 0s; /* Instant appearance */
}

.waveform-volume-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waveform-volume-btn:hover {
    color: #333;
    background-color: #f0f0f0;
}

.waveform-volume-btn svg {
    width: 18px;
    height: 18px;
}

.waveform-volume-muted-icon {
    display: none;
}

.waveform-volume-slider {
    width: 100px; /* This becomes the height when rotated */
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    transform: rotate(-90deg); /* Rotate to vertical */
    transform-origin: center center;
}

.waveform-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f9cd01;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.waveform-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.waveform-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f9cd01;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.waveform-volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* ==========================================================================
   5. FULL TOGGLEABLE TRANSCRIPT
   ========================================================================== */

.podcast-transcript-wrapper {
    margin-top: 25px;
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

.transcript-toggle-button {
    background-color: #333;
    color: #fff;
    border: none;
    padding: 10px 12px; /* Adjusted padding for icon */
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.transcript-toggle-button:hover {
    background-color: #555;
}

.transcript-toggle-button svg {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    stroke: currentColor; /* Support for outline icons */
    fill: none; /* Ensure no fill for outline icons */
}

.podcast-transcript {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    line-height: 1.6;
    font-size: 1em;
    color: #444;
}

.podcast-transcript .transcript-highlight {
    background-color: #f9cd01; /* Your vibrant yellow color */
    padding: 2px 4px;
    border-radius: 3px;
}

/* ==========================================================================
   6. SPEAKER ANIMATION
   ========================================================================== */

/**
 * The class that will be added by JavaScript to the active speaker.
 */
.podcaster.is-speaking {
    animation: pulse 1.5s infinite;
}

/**
 * The keyframes for the pulse animation.
 * It makes the avatar grow slightly and then return to normal size.
 */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/**
 * Ensure the hover effect still works nicely with the speaking animation.
 * We'll apply the same transform, but with a higher z-index.
 */
.podcaster.is-speaking:hover {
    transform: translateY(-5px) scale(1.1);
    z-index: 20; /* Higher than the normal hover z-index */
}


/* ==========================================================================
   7. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 950px) {
    .podcast-live-text {
        max-width: 180px; /* Shorter text on medium screens */
    }
}

@media (max-width: 768px) {
    /* On medium screens, stack the left and right columns */
    .podcast-authors-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .podcast-right-side {
        align-items: center;
        width: 100%;
    }
    .podcast-title h3 {
        text-align: center;
    }
    .podcast-live-transcript-container {
        flex-direction: column;
        gap: 5px;
    }
    .podcast-live-text {
        max-width: 100%;
        text-align: center;
    }

    /* Hide publication date on mobile to prevent overlap */
    .podcast-publication-date {
        display: none;
    }
}

@media (max-width: 600px) {
    .podcast-wrapper {
        padding: 20px;
    }
    .podcast-authors {
        gap: 15px; /* Keep gap for mobile, as overlap can be hard to tap */
    }
    /* Reset the overlap on mobile for better usability */
    .podcaster {
        margin-left: 0;
    }
    .podcaster-avatar {
        width: 54px;
        height: 54px;
    }
    .podcast-waveform-container {
        margin: 10px auto 0;
    }

    /* Unified controls - wrap to 2 rows */
    .podcast-unified-controls {
        flex-wrap: wrap;
        padding: 12px 10px;
        gap: 10px;
    }

    /* First row: Play, Time, Volume */
    .waveform-play-pause {
        order: 1;
        width: 36px;
        height: 36px;
    }

    .waveform-play-pause svg {
        width: 18px;
        height: 18px;
    }

    .waveform-time-display {
        order: 2;
        font-size: 0.8em;
        min-width: 80px;
    }

    .waveform-volume-container {
        order: 3;
        margin-left: auto; /* Push to right */
        flex-direction: row; /* Reset to horizontal on mobile */
    }
    
    /* Hide slider wrapper completely on mobile */
    .waveform-volume-slider-wrapper {
        display: none !important;
    }

    .waveform-volume-btn svg {
        width: 16px;
        height: 16px;
    }

    .waveform-volume-slider {
        width: 60px;
    }

    /* Second row: Waveform (full width) */
    .podcast-waveform {
        order: 4;
        width: 100%;
        flex-basis: 100%;
        min-width: 100%;
        height: 60px; /* Slightly taller on mobile */
    }
}

/* ==========================================================================
   8. FOOTER STICKY PLAYER
   ========================================================================== */

/**
 * Fixed footer player that appears when any inline player starts playing.
 * Shows full controls on desktop, simplified on mobile.
 */
.podcast-footer-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #f9cd01;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 9999;
    padding: 15px 20px;
    display: none; /* Hidden by default */
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.podcast-footer-player.visible {
    display: block;
}

.podcast-footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Footer Title Section */
.podcast-footer-title {
    flex-shrink: 0;
    min-width: 200px;
    max-width: 300px;
}

.podcast-footer-title h4 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer Controls Section */
.podcast-footer-controls {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: #fff;
    border-radius: 8px;
    padding: 10px 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Footer Play/Pause Button */
.footer-play-pause {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #333;
    border: none;
    color: #f9cd01;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.footer-play-pause:hover {
    background-color: #555;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.footer-play-pause:active {
    transform: scale(0.95);
}

.footer-play-pause svg {
    width: 20px;
    height: 20px;
}

.footer-pause-icon {
    display: none;
}

/* Footer Time Display */
.footer-time-display {
    flex-shrink: 0;
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
    min-width: 100px;
    text-align: center;
}

/* Footer Waveform */
.podcast-footer-waveform {
    flex: 1;
    height: 50px;
    position: relative;
    background-color: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
    min-width: 200px;
}

.podcast-footer-waveform .static-waveform {
    cursor: pointer;
}

/* Footer Volume Controls */
.footer-volume-container {
    flex-shrink: 0;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    position: relative;
    z-index: 100;
}

.footer-volume-slider-wrapper {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    height: 116px;
    width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0s 0.3s, visibility 0s 0.3s;
    z-index: 101;
    padding: 8px;
    margin-bottom: 0;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.footer-volume-container:hover .footer-volume-slider-wrapper,
.footer-volume-slider-wrapper:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0s, visibility 0s;
}

.footer-volume-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-volume-btn:hover {
    color: #333;
    background-color: #f0f0f0;
}

.footer-volume-btn svg {
    width: 18px;
    height: 18px;
}

.footer-volume-muted-icon {
    display: none;
}

.footer-volume-slider {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    transform: rotate(-90deg);
    transform-origin: center center;
}

.footer-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f9cd01;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.footer-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.footer-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f9cd01;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.footer-volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Mobile Responsive - Footer Player */
@media (max-width: 768px) {
    .podcast-footer-player {
        padding: 12px 15px;
    }
    
    .podcast-footer-content {
        gap: 10px;
    }
    
    .podcast-footer-title {
        flex: 1;
        min-width: 0;
        max-width: none;
        order: 2;
    }
    
    .podcast-footer-title h4 {
        font-size: 0.9em;
    }
    
    .podcast-footer-controls {
        flex: 0 0 auto;
        padding: 0;
        background: none;
        box-shadow: none;
        gap: 0;
        order: 1;
    }
    
    /* Show only play button on mobile */
    .footer-play-pause {
        width: 36px;
        height: 36px;
    }
    
    .footer-play-pause svg {
        width: 18px;
        height: 18px;
    }
    
    /* Hide all other controls on mobile */
    .footer-time-display,
    .podcast-footer-waveform,
    .footer-volume-container {
        display: none !important;
    }
}