@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Lora:ital,wght@0,400..700;1,400..700&family=Fraunces:ital,opsz,wght@0,9..144,100..900;1,9..144,100..900&family=Inter:wght@100..900&family=Bitter:ital,wght@0,100..900;1,100..900&family=Merriweather:ital,wght@0,300..900;1,300..900&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&family=Cormorant+Garamond:ital,wght@0,300..700;1,300..700&family=Outfit:wght@100..900&family=DM+Mono:wght@300..500&display=swap');

:root {
    /* DEFAULT LIGHT MODE (Warm Light Editorial) */
    --bg-main: #fcfcf9;
    --bg-card: #f5f5f0;
    --border-color: #e6e6dc;
    --text-primary: #1c1c19;
    --text-secondary: #4a4a45;
    --text-muted: #8c8c82;
    --accent-gold: #8f6d2e;
    --accent-bronze: #8f6d2e;
    --accent-main: #1c1c19;
    --accent-hover: #4a4a45;
    --shadow-tint: rgba(149, 132, 116, 0.08);
    
    --font-display: 'Merriweather', serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'DM Mono', monospace;

    /* Dynamic Sizing System variables */
    --text-scale: 1.15;
    --body-line-height: 1.75;
}

body.font-pairing-editorial {
    --font-display: 'Cormorant Garamond', serif;
    --font-body: 'Lora', serif;
}
body.font-pairing-literary {
    --font-display: 'Playfair Display', serif;
    --font-body: 'Lora', serif;
}
body.font-pairing-slab {
    --font-display: 'Bitter', serif;
    --font-body: 'Bitter', serif;
}
body.font-pairing-corporate {
    --font-display: 'Merriweather', serif;
    --font-body: 'Source Sans 3', sans-serif;
}

body.dark {
    /* DARK MODE (Warm Editorial Charcoal/Beige) */
    --bg-main: #110f0e;
    --bg-card: #1a1715;
    --border-color: #2a231f;
    --text-primary: #f3ece0;
    --text-secondary: #c5bca9;
    --text-muted: #857b6d;
    --accent-gold: #cca869;
    --accent-bronze: #9c805f;
    --accent-main: #f3ece0;
    --accent-hover: #e5dbcb;
    --shadow-tint: rgba(0, 0, 0, 0.5);
}

/* Base elements forced to typography variables */
body {
    font-family: var(--font-body), ui-sans-serif, system-ui, -apple-system, sans-serif !important;
    font-size: calc(1rem * var(--text-scale)) !important;
    line-height: var(--body-line-height) !important;
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color 0.4s ease, color 0.4s ease;
    /* Soft noise-like paper grain texture using CSS */
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(200, 190, 175, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 0 0, rgba(200, 190, 175, 0.02) 1px, transparent 1px);
    background-size: 20px 20px, 40px 40px;
}

h1, h2, h3, h4, h5, h6, .font-display {
    font-family: var(--font-display), Georgia, serif !important;
}

p, li, .font-body {
    font-family: var(--font-body), sans-serif !important;
}

/* Sizing Helper Classes mapped to dynamic scale factor */
.text-xs-scale { font-size: calc(0.8rem * var(--text-scale)) !important; }
.text-sm-scale { font-size: calc(0.92rem * var(--text-scale)) !important; }
.text-base-scale { font-size: calc(1.05rem * var(--text-scale)) !important; }
.text-lg-scale { font-size: calc(1.2rem * var(--text-scale)) !important; }
.text-xl-scale { font-size: calc(1.4rem * var(--text-scale)) !important; }
.text-2xl-scale { font-size: calc(1.7rem * var(--text-scale)) !important; }
.text-3xl-scale { font-size: calc(2.1rem * var(--text-scale)) !important; }

.font-display {
    font-family: var(--font-display);
}

.font-mono {
    font-family: var(--font-mono);
}

/* Luxury Editorial Card Frames */
.editorial-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-tint);
    transition: background-color 0.4s ease, border-color 0.4s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.editorial-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--shadow-tint);
}

/* Custom interactive buttons */
.btn-editorial {
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.15em;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.btn-editorial:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background-color: rgba(204, 168, 105, 0.05);
}

/* Theme Toggle Slider Button */
.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* Beautiful serif links */
.editorial-link {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--accent-gold);
    border-bottom: 1px solid rgba(204, 168, 105, 0.3);
    transition: all 0.3s ease;
}

.editorial-link:hover {
    color: var(--accent-bronze);
    border-bottom-color: var(--accent-bronze);
}

/* Custom decorative elements */
.gold-pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--accent-gold);
    box-shadow: 0 0 8px var(--accent-gold);
    border-radius: 50%;
}

/* Staggered load animation */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-item {
    animation: fadeInSlide 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.delay-1 { animation-delay: 80ms; }
.delay-2 { animation-delay: 160ms; }
.delay-3 { animation-delay: 240ms; }
.delay-4 { animation-delay: 320ms; }

/* Typography Playground Active state */
.font-card-select {
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}
.font-card-select.active-font-card {
    border-color: var(--accent-gold) !important;
    background-color: rgba(204, 168, 105, 0.06) !important;
    box-shadow: 0 0 15px rgba(204, 168, 105, 0.15) !important;
}

/* Mobile Hamburger transitions & Menu state */
#mobile-menu-toggle span {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

header.menu-open #hamburger-bar-1 {
    transform: translateY(5px) rotate(45deg);
}

header.menu-open #hamburger-bar-2 {
    opacity: 0;
}

header.menu-open #hamburger-bar-3 {
    transform: translateY(-5px) rotate(-45deg);
}

/* Ensure no horizontal scroll across the application viewport */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Custom feed input fields for contrast and readability in dark/light mode */
.feed-input {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    font-family: var(--font-mono) !important;
    font-size: 16px !important; /* Prevents mobile Safari auto-zoom on focus */
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.feed-input:focus {
    border-color: var(--accent-gold) !important;
    box-shadow: 0 0 0 2px rgba(204, 168, 105, 0.2) !important;
}

.feed-input::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.6 !important;
}

/* Fix autofill coloring which can make input text invisible if background stays white */
.feed-input:-webkit-autofill,
.feed-input:-webkit-autofill:hover, 
.feed-input:-webkit-autofill:focus, 
.feed-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-card) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Beautiful, highly contrasting Delete Button */
.btn-delete {
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-size: calc(0.85rem * var(--text-scale));
    font-weight: 700;
    letter-spacing: 0.12em;
    border: 1px solid #dc2626 !important;
    background-color: #dc2626 !important;
    color: #ffffff !important;
    cursor: pointer;
    transition: all 0.2s ease !important;
}

.btn-delete:hover {
    background-color: #b91c1c !important;
    border-color: #b91c1c !important;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.4) !important;
}

.btn-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Offset for smooth-scrolling to prevent sticky header overlap */
.story-node {
    scroll-margin-top: 110px;
}


/* Temporarily visible search term highlight */
.search-highlight {
    background-color: rgba(204, 168, 105, 0.25);
    border-bottom: 1px solid rgba(204, 168, 105, 0.5);
    color: var(--text-primary);
    padding: 0 1.5px;
    border-radius: 2px;
    transition: background-color 1.2s ease, border-color 1.2s ease, color 1.2s ease;
}
.search-highlight.fade-out {
    background-color: transparent;
    border-bottom-color: transparent;
}
