:root {
    --font-display: 'Abril Fatface', cursive;
    --font-body: 'Lora', serif;

    --color-bg: #fdfbf7;
    --color-text: #2b2b2b;
    --color-accent: #e76f51; /* Burnt Orange */
    --color-accent-hover: #d65a3b;
    --color-secondary: #2a9d8f; /* Vintage Teal */
    --color-border: #e0ded9;
    --color-card-bg: #ffffff;

    --spacing-unit: 1rem;
    --container-width: 800px; /* Narrow reading column */
    --grid-container-width: 1200px;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.8;
    font-size: 18px;
    /* Subtle grain texture */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-accent-hover);
}

/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing-unit);
}

.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-content {
    flex: 1;
    padding: calc(var(--spacing-unit) * 4) 0;
}

/* Header */
.site-header {
    padding: calc(var(--spacing-unit) * 4) 0;
    text-align: center;
    border-bottom: 4px double var(--color-border);
    background: linear-gradient(to bottom, rgba(255,255,255,0.5), transparent);
    margin-bottom: 2rem;
}

.site-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.8), 2px 2px 0px rgba(0,0,0,0.05);
}

.site-title:hover {
    color: var(--color-text);
}

.site-tagline {
    font-family: var(--font-body);
    font-style: italic;
    color: #555;
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

.site-nav {
    margin-top: 2.5rem;
}

.site-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.site-nav a {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid transparent;
    padding-bottom: 2px;
}

.site-nav a:hover {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* Story Content (Reading View) */
.story-header {
    text-align: center;
    margin-bottom: 3rem;
}

.story-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.story-meta {
    font-style: italic;
    color: #666;
    font-size: 1rem;
}

.story-body {
    font-size: 1.2rem;
}

.story-body p {
    margin-bottom: 1.5rem;
}

/* Drop Cap */
.story-body > p:first-of-type:not(:has(strong:only-child))::first-letter,
.story-body > p:first-of-type:has(strong:only-child) + p::first-letter {
    font-family: var(--font-display);
    font-size: 4.5rem;
    float: left;
    line-height: 0.8;
    margin-right: 0.5rem;
    margin-top: 0.1rem;
    color: var(--color-accent);
}

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--color-secondary);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: #555;
}

/* Homepage Grid (Book Covers) */
.home-grid-wrapper .container {
    max-width: var(--grid-container-width);
}

.book-grid h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    text-align: center;
    margin-bottom: 3rem;
    color: var(--color-text);
}

/* Targeting the markdown list in index.md */
.book-grid ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    list-style: none;
    padding: 0;
}

.book-grid li {
    margin: 0; /* Reset markdown list margins */
}

/* Vintage Mystery / Hardy Boys Style */
.book-grid li a {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Title at top */
    align-items: center;

    height: 380px; /* Taller aspect ratio */
    padding: 1.5rem;

    /* Default Cover Color (Dark Blue) */
    background-color: #2c3e50;

    /* Complex background: Spine crease + Texture + Image */
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0.2) 0%, rgba(0,0,0,0.2) 4%, transparent 6%), /* Spine highlight/shadow */
        linear-gradient(to right, rgba(0,0,0,0.6) 0%, transparent 5%, transparent 95%, rgba(0,0,0,0.4) 100%), /* Edge darkening */
        var(--cover-image);

    background-size: cover;
    background-position: center;
    color: #f1c40f; /* Vintage Yellow Title */

    /* Spine Effect */
    border-left: none;
    border-radius: 2px 5px 5px 2px;

    box-shadow:
        1px 1px 0 #bbb,
        2px 2px 0 #bbb,
        3px 3px 0 #bbb,
        4px 4px 0 #bbb,
        5px 5px 10px rgba(0,0,0,0.3); /* Stacked paper effect */

    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    z-index: 1;
}

/* Title Styling */
.book-grid li a .book-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 0 10px rgba(0,0,0,0.9), 2px 2px 4px rgba(0,0,0,0.9);
    z-index: 10; /* Above the "art" */
    padding-bottom: 1rem;
    width: 100%;
    margin-top: 1rem;
}

/* Hover Effects */
.book-grid li a:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        1px 1px 0 #bbb,
        2px 2px 0 #bbb,
        3px 3px 0 #bbb,
        4px 4px 0 #bbb,
        5px 5px 0 #bbb,
        6px 6px 0 #bbb,
        10px 10px 20px rgba(0,0,0,0.4);
    color: #fff; /* White title on hover */
}

/* Footer */
.site-footer {
    background-color: transparent;
    padding: 3rem 0;
    margin-top: auto;
    border-top: 4px double var(--color-border);
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    font-family: var(--font-body);
}

/* Story Page Cover */
.single-book-cover-container {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.single-book-cover {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;

    width: 300px;
    height: 460px; /* Larger than homepage */
    padding: 2rem;

    /* Default Cover Color (Dark Blue) */
    background-color: #2c3e50;

    /* Complex background: Spine crease + Texture + Image */
    background-image:
        linear-gradient(90deg, rgba(255,255,255,0.2) 0%, rgba(0,0,0,0.2) 4%, transparent 6%), /* Spine highlight/shadow */
        linear-gradient(to right, rgba(0,0,0,0.6) 0%, transparent 5%, transparent 95%, rgba(0,0,0,0.4) 100%), /* Edge darkening */
        var(--cover-image);

    background-size: cover;
    background-position: center;
    color: #f1c40f; /* Vintage Yellow Title */

    /* Spine Effect */
    border-left: none;
    border-radius: 2px 5px 5px 2px;

    box-shadow:
        1px 1px 0 #bbb,
        2px 2px 0 #bbb,
        3px 3px 0 #bbb,
        4px 4px 0 #bbb,
        5px 5px 0 #bbb,
        6px 6px 0 #bbb,
        15px 15px 30px rgba(0,0,0,0.4); /* Deep shadow */

    position: relative;
    overflow: hidden;
}

.single-book-cover .book-title {
    font-family: var(--font-display);
    font-size: 2rem; /* Larger title */
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 0 10px rgba(0,0,0,0.9), 2px 2px 4px rgba(0,0,0,0.9);
    z-index: 10;
    padding-bottom: 1rem;
    width: 100%;
    margin-top: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .site-title {
        font-size: 2.5rem;
    }

    .story-title {
        font-size: 2.5rem;
    }

    .book-grid ul {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* Story Footer */
.story-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.back-link {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--color-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

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