/* ============================================
   CSS VARIABLES & ROOT STYLES
   ============================================ */
:root {
    --wine: #7d1e3e;
    --wine-light: #9d3a5a;
    --wine-dark: #5a1529;
    --cream: #faf8f5;
    --charcoal: #2a2a2a;
    --gray: #6a6a6a;
    --light-gray: #e8e6e3;
    scroll-behavior: smooth;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Work Sans', sans-serif;
    background: linear-gradient(135deg, var(--cream) 0%, #f5f2ed 100%);
    color: var(--charcoal);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
    cursor: default;
}

a, button {
    cursor: pointer;
}

/* Subtle texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.01) 2px,
            rgba(0, 0, 0, 0.01) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.01) 2px,
            rgba(0, 0, 0, 0.01) 4px
        );
    pointer-events: none;
    z-index: 1;
}

.container {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ============================================
   NAVIGATION
   ============================================ */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(250, 248, 245, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--light-gray);
    z-index: 1000;
    padding: 1rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

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

.nav-logo {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--wine);
    text-decoration: none;
    transition: all 0.3s ease;
    letter-spacing: -0.3px;
}

.nav-logo:hover {
    color: var(--wine-dark);
    transform: translateY(-1px);
}

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

.nav-links a {
    color: var(--charcoal);
    text-decoration: none;
    font-weight: 400;
    transition: all 0.3s ease;
    position: relative;
    padding: 0.25rem 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--wine);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.nav-links a.active {
    color: var(--wine);
    font-weight: 500;
}

/* ============================================
   SCROLL PROGRESS INDICATOR
   ============================================ */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--wine), var(--wine-light));
    z-index: 9999;
    transition: width 0.1s ease;
    box-shadow: 0 1px 3px rgba(125, 30, 62, 0.3);
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--wine);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(125, 30, 62, 0.3);
}

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

.back-to-top:hover {
    background: var(--wine-dark);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(125, 30, 62, 0.4);
}

.back-to-top:active {
    transform: translateY(-1px);
}

/* ============================================
   PAGE LOADER
   ============================================ */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--light-gray);
    border-top-color: var(--wine);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loader-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    color: var(--wine);
    letter-spacing: 2px;
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    text-align: center;
    padding: 3rem 0 2rem;
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 4rem;
    border-top: 1px solid var(--light-gray);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInCard {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    /* Smaller padding for mobile - just enough to clear the nav */
    body {
        padding-top: 75px;
    }

    nav {
        padding: 0.75rem 0;
    }

    .nav-content {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1.5rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .nav-logo {
        font-size: 1.3rem;
    }

    .nav-links a {
        font-size: 0.95rem;
    }

    .container {
        padding: 0 1.5rem;
    }

    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    /* Slightly more padding for very small screens */
    body {
        padding-top: 80px;
    }

    .container {
        padding: 0 1rem;
    }

    .nav-content {
        padding: 0.5rem 1rem;
    }
}
/* ============================================
   DARK MODE — append to bottom of main.css
   ============================================ */

body.dark-mode {
    /* Wine tones stay recognisable but are slightly warmer/brighter */
    --wine: #c43d5c;
    --wine-light: #d9566f;
    --wine-dark: #a82d4a;

    /* Backgrounds: warm dark rather than cold black */
    --cream: #1c1917;          /* warm near-black, mirrors the light cream tone */
    --charcoal: #ede9e4;       /* light text, same warmth as light-mode charcoal */
    --gray: #9a958e;           /* muted warm mid-tone */
    --light-gray: #2c2825;     /* warm dark border/divider, mirrors light-gray */

    background: linear-gradient(135deg, #1c1917 0%, #141210 100%);
    color: #ede9e4;
}

/* Match the light-mode texture — same opacity, just lightened strands */
body.dark-mode::before {
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.015) 2px,
            rgba(255, 255, 255, 0.015) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.015) 2px,
            rgba(255, 255, 255, 0.015) 4px
        );
}

body.dark-mode nav {
    background: rgba(22, 19, 17, 0.95);
    border-bottom-color: var(--light-gray);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body.dark-mode .page-loader {
    background: var(--cream);
}

/* Cards: slightly raised warm surface — mirrors light mode's white cards on cream */
body.dark-mode .entry,
body.dark-mode .note-card {
    background: #231f1c;
    border-color: rgba(196, 61, 92, 0.12);
}

body.dark-mode .note-card:hover,
body.dark-mode .entry:hover {
    box-shadow: 0 4px 20px rgba(196, 61, 92, 0.1);
    border-color: rgba(196, 61, 92, 0.22);
}

body.dark-mode .entry-logo {
    background: #2a2420;
    border-color: var(--light-gray);
}

body.dark-mode .skills-list {
    background: #231f1c;
    border-color: rgba(196, 61, 92, 0.12);
}

body.dark-mode .skill-row {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .quote-container {
    background: linear-gradient(135deg, rgba(196, 61, 92, 0.07), rgba(196, 61, 92, 0.03));
}

/* Buttons: keep solid style like light mode, just invert colours */
body.dark-mode .contact-links a,
body.dark-mode .entry-link,
body.dark-mode .download-btn {
    background: var(--wine);
    color: #f5f0eb;
    border-color: var(--wine);
    box-shadow: 0 2px 8px rgba(196, 61, 92, 0.25);
}

body.dark-mode .contact-links a:hover,
body.dark-mode .entry-link:hover,
body.dark-mode .download-btn:hover {
    background: var(--wine-dark);
    border-color: var(--wine-dark);
    box-shadow: 0 4px 14px rgba(196, 61, 92, 0.35);
}

body.dark-mode .btn {
    background: var(--wine);
    color: #f5f0eb;
    border-color: var(--wine);
    box-shadow: 0 2px 8px rgba(196, 61, 92, 0.25);
}
body.dark-mode .btn:hover {
    background: var(--wine-dark);
    border-color: var(--wine-dark);
}
body.dark-mode .btn-secondary {
    background: transparent;
    border-color: var(--light-gray);
    color: var(--charcoal);
    box-shadow: none;
}
body.dark-mode .btn-secondary:hover {
    background: rgba(237, 233, 228, 0.08);
    border-color: var(--gray);
}

body.dark-mode .detail-section {
    border-top-color: rgba(255, 255, 255, 0.07);
}

body.dark-mode .sub-entry {
    border-left-color: rgba(196, 61, 92, 0.25);
}

body.dark-mode .note-body code {
    background: rgba(196, 61, 92, 0.12);
    color: var(--wine-light);
}

body.dark-mode .note-body pre {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(196, 61, 92, 0.3);
}

body.dark-mode footer {
    border-top-color: var(--light-gray);
    color: var(--gray);
}

body.dark-mode .profile-photo {
    filter: contrast(0.97) saturate(0.9) brightness(0.88);
}

body.dark-mode .tag {
    background: rgba(196, 61, 92, 0.12);
    color: var(--wine-light);
}
body.dark-mode .tag:hover {
    background: rgba(196, 61, 92, 0.2);
}

body.dark-mode .back-to-top {
    background: var(--wine);
    box-shadow: 0 4px 12px rgba(196, 61, 92, 0.35);
}
body.dark-mode .back-to-top:hover {
    background: var(--wine-dark);
    box-shadow: 0 6px 16px rgba(196, 61, 92, 0.45);
}

/* ============================================
   DARK MODE TOGGLE BUTTON — fixed bottom right
   ============================================ */

.dark-mode-toggle {
    position: fixed;
    bottom: 5.5rem; /* sits just above the back-to-top button */
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--cream);
    color: var(--wine);
    border: 1px solid var(--light-gray);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-mode-toggle:hover {
    background: var(--wine);
    color: white;
    border-color: var(--wine);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(125, 30, 62, 0.3);
}

.dark-mode-toggle svg {
    pointer-events: none;
}

body.dark-mode .dark-mode-toggle {
    background: #231f1c;
    color: var(--wine-light);
    border-color: var(--light-gray);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

body.dark-mode .dark-mode-toggle:hover {
    background: var(--wine);
    color: #f5f0eb;
    border-color: var(--wine);
    box-shadow: 0 6px 16px rgba(196, 61, 92, 0.35);
}

@media (max-width: 768px) {
    .dark-mode-toggle {
        bottom: 4.5rem;
        right: 1.5rem;
        width: 45px;
        height: 45px;
    }
}