/**
 * RSite — Audio Player Component  v3.0
 * Depends on: base.css (variables, glass-card)
 *
 * Discipline over decoration.
 * One accent (play), one animation (pulse on playing),
 * clear hierarchy: play → progress → everything else.
 */

/*  CHAPTER NAVBAR (MAIN CONTAINER)  */

.chapter-navbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: min(87%, calc(1100px * 0.87));
    z-index: 100;
    padding: var(--space-md) var(--space-md) var(--space-sm);
    border-radius: var(--radius-lg);
    /* display: flex; */
    flex-direction: column;
    gap: 0;

    /* Matte Plastic Customization for Navbar */
    --plastic-border: rgba(212, 175, 55, 0.18);
    --plastic-border-hover: rgba(212, 175, 55, 0.3);

    /* Hide/show animation */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-navbar.navbar-hidden {
    transform: translateX(-50%) translateY(calc(100% + 32px));
    opacity: 0;
    pointer-events: none;
}

.chapter-navbar.expanded {
    gap: var(--space-md);
}

/* ── Golden Progress Line ── */

.chapter-progress-line {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.01);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show golden line only when playing AND player is NOT expanded */
.chapter-navbar.playing:not(.expanded) .chapter-progress-line {
    opacity: 1;
}

.chapter-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg,
            var(--gold-dark) 0%,
            var(--gold-accent) 100%);
    transition: width 0.1s linear;
    position: relative;
}

/* Subtle pulse on the progress fill */
.chapter-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(212, 175, 55, 0.3),
            transparent);
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes nav-arrow-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
    }

    50% {
        box-shadow: 0 0 10px 2px rgba(212, 175, 55, 0.2);
    }
}

/* Subtle top-edge highlight — just a hint of glass glint */
.chapter-navbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(212, 175, 55, 0.22) 50%,
            transparent);
    pointer-events: none;
    border-radius: var(--radius-full);
}

/* 
   CHAPTER NAVIGATION (ROW)
*/

.chapter-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 7px;
}

/* ── Prev / Next arrow buttons ── */

.audio-nav-btn {
    position: relative;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.audio-nav-btn:hover:not(.disabled) {
    background: rgba(212, 175, 55, 0.07);
    border-color: rgba(212, 175, 55, 0.25);
    color: var(--gold-accent);
    animation: nav-arrow-pulse 1.2s ease-in-out infinite;
}

/* hover-wut effect for audio-nav-btn */
.audio-nav-btn.hover-wut:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.015);
    border-color: transparent;
    animation: hover-wut-main 1.5s ease-in-out infinite;
}

.audio-nav-btn.hover-wut:hover:not(.disabled)::before {
    background: rgba(255, 255, 255, 0.02);
    opacity: 0.45;
}

.audio-nav-btn.hover-wut:hover:not(.disabled)::after {
    background: rgba(255, 255, 255, 0.015);
    opacity: 0.4;
}

.audio-nav-btn:active:not(.disabled) {
    opacity: 0.7;
}

.audio-nav-btn.disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Play button in navbar (secondary) ── */

.chapter-nav-play-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: var(--gold-accent);
    order: -1;
    margin-right: 8px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.chapter-nav-play-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.4);
    transform: scale(1.05);
}

.chapter-nav-play-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Playing state - sync with audio-toggle */
.chapter-nav-play-btn.playing {
    background: transparent;
    border-color: rgba(212, 175, 55, 0.5);
}

/* Hide nav play button when player is expanded */
.chapter-navbar.expanded .chapter-nav-play-btn {
    display: none;
}

/* ── Audio player expansion states ── */

#audio-player-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-navbar.expanded #audio-player-wrapper {
    grid-template-rows: 1fr;
}

#audio-player {
    overflow: hidden;
    min-height: 0;
}

.chapter-navbar.expanded #audio-player {
    overflow: visible;
}

/* ── Settings button in navbar ── */

.chapter-nav-settings-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.chapter-nav-settings-btn:hover {
    color: var(--text-secondary);
    border-color: var(--glass-border-hover);
    background: rgba(255, 255, 255, 0.04);
    opacity: 0.8;
}

.chapter-nav-settings-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Chapter select dropdown ── */

.audio-chapter-select-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    margin: 0 var(--space-sm);
}

/* 
   CONTROLS ROW
*/

.audio-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* ── Secondary Controls (right zone) ── */

.audio-secondary-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* ── Play / Pause — the ONE accent element ── */

