:root {
    /* Palette - Coffee Theme */
    --color-coffee-dark: #3b2f2f; /* Dark Roast - Replaces Charcoal */
    --color-coffee-medium: #6F4E37; /* Medium Roast */
    --color-cream: #F5E8C7; /* Light Roast/Foam */
    --color-gold: #D4A574; /* Caramel/Gold Accent */
    --color-teal: #1D7874; /* Deep Teal Accent - Optimized for contrast */
    --color-orange: #E76F51; /* Warm Orange/Terracotta */
    
    /* Semantic Colors - Light Mode Default */
    --bg-body: var(--color-cream);
    --text-body: var(--color-coffee-dark);
    --bg-surface: color-mix(in srgb, var(--color-cream), white 40%);
    --color-primary: var(--color-teal); /* Replaces Electric Blue */
    --color-secondary: var(--color-gold);
    
    --border-subtle: color-mix(in srgb, var(--color-coffee-medium), transparent 85%);
    --shadow-soft: 0 4px 20px -2px color-mix(in srgb, var(--color-coffee-dark), transparent 90%);
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* BS Overrides */
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-body);
    --bs-primary: var(--color-primary);
    --bs-primary-rgb: 42, 157, 143; /* RGB of Teal */
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Semantic Colors - Dark Mode */
        --bg-body: var(--color-coffee-dark);
        --text-body: var(--color-cream);
        --bg-surface: color-mix(in srgb, var(--color-coffee-dark), black 20%);
        --border-subtle: color-mix(in srgb, var(--color-cream), transparent 85%);
        --shadow-soft: 0 4px 20px -2px black;
        
        /* BS Overrides */
        --bs-body-bg: var(--bg-body);
        --bs-body-color: var(--text-body);
        --bs-dark: #1f1a17;
    }
}

/* Global Reset & Base */
body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: text-decoration-color 0.2s;
    
    &:hover {
        text-decoration: underline;
        text-decoration-thickness: 2px;
        text-underline-offset: 4px;
    }
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 800;
    letter-spacing: -0.03em;
    color: currentColor;
    margin-bottom: 1rem;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    margin-top: 3rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-secondary);
    display: inline-block;
}

/* Header/Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    padding: 2rem 1rem;
    z-index: 1;
}

.hero-content {
    max-width: 900px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(3rem, 8vw, 5.5rem);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--color-coffee-dark) 0%, var(--color-coffee-medium) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

.hero-subtitle {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    margin-bottom: 2.5rem;
    color: var(--color-coffee-dark);
    font-weight: 500;
    min-height: 1.5em;
    opacity: 0.9;
}

@media (prefers-color-scheme: dark) {
    .hero-title {
        background: linear-gradient(135deg, var(--color-cream) 0%, var(--color-gold) 100%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    
    .hero-subtitle {
        color: var(--color-cream);
    }
}

/* Cards (Services & Portfolio) */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
    height: 100%;
    
    /* Scroll Animation Entry */
    view-timeline-name: --card-entry;
    view-timeline-axis: block;
    animation: fade-in-up linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 20%;

    &:hover {
        transform: translateY(-4px) scale(1.01);
        box-shadow: var(--shadow-soft);
        border-color: var(--color-secondary);
    }
    
    .card-img-top {
        aspect-ratio: 16/9;
        object-fit: cover;
        transition: transform 0.5s ease;
    }
    
    &:hover .card-img-top {
        transform: scale(1.05);
    }

    .card-body {
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        
        h5.card-title {
            font-size: 1.25rem;
            margin-bottom: 0.75rem;
        }
        
        p.card-text {
            font-size: 0.95rem;
            opacity: 0.9;
            flex-grow: 1;
        }
    }
}

/* List Group (Services) */
.list-group {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--border-subtle);
    
    .list-group-item {
        background-color: var(--bg-surface);
        border-color: var(--border-subtle);
        font-weight: 500;
        transition: background-color 0.2s;
        
        &:hover {
            background-color: color-mix(in srgb, var(--color-primary), transparent 95%);
            border-left: 4px solid var(--color-secondary);
        }
    }
}

