/**
 * NewsFlow Immersive Story Mode & Digital Magazine Design System
 * Supports category-specific themes: Gothic & Halloween, Fantasy & Mythology,
 * Mystery & Folklore, History & Culture, and Entertainment VIP.
 * Fonts loaded via preconnected <link> in HTML <head> for Core Web Vitals optimization.
 */

:root {
    --mag-font-gothic: 'Cinzel', 'Playfair Display', Georgia, serif;
    --mag-font-literary: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    --mag-font-editorial: 'Playfair Display', Georgia, serif;
    --mag-font-body: 'Source Sans 3', 'Inter', -apple-system, sans-serif;
    --mag-bg-default: #0c0f17;
    --mag-surface-default: #141b26;
    --mag-text-default: #f1f5f9;
    --mag-accent-default: #d97706;
}

/* ==========================================================================
   THEME 1: Gothic & Halloween (Deep charcoal, midnight purple, muted orange, antique gold)
   ========================================================================== */
.theme-gothic-halloween, .gothic_halloween {
    --mag-bg: #0b0813;
    --mag-surface: #140d24;
    --mag-card: #1c1333;
    --mag-border: rgba(217, 119, 6, 0.25);
    --mag-accent: #ea580c;
    --mag-gold: #eab308;
    --mag-text: #f5f3ff;
    --mag-text-muted: #c4b5fd;
    --mag-heading-font: var(--mag-font-gothic);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

.theme-gothic-halloween .mag-glow, .gothic_halloween .mag-glow {
    box-shadow: 0 0 35px rgba(234, 88, 12, 0.15);
}

.theme-gothic-halloween .mag-hero-border, .gothic_halloween .mag-hero-border {
    border: 1px solid rgba(234, 88, 12, 0.3);
}

/* ==========================================================================
   THEME 2: Fantasy & Mythology (Rich jewel sapphire, emerald, gold, parchment)
   ========================================================================== */
.theme-fantasy-myth, .fantasy_myth {
    --mag-bg: #06151f;
    --mag-surface: #0a2233;
    --mag-card: #0f3047;
    --mag-border: rgba(202, 138, 4, 0.3);
    --mag-accent: #059669;
    --mag-gold: #ca8a04;
    --mag-text: #f0fdfa;
    --mag-text-muted: #99f6e4;
    --mag-heading-font: var(--mag-font-literary);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

/* ==========================================================================
   THEME 3: Mystery & Folklore (Archival paper, sepia, evidence cards, dark slate)
   ========================================================================== */
.theme-mystery-folklore, .mystery_folklore {
    --mag-bg: #0f141c;
    --mag-surface: #16202c;
    --mag-card: #1e2b3b;
    --mag-border: rgba(148, 163, 184, 0.25);
    --mag-accent: #38bdf8;
    --mag-gold: #f59e0b;
    --mag-text: #f8fafc;
    --mag-text-muted: #94a3b8;
    --mag-heading-font: var(--mag-font-editorial);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

/* ==========================================================================
   THEME 4: History & Culture (Museum ivory & deep bronze slate)
   ========================================================================== */
.theme-history-culture, .history_culture {
    --mag-bg: #111417;
    --mag-surface: #1b2126;
    --mag-card: #252d34;
    --mag-border: rgba(217, 119, 6, 0.25);
    --mag-accent: #d97706;
    --mag-gold: #b45309;
    --mag-text: #fbfbf9;
    --mag-text-muted: #cbd5e1;
    --mag-heading-font: var(--mag-font-editorial);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

/* ==========================================================================
   THEME 5: Entertainment & Celebrity (VIP Cinema Noir, Gold, Electric Magenta)
   ========================================================================== */
.theme-entertainment-vip, .entertainment_vip {
    --mag-bg: #09090b;
    --mag-surface: #18181b;
    --mag-card: #27272a;
    --mag-border: rgba(234, 179, 8, 0.3);
    --mag-accent: #db2777;
    --mag-gold: #eab308;
    --mag-text: #fafafa;
    --mag-text-muted: #a1a1aa;
    --mag-heading-font: var(--mag-font-editorial);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

/* ==========================================================================
   THEME 6: Classic Editorial (Prestige Magazine)
   ========================================================================== */
.theme-classic-editorial, .classic_editorial {
    --mag-bg: #0f172a;
    --mag-surface: #1e293b;
    --mag-card: #334155;
    --mag-border: rgba(255, 255, 255, 0.1);
    --mag-accent: #3b82f6;
    --mag-gold: #fbbf24;
    --mag-text: #f8fafc;
    --mag-text-muted: #94a3b8;
    --mag-heading-font: var(--mag-font-editorial);
    background-color: var(--mag-bg);
    color: var(--mag-text);
}

/* Base Magazine Shell */
.magazine-shell {
    min-height: 100vh;
    font-family: var(--mag-font-body);
    transition: background-color 0.4s ease, color 0.4s ease;
}

.mag-title {
    font-family: var(--mag-heading-font, var(--mag-font-editorial));
    letter-spacing: -0.015em;
    line-height: 1.15;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Drop cap for magazine articles */
.mag-drop-cap::first-letter {
    font-family: var(--mag-heading-font, Georgia);
    float: left;
    font-size: 4.85rem;
    line-height: 0.8;
    padding-top: 6px;
    padding-right: 14px;
    padding-bottom: 2px;
    color: var(--mag-gold, #eab308);
    font-weight: 700;
}

/* Decorative divider */
.mag-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2.5rem 0;
    color: var(--mag-gold, #eab308);
    font-size: 1.25rem;
    opacity: 0.75;
}
.mag-divider::before,
.mag-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--mag-border, rgba(255,255,255,0.15));
    margin: 0 1rem;
}

/* Magazine Pull Quotes */
.mag-pull-quote {
    position: relative;
    padding: 2.25rem 2.5rem;
    margin: 3rem 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
    border-left: 4px solid var(--mag-accent, #eab308);
    border-radius: 0 1rem 1rem 0;
}
.mag-pull-quote p {
    font-family: var(--mag-heading-font, Georgia);
    font-size: 1.5rem;
    line-height: 1.45;
    font-style: italic;
    color: #ffffff;
    margin: 0;
}
.mag-pull-quote cite {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--mag-gold, #eab308);
    font-weight: 600;
}

/* Archival Dossier Context Card */
.mag-dossier-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--mag-border, rgba(255, 255, 255, 0.15));
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin: 2rem 0;
    backdrop-filter: blur(8px);
}

/* Sticky Reading Progress Indicator */
#magazine-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #ea580c, #eab308, #3b82f6);
    width: 0%;
    z-index: 100;
    transition: width 0.1s ease-out;
}

/* Mode Switcher Header Pill */
.mode-switcher-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    background: #020617;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    white-space: nowrap;
}
.mode-switcher-btn {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 9999px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    line-height: 1;
}
@media (max-width: 639px) {
    .mode-switcher-btn {
        padding: 5px 8px;
        font-size: 10px;
        gap: 3px;
    }
}
.mode-switcher-btn.active {
    background: linear-gradient(135deg, #003399 0%, #1e3a8a 100%);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.mode-switcher-btn.magazine-active {
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    color: #020617;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}
.mode-switcher-btn.inactive {
    color: #94a3b8;
}
.mode-switcher-btn.inactive:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   CLASSIC WARM LIVING LIGHT FLOW SYSTEM (Live Website Warm Lighting)
   ========================================================================== */

/* Live Flow Toggle Button in Header */
.mag-live-flow-btn {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
}
.mag-live-flow-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
    color: #fef08a;
}
.mag-live-flow-btn.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.28) 0%, rgba(217, 119, 6, 0.38) 100%);
    border-color: #f59e0b;
    color: #fffbeb;
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.mag-live-flow-btn.inactive {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    box-shadow: none;
}

.mag-flow-state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
    display: inline-block;
    transition: all 0.25s ease;
}
.mag-live-flow-btn.active .mag-flow-state-dot {
    animation: magWarmPulse 2s ease-in-out infinite;
}
.mag-live-flow-btn.inactive .mag-flow-state-dot {
    background-color: #64748b;
    box-shadow: none;
    animation: none;
}

