/* Root Variables */
:root {
    --primary-color: #f3eadb;
    --primary-rgb: 243, 234, 219;
    --secondary-color: #171512;
    --background-color: #171512;
    --surface-color: #211f1b;
    --text-primary: #f8f3ea;
    --text-secondary: #b9b0a2;
    --accent-color: #c9bda7;
    --border-color: #4b463e;
    --gradient-primary: #f3eadb;
    --gradient-secondary: #c9bda7;
    --code-bg: rgba(33, 31, 27, 0.88);
    --card-hover-shadow: rgba(var(--primary-rgb), 0.12);
}

/* Light Theme Variables */
body.light-theme {
    --primary-color: #322d26;
    --primary-rgb: 50, 45, 38;
    --secondary-color: #f4ecde;
    --background-color: #f4ecde;
    --surface-color: #fbf7ef;
    --text-primary: #211e19;
    --text-secondary: #6b6256;
    --accent-color: #8e7d67;
    --border-color: #d8cebc;
    --gradient-primary: #322d26;
    --gradient-secondary: #8e7d67;
    --code-bg: rgba(251, 247, 239, 0.88);
    --card-hover-shadow: rgba(var(--primary-rgb), 0.12);
    background-color: #f4ecde;
    background-image: url('../assets/handmade-paper.png');
    background-repeat: repeat;
    background-size: 520px auto;
}

body.light-theme .hero-section,
body.light-theme .about-section,
body.light-theme .skills-section,
body.light-theme .education-section,
body.light-theme .experience-section,
body.light-theme .projects-section,
body.light-theme .contact-section,
body.light-theme .footer {
    background-image: url('../assets/handmade-paper.png');
    background-repeat: repeat;
    background-size: 520px auto;
}

body:not(.light-theme) {
    background-image: linear-gradient(rgba(23, 21, 18, 0.38), rgba(23, 21, 18, 0.38)), url('../assets/dark-handmade-paper.jpg');
    background-repeat: no-repeat, repeat;
    background-size: 100% 100%, 520px 520px;
}

body:not(.light-theme) .hero-section,
body:not(.light-theme) .about-section,
body:not(.light-theme) .skills-section,
body:not(.light-theme) .education-section,
body:not(.light-theme) .experience-section,
body:not(.light-theme) .projects-section,
body:not(.light-theme) .contact-section,
body:not(.light-theme) .footer {
    background-image: linear-gradient(rgba(23, 21, 18, 0.38), rgba(23, 21, 18, 0.38)), url('../assets/dark-handmade-paper.jpg');
    background-repeat: no-repeat, repeat;
    background-size: 100% 100%, 520px 520px;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Let the loading moment establish the same tactile paper identity as the site. */
body.light-theme #loading-screen {
    background-color: #f4ecde;
    background-image: url('../assets/handmade-paper.png');
    background-repeat: repeat;
    background-size: 520px auto;
}

body:not(.light-theme) #loading-screen {
    background-image: linear-gradient(rgba(23, 21, 18, 0.38), rgba(23, 21, 18, 0.38)), url('../assets/dark-handmade-paper.jpg');
    background-repeat: no-repeat, repeat;
    background-size: 100% 100%, 520px 520px;
}

.loader {
    text-align: center;
}

.typing {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-brand {
    align-items: center;
    animation: logoFloat 2s ease-in-out infinite;
    color: var(--primary-color);
    display: flex;
    font-size: 2rem;
    font-weight: 600;
    gap: 0.45rem;
    justify-content: center;
    letter-spacing: 0.04em;
    line-height: 1;
}

.loading-brand .brand-mark {
    --brand-mark-size: 60px;
}

.loading-brand .brand-wordmark {
    font-size: 2rem;
}

.brand-mark {
    --brand-mark-size: 48px;
    display: block;
    flex: 0 0 var(--brand-mark-size);
    height: var(--brand-mark-size);
    overflow: hidden;
    width: var(--brand-mark-size);
}

.brand-mark img {
    display: block;
    height: 100%;
    max-width: none;
    object-fit: fill;
    transition: none;
    width: auto;
}

.brand-wordmark {
    color: var(--primary-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: lowercase;
}

.navbar-brand {
    gap: 0.45rem;
}

.navbar-brand:hover .brand-wordmark {
    color: var(--accent-color);
}

.loading-brand .brand-wordmark {
    font-weight: 600;
}

body:not(.light-theme) .brand-mark img {
    filter: invert(1) brightness(1.2);
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-10px) scale(1.05); }
}

.typing span {
    display: inline-block;
    animation: typing 1.5s ease-in-out infinite;
    color: var(--primary-color);
}

.typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60% { opacity: 1; transform: translateY(0); }
    30% { opacity: 0.5; transform: translateY(-10px); }
}

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.loading-text .cursor {
    animation: blink 1s infinite;
    color: var(--primary-color);
    font-weight: bold;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.progress-bar {
    width: 200px;
    height: 2px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    width: 0%;
    animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Navigation */
.navbar {
    background: rgba(23, 21, 18, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.navbar.navbar-scrolled {
    background: rgba(23, 21, 18, 0.98);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.brand-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.5rem 1rem !important;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 80%;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 1rem;
    font-size: 1rem;
}

.theme-toggle:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: rotate(180deg);
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Light theme specific styles */
body.light-theme .theme-toggle i::before {
    content: '\f186'; /* moon icon */
}

body.light-theme .hero-bg {
    opacity: 0.14;
}

body.light-theme .code-snippet {
    background: transparent;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(107, 98, 86, 0.16);
    color: #5f5649;
}

body.light-theme .navbar {
    background: rgba(232, 220, 199, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #d1c3ac;
    box-shadow: 0 4px 16px rgba(50, 45, 38, 0.06);
}

body.light-theme .navbar.navbar-scrolled {
    background: rgba(225, 211, 187, 0.98);
    box-shadow: 0 6px 20px rgba(50, 45, 38, 0.12);
}

body.light-theme .nav-link {
    color: #51483c !important;
}

body.light-theme .nav-link:hover,
body.light-theme .nav-link.active {
    color: var(--primary-color) !important;
}

body.light-theme .skill-badge:hover {
    background: var(--primary-color);
    color: var(--background-color);
}

body.light-theme .featured-project-card:hover {
    box-shadow: 0 10px 30px var(--card-hover-shadow);
}

body.light-theme .social-links a:hover {
    background: var(--primary-color);
    color: var(--background-color);
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 0;
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.hero-section > .container {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    text-align: center;
    z-index: 1;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.code-snippet {
    position: absolute;
    top: 20%;
    right: -20%;
    font-size: 1.0rem;
    color: var(--text-secondary);
    transform: rotate(15deg);
    animation: float 6s ease-in-out infinite;

}

.code-snippet-left {
    left: -5%;
    right: auto;
    top: 32%;
    transform: rotate(-14deg);
    animation: float-left 7s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: rotate(15deg) translateY(0px); }
    50% { transform: rotate(15deg) translateY(-20px); }
}

@keyframes float-left {
    0%, 100% { transform: rotate(-14deg) translateY(0px); }
    50% { transform: rotate(-14deg) translateY(16px); }
}

.hero-content {
    position: relative;
    text-align: center;
    z-index: 2;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.1;
}

.greeting {
    display: block;
    font-size: 0.4em;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.name {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hero-cta {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 3rem;
}

.hero-cta .me-3 {
    margin-right: 0 !important;
}

.btn {
    padding: 0.8rem 2rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn.btn-primary {
    --bs-btn-active-bg: var(--gradient-primary);
    --bs-btn-active-border-color: var(--gradient-primary);
    --bs-btn-bg: var(--gradient-primary);
    --bs-btn-border-color: var(--gradient-primary);
    --bs-btn-focus-shadow-rgb: var(--primary-rgb);
    --bs-btn-hover-bg: var(--gradient-primary);
    --bs-btn-hover-border-color: var(--gradient-primary);
    background-color: var(--gradient-primary) !important;
    background-image: none !important;
    border-color: var(--gradient-primary) !important;
    color: var(--background-color) !important;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.22);
}

.btn.btn-primary:hover,
.btn.btn-primary:focus,
.btn.btn-primary:active {
    background-color: var(--gradient-primary) !important;
    border-color: var(--gradient-primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.32);
    color: var(--background-color) !important;
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--text-primary);
    color: var(--background-color);
    border-color: var(--text-primary);
}

.social-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 4rem;
}

.social-links a {
    width: 50px;
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-links a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-3px);
}

.scroll-indicator {
    animation: scroll-bounce 2s infinite;
    bottom: 1.75rem;
    left: 50%;
    position: absolute;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    transform: translateX(-50%);
}

.scroll-arrow {
    margin-top: 0.3rem;
    font-size: 1.3rem;
}

@keyframes scroll-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) translateY(0); }
    40% { transform: translateX(-50%) translateY(-10px); }
    60% { transform: translateX(-50%) translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-indicator {
        animation: none;
    }
}

/* The chess board has been replaced visually by a quieter, portfolio-specific companion. */
.chess-board-container {
    display: none !important;
    position: absolute;
    right: 10%;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.15;
    z-index: 1;
    animation: chessFloat 6s ease-in-out infinite;
}

@keyframes chessFloat {
    0%, 100% { transform: translateY(-50%) rotate(0deg); }
    33% { transform: translateY(-45%) rotate(1deg); }
    66% { transform: translateY(-55%) rotate(-1deg); }
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 35px);
    grid-template-rows: repeat(8, 35px);
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface-color);
    box-shadow: 0 15px 40px rgba(var(--primary-rgb), 0.2);
    position: relative;
    transform: rotate(15deg);
}

.chess-square {
    width: 35px;
    height: 35px;
    transition: all 0.3s ease;
}

.chess-square.light {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.bug {
    filter: grayscale(1) contrast(0.82);
    mix-blend-mode: multiply;
    opacity: 0.48;
    pointer-events: none !important;
    z-index: 6 !important;
}

body:not(.light-theme) .bug {
    filter: grayscale(1) invert(1) contrast(0.8);
    mix-blend-mode: screen;
    opacity: 0.54;
}

.ladybug {
    font-size: 1.15rem;
    line-height: 1;
    opacity: 0.92;
    pointer-events: none;
    position: fixed;
    z-index: 6;
}

.ladybug-one {
    animation: ladybug-wander-one 13s ease-in-out infinite;
    right: 12vw;
    top: 18vh;
}

.ladybug-two {
    animation: ladybug-wander-two 16s ease-in-out infinite;
    bottom: 16vh;
    left: 14vw;
}

@keyframes ladybug-wander-one {
    0%, 100% { transform: translate(0, 0) rotate(8deg); }
    35% { transform: translate(-8vw, 7vh) rotate(-14deg); }
    70% { transform: translate(-3vw, 15vh) rotate(18deg); }
}

@keyframes ladybug-wander-two {
    0%, 100% { transform: translate(0, 0) rotate(-12deg); }
    40% { transform: translate(9vw, -8vh) rotate(16deg); }
    75% { transform: translate(5vw, -17vh) rotate(-6deg); }
}

@media (max-width: 991px) {
    .ladybug {
        font-size: 0.8rem;
        opacity: 0.78;
    }

    .ladybug-one {
        animation-duration: 19s;
        right: 8vw;
        top: 16vh;
    }

    .ladybug-two {
        animation-duration: 22s;
        bottom: 12vh;
        left: 9vw;
    }

    .bug {
        opacity: 0.38;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ladybug,
    .bug {
        display: none;
    }
}

.chess-square.dark {
    background-color: var(--primary-color);
    border: 1px solid rgba(var(--primary-rgb), 0.4);
    box-shadow: inset 0 0 10px rgba(var(--primary-rgb), 0.3);
}

.chess-piece {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-primary);
    text-shadow: 0 0 10px var(--primary-color);
    animation: pieceGlow 3s ease-in-out infinite alternate;
    pointer-events: none;
    width: 35px;
    height: 35px;
    z-index: 2;
}

@keyframes pieceGlow {
    0% { 
        text-shadow: 0 0 10px var(--primary-color);
        transform: scale(1);
    }
    100% { 
        text-shadow: 0 0 18px var(--primary-color), 0 0 25px var(--primary-color);
        transform: scale(1.1);
    }
}

.chess-board:hover {
    transform: rotate(15deg) scale(1.05);
    box-shadow: 0 15px 40px rgba(var(--primary-rgb), 0.28);
}

.chess-board:hover .chess-square.dark {
    background-color: var(--primary-color);
    box-shadow: inset 0 0 15px rgba(var(--primary-rgb), 0.45);
}

.chess-board:hover .chess-piece {
    animation-duration: 1.5s;
}

/* Larger screens get an even bigger board */
@media (min-width: 1400px) {
    .chess-board {
        grid-template-columns: repeat(8, 42px);
        grid-template-rows: repeat(8, 42px);
        border: 4px solid var(--primary-color);
        padding: 15px;
    }
    
    .chess-square {
        width: 42px;
        height: 42px;
    }
    
    .chess-piece {
        width: 42px;
        height: 42px;
        font-size: 28px;
    }
}

/* Section Styles */
section {
    padding: 6rem 0;
}

.section-header {
    margin-bottom: 4rem;
}

.section-kicker {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    margin: 0 0 0.55rem;
    text-transform: uppercase;
}

.section-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
    display: inline-block;
}

.section-header h2::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--gradient-primary);
}

/* About Section */
.about-section {
    background-color: var(--surface-color);
}

.about-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.about-content .lead {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.profile-image {
    text-align: center;
    max-width: 250px;
    margin: 0 auto;
    padding-left: 2rem;
}

.profile-image img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: center;
    border-radius: 20px;
    border: 3px solid var(--border-color);
    transition: all 0.3s ease;
    display: block;
}

.profile-image img:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Skills Section */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.skill-category h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.skill-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.skill-badge {
    background: var(--surface-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.skill-badge:hover {
    background: var(--primary-color);
    color: var(--background-color);
    transform: translateY(-2px);
}

/* Education Section */
.education-section {
    background: var(--surface-color);
}

.education-item {
    background: var(--background-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.education-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.education-header h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.duration {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.education-details h4 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.gpa {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Achievements Sidebar (Education Section) */
.achievements-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-left: 2rem;
}

.achievement-card {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.achievement-card h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
}

.achievement-card h4::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 2px;
    background: var(--gradient-primary);
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: var(--surface-color);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.achievement-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.achievement-item i {
    color: var(--primary-color);
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.achievement-item div strong {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.achievement-item div span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.skills-highlight {
    background: var(--background-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.skills-highlight h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
}

.skills-highlight h4::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 2px;
    background: var(--gradient-primary);
}

.focus-area {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.focus-area:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.focus-icon {
    background: var(--gradient-primary);
    color: var(--background-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.focus-content strong {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.focus-content p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
}

/* Experience Section */
.experience-item {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.experience-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.company-info h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.location {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tech-badge {
    background: var(--background-color);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    border: 1px solid var(--primary-color);
}

.achievements {
    list-style: none;
    padding: 0;
}

.achievements li {
    margin-bottom: 0.8rem;
    position: relative;
    padding-left: 1.5rem;
}

.achievements li::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-size: 0.8rem;
}

/* Projects Section */
.projects-section {
    background-color: var(--surface-color);
}

.projects-intro {
    color: var(--text-secondary);
    font-size: 1.12rem;
    margin: -2rem 0 2.5rem;
    max-width: 650px;
}

.featured-projects {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.featured-project-card {
    background: var(--background-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.featured-project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.featured-project-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px var(--card-hover-shadow);
}

.project-preview {
    background: var(--background-color);
    border: 0;
    cursor: pointer;
    display: block;
    overflow: hidden;
    padding: 0;
    position: relative;
}

.project-preview img {
    display: block;
    height: 250px;
    object-fit: cover;
    object-position: top;
    transition: transform 0.35s ease;
    width: 100%;
}

.project-preview::after {
    background: linear-gradient(to top, rgba(33, 30, 25, 0.55), transparent 45%);
    content: '';
    inset: 0;
    position: absolute;
}

.project-preview:hover img,
.project-preview:focus-visible img {
    transform: scale(1.04);
}

.project-preview:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

.preview-label {
    bottom: 0.85rem;
    color: #fffaf0;
    font-size: 0.76rem;
    font-weight: 700;
    left: 1rem;
    letter-spacing: 0.08em;
    position: absolute;
    text-transform: uppercase;
    z-index: 1;
}

.featured-project-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 1.5rem;
}

.featured-project-content .tech-stack {
    margin-top: auto;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.project-header h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.project-duration {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.project-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.project-details ul {
    list-style: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

.project-details li {
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.95rem;
}

.project-details li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

.project-links {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.project-link {
    background: transparent;
    border: 0;
    color: var(--primary-color);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: inherit;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.project-link:hover {
    color: var(--text-primary);
}

.project-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
    margin-top: 1.25rem;
}

.featured-project-content .project-actions {
    align-self: flex-start;
}

.compact-project .project-actions {
    justify-content: flex-end;
}

.more-work {
    border-top: 1px solid var(--border-color);
    margin-top: 3.5rem;
    padding-top: 1.1rem;
}

.more-work summary {
    align-items: center;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    font-size: 1.05rem;
    font-weight: 700;
    justify-content: space-between;
    list-style: none;
}

.more-work summary::-webkit-details-marker { display: none; }

.more-work-count {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.more-work[open] .more-work-count .fa-plus { transform: rotate(45deg); }

.more-work-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1.5rem;
}

.compact-project {
    align-items: center;
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1.15rem 1.25rem;
}

.compact-project h3 { color: var(--text-primary); font-size: 1rem; margin: 0 0 0.25rem; }
.compact-project p { color: var(--text-secondary); font-size: 0.86rem; margin: 0; }

.mobile-only-project { display: none; }
.mobile-more-count { display: none; }

.project-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

/* Contact Section */
.contact-section {
    background: var(--background-color);
}

.contact-content h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.contact-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.contact-info {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.contact-item i {
    color: var(--primary-color);
    width: 20px;
}

/* Footer */
.footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-content p {
    color: var(--text-secondary);
    margin: 0;
}

.footer-social {
    display: flex;
    gap: 1rem;
}

.footer-social a {
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.footer-social a:hover {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .section-header h2 {
        font-size: 2rem;
    }
    
    .featured-projects {
        grid-template-columns: 1fr;
    }

    .desktop-featured { display: none; }
    .mobile-only-project { display: flex; }
    .desktop-more-count { display: none; }
    .mobile-more-count { display: inline; }
    
    .skills-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .education-header,
    .experience-header,
    .project-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .hero-cta {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .hero-cta .btn {
        text-align: center;
        width: 100%;
        max-width: 280px;
        margin: 0 !important; /* Override Bootstrap margin classes */
        padding: 1rem 2rem;
        font-size: 1rem;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .theme-toggle {
        margin-left: 0.5rem;
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .navbar-brand .brand-mark {
        --brand-mark-size: 42px;
    }

    .navbar-brand .brand-wordmark {
        font-size: 1.3rem;
    }
    
    .profile-image {
        max-width: 200px;
        margin-bottom: 2rem;
        padding-left: 1rem;
    }
    
    .profile-image img {
        height: 320px;
    }

    .more-work-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    section {
        padding: 4rem 0;
    }
    
    .hero-section {
        text-align: center;
        min-height: 100svh;
    }

    .hero-section > .container {
        min-height: 100svh;
        padding-top: 4.75rem;
    }
    
    .code-snippet {
        display: none;
    }
    
    .experience-item,
    .education-item {
        padding: 1.5rem;
    }

    .featured-project-content { padding: 1.35rem; }
    .project-preview img { height: 225px; }
    .projects-intro { font-size: 1rem; margin-top: -2.5rem; }
    .compact-project { align-items: flex-start; flex-direction: column; }
    
    .profile-image {
        max-width: 150px;
        padding-left: 0;
        margin: 0 auto 2rem auto;
    }
    
    .profile-image img {
        height: 280px;
    }
    
    .navbar-brand .brand-mark {
        --brand-mark-size: 40px;
    }

    .navbar-brand .brand-wordmark {
        font-size: 1.2rem;
    }
    
    .about-content {
        text-align: center;
    }
}

/* Landscape phones have very little vertical space once the browser chrome and
   fixed navigation are visible. Keep the introduction below the navigation
   instead of vertically centering it underneath the bar. */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .navbar {
        inset-inline: 0;
        max-width: none;
        padding-block: 0.65rem;
        width: 100vw;
    }

    .navbar > .container {
        max-width: none;
        padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right));
        width: 100%;
    }

    .hero-section,
    .hero-section > .container {
        min-height: 100svh;
    }

    .hero-section > .container {
        justify-content: flex-start;
        padding-bottom: 1rem;
        padding-top: max(7.5rem, calc(env(safe-area-inset-top) + 6.5rem));
    }

    .hero-title {
        font-size: clamp(2rem, 4vw, 2.8rem);
        margin-bottom: 0.35rem;
    }

    .greeting { margin-bottom: 0.15rem; }

    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 0.85rem;
    }

    .hero-cta { margin-bottom: 0.9rem; }
    .social-links { display: none; }
    .scroll-indicator { display: none; }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: var(--background-color);
}

/* Smooth transitions */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* Smooth theme transition for specific elements */
body,
.navbar,
.hero-section,
.about-section,
.skills-section,
.education-section,
.experience-section,
.projects-section,
.contact-section,
.footer,
.featured-project-card,
.education-item,
.experience-item,
.contact-info,
.skill-badge,
.tech-badge {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Project Modal Styles */
.modal-content {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.modal-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.modal-header .modal-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
}

.btn-close {
    background: transparent !important;
    background-image: none !important;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    flex: 0 0 44px;
    height: 44px;
    opacity: 1;
    padding: 0;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* The themed close button intentionally replaces Bootstrap's background SVG. */
.btn-close::before {
    content: '×';
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
}

.btn-close:hover {
    background-color: var(--border-color) !important;
    color: var(--text-primary);
}

.btn-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-close:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-rgb), 0.22);
}

.modal-body {
    padding: 2rem;
    background-color: var(--surface-color);
}

.project-modal-content {
    color: var(--text-primary);
}

.screenshot-gallery {
    margin: 0 auto;
    max-width: 320px;
    width: 100%;
}

.main-screenshot {
    width: 100%;
    aspect-ratio: 0.49;
    height: auto;
    overflow: hidden;
    border-radius: 8px;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-screenshot img {
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    width: 100%;
}

.screenshot-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.thumbnail {
    width: 80px;
    height: 60px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.thumbnail.active {
    border-color: var(--primary-color);
    opacity: 1;
}

.thumbnail:focus-visible {
    opacity: 1;
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.project-info {
    padding-left: 1rem;
}

.project-info h6 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
    font-size: 1rem;
}

.project-info h6:first-child {
    margin-top: 0;
}

.project-info p,
.project-info li {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.project-info ul {
    padding-left: 1.2rem;
}

.project-stats {
    background-color: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.project-stats .stat {
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.project-stats .stat strong {
    color: var(--text-primary);
}

/* Keep desktop case studies compact enough to read without page scrolling. */
@media (min-width: 769px) {
    .modal-dialog.modal-lg {
        max-width: 1060px;
    }

    .modal-header {
        padding: 1rem 1.35rem;
    }

    .modal-header .modal-title {
        font-size: 1.15rem;
    }

    .modal-body {
        padding: 1.1rem 1.35rem;
    }

    .modal-body .row {
        --bs-gutter-x: 1.6rem;
    }

    .screenshot-gallery {
        max-width: 280px;
        text-align: center;
    }

    .main-screenshot {
        aspect-ratio: auto;
        display: inline-flex;
        height: min(54vh, 435px);
        width: auto;
    }

    .main-screenshot img {
        object-fit: contain;
        width: auto;
    }

    .screenshot-thumbnails {
        flex-wrap: nowrap;
        gap: 0.35rem;
        margin-top: 0.55rem !important;
        overflow-x: auto;
        padding-bottom: 0.2rem;
        text-align: initial;
    }

    .thumbnail {
        flex: 0 0 auto;
        height: 48px;
        width: 36px;
    }

    .project-info {
        padding-left: 0;
    }

    .project-info h6 {
        font-size: 0.95rem;
        margin: 0.7rem 0 0.3rem;
    }

    .project-info p,
    .project-info li {
        font-size: 0.79rem;
        line-height: 1.4;
        margin-bottom: 0.24rem;
    }

    .project-info ul {
        column-count: 2;
        column-gap: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .project-info li {
        break-inside: avoid;
    }

    .project-info .tech-stack {
        gap: 0.3rem;
        margin-bottom: 0.65rem;
    }

    .project-info .tech-badge {
        font-size: 0.69rem;
        padding: 0.18rem 0.54rem;
    }

    .project-stats {
        padding: 0.62rem 0.78rem;
    }

    .project-stats .stat {
        font-size: 0.75rem;
        margin-bottom: 0.18rem;
    }
}

/* Modal Responsive Design */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .project-info {
        padding-left: 0;
        margin-top: 1.5rem;
    }
    
    .main-screenshot {
        aspect-ratio: 0.49;
    }
    
    .thumbnail {
        width: 60px;
        height: 45px;
    }
    
    /* Enhanced mobile close button */
    .btn-close {
        font-size: 1.5rem;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--surface-color);
        border: 2px solid var(--border-color);
        border-radius: 50%;
        color: var(--text-primary);
        opacity: 1;
        position: relative;
        z-index: 1050;
    }
    
    .btn-close:hover,
    .btn-close:focus-visible {
        background-color: var(--primary-color) !important;
        color: var(--background-color);
        border-color: var(--primary-color);
        transform: scale(1.1);
        transition: all 0.2s ease;
    }
    
    /* Mobile modal swipe indicator */
    .mobile-modal-indicator {
        position: sticky;
        top: 0;
        z-index: 1050;
        padding: 8px 0;
        display: flex;
        justify-content: center;
        background-color: var(--surface-color);
    }
    
    .swipe-bar {
        width: 40px;
        height: 4px;
        background-color: var(--border-color);
        border-radius: 2px;
        opacity: 0.7;
    }
    
    /* Adjust modal header padding for mobile */
    .modal-header {
        padding: 1rem 1.5rem 1rem 1rem;
        position: relative;
    }
    
    .modal-title {
        padding-right: 50px; /* Space for close button */
        font-size: 1.1rem;
    }
}

/* Modal Animation */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: scale(0.9);
}

.modal.show .modal-dialog {
    transform: scale(1);
}

/* Screenshot placeholder styles */
.main-screenshot img[src*="data:image/svg+xml"] {
    opacity: 0.5;
}

/* Dark theme modal adjustments */
body.light-theme .modal-content {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body:not(.light-theme) .modal-content {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Keep the About section on one uninterrupted sheet of paper on phones. */
@media (max-width: 768px) {
    body.light-theme .about-section {
        background-color: #f4ecde;
        background-image: url('../assets/handmade-paper.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
    }

    .contact-content {
        margin-bottom: 2.25rem;
    }
}

/* Keep the code texture away from the hero copy in narrower desktop windows. */
@media (min-width: 769px) and (max-width: 1599px) {
    .hero-bg {
        opacity: 0.055;
    }

    body.light-theme .hero-bg {
        opacity: 0.07;
    }

    .code-snippet {
        font-size: 0.88rem;
    }

    .code-snippet:not(.code-snippet-left) {
        right: -32%;
        top: 13%;
    }

    .code-snippet-left {
        left: -12%;
        top: 35%;
    }
}
