/* Main Styles */
:root {
    --primary-dark: #2D1637;
    --accent-dark: #1A0F1F;
    --light-accent: #D4BBEC;
    --base-light: #F9F7FC;
    --text-dark: #F0EDF5;
    --text-light: #2A242E;
    --link-color: #A66ACA;
    --button-gradient-start: #7B439C;
    --button-gradient-end: #A66ACA;
    --hover-accent: #4A2960;
    --card-radius: 16px;
    --header-height: 96px;
    --mobile-header-height: 72px;
}

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

/* Base Styles */
body {
    font-family: var(--body-font, 'Inter', sans-serif);
    line-height: 1.6;
    background: var(--primary-dark);
    color: var(--text-dark);
    transition: background-color 0.3s ease;
    overflow-x: hidden;
}

body.light-mode {
    background: var(--base-light);
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font, 'Playfair Display', serif);
    margin-bottom: 1rem;
}

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

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

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 3rem;
    padding: 3rem 0;
}

.main-layout > * {
    min-width: 0;
}


.back-to-top {
    position: fixed;
    right: 1.75rem;
    bottom: 1.75rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 120;
}

.back-to-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.light-mode .back-to-top {
    color: var(--text-dark);
}


.tagline {
    font-size: 0.95rem;
    opacity: 0.75;
    margin-top: 0.25rem;
    color: var(--text-dark);
}

.light-mode .tagline {
    color: var(--text-dark);
}

/* Header */
.header {
    background: rgba(30, 15, 38, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(191, 162, 219, 0.2);
}

.light-mode .header {
    background: rgba(245, 243, 247, 0.95);
    border-bottom: 1px solid rgba(59, 28, 74, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    position: relative;
}

.logo {
    font-family: var(--heading-font, 'Playfair Display', serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--light-accent);
    text-decoration: none;
}

.logo:hover {
    color: var(--link-color);
}

/* Navigation */
.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    position: relative;
}

.light-mode .nav-menu a {
    color: var(--text-dark);
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--light-accent);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after {
    width: 100%;
}

.mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: inherit;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.45);
}

.light-mode .mobile-menu-toggle {
    border-color: rgba(59, 28, 74, 0.15);
}

.light-mode .mobile-menu-toggle:hover,
.light-mode .mobile-menu-toggle:focus-visible {
    background: rgba(59, 28, 74, 0.08);
    border-color: rgba(59, 28, 74, 0.35);
}

.menu-icon {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: background 0.3s ease;
}

.menu-icon::before,
.menu-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.3s ease, top 0.3s ease;
}

.menu-icon::before {
    top: -7px;
}

.menu-icon::after {
    top: 7px;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon {
    background: transparent;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

@media (max-width: 768px) {
    :root {
        --header-height: 84px;
    }

    .header-content {
        flex-wrap: wrap;
        align-items: center;
        gap: 0.6rem;
        position: relative;
    }

    nav[role="navigation"] {
        order: 3;
        width: auto;
        position: static;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: 0;
        width: min(320px, 85vw);
        height: 100vh;
        padding: calc(var(--mobile-header-height, 72px) + 1rem) 1.75rem 2rem;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        background: var(--accent-dark);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 111;
        pointer-events: none;
        visibility: hidden;
    }

    .nav-menu.is-active {
        transform: translateX(0);
        pointer-events: auto;
        visibility: visible;
    }

    .light-mode .nav-menu {
        background: rgba(245, 243, 247, 0.98);
        border-left: 1px solid rgba(59, 28, 74, 0.1);
    }

    .mobile-menu-toggle {
        display: inline-flex;
        order: 2;
        margin-left: auto;
        cursor: pointer;
        z-index: 112;
    }

    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 110;
    }

    .mobile-menu-overlay.is-active {
        opacity: 1;
        pointer-events: auto;
    }

    body.nav-open {
        overflow: hidden;
    }

    .header {
        padding: 0.75rem 0;
    }

    .logo {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.85rem;
        opacity: 0.7;
        margin-top: 0;
    }

    .theme-toggle {
        margin-left: auto;
        padding: 0.45rem 0.85rem;
    }

}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 2px solid var(--light-accent);
    color: var(--light-accent);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.theme-toggle:hover {
    background: var(--light-accent);
    color: var(--primary-dark);
}

.theme-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    line-height: 1;
}

.theme-toggle-icon[hidden] {
    display: none !important;
}

.theme-toggle-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.theme-toggle-icon circle,
.theme-toggle-icon line {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.5;
}

.theme-toggle-icon path {
    fill: currentColor;
}

/* Posts */
.post-card {
    background: rgba(30, 15, 38, 0.6);
    border-radius: var(--card-radius, 16px);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(191, 162, 219, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.light-mode .post-card {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(59, 28, 74, 0.1);
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(59, 28, 74, 0.3);
}

.post-title {
    color: var(--light-accent);
    margin-bottom: 1rem;
}

.light-mode .post-title {
    color: var(--primary-dark);
}

.post-excerpt {
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.read-more {
    display: inline-block;
    background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end));
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.read-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(155, 89, 182, 0.4);
    color: white;
}

/* Featured Post */
.featured-post {
    background: linear-gradient(135deg, var(--accent-dark), var(--hover-accent));
    border-radius: var(--card-radius, 16px);
    padding: 2.5rem;
    margin-bottom: 3rem;
    position: relative;
}

.light-mode .featured-post {
    background: linear-gradient(135deg, #f8f6fa, #ede7f0);
}

.featured-post h2 {
    font-size: 2.5rem;
    color: var(--light-accent);
}

.light-mode .featured-post h2 {
    color: var(--primary-dark);
}

/* Sidebar */
.sidebar {
    background: rgba(30, 15, 38, 0.4);
    border-radius: var(--card-radius, 16px);
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.light-mode .sidebar {
    background: rgba(255, 255, 255, 0.6);
}

.sidebar-title {
    color: var(--light-accent);
    border-bottom: 2px solid var(--light-accent);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.light-mode .sidebar-title {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-dark);
}

/* Footer */
.footer {
    background: var(--accent-dark);
    padding: 3rem 0;
    margin-top: 4rem;
}

.light-mode .footer {
    background: #e8e2ed;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section {
    padding: 0 1rem;
}

.footer-section h3 {
    color: var(--light-accent);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-accent);
    font-size: 1.2rem;
}

.light-mode .footer-section h3 {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-dark);
}

.footer-posts,
.footer-categories {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-posts li,
.footer-categories li {
    margin-bottom: 0.5rem;
}

.footer-posts a,
.footer-categories a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.3s ease;
}

.light-mode .footer-posts a,
.light-mode .footer-categories a {
    color: var(--text-dark);
}

.footer-posts a:hover,
.footer-categories a:hover {
    color: var(--light-accent);
}

.footer-copyright {
    text-align: center;
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.light-mode .footer-copyright {
    border-top-color: rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        padding: 2rem 0;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .featured-post {
        padding: 1.5rem;
    }
    
    .featured-post h2 {
        font-size: 2rem;
    }
    
    .sidebar {
        position: static;
        margin-top: 2rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .featured-post,
    .post-card {
        padding: 1.5rem;
    }
    
    .featured-post h2 {
        font-size: 1.5rem;
    }
}

/* Social Media Links */
.social-links {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
}

.social-link {
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.light-mode .social-link {
    color: var(--text-dark);
    background: rgba(0, 0, 0, 0.05);
}

.social-link:hover {
    color: var(--light-accent);
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.2);
}

.light-mode .social-link:hover {
    background: rgba(0, 0, 0, 0.1);
}

.social-icon {
    font-size: 1.2rem;
    line-height: 1;
}

@media (max-width: 600px) {
    :root {
        --header-height: 96px;
        --book-header-offset: 100px;
    }

    .header {
        padding: 0.6rem 0;
    }

    .header-content {
        align-items: flex-start;
        gap: 0.45rem;
    }

    .tagline {
        display: block;
        font-size: 0.8rem;
        opacity: 0.65;
        margin-top: 0;
    }

    nav[role="navigation"] {
        margin-top: 0.2rem;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .mobile-menu-toggle {
        margin-left: auto;
    }
}
