/* Persistent audio player bar */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    height: var(--player-height);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform var(--transition-base);
}

.player-bar:not([hidden]) {
    transform: translateY(0);
}

.player-inner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 100%;
}

/* Player info (cover + meta) */
.player-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 0;
    flex: 0 0 200px;
}

.player-cover {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.player-meta {
    min-width: 0;
    flex: 1;
}

.player-title {
    display: block;
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-author {
    display: block;
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    color: rgba(255, 255, 255, 0.8);
    transition: all var(--transition-fast);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.player-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.player-btn--play {
    width: 44px;
    height: 44px;
    background: var(--color-accent);
    color: white;
}

.player-btn--play:hover {
    background: var(--color-accent-hover);
    color: white;
}

/* Loading spinner (hidden by default, shown via .is-loading on button) */
.player-spinner {
    display: none;
    animation: player-spin 0.8s linear infinite;
}

.player-btn--play.is-loading .player-spinner,
.player-expanded-btn--play.is-loading .player-spinner {
    display: block;
}

.player-btn--play.is-loading #icon-play,
.player-btn--play.is-loading #icon-pause,
.player-expanded-btn--play.is-loading .icon-play,
.player-expanded-btn--play.is-loading .icon-pause {
    display: none !important;
}

@keyframes player-spin {
    to { transform: rotate(360deg); }
}

/* Progress bar */
.player-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
}

.player-time {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.6);
    min-width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.player-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    cursor: pointer;
    position: relative;
    outline: none;
}

.player-progress-bar:hover,
.player-progress-bar:focus {
    height: 8px;
}

.player-progress-filled {
    height: 100%;
    background: var(--color-accent);
    border-radius: var(--radius-full);
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

.player-progress-filled::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--color-accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.player-progress-bar:hover .player-progress-filled::after,
.player-progress-bar:focus .player-progress-filled::after {
    opacity: 1;
}

/* Volume */
.player-volume {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.player-volume-bar {
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    cursor: pointer;
    outline: none;
}

.player-volume-bar:hover {
    height: 6px;
}

.player-volume-filled {
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-full);
}

/* Mini player wrapper */
.player-mini {
    position: relative;
    height: 100%;
}

/* Mini progress line (hidden on desktop, shown on mobile via responsive.css) */
.player-mini-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    display: none;
}

.player-mini-progress-fill {
    height: 100%;
    background: var(--color-accent);
    width: 0%;
    transition: width 0.3s linear;
}

/* Expanded view (hidden by default, activated on mobile) */
.player-expanded {
    display: none;
}

/* Speed button */
.player-speed-btn {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    width: auto;
    padding: 0 var(--space-xs);
    letter-spacing: 0.02em;
}

/* Speed menu popup */
.player-speed-menu {
    position: fixed;
    bottom: calc(var(--player-height) + var(--space-sm));
    right: var(--space-lg);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: var(--space-xs);
    display: flex;
    flex-direction: column;
    z-index: 210;
}

.player-speed-menu[hidden] {
    display: none;
}

.player-speed-option {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    background: none;
    color: var(--color-text);
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: center;
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.player-speed-option:hover {
    background: var(--color-surface-alt);
}

.player-speed-option.active {
    color: var(--color-accent);
    font-weight: var(--weight-bold);
}

/* Pages container (horizontal swipe on mobile) */
.player-expanded-pages {
    display: flex;
    width: 200%;
    min-height: 100%;
    transition: transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

.player-expanded-page {
    width: 50%;
    flex-shrink: 0;
}

/* Info panel (hidden on desktop — parent .player-expanded is display:none) */
.player-expanded-info-inner { display: none; }

/* Info panel typography */
.player-info-title { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: var(--leading-tight); margin-bottom: var(--space-xs); }
.player-info-author { font-family: var(--font-heading); font-size: var(--text-sm); color: rgba(255,255,255,0.6); margin-bottom: var(--space-lg); }
.player-info-description { font-size: var(--text-sm); line-height: var(--leading-loose); color: rgba(255,255,255,0.85); }
.player-info-description h3 { font-family: var(--font-heading); font-size: var(--text-base); font-weight: var(--weight-semibold); margin: var(--space-lg) 0 var(--space-sm); color: rgba(255,255,255,0.95); }
.player-info-description h3:first-child { margin-top: 0; }
.player-info-description strong { font-weight: var(--weight-semibold); color: rgba(255,255,255,0.95); }
.player-info-description a { color: var(--color-accent); text-decoration: underline; }
.player-info-description ul { padding-left: var(--space-lg); margin: var(--space-sm) 0; }
.player-info-description li { margin-bottom: var(--space-xs); }

/* Dot indicators (hidden on desktop, shown on mobile) */
.player-expanded-dots { display: none; }
.player-expanded-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.3); transition: background var(--transition-fast); }
.player-expanded-dot.active { background: rgba(255,255,255,0.8); }

/* Mini player chapter subtitle */
.player-chapter-subtitle {
    display: none;
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Expanded player chapter label (counter: "Ch. X of Y") */
.player-expanded-chapter-label {
    display: none;
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* Expanded player chapter title */
.player-expanded-chapter-title {
    display: none;
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

/* Chapter navigation buttons (hidden by default until chapters loaded) */
.player-expanded-btn--ch {
    width: 40px;
    height: 40px;
}

.player-expanded-btn--ch[hidden] {
    display: none;
}

/* Expanded player chapters page (hidden by default) */
.player-expanded-page--chapters { display: none; }
.player-expanded-chapters-inner { display: none; }

/* Chapters list in expanded player */
.player-chapters-list {
    display: flex;
    flex-direction: column;
}

.player-chapter-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background var(--transition-fast);
    width: 100%;
}

.player-chapter-row:hover,
.player-chapter-row:active {
    background: rgba(255, 255, 255, 0.06);
}

.player-chapter-row--playing {
    color: var(--color-accent);
}

.player-chapter-row__number {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.player-chapter-row__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-chapter-row__duration {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    flex-shrink: 0;
    opacity: 0.6;
}

.player-chapter-row__playing-indicator {
    flex-shrink: 0;
    font-size: var(--text-xs);
    color: var(--color-accent);
}

/* Sleep menu popup (mirrors speed menu styling) */
.player-sleep-menu {
    position: fixed;
    bottom: calc(var(--player-height) + var(--space-sm));
    right: var(--space-lg);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: var(--space-xs);
    display: flex;
    flex-direction: column;
    z-index: 210;
}

.player-sleep-menu[hidden] {
    display: none;
}

.player-sleep-option {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    background: none;
    color: var(--color-text);
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: center;
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.player-sleep-option:hover {
    background: var(--color-surface-alt);
}

.player-sleep-option--off {
    color: var(--color-accent);
    font-weight: var(--weight-bold);
}

.player-sleep-custom {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
}

.player-sleep-custom-input {
    width: 60px;
    padding: var(--space-xs);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    background: var(--color-bg-alt);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    text-align: center;
    -moz-appearance: textfield;
}

.player-sleep-custom-input::-webkit-inner-spin-button,
.player-sleep-custom-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.player-sleep-custom-set {
    padding: var(--space-xs) var(--space-sm);
    border: none;
    background: var(--color-accent);
    color: white;
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.player-sleep-custom-set:hover {
    background: var(--color-accent-hover);
}

/* Bottom row for speed + sleep buttons (hidden on desktop, shown on mobile) */
.player-expanded-bottom-row {
    display: none;
}

/* Desktop seek bar hit area enhancement */
.player-progress-bar::before {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: 0;
    right: 0;
}
