/* --- Global Styles & Variables --- */
:root {
    --bg-color: #0f1015;          /* Deep dark background */
    --card-bg: #161821;           /* Slightly lighter dark for cards */
    --text-primary: #f3f4f6;      /* Crisp off-white text */
    --text-muted: #9ca3af;        /* Muted gray text */
    
    /* Updated to a deep, rich cosmic purple theme (darker than your previous header[cite: 2]) */
    --accent-color: #9333ea;      /* Rich purple for links, badges, buttons */
    --accent-hover: #a855f7;      /* Lighter glowing purple on hover */
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-stack);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header & Navigation (Flexbox) --- */
.site-header {
    background-color: rgba(15, 17, 21, 0.95);
    border-bottom: 1px solid #262a33;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

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

/* --- Main Layout Container --- */
.site-main {
    flex: 1; /* Pushes footer to the bottom */
}

/* --- Hero Section (Flexbox Centering) --- */
.hero {
    padding: 6rem 2rem;
    text-align: center;
    background: linear-gradient(to bottom, #161920, var(--bg-color));
}

.hero-content {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.btn {
    background-color: var(--accent-color);
    color: white;
    padding: 0.75rem 1.75rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s ease;
}

.btn:hover {
    background-color: var(--accent-hover);
}

/* --- Projects Section & Cards (Flexbox Wrap) --- */
.projects-section {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 0 2rem;
}

.projects-section h2 {
    margin-bottom: 2rem;
    font-size: 1.8rem;
}

.card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem; /* Space between the cards */
}

.card {
    /* This forces each card to take up roughly half the width minus the gap */
    flex: 1 1 calc(50% - 1rem); 
    box-sizing: border-box;
    background-color: var(--card-bg);
    border: 1px solid #262a33;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
}

.card-image-placeholder {
    height: 180px;
    background-color: #222630;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
}

.card-body h3 {
    font-size: 1.3rem;
}

.card-body p {
    color: var(--text-muted);
    font-size: 0.95rem;
    flex: 1; /* Pushes link to the bottom */
}

.card-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    margin-top: 0.5rem;
}

.card-link:hover {
    text-decoration: underline;
}

/* --- Footer --- */
.site-footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid #262a33;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Book Reader Layout & Typography --- */
.book-container {
    max-width: 750px; /* Keeps line length comfortable for reading */
    margin: 3rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.book-nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 1px solid #262a33;
    padding-bottom: 1rem;
}

.book-nav-top a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.book-nav-top a:hover {
    color: var(--accent-color);
}

.book-prose {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #e2e8f0;
}

/* Styling elements rendered from Markdown */
.book-prose h1, .book-prose h2, .book-prose h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.book-prose p {
    margin-bottom: 1.5rem;
}

.book-nav-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #262a33;
    padding-top: 2rem;
    margin-top: 1rem;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid #262a33;
    color: var(--text-primary);
    padding: 0.75rem 1.75rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: border-color 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--accent-color);
}

/* --- Book Header Banner --- */
.book-header-banner {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #262a33;
}

.book-header-banner h2 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.author-credit {
    font-size: 1rem;
    color: var(--accent-color);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* --- Blog Container & Header Layout --- */
.blog-container {
    max-width: 1200px;
    margin: 4rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.blog-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.blog-header h1 {
    font-size: 2rem;
    font-weight: 800;
}

.blog-header p {
    color: var(--text-muted);
}

.post-date {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

/* --- Portfolio Screenshot Gallery (Flexbox) --- */
.screenshot-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.screenshot-card {
    background-color: var(--card-bg);
    border: 1px solid #262a33;
    border-radius: 8px;
    overflow: hidden;
}

.screenshot-card img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Chapter Selector Dropdown --- */
.chapter-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapter-selector-wrapper label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chapter-selector-wrapper select {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid #262a33;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.chapter-selector-wrapper select:hover {
    border-color: var(--accent-color);
}

.chapter-selector-wrapper select:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* --- Comic Reader Layout --- */
.comic-container {
    max-width: 900px; /* Gives comic scans more breathing room than text */
    margin: 3rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.comic-image-wrapper {
    background-color: var(--card-bg);
    border: 1px solid #262a33;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.comic-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- 3-Column Community Grid --- */
.community-grid .card {
    flex: 1 1 calc(33.333% - 1.35rem);
}

/* @font-face {
    font-family: 'Great Lakes';
    src: url('../fonts/GreatLakesNF.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
} */

.site-logo {
    font-family: 'Audiowide', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-decoration: none;
    text-transform: uppercase;
}

/* --- About Team Grid --- */
.about-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-top: 2rem;
}

.about-grid .card {
    flex: 1 1 calc(33.333% - 1.35rem);
    min-width: 260px;
}

/* Responsive Blog Images */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
}

/* Responsive Video Container (16:9 Aspect Ratio) */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.card {
    /* Keeps your existing card rules */
    flex: 1 1 calc(50% - 1rem); 
    box-sizing: border-box;
    background-color: var(--card-bg);
    border: 1px solid #262a33;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-image-placeholder {
    /* Replaces fixed height: 180px with a fluid 16:9 ratio */
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #222630;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    overflow: hidden;
}

.card-image-placeholder img {
    width: 100%;
    height: auto;
    background-color: #12141a; /* Dark backdrop for letterboxing */
    display: block;
}

/* Card container for portrait aspect ratio content */
.book-card {
    flex: 1 1 calc(25% - 1.5rem); /* 4 across on desktop */
    min-width: 200px;
    background-color: var(--card-bg);
    border: 1px solid #262a33;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
}

.book-card-image {
    width: 100%;
    aspect-ratio: 2 / 3; /* Standard book cover ratio */
    overflow: hidden;
    background-color: #181a20;
}

.book-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Shows entire vertical cover cleanly */
    display: block;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.card-image img {
    width: 100%;
    height: 220px; /* Adjust height to your liking */
    object-fit: cover;
    display: block;
}