/*
 * Aureum Luxury Editorial Layer
 *
 * This file is intentionally a visual override layer. It keeps the existing
 * DOM contract and theme variables intact while replacing the louder
 * gradients/glows with a quieter editorial hierarchy.
 */
:root {
    --luxury-ink: var(--theme-bg, #0B0A08);
    --luxury-surface: var(--theme-surface, #14120F);
    --luxury-raised: var(--theme-surface-high, #1C1915);
    --luxury-ivory: var(--theme-text, #F3EEE6);
    --luxury-reading: var(--theme-text-reading, #E7DED2);
    --luxury-muted: var(--theme-text-muted, #9B9185);
    --luxury-champagne: var(--theme-primary, #C8A873);
    --luxury-line: color-mix(in srgb, var(--theme-text, #F3EEE6) 12%, transparent);
    --luxury-shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
}

html,
body {
    background: var(--theme-bg, var(--luxury-ink));
}

body {
    background-image:
        radial-gradient(circle at 76% -12%, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 7%, transparent), transparent 34rem),
        radial-gradient(circle at 12% 110%, rgba(255, 255, 255, 0.025), transparent 30rem);
    color: var(--theme-text, var(--luxury-ivory));
}

nav {
    background: color-mix(in srgb, var(--theme-bg, var(--luxury-ink)) 92%, transparent) !important;
    border-bottom: 1px solid color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 11%, transparent) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

/* One restrained brand mark instead of a wall of gold glow. */
#logo-btn > div:first-child {
    width: 2.75rem !important;
    height: 2.75rem !important;
    border-radius: 0.85rem !important;
    background: linear-gradient(145deg, var(--theme-surface-high, var(--luxury-raised)), var(--theme-surface, var(--luxury-ink))) !important;
    background-image: linear-gradient(145deg, var(--theme-surface-high, var(--luxury-raised)), var(--theme-surface, var(--luxury-ink))) !important;
    border-color: var(--theme-glass-border, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 42%, transparent)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 14px rgba(0,0,0,0.12) !important;
    color: var(--theme-primary) !important;
}

#logo-btn > div:first-child i {
    color: var(--theme-primary) !important;
}

/* Header buttons dynamic theme styling */
#quick-settings-btn,
#stats-toggle-btn {
    background: linear-gradient(145deg, var(--theme-surface-high, var(--luxury-raised)), var(--theme-surface, var(--luxury-surface))) !important;
    background-image: linear-gradient(145deg, var(--theme-surface-high, var(--luxury-raised)), var(--theme-surface, var(--luxury-surface))) !important;
    border-color: var(--theme-glass-border, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 32%, transparent)) !important;
    color: var(--theme-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

#quick-settings-btn i,
#stats-toggle-btn i {
    color: var(--theme-primary) !important;
}

#logo-btn h1 {
    font-family: "Playfair Display", "Be Vietnam Pro", Georgia, serif !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em !important;
}

#logo-btn span {
    color: var(--theme-text-muted, var(--luxury-muted)) !important;
    letter-spacing: 0.2em !important;
}

.glass {
    background: color-mix(in srgb, var(--theme-surface, var(--luxury-surface)) 94%, transparent) !important;
    border-color: color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 11%, transparent) !important;
    box-shadow: none;
}

.btn-primary {
    background: var(--theme-primary, var(--luxury-champagne)) !important;
    border: 1px solid color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 72%, white) !important;
    border-radius: 0.8rem !important;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 16%, transparent) !important;
    font-weight: 700 !important;
}

.btn-primary:hover {
    box-shadow: 0 12px 28px color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 24%, transparent) !important;
}

/* Discovery: make the library feel like a curated collection. */
#discovery-mode {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--theme-bg, var(--luxury-ink)) 82%, transparent), var(--theme-bg, var(--luxury-ink)) 30%),
        var(--theme-bg, var(--luxury-ink)) !important;
}

#discovery-mode::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.42;
    background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 10%, transparent), transparent 32rem);
}

#discovery-mode > * {
    position: relative;
    z-index: 1;
}

#discovery-mode > div:first-child {
    padding-top: clamp(3rem, 9vh, 7rem) !important;
}

