:root {
    /* Color Palette */
    --bg-color: #fffdf7;
    --primary-color: #084887;
    --secondary-color: #666370;
    --accent-color: #000f08;
    --text-color: #000f08;
    --light-text: #fffdf7;
    --border-color: #e0e0e0;

    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 4rem;

    /* Border Radius */
    --radius-md: 8px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --primary-color: #38bdf8;
    --secondary-color: #94a3b8;
    --accent-color: #f8fafc;
    --text-color: #e2e8f0;
    --light-text: #0f172a;
    --border-color: #1e293b;

    /* Dark specific overrides */
    --card-bg: #1e293b;
    --header-bg: rgba(15, 23, 42, 0.95);
    --hero-gradient: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(15, 23, 42, 1) 100%);
}

/* Reset & Base Styles */
html {
    scroll-behavior: smooth;
}

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

/* ================================================
   Accessibility - Skip Links
   ================================================ */

.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    z-index: 10000;
    transition: top 0.3s ease;
    box-shadow: 0 4px 12px rgba(8, 72, 135, 0.3);
}

.skip-link:focus {
    top: 16px;
    outline: none;
}

/* ================================================
   Accessibility - Focus Indicators
   ================================================ */

/* Custom focus styles for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Enhanced focus for buttons */
.btn:focus-visible {
    outline-offset: 4px;
    box-shadow: 0 0 0 4px rgba(8, 72, 135, 0.2);
}

/* Focus indicator for cards */
.card:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 72, 135, 0.15);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

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

/* Header */
header {
    background-color: var(--header-bg, rgba(255, 253, 247, 0.95));
    border-bottom: 1px solid transparent;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-bottom-color: var(--border-color);
    padding-top: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
}

.logo {
    font-size: 1.5rem;
    /* Container for font size */
    font-weight: 700;
    color: var(--primary-color);
}

.logo a {
    display: flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
    line-height: 1;
}

.logo img {
    height: 40px;
    width: auto;
    margin-right: 12px;
    display: block;
}

nav ul {
    display: flex;
    gap: var(--spacing-lg);
    list-style: none;
}

nav a {
    color: var(--secondary-color);
    font-weight: 500;
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

nav a:hover::after {
    width: 100%;
}

nav a:hover {
    color: var(--primary-color);
}

/* Main Content */
main {
    flex: 1;
}

/* Animations */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* Hero Section */
.hero {
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    background: var(--hero-gradient, linear-gradient(135deg, rgba(8, 72, 135, 0.05) 0%, rgba(255, 253, 247, 1) 100%));
}

.hero-cover {
    max-width: 800px;
    width: 100%;
    height: auto;
    margin-bottom: var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.hero-cover:hover {
    transform: translateY(-5px);
}

.hero h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    color: var(--secondary-color);
    max-width: 600px;
    margin: 0 auto var(--spacing-lg);
}

.btn {
    display: inline-block;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--primary-color);
    color: var(--light-text);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(8, 72, 135, 0.2);
}

.btn:hover {
    background-color: var(--accent-color);
    color: var(--light-text);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(8, 72, 135, 0.3);
}

/* Features/Chapters Grid */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

.section-title {
    text-align: center;
    color: var(--accent-color);
    margin-bottom: var(--spacing-xl);
    font-size: 2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Springy effect */
    display: flex;
    flex-direction: column;
    opacity: 0;
    /* Hidden initially for JS animation */
    transform: translateY(20px);
}

.card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-color);
    transform: translateY(-8px) !important;
    /* Override visibility transform */
}

.card h3 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.card p {
    color: var(--secondary-color);
    font-size: 0.95rem;
    margin-bottom: var(--spacing-md);
    flex-grow: 1;
}

.card-link {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-link span {
    transition: transform 0.2s ease;
}

.card:hover .card-link span {
    transform: translateX(4px);
}

/* Featured Card */
.card.featured {
    background: linear-gradient(135deg, rgba(8, 72, 135, 0.02), rgba(8, 72, 135, 0.08));
    border-color: var(--primary-color);
    position: relative;
    overflow: visible;
}

.card.featured::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), #1a5fb4);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-badge {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, var(--primary-color), #1a5fb4);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    margin-bottom: var(--spacing-sm);
}

.card.featured:hover {
    box-shadow: 0 20px 40px rgba(8, 72, 135, 0.15);
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: var(--light-text);
    padding: var(--spacing-lg);
    text-align: center;
}

footer p {
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    header {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    nav ul {
        gap: var(--spacing-md);
    }
}