/* =========================================
   Import Fonts (Sora)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&display=swap');

/* =========================================
   Variables & Theme System (Premium Zinc/Slate)
   ========================================= */
:root {
    /* Typography - Sora */
    --font-main: 'Sora', sans-serif;
    --font-heading: 'Sora', sans-serif;
    
    /* Light Mode Palette */
    --bg-body: #fafafa;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f4f4f5;
    --bg-header: rgba(255, 255, 255, 0.85); /* Slightly more opaque for blur */
    
    --text-main: #18181b;
    --text-muted: #52525b;
    --text-light: #a1a1aa;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8; 
    --primary-soft: rgba(37, 99, 235, 0.08);
    --primary-glow: rgba(37, 99, 235, 0.25);
    
    --border: #e4e4e7;
    --border-hover: #d4d4d8;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --shadow-card-hover: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    
    /* Layout */
    --nav-height: 80px;
    --container-width: 1140px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    /* Transitions */
    --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.4s;
}

[data-theme="dark"] {
    --bg-body: #09090b;
    --bg-surface: #18181b;
    --bg-surface-alt: #27272a;
    --bg-header: rgba(9, 9, 11, 0.85);
    
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-light: #52525b;
    
    --primary: #60a5fa;
    --primary-hover: #93c5fd; 
    --primary-soft: rgba(96, 165, 250, 0.1);
    --primary-glow: rgba(96, 165, 250, 0.2);
    
    --border: #27272a;
    --border-hover: #3f3f46;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-card-hover: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.65; /* Improved readability */
    font-weight: 400;
    transition: background-color var(--duration) var(--ease-premium), color var(--duration) var(--ease-premium);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

img {
    max-width: 100%;
    display: block;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    line-height: 1.2;
    margin-bottom: 0.75em;
    font-weight: 600; /* Sora Bold/SemiBold */
    letter-spacing: -0.02em;
    color: var(--text-main);
}

h1 { font-weight: 700; }

p {
    margin-bottom: 1.6em;
    color: var(--text-muted);
    font-weight: 400;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

/* =========================================
   Header & Nav
   ========================================= */
header {
    height: var(--nav-height);
    position: sticky;
    top: 0;
    background-color: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0,0,0,0);
    z-index: 100;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

header.scrolled {
    border-bottom-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%; /* Ensure full height for vertical centering */
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.logo img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* FORCE header title color */
header .logo .site-title {
    color: #FEC107;
}


.nav-links {
    display: flex;
    gap: 2.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    padding: 0.5rem 0;
    transition: color 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-main);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: width 0.3s var(--ease-premium);
    border-radius: 2px;
    opacity: 0.9;
}

.nav-links a:hover::after, .nav-links a.active::after {
    width: 100%;
}

/* =========================================
   Modern Pill Toggle
   ========================================= */
.theme-toggle {
    width: 56px;
    height: 30px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border);
    border-radius: 50px; /* Pill shape */
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    margin-left: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface);
}

/* Icons on the track */
.icon-sun, .icon-moon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
    opacity: 0.6;
}

.theme-toggle:hover .icon-sun, 
.theme-toggle:hover .icon-moon {
    opacity: 0.9;
}

/* Sliding Thumb */
.theme-toggle-thumb {
    position: absolute;
    top: 3px; /* (30px height - 22px thumb - 2px border approx) / 2 */
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: #ffffff; /* White thumb default */
    transition: transform 0.35s var(--ease-premium);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    z-index: 2;
    border: 1px solid rgba(0,0,0,0.05);
}

/* Dark Mode State */
[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(26px); /* 56w - 3left - 3right - 22thumb = 28px travel. Adjusted for visual balance */
    background-color: var(--text-main); /* Light thumb in dark mode */
    border-color: transparent;
}

/* Mobile Menu */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s;
}

.hamburger:hover {
    background-color: var(--bg-surface-alt);
}

/* =========================================
   Hero Section
   ========================================= */
.hero {
    padding: 9rem 0 5rem;
    text-align: center;
    position: relative;
    background: radial-gradient(50% 50% at 50% 50%, var(--primary-soft) 0%, transparent 100%);
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 3.75rem; /* Larger for Sora */
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    color: var(--text-main); /* Fallback */
    letter-spacing: -0.03em;
    font-weight: 700;
}

.hero p {
    font-size: 1.35rem;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto;
    font-weight: 400;
    line-height: 1.6;
}

/* =========================================
   Filter Bar
   ========================================= */
.filter-bar {
    margin: 0 0 4rem;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.search-input {
    padding: 1rem 1.75rem;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--bg-surface);
    color: var(--text-main);
    width: 100%;
    max-width: 520px;
    font-size: 1.05rem;
    font-family: var(--font-main);
    transition: all 0.3s var(--ease-premium);
    box-shadow: var(--shadow-sm);
}

.search-input::placeholder {
    color: var(--text-light);
}

.search-input:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow), var(--shadow-md);
}

/* =========================================
   Book Grid
   ========================================= */
.book-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    padding-bottom: 8rem;
}

.book-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.4s var(--ease-premium);
    display: flex;
    flex-direction: column;
    position: relative;
    opacity: 0;
    animation: fadeInUp 0.6s var(--ease-premium) forwards;
    box-shadow: var(--shadow-sm);
}

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

.book-link-wrapper {
    display: block;
    overflow: hidden;
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background-color: var(--bg-surface-alt);
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-premium);
}

.book-card:hover .book-cover {
    transform: scale(1.06);
}

.book-content {
    padding: 2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    line-height: 1.3;
    font-weight: 600;
}

.book-title a {
    transition: color 0.2s;
}

.book-title a:hover {
    color: var(--primary);
}

.book-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    flex-grow: 1;
    line-height: 1.65;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    background-color: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-align: center;
    transition: all 0.3s var(--ease-premium);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
    font-family: var(--font-main);
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 100%;
    justify-content: center;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s var(--ease-premium);
    font-family: var(--font-main);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--primary-soft);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* =========================================
   Book Detail Page
   ========================================= */
.book-detail {
    padding: 5rem 0;
    max-width: 960px;
    margin: 0 auto;
}

.detail-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4rem;
    margin-bottom: 5rem;
    align-items: start;
}

.detail-cover {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    aspect-ratio: 3/4;
    object-fit: cover;
}

.detail-info h1 {
    font-size: 2.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.1;
    font-weight: 700;
}

.meta-tags {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0 2.5rem;
    flex-wrap: wrap;
}

.tag {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border);
    padding: 0.4rem 1.1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tag:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-surface);
}

.detail-content {
    font-size: 1.15rem;
    color: var(--text-muted);
    line-height: 1.85;
}

.detail-content h2 {
    font-size: 1.85rem;
    margin-top: 3.5rem;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    border-left: 4px solid var(--primary);
    padding-left: 1.25rem;
}

.detail-content ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 2.5rem;
}

.detail-content li {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 1rem;
}

.detail-content li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2em;
    line-height: 1.6rem;
}

.related-books {
    margin-top: 6rem;
    padding-top: 4rem;
    border-top: 1px solid var(--border);
}

.related-books h3 {
    font-size: 1.75rem;
    margin-bottom: 2.5rem;
}

/* =========================================
   About & Contact
   ========================================= */
.about-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5rem;
    margin-top: 4rem;
    margin-bottom: 6rem;
}

.author-photo {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
    transform: rotate(-2deg);
    transition: transform 0.4s var(--ease-premium);
}

.author-photo:hover {
    transform: rotate(0deg) scale(1.02);
}

.contact-form {
    max-width: 640px;
    margin: 0 auto 5rem;
    background: var(--bg-surface);
    padding: 3rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: 2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.3s var(--ease-premium);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-surface);
}

/* =========================================
   Footer
   ========================================= */
footer {
    margin-top: auto;
    padding: 4rem 0 3rem;
    border-top: 1px solid var(--border);
    background-color: var(--bg-surface);
    text-align: center;
}

footer p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.social-links a {
    color: var(--text-muted);
    transition: all 0.3s var(--ease-premium);
    padding: 0.75rem;
    border-radius: 50%;
    background: var(--bg-surface-alt);
    border: 1px solid transparent;
}

.social-links a:hover {
    color: var(--primary);
    background: var(--bg-surface);
    border-color: var(--border);
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
}

/* =========================================
   Animations
   ========================================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Responsive
   ========================================= */
@media (min-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .detail-header {
        grid-template-columns: 340px 1fr;
        text-align: left;
    }
    
    .detail-cover {
        margin: 0;
    }
  
    .about-grid {
        grid-template-columns: 1fr 1fr;
        align-items: center;
    }
  
    .hamburger {
        display: none;
    }
  
    .nav-links {
        display: flex;
    }
}
  
@media (min-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
  
@media (max-width: 767px) {
    :root {
        --nav-height: 70px;
    }

    .hero h1 {
        font-size: 2.75rem;
    }
    
    .hero p {
        font-size: 1.15rem;
    }

    /* Fix for mobile header title wrapping */
    .logo {
        font-size: 1rem; /* ~16px */
        gap: 0.6rem;
        max-width: 80%; /* Leave room for hamburger */
    }

    .logo span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-header);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 2rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        gap: 1.5rem;
    }
  
    .nav-links.active {
        display: flex;
    }
  
    .hamburger {
        display: block;
    }
    
    .theme-toggle {
        margin-left: 0;
        margin-top: 0.5rem;
    }
    
    .book-card {
        max-width: 420px;
        margin: 0 auto;
        width: 100%;
    }
}
