/* ===== DESIGN SYSTEM ===== */
:root {
    /* Storyteller Palette */
    --color-bg: #FDFBF7;
    /* Warm Cream */
    --color-text: #2C2C2C;
    /* Dark Charcoal */
    --color-text-light: #5C5C5C;
    /* Muted Charcoal */

    --color-primary: #8F9E8B;
    /* Soft Olive */
    --color-secondary: #D48C70;
    /* Terracotta */
    --color-accent: #2C2C2C;
    /* Dark Interaction Color */

    --color-white: #FFFFFF;
    --color-paper: #F5F2EB;
    /* Slightly darker cream for cards */

    /* Typography */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 2rem;
    --space-lg: 3rem;
    --space-xl: 5rem;
    --space-xxl: 8rem;

    /* Effects */
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-paper: 1px 1px 3px rgba(0, 0, 0, 0.1);

    /* Animations */
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Dark Mode Theme - Subtle shift for comfort, keeping warmth */
[data-theme="dark"] {
    --color-bg: #1A1A1A;
    --color-text: #E8E8E8;
    --color-text-light: #B0B0B0;

    --color-primary: #A3B59E;
    /* Lighter Olive */
    --color-secondary: #E6B8A2;
    /* Muted Pink/Terracotta */
    --color-accent: #FFFFFF;

    --color-white: #2D2D2D;
    --color-paper: #252525;

    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    line-height: 1.8;
    overflow-x: hidden;
    color: var(--color-text);
    line-height: 1.8;
    overflow-x: hidden;
    background: transparent;
    /* Changed from var(--color-bg) for lava lamp */
    transition: background 0.3s ease, color 0.3s ease;
}

/* ===== PARTICLE CANVAS ===== */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
    /* Subtler */
}

.site-container {
    position: relative;
    z-index: 2;
}

/* ===== HERO SECTION ===== */
.hero {
    min-height: 90vh;
    /* Slightly reduced to show content peeking */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 900px;
}

/* ===== HERO INTERACTIVE LOGO (WebGL Shader) ===== */
.hero-logo-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto var(--space-md) auto;
    width: 100%;
    position: relative;
    z-index: 10;
}

.hero-logo-container {
    position: relative;
    width: clamp(200px, 24vw, 300px);
    aspect-ratio: 578 / 1024;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.hero-logo-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.logo-tagline {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.22em;
    color: var(--color-secondary);
    text-align: center;
    margin-top: var(--space-xs);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}

.hero-logo-wrapper:hover .logo-tagline,
.hero-logo-wrapper.touched .logo-tagline {
    opacity: 1;
    transform: translateY(0);
}

.author-name {
    font-family: var(--font-heading);
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 700;
    /* Bold but not black */
    color: var(--color-text);
    margin-bottom: var(--space-sm);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.name-part {
    display: block;
}

.tagline {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: var(--color-primary);
    /* Olive accent */
    margin-bottom: var(--space-md);
    font-weight: 400;
    font-style: italic;
}

.tagline-subtitle {
    max-width: 600px;
    margin: 0 auto;
}

.tagline-subtitle p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--color-text-light);
    font-weight: 300;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    opacity: 0.6;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-10px);
    }

    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

.scroll-arrow {
    width: 20px;
    height: 20px;
    border-left: 2px solid var(--color-text);
    border-bottom: 2px solid var(--color-text);
    transform: rotate(-45deg);
}

/* ===== SVG ANIMATION CONTAINER ===== */
.library-animation-container {
    width: 100%;
    max-width: 900px;
    margin: var(--space-xl) auto var(--space-md);
    padding: 0 var(--space-md);
    position: relative;
    z-index: 10;
}

.animated-library-scene {
    width: 100%;
    height: auto;
    display: block;
    background: transparent;
}

/* ===== SECTION STYLES ===== */
.books-section,
.about-section {
    padding: var(--space-xxl) var(--space-md);
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.section-title {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-light);
    max-width: 600px;
    margin: 0 auto;
    font-weight: 300;
}

/* ===== BOOKS GRID ===== */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-xl);
    margin-top: var(--space-xl);
}

.book-card {
    background: var(--color-white);
    border-radius: 4px;
    /* Slightly rounded, almost paper-like */
    padding: 0;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    overflow: hidden;
    border: none;
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-medium);
}

.book-cover-wrapper {
    position: relative;
    overflow: hidden;
    padding-top: 100%;
    /* Aspect ratio 1:1 */
    background: var(--color-paper);
}

.book-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.book-cover-wrapper.wrapper-square {
    padding-top: 100%;
    /* Aspect ratio 1:1 */
}

.book-card:hover .book-cover {
    transform: scale(1.05);
    /* Gentle zoom */
}

.book-info {
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.book-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    font-weight: 700;
}

.book-subtitle {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--color-secondary);
    /* Terracotta */
    margin-bottom: var(--space-md);
    font-weight: 400;
    font-style: italic;
}

.book-description {
    font-size: 0.95rem;
    color: var(--color-text-light);
    line-height: 1.6;
    margin-bottom: var(--space-lg);
}

.read-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    background: var(--color-accent);
    color: var(--color-white);
    /* Contrast text */
    padding: 0.8rem 2rem;
    border-radius: 50px;
    /* Pill shape */
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: auto;
}

.book-card:hover .read-more {
    background: var(--color-secondary);
    /* Hover to Terracotta */
    transform: scale(1.05);
}

.arrow-icon {
    display: none;
    /* Hide standard arrow for cleaner pill button look */
}

/* ===== ABOUT SECTION ===== */
.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: center;
}

.about-text {
    padding-right: var(--space-md);
}

.about-paragraphs p {
    font-size: 1.05rem;
    color: var(--color-text-light);
    margin-bottom: var(--space-md);
    line-height: 1.8;
}

.tagline-text {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--color-secondary);
    font-size: 1.4rem;
    font-weight: 400;
    margin-top: var(--space-lg);
    display: block;
    text-align: center;
    position: relative;
    padding: var(--space-md) 0;
}

.tagline-text::before,
.tagline-text::after {
    content: "“";
    font-family: serif;
    font-size: 4rem;
    color: rgba(212, 140, 112, 0.2);
    /* Faded Terracotta */
    position: absolute;
    line-height: 0;
}

.tagline-text::before {
    top: 0;
    left: 40%;
}

.tagline-text::after {
    content: "”";
    bottom: 0;
    right: 40%;
}


.author-photo {
    width: 100%;
    height: auto;
    border-radius: 4px;
    /* Sharp clean corners */
    box-shadow: var(--shadow-medium);
    transition: var(--transition-smooth);
    border: 8px solid var(--color-white);
    /* Photo frame effect */
}

.author-photo:hover {
    transform: scale(1.02) rotate(1deg);
    /* Slight organic tilt */
}

/* ===== FOOTER ===== */
.footer {
    background: var(--color-paper);
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    color: var(--color-text-light);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.footer-text {
    font-size: 0.9rem;
    margin-bottom: var(--space-xs);
}

.footer-tagline {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--color-primary);
    font-style: italic;
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-white);
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
    color: var(--color-text);
}

.theme-toggle:hover {
    transform: rotate(15deg);
    box-shadow: var(--shadow-medium);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: 1fr;
    }

    .about-content {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .about-image {
        order: -1;
        margin-bottom: var(--space-md);
    }

    .author-name {
        font-size: clamp(2.5rem, 8vw, 4rem);
    }
}

/* ===== UTILITY ANIMATIONS ===== */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}