@keyframes magWarmPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.85;
        box-shadow: 0 0 6px #f59e0b;
    }
    50% {
        transform: scale(1.35);
        opacity: 1;
        box-shadow: 0 0 14px #fbbf24;
    }
}

/* Living Warm Light Atmosphere Backdrop */
.mag-living-light-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

body.live-light-flow .mag-living-light-backdrop {
    opacity: 0.95;
}

.mag-light-orb {
    position: absolute;
    border-radius: 9999px;
    mix-blend-mode: screen;
    pointer-events: none;
    will-change: transform, opacity;
}

/* Warm Flow Orb 1: Golden Hearth Amber */
.mag-light-solar {
    width: 760px;
    height: 760px;
    top: -150px;
    left: -100px;
    filter: blur(105px);
    animation: magWarmFlowSolar 24s ease-in-out infinite alternate;
}

/* Warm Flow Orb 2: Candlelight Honey Ember */
.mag-light-twilight {
    width: 820px;
    height: 820px;
    bottom: -150px;
    right: -120px;
    filter: blur(125px);
    animation: magWarmFlowTwilight 28s ease-in-out infinite alternate;
}

/* Warm Flow Orb 3: Velvet Champagne Veil */
.mag-light-aurora {
    width: 920px;
    height: 520px;
    top: 20%;
    left: 10%;
    filter: blur(115px);
    animation: magWarmFlowVeil 20s ease-in-out infinite alternate;
}

/* Interactive Ambient Warm Spotlight (Follows cursor smoothly or gently drifts) */
.mag-interactive-spotlight {
    position: fixed;
    width: 620px;
    height: 620px;
    top: 0;
    left: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    mix-blend-mode: screen;
    filter: blur(80px);
    background: radial-gradient(circle, rgba(251, 191, 36, 0.16) 0%, rgba(245, 158, 11, 0.08) 35%, rgba(217, 119, 6, 0.02) 60%, transparent 75%);
    opacity: 0;
    z-index: 2;
    transition: opacity 0.6s ease;
    will-change: transform, left, top;
}