.audio-toggle {
    position: relative;
    overflow: visible;
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    min-width: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.16) 0%,
            rgba(212, 175, 55, 0.06) 100%);
    border: 1.5px solid rgba(212, 175, 55, 0.35);
    color: var(--gold-accent);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.audio-toggle:hover {
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.24) 0%,
            rgba(212, 175, 55, 0.1) 100%);
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.16);
}

.audio-toggle:active {
    transform: scale(0.94);
}

.audio-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Playing state — JS adds .playing to #audio-toggle */
#audio-toggle.playing {
    background: transparent;
    border-color: rgba(212, 175, 55, 0.5);
}

/* Pulse animation via ::after - entire button pulses */
#audio-toggle.playing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    border-radius: 50%;
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.16) 0%,
            rgba(212, 175, 55, 0.06) 100%);
    border: 1.5px solid rgba(212, 175, 55, 0.35);
    animation: pulse-scale 0.4s ease infinite alternate;
    z-index: -1;
}

@keyframes pulse-scale {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 2px rgba(212, 175, 55, 0.2);
        border-radius: 50%;
    }

    100% {
        transform: scale(1.05);
        box-shadow: 0 2px 2px rgba(212, 175, 55, 0.2);
        border-radius: 45%;
    }
}

/* ── Autoplay — secondary, quiet by default ── */

.autoplay-btn {
    position: relative;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition:
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        background var(--duration-fast) ease,
        opacity var(--duration-fast) ease;
}

.autoplay-btn:hover {
    color: var(--text-secondary);
    border-color: var(--glass-border-hover);
    background: rgba(255, 255, 255, 0.04);
    opacity: 0.8;
}

.autoplay-btn.active {
    color: var(--gold-accent);
    border-color: rgba(212, 175, 55, 0.4);
    background: rgba(212, 175, 55, 0.08);
}

/* Blink animation via ::after - more intense */
.autoplay-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    border-radius: inherit;
    background: rgba(212, 175, 55, 0.15);
    animation: blink-opacity 1s ease-in-out infinite;
    z-index: -1;
}

@keyframes blink-opacity {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

/* ── Speed Toggle — pill style ── */

.speed-btn {
    flex-shrink: 0;
    min-width: 50px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition:
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        background var(--duration-fast) ease,
        opacity var(--duration-fast) ease;
}

.speed-btn:hover {
    color: var(--gold-accent);
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(0, 0, 0, 0.35);
    opacity: 0.8;
}

#speed-display {
    line-height: 1;
}

/* ── Volume Control ── */

.volume-control-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(212, 175, 55, 0.15);
    color: var(--text-muted);
    cursor: pointer;
    transition:
        color var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        background var(--duration-fast) ease;
}

.volume-btn:hover {
    color: var(--gold-accent);
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

.volume-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Volume slider popup — fixed + DOM teleport to body */
.volume-slider-container {
    position: fixed;
    width: 36px;
    height: 130px;
    padding: var(--space-md) var(--space-sm);
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(7px) brightness(115%) contrast(85%) saturate(70%);
    -webkit-backdrop-filter: blur(7px) brightness(115%) contrast(85%) saturate(70%);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 4px rgba(255, 255, 255, 0.05);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.volume-slider-container.active {
    display: flex;
}

/* Vertical slider — track */
.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    outline: none;
    transform: rotate(-90deg);
    cursor: pointer;
}

/* Thumb — webkit */
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--gold-accent);
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 8px rgba(212, 175, 55, 0.3);
    transition: box-shadow var(--duration-fast) ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 12px rgba(212, 175, 55, 0.5);
}

/* Thumb — firefox */
.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--gold-accent);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 8px rgba(212, 175, 55, 0.3);
}

.volume-slider::-moz-range-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    height: 4px;
}

/* 
   HOVER-WUT EFFECT FOR AUDIO BUTTONS
*/

/* Play button - hover-wut when NOT playing */
#audio-toggle.hover-wut:hover:not(.playing) {
    border-color: transparent;
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.08) 0%,
            rgba(212, 175, 55, 0.03) 100%);
    animation: hover-wut-main 1.5s ease-in-out infinite;
}

#audio-toggle.hover-wut:hover:not(.playing)::before {
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.1) 0%,
            rgba(212, 175, 55, 0.04) 100%);
    opacity: 0.5;
}