/* Footer */
footer {
    background-color: var(--color-coffee-dark) !important;
    color: var(--color-cream) !important;
    padding: 3rem 0;
    margin-top: 5rem;
    border-top: 4px solid var(--color-secondary);
    
    a {
        color: var(--color-cream);
        opacity: 0.7;
        
        &:hover {
            opacity: 1;
            color: var(--color-secondary);
        }
    }
}

/* Animations */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Container Queries for Responsive Typography inside cards if needed */
.card-body {
    container-type: inline-size;
}

@container (max-width: 300px) {
    .card-title {
        font-size: 1.1rem;
    }
}

/* Utility Overrides for Bootstrap Buttons to match theme */
.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    padding: 0.6em 1.2em;
    border-radius: 50px;
    
    &:hover, &:focus, &:active {
        background-color: color-mix(in srgb, var(--color-primary), black 10%) !important;
        border-color: color-mix(in srgb, var(--color-primary), black 10%) !important;
    }
}

/* ===== SCROLL PROGRESS BAR ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(
        to right,
        var(--color-primary) 0%,
        var(--color-primary) var(--scroll-progress, 0%),
        transparent var(--scroll-progress, 0%)
    );
    z-index: 9999;
    transition: none;
}

/* ===== PARTICLE CANVAS ===== */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.6;
}

/* ===== TYPEWRITER EFFECT ===== */
.typewriter {
    opacity: 0;
    transition: opacity 0.3s;
    position: relative;
    display: inline-block;
}

.typewriter::after {
    content: '|';
    position: absolute;
    right: -8px;
    animation: blink 0.7s infinite;
    color: var(--color-secondary);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ===== ANIMATED SKILL BARS ===== */
.skill-bars {
    --bs-list-group-bg: transparent;
}

.skill-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
    border-left: 4px solid transparent;
    transition: border-color 0.3s, background-color 0.3s;
}

.skill-item:hover {
    border-left-color: var(--color-secondary);
}

.skill-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-body);
}

.skill-bar-track {
    width: 100%;
    height: 8px;
    background: color-mix(in srgb, var(--color-coffee-medium), transparent 85%);
    border-radius: 50px;
    overflow: hidden;
    position: relative;
}

.skill-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 50px;
    transition: width 1.5s cubic-bezier(0.65, 0, 0.35, 1);
    position: relative;
    overflow: hidden;
}

.skill-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skill-item.animate .skill-bar-fill {
    width: var(--skill-level);
}

/* ===== INTERACTIVE TESTIMONIALS ===== */
.testimonial-card {
    position: relative;
    overflow: visible;
}

.testimonial-full {
    display: none;
}

.testimonial-excerpt {
    display: block;
}

.testimonial-card.expanded .testimonial-excerpt {
    display: none;
}

.testimonial-card.expanded .testimonial-full {
    display: block;
}

.testimonial-author {
    font-weight: 600;
    font-style: italic;
    color: var(--color-coffee-medium);
    margin-top: 1rem;
    margin-bottom: 0;
}

.testimonial-toggle {
    margin-top: 1rem;
    background: var(--color-secondary);
    color: var(--color-coffee-dark);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: transform 0.2s, background-color 0.2s;
}

.testimonial-toggle:hover {
    background: var(--color-primary);
    color: white;
    transform: translateY(-2px);
}

.testimonial-toggle:active {
    transform: translateY(0);
}

/* Custom Coffee Outline Button */
.btn-outline-coffee {
    color: var(--color-coffee-dark);
    border: 2px solid var(--color-coffee-dark);
    background: transparent;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    padding: 0.6em 1.2em;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.btn-outline-coffee:hover,
.btn-outline-coffee:focus {
    background-color: var(--color-coffee-dark);
    color: var(--color-cream);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(59, 47, 47, 0.2);
}

@media (prefers-color-scheme: dark) {
    .btn-outline-coffee {
        color: var(--color-cream);
        border-color: var(--color-cream);
    }

    .btn-outline-coffee:hover {
        background-color: var(--color-cream);
        color: var(--color-coffee-dark);
    }
}

.btn-group-custom {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

/* Scroll Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-10px);}
    60% {transform: translateY(-5px);}
}
.animate-bounce {
    animation: bounce 2s infinite;
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .typewriter::after {
        animation: none;
    }
    
    .skill-bar-fill::after {
        animation: none;
    }
    
    .animate-bounce {
        animation: none;
    }
}