#discovery-mode h1 {
    max-width: 48rem;
    font-family: "Playfair Display", "Be Vietnam Pro", Georgia, serif !important;
    font-size: clamp(2.25rem, 5vw, 4.75rem) !important;
    font-weight: 500 !important;
    letter-spacing: -0.035em !important;
    line-height: 0.98 !important;
    text-shadow: none !important;
}

#discovery-mode > div:first-child > p {
    color: var(--theme-text-muted, var(--luxury-muted)) !important;
    font-family: "Be Vietnam Pro", sans-serif !important;
    font-size: 0.68rem !important;
    font-style: normal !important;
    letter-spacing: 0.19em !important;
    text-transform: uppercase;
}

#discovery-search {
    min-height: 3.25rem;
    border-radius: 0.9rem !important;
    background: color-mix(in srgb, var(--theme-surface, var(--luxury-surface)) 96%, transparent) !important;
    border-color: color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 14%, transparent) !important;
    box-shadow: var(--luxury-shadow) !important;
}

#discovery-search:focus {
    border-color: color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 72%, transparent) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 9%, transparent), var(--luxury-shadow) !important;
}

#discovery-continue-card {
    border-radius: 1.35rem !important;
    background: linear-gradient(135deg, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 9%, var(--theme-surface, var(--luxury-surface))), var(--theme-surface, var(--luxury-surface))) !important;
    border-color: color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 28%, transparent) !important;
    box-shadow: var(--luxury-shadow) !important;
}

#discovery-mode h2 {
    font-family: "Playfair Display", "Be Vietnam Pro", Georgia, serif !important;
    font-weight: 600 !important;
    letter-spacing: -0.015em;
}

.discovery-book-card {
    min-height: 19rem !important;
    border-radius: 1.15rem !important;
    background: linear-gradient(160deg, var(--theme-surface-high, var(--luxury-raised)), var(--theme-surface, var(--luxury-ink))) !important;
    border: 1px solid color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 13%, transparent) !important;
    box-shadow: 0 14px 34px rgba(0,0,0,0.16) !important;
}

.discovery-book-card:hover {
    border-color: color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 55%, transparent) !important;
    box-shadow: 0 22px 44px rgba(0,0,0,0.38) !important;
}

.discovery-book-card::before {
    width: 4px !important;
    opacity: 0.55;
    background: var(--theme-primary, var(--luxury-champagne)) !important;
    border-right: 0 !important;
}

.discovery-book-art {
    border-top-left-radius: 1.15rem !important;
    border-top-right-radius: 1.15rem !important;
}

.discovery-book-card .discovery-book-title {
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-shadow: none !important;
}

.discovery-book-card:hover .discovery-book-title {
    color: var(--theme-text, var(--luxury-ivory)) !important;
    text-shadow: none !important;
}

.discovery-book-card .discovery-book-meta {
    color: var(--theme-text-muted, var(--luxury-muted)) !important;
    text-shadow: none !important;
}

/* Reader: long-form text gets a calm, book-like measure and rhythm. */
#reader-container {
    border-radius: 1.35rem !important;
    border: 1px solid color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 12%, transparent) !important;
    box-shadow: var(--luxury-shadow) !important;
}

#reader-header {
    background: color-mix(in srgb, var(--theme-surface, var(--luxury-surface)) 72%, transparent) !important;
}

#current-title {
    font-family: "Playfair Display", "Be Vietnam Pro", Georgia, serif !important;
    font-weight: 600 !important;
    letter-spacing: -0.02em !important;
}

#text-container {
    background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 4%, transparent), transparent 32rem);
    padding-top: clamp(2rem, 6vh, 5rem) !important;
}

#text-container .chunk-text {
    width: min(100%, 68ch) !important;
    margin-inline: auto !important;
    margin-bottom: 1.15rem !important;
    padding: 0.7rem 1rem 0.7rem 1.15rem !important;
    border-left: 2px solid transparent !important;
    border-radius: 0 0.75rem 0.75rem 0 !important;
    color: var(--reader-text-color, var(--luxury-reading)) !important;
    line-height: 1.78 !important;
}

#text-container .chunk-active {
    background: var(--theme-active-chunk-bg, linear-gradient(90deg, color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 10%, transparent), transparent 75%)) !important;
    border-left: var(--theme-active-chunk-border, 3px solid var(--theme-primary, var(--luxury-champagne))) !important;
    box-shadow: var(--theme-active-chunk-shadow, none) !important;
    border-radius: var(--theme-active-chunk-radius, 0 0.75rem 0.75rem 0) !important;
    filter: none;
}

/* Desktop reading expands to full width with comfortable padding */
@media (min-width: 1024px) {
    #text-container {
        padding-top: clamp(1.25rem, 2.5vh, 2.5rem) !important;
        padding-left: clamp(1.25rem, 2.5vw, 2.5rem) !important;
        padding-right: clamp(2rem, 3.5vw, 4rem) !important;
        max-width: none !important;
    }

    #text-container .chunk-text,
    .reader-copy {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 0.8rem !important;
        padding-top: 0.45rem !important;
        padding-bottom: 0.45rem !important;
    }
}

/* Player: a quiet, high-end audio object. */
#media-player {
    border-radius: 1.35rem !important;
    background: linear-gradient(135deg, color-mix(in srgb, var(--theme-surface, var(--luxury-surface)) 98%, white), var(--theme-surface, var(--luxury-surface))) !important;
    border-color: color-mix(in srgb, var(--theme-text, var(--luxury-ivory)) 15%, transparent) !important;
    box-shadow: 0 22px 52px rgba(0,0,0,0.42) !important;
}

#media-player #play-btn,
#media-player .horlogerie-dial {
    background: var(--theme-primary, var(--luxury-champagne)) !important;
    border: 1px solid color-mix(in srgb, var(--theme-primary, var(--luxury-champagne)) 42%, transparent) !important;
    box-shadow: 0 10px 24px rgba(0,0,0,0.20) !important;
    color: #FFFFFF !important;
}

#media-player #play-btn i {
    color: #FFFFFF !important;
}

#media-player #play-btn:hover,
#media-player .horlogerie-dial:hover {
    box-shadow: 0 14px 30px rgba(0,0,0,0.30) !important;
    transform: scale(1.04);
}

#media-player #player-title {
    font-weight: 600 !important;
}

#media-player #player-author {
    color: var(--theme-text-muted, var(--luxury-muted)) !important;
}

#media-player-shell.player-discovery-dock #media-player {
    border-radius: 1.2rem !important;
}

/* Floating centered luxury player bar */
#media-player-shell:not(.player-discovery-dock) {
    position: absolute !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    pointer-events: none !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    padding-inline: 1rem !important;
    z-index: 70 !important;
}

#media-player-shell:not(.player-discovery-dock) #media-player:not(.minimized-player) {
    pointer-events: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    max-width: min(100%, 72rem) !important;
    border-radius: 1.25rem !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 20px -2px color-mix(in srgb, var(--theme-primary, #D4AF37) 15%, transparent) !important;
}

#media-player-shell:not(.player-discovery-dock) #media-player.minimized-player {
    pointer-events: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Hide redundant scrollbar inside text reading area */
#text-container,
.hide-scrollbar {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}
#text-container::-webkit-scrollbar,
.hide-scrollbar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Motion guardrails: keep state cues, remove decorative infinite glow. */
.glow-pulse::before {
    animation: none !important;
    box-shadow: none !important;
}

.animate-spin-slow {
    animation-duration: 7s !important;
}

.audio-wave-bars.is-playing .audio-wave-bar {
    animation: none !important;
    transform-origin: center center;
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

@media (max-width: 640px) {
    #discovery-mode > div:first-child {
        padding-top: 2.25rem !important;
    }

    #discovery-mode h1 {
        font-size: clamp(2rem, 11vw, 3rem) !important;
    }

    .discovery-book-card {
        min-height: 15.5rem !important;
    }

    #text-container .chunk-text {
        padding-left: 0.85rem !important;
        padding-right: 0.35rem !important;
    }

    #media-player {
        border-radius: 1.15rem !important;
    }
}