body.live-light-flow .mag-interactive-spotlight {
    opacity: 0.9;
}

/* Ambient contrast protection mesh */
.mag-ambient-mesh {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, transparent 60%, rgba(2, 6, 23, 0.55) 100%);
    pointer-events: none;
}

/* Organic Warm Color Flow Keyframes (Soft, classic warm lighting) */
@keyframes magWarmFlowSolar {
    0% {
        background: radial-gradient(circle, rgba(245, 158, 11, 0.45) 0%, rgba(217, 119, 6, 0.22) 40%, rgba(180, 83, 9, 0.08) 65%, transparent 80%);
        transform: translate3d(0, 0, 0) scale(1);
    }
    33% {
        background: radial-gradient(circle, rgba(251, 191, 36, 0.42) 0%, rgba(245, 158, 11, 0.2) 42%, rgba(234, 88, 12, 0.08) 68%, transparent 80%);
        transform: translate3d(110px, 50px, 0) scale(1.15);
    }
    66% {
        background: radial-gradient(circle, rgba(234, 88, 12, 0.4) 0%, rgba(217, 119, 6, 0.22) 40%, rgba(245, 158, 11, 0.06) 65%, transparent 80%);
        transform: translate3d(30px, 110px, 0) scale(0.96);
    }
    100% {
        background: radial-gradient(circle, rgba(245, 158, 11, 0.45) 0%, rgba(217, 119, 6, 0.22) 40%, rgba(180, 83, 9, 0.08) 65%, transparent 80%);
        transform: translate3d(-50px, 40px, 0) scale(1.08);
    }
}

@keyframes magWarmFlowTwilight {
    0% {
        background: radial-gradient(circle, rgba(217, 119, 6, 0.38) 0%, rgba(180, 83, 9, 0.22) 38%, rgba(120, 53, 15, 0.06) 65%, transparent 80%);
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }
    33% {
        background: radial-gradient(circle, rgba(234, 88, 12, 0.35) 0%, rgba(245, 158, 11, 0.2) 40%, rgba(180, 83, 9, 0.05) 65%, transparent 80%);
        transform: translate3d(-100px, -70px, 0) scale(1.18) rotate(12deg);
    }
    66% {
        background: radial-gradient(circle, rgba(245, 158, 11, 0.4) 0%, rgba(217, 119, 6, 0.24) 42%, rgba(146, 64, 14, 0.07) 68%, transparent 80%);
        transform: translate3d(-40px, -120px, 0) scale(0.92) rotate(-8deg);
    }
    100% {
        background: radial-gradient(circle, rgba(217, 119, 6, 0.38) 0%, rgba(180, 83, 9, 0.22) 38%, rgba(120, 53, 15, 0.06) 65%, transparent 80%);
        transform: translate3d(70px, -40px, 0) scale(1.05) rotate(6deg);
    }
}

@keyframes magWarmFlowVeil {
    0% {
        background: radial-gradient(ellipse at center, rgba(251, 191, 36, 0.24) 0%, rgba(245, 158, 11, 0.15) 38%, rgba(217, 119, 6, 0.05) 65%, transparent 80%);
        transform: translate3d(0, 0, 0) scaleX(1);
    }
    50% {
        background: radial-gradient(ellipse at center, rgba(234, 88, 12, 0.22) 0%, rgba(245, 158, 11, 0.16) 40%, rgba(251, 191, 36, 0.05) 65%, transparent 80%);
        transform: translate3d(70px, -30px, 0) scaleX(1.22) scaleY(1.1);
    }
    100% {
        background: radial-gradient(ellipse at center, rgba(245, 158, 11, 0.26) 0%, rgba(217, 119, 6, 0.16) 40%, rgba(180, 83, 9, 0.05) 65%, transparent 80%);
        transform: translate3d(-60px, 30px, 0) scaleX(0.95);
    }
}

/* Warm card highlights in live flowing mode */
body.live-light-flow .mag-pull-quote {
    border-left-color: #f59e0b;
    box-shadow: 0 4px 30px -4px rgba(245, 158, 11, 0.12);
}

body.live-light-flow .mag-dossier-card {
    border-color: rgba(245, 158, 11, 0.25);
    box-shadow: 0 4px 25px -3px rgba(245, 158, 11, 0.08);
}

/* Reduced Motion Mode */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .mag-living-light-backdrop,
    .mag-interactive-spotlight {
        display: none !important;
    }
}

body.simple-reading-mode * {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    backdrop-filter: none !important;
}

body.simple-reading-mode .mag-living-light-backdrop,
body.simple-reading-mode .mag-interactive-spotlight {
    display: none !important;
}

body.simple-reading-mode .mag-glow {
    box-shadow: none !important;
}