#audio-toggle.hover-wut:hover:not(.playing)::after {
    background: linear-gradient(135deg,
            rgba(212, 175, 55, 0.07) 0%,
            rgba(212, 175, 55, 0.02) 100%);
    opacity: 0.45;
}

/* Autoplay button - hover-wut when NOT active */
.audio-toggle.autoplay-btn.hover-wut:hover:not(.active) {
    border-color: transparent;
    background: rgba(212, 175, 55, 0.05);
    animation: hover-wut-main 1.5s ease-in-out infinite;
}

.audio-toggle.autoplay-btn.hover-wut:hover:not(.active)::before {
    background: rgba(212, 175, 55, 0.06);
    opacity: 0.45;
}

.audio-toggle.autoplay-btn.hover-wut:hover:not(.active)::after {
    background: rgba(212, 175, 55, 0.04);
    opacity: 0.4;
}

/* 
   PROGRESS BAR
*/

.audio-progress-wrapper {
    flex: 1;
    min-width: 0;
}

.audio-time-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-family: var(--font-mono);
    font-size: 0.72em;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Track */
#audio-progress-container {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: height var(--duration-fast) ease;
}

#audio-progress-container:hover {
    height: 6px;
}

/* Fill */
#audio-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg,
            var(--gold-dark) 0%,
            var(--gold-accent) 100%);
    border-radius: var(--radius-full);
    transition: width 0.05s linear;
    position: relative;
}

/* Thumb — appears on hover, no glow circus */
#audio-progress::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--gold-accent);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 2px rgba(10, 10, 20, 0.85);
    opacity: 0;
    transition: opacity var(--duration-fast) ease;
}

#audio-progress-container:hover #audio-progress::after,
#audio-progress-container.dragging #audio-progress::after {
    opacity: 1;
}

/* Dragging state */
#audio-progress-container.dragging {
    cursor: grabbing;
}

#audio-progress-container.dragging #audio-progress {
    transition: none;
}

/* 
   AUDIO MARKERS LIST
*/

.audio-markers-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.audio-marker-item {
    margin: var(--space-sm) 0;
}

.audio-marker-btn {
    width: 100%;
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9em;
    transition:
        background var(--duration-fast) ease,
        border-color var(--duration-fast) ease,
        color var(--duration-fast) ease;
}

.audio-marker-btn:hover {
    background: rgba(212, 175, 55, 0.06);
    border-color: rgba(212, 175, 55, 0.18);
    color: var(--gold-accent);
}

.audio-marker-btn svg {
    flex-shrink: 0;
    opacity: 0.5;
}

/* Settings panel styles → see settings-panel.css */

/*
   RESPONSIVE
*/

@media (max-width: 768px) {
    .chapter-navbar {
        padding: var(--space-sm) var(--space-sm) 1px;
        bottom: var(--space-md);
        width: calc(100% - 16px);
        border-radius: var(--radius-md);
    }

    .audio-chapter-select {
        font-size: 0.88em;
    }

    .audio-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .autoplay-btn,
    .volume-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .chapter-nav-play-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .chapter-nav-settings-btn {
        width: 32px;
        height: 32px;
    }

    .speed-btn {
        min-width: 46px;
        padding: 7px 10px;
        font-size: 0.85em;
    }

    .audio-time-display {
        font-size: 0.68em;
    }

    .dropdown-text {
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.88em;
    }

    /* Settings panel mobile */
    .settings-panel:not(.active) .settings-panel-inner {
        padding: 0;
    }

    .settings-panel.active .settings-panel-inner {
        padding: 14px 16px 10px;
    }

    .settings-font-card {
        padding: 10px 4px;
        min-height: 48px;
    }

    .settings-theme-card {
        padding: 8px 4px;
        min-height: 48px;
    }

    .settings-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .settings-slider::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .audio-controls {
        gap: var(--space-sm);
        flex-wrap: wrap;
    }

    .audio-toggle {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .autoplay-btn,
    .volume-btn,
    .chapter-nav-play-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .chapter-nav-settings-btn {
        width: 30px;
        height: 30px;
    }

    .audio-toggle svg,
    .autoplay-btn svg,
    .volume-btn svg,
    .chapter-nav-play-btn svg,
    .chapter-nav-settings-btn svg {
        width: 16px;
        height: 16px;
    }

    .speed-btn {
        min-width: 42px;
        padding: 6px 9px;
        font-size: 0.8em;
    }

    .audio-secondary-controls {
        gap: var(--space-xs);
    }
}