/* ==========================================================================
   1. Imports andRoot Variables
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600&family=Source+Serif+Pro:wght@400;500&display=swap');

:root {
    /* Dark theme (default) - Warm and pleasant */
    --bg-color: #0f1419;
    --text-color: #e6e1dc;
    --bg-gradient-from: #0f1419;
    --bg-gradient-to: #1a1f2e;
    --link-color: #80b4ff;
    --link-hover-color: #99c7ff;
    --border-color: rgba(230, 225, 220, 0.1);
}

:root[data-theme="light"] {
    --bg-color: #fefcfb;
    --text-color: #2d3748;
    --bg-gradient-from: #fefcfb;
    --bg-gradient-to: #f0f4f8;
    --link-color: #3b82f6;
    --link-hover-color: #2563eb;
    --border-color: rgba(160, 174, 192, 0.15);
    --accent-rose: #f687b3;
    --accent-teal: #4fd1c7;
    --accent-orange: #ed8936;
}

/* ==========================================================================
   2. Base Styles
   ========================================================================== */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Source Serif Pro', Georgia, serif;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
    font-size: 1.05rem;
}

/* Remove transitions for instant theme switching */
body, 
.front-page,
.page-description,
.page-navigation,
.mobile-menu,
h1, h2, h3, h4, h5, h6,
p, li, a {
    transition: none;
}

/* Keep transitions only for interactive elements */
.theme-toggle,
.social-links a {
    transition: opacity 0.15s ease, transform 0.15s ease;
}

/* ==========================================================================
   3. Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-color);
    margin-bottom: 1rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.75rem;
    margin-top: 2rem;
}

p {
    margin-bottom: 1.5rem;
    letter-spacing: -0.003em;
}

/* ==========================================================================
   4. Layout
   ========================================================================== */
.front-page {
    background: linear-gradient(145deg, var(--bg-gradient-from) 0%, var(--bg-gradient-to) 100%);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Light mode: Subtle colorful gradient */
:root[data-theme="light"] .front-page {
    background: linear-gradient(135deg, #fefcfb 0%, #f8fafc 40%, #f6f9fc 60%, #f0f4f8 100%);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.04);
}

/* Dark mode: More varied, subtle gradient */
:root[data-theme="dark"] .front-page,
:root:not([data-theme="light"]) .front-page {
    background: linear-gradient(135deg, #0f1419 0%, #111621 25%, #131924 65%, #151b26 100%);
    box-shadow: 0 4px 20px rgba(128, 180, 255, 0.02);
}

@media screen and (min-width: 640px) {
    .front-page {
        position: absolute;
        left: 50%;
        top: 5%;
        transform: translate(-50%, 0%);
        line-height: 25px;
        display: flex;
        max-width: 1200px;
        width: 90%;
    }

    .page-description {
        flex: 5;
        padding-right: 2rem;
    }
}

/* ==========================================================================
   5. Navigation
   ========================================================================== */
.page-navigation {
    padding-top: 2.5%;
    flex: 1;
}

.page-navigation a {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    margin-bottom: 1rem;
    display: inline-block;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.page-navigation a:hover {
    color: var(--link-color) !important;
    text-decoration: none;
}



@media screen and (min-width: 640px) {
    .page-navigation {
        border-left: 1px solid var(--border-color);
        padding-left: 2rem;
    }
}

/* ==========================================================================
   6. Links and Buttons
   ========================================================================== */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 18px;
    border: none;
    background-color: transparent;
    color: var(--text-color);
    cursor: pointer;
    transition: opacity 0.15s ease;
    z-index: 1000;
    font-size: 0.8rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0.6;
    text-decoration: underline;
}

.theme-toggle:hover {
    opacity: 1;
}

/* Light mode: Remove background, keep as text only */
:root[data-theme="light"] .theme-toggle {
    background-color: transparent;
    box-shadow: none;
    border: none;
}

:root[data-theme="light"] .theme-toggle:hover {
    background-color: transparent;
    box-shadow: none;
    opacity: 1;
}

/* Back Navigation Container */
.back-navigation {
    margin-bottom: -1rem;
    margin-top: 0.5rem;
}

/* Back Button - Simple and clear */
.back-button {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0;
    background: transparent;
    border: none;
    color: var(--text-color) !important;
    text-decoration: underline;
    text-decoration-color: var(--border-color);
    text-underline-offset: 3px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 0.9;
}

.back-button:hover {
    opacity: 1;
    text-decoration-color: var(--link-color);
    transform: translateX(-2px);
    text-decoration: underline !important;
}

.back-arrow {
    margin-right: 0.5rem;
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.2s ease;
    opacity: 0.9;
}

.back-button:hover .back-arrow {
    transform: translateX(-2px);
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .back-navigation {
        text-align: center;
        margin-bottom: 1.5rem;
        margin-top: 1rem;
    }
    
    .back-button {
        font-size: 1rem;
        font-weight: 500;
        opacity: 1;
        padding: 0.5rem 1rem;
        background: rgba(var(--text-color), 0.05);
        border-radius: 8px;
        text-decoration: none;
    }
    
    .back-arrow {
        font-size: 1rem;
        margin-right: 0.5rem;
    }
    
    .back-button:hover {
        background: rgba(var(--text-color), 0.1);
        text-decoration: none !important;
    }
}

/* ==========================================================================
   7. Mobile Navigation
   ========================================================================== */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 1.2rem;
    left: 1.2rem;
    z-index: 1001;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mobile-nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 5px 0;
    background: var(--text-color);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 45%;
    max-width: 200px;
    height: 100vh;
    background: var(--bg-gradient-from);
    padding: 4rem 1.5rem;
    transition: left 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.mobile-menu.active {
    left: 0;
    position: fixed;
    top: 0;
    z-index: 1003;
}

.mobile-menu a {
    display: block;
    padding: 1rem 0;
    color: var(--text-color);
    text-decoration: none;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: transform 0.2s ease;
}

.mobile-menu a:hover {
    color: var(--link-color);
    transform: translateX(3px);
}

/* ==========================================================================
   8. Back to Top Button
   ========================================================================== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: var(--text-color);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--link-color);
    color: var(--bg-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Hide back-to-top on desktop where it's less needed */
@media screen and (min-width: 768px) {
    .back-to-top {
        display: none;
    }
}

/* ==========================================================================
   9. Media Queries
   ========================================================================== */
/* Mobile and Tablet */
@media screen and (max-width: 768px) {
    .front-page {
        margin-top: 0;
        padding: 3.5rem 1.5rem 1.5rem;
        position: relative;
    }

    .mobile-nav-toggle {
        position: fixed;
        top: 1rem;
        left: 1rem;
        display: block;
    }

    .theme-toggle {
        position: absolute;
        top: 1rem;
        right: 1rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        z-index: 1002;
    }

    .back-button {
        position: absolute;
        top: 3.5rem;
        right: 1rem;
        z-index: 1001;
    }

    .page-navigation {
        display: none;
    }
}

/* iPhone XR/similar sizes */
@media screen and (max-width: 414px) {
    .front-page {
        padding: 3rem 1rem 1rem;
        border-radius: 12px;
        position: relative;
    }

    .mobile-nav-toggle {
        top: 0.8rem;
        left: 0.8rem;
    }

    .theme-toggle {
        top: 0.8rem;
        right: 0.8rem;
        padding: 0.3rem 0.7rem;
        font-size: 0.8rem;
    }

    .back-button {
        top: 3.2rem;
        right: 0.8rem;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
}

/* Laptop screens (13-14 inch) */
@media screen and (min-width: 1024px) and (max-width: 1440px) {
    .front-page {
        width: 85%;
        max-width: 1100px;
    }
    
    /* Adjust theme toggle position for 13-inch MacBooks */
    .theme-toggle {
        top: 1rem;
        right: 1rem;
    }
}

/* Book title styling */
.page-description ol i {
    color: #d4a5a5;  /* Soft rose for dark mode */
    transition: color 0.2s ease;
}

/* Adjust book title color for light mode */
:root[data-theme="light"] .page-description ol i {
    color: #9e4244;  /* Deep rose for light mode */
}

/* Optional hover effect */
.page-description ol i:hover {
    color: var(--link-color);
}

/* ==========================================================================
   Social Links
   ========================================================================== */
.social-links {
    position: absolute;
    top: 3.5rem;
    right: 1rem;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 14px;
    z-index: 900;
    transform: translateX(-15px); /* Center under button with 4 icons */
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.5;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.social-links a:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.social-links svg {
    width: 16px;
    height: 16px;
}

/* Mobile: Move to bottom of content */
@media (max-width: 768px) {
    .social-links {
        position: static;
        flex-direction: row;
        justify-content: center;
        margin-top: 40px;
        margin-bottom: 40px;
        gap: 30px;
        transform: none; /* Reset desktop transform */
    }
    
    .social-links a {
        opacity: 0.7;
    }
    
    .social-links svg {
        width: 22px;
        height: 22px;
    }
}
