@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;
    }
}

/* Font fallback to prevent layout shift */
@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local('Arial');
}

body {
    font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    position: relative;
    overflow-x: hidden;
}

/* Focus styles */
:focus-visible {
    outline: 2px solid #ff5733;
    outline-offset: 2px;
}

.dark :focus-visible {
    outline-color: #60a5fa;
}

/* Remove default focus on buttons while keeping keyboard focus */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus styles for form inputs */
input:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #ff5733;
}

.dark input:focus-visible,
.dark textarea:focus-visible {
    box-shadow: 0 0 0 2px #60a5fa;
}

/* Theme toggle glow effects */
#theme-toggle {
    position: fixed;
    will-change: transform;
}

#theme-toggle::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 9999px;
    background: transparent;
    transition: all 0.7s ease-out;
}

.dark #theme-toggle::before {
    box-shadow: 0 0 20px rgba(255,87,51,0.8);
}

#theme-toggle:hover::before {
    box-shadow: 0 0 25px rgba(96,165,250,0.4);
}

.dark #theme-toggle:hover::before {
    box-shadow: 0 0 25px rgba(255,87,51,0.9);
}

/* Horizontal scrolling pills containers */
.pills-container {
    scrollbar-width: none; /* Hide scrollbar for Firefox */
    -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
    scroll-snap-type: x proximity; /* Less rigid than 'mandatory' */
    scroll-padding: 8px; /* Add padding for smoother snapping */
    -webkit-overflow-scrolling: touch; /* Momentum scrolling on iOS */
    scroll-behavior: smooth; /* Smooth scrolling for browsers that support it */
    /* Hardware acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform, scroll-position; /* Inform browser about properties that will change */
    position: relative;
    margin-left: -0.25rem; /* Negative margin to offset the first pill's gap */
    padding-left: 0.25rem; /* Padding to ensure pills aren't cut off */
    padding-top: 0.25rem; /* Add padding to prevent top cutoff */
    padding-bottom: 0.25rem; /* Add padding to prevent bottom cutoff */
    margin-top: -0.25rem; /* Offset the top padding to maintain layout */
    margin-bottom: -0.25rem; /* Offset the bottom padding to maintain layout */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.pills-container::-webkit-scrollbar {
    display: none;
}

/* Right scroll shadow indicator */
.pills-container::after,
.pills-container::before {
    content: '';
    position: absolute;
    top: 0;
    height: 100%;
    width: 2rem;
    pointer-events: none;
    opacity: 0;
    /* Use transform instead of opacity for better performance */
    transform: translateZ(0);
    transition: opacity 0.3s ease;
    z-index: 10;
}

.pills-container::after {
    right: 0;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.6));
}

.pills-container::before {
    left: 0;
    background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.6));
}

.dark .pills-container::after {
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.6));
}

.dark .pills-container::before {
    background: linear-gradient(to left, transparent, rgba(0, 0, 0, 0.6));
}

/* Show shadow indicators when content is scrollable */
@media (max-width: 768px) {
    .pills-container.has-overflow::after {
        opacity: 1;
    }
    
    .pills-container.has-overflow.scrolled-end::after {
        opacity: 0;
    }
    
    .pills-container.scrolled-start::before {
        opacity: 1;
    }
}

/* Make sure pills are above shadows when hovered */
.pills-container > span {
    scroll-snap-align: start;
    /* Prevent subpixel rendering issues */
    transform: translateZ(0);
    /* Add subtle transition for smoother hover states */
    transition: transform 0.2s cubic-bezier(0.33, 1, 0.68, 1),
                background-color 0.2s cubic-bezier(0.33, 1, 0.68, 1),
                color 0.2s cubic-bezier(0.33, 1, 0.68, 1),
                box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1);
    /* Prevent text rendering issues */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    z-index: 5;
    margin: 0.125rem 0; /* Add vertical margin to prevent cutoff */
}

.pills-container > span:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.dark .pills-container > span:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* Active touch indicator */
.pills-container > span:active {
    transform: translateY(0);
    background-color: rgba(255, 87, 51, 0.8) !important;
    color: white !important;
    /* Fix for active state to prevent cutoff */
    outline: none;
    box-shadow: 0 0 0 1px rgba(255, 87, 51, 0.8);
}

/* Back to top button styles */
#back-to-top {
    will-change: transform, opacity;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 9999px;
    background: transparent;
    transition: all 0.3s ease-out;
}

#back-to-top:hover::before {
    box-shadow: 0 0 20px rgba(255,87,51,0.6);
}

.dark #back-to-top:hover::before {
    box-shadow: 0 0 20px rgba(96,165,250,0.6);
}

/* Hide back to top button on desktop */
@media (min-width: 768px) {
    #back-to-top {
        display: none;
    }
}

/* Timeline hover effects */
.timeline-item .relative {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.timeline-item:hover .relative {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.dark .timeline-item:hover .relative {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.timeline-item h4 {
    transition: color 0.3s ease;
}

/* Light mode hover colors */
.timeline-item:hover h4.text-secondary {
    color: var(--primary-color) !important;
}

.timeline-item:hover h4.text-primary {
    color: var(--secondary-color) !important;
}

/* Dark mode hover colors */
.dark .timeline-item:hover h4.dark\:text-primary {
    color: var(--secondary-color) !important;
}

.dark .timeline-item:hover h4.dark\:text-secondary {
    color: var(--primary-color) !important;
}

/* Section visibility control */
.section-hidden {
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
}

.section-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 1s ease, transform 1s ease;
}

/* Enhanced focus styles for timeline items */
.timeline-item:focus-visible {
    outline: none;
}

.timeline-item:focus-visible .relative {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.dark .timeline-item:focus-visible .relative {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    outline-color: var(--secondary-color);
}

/* Ensure focus styles match hover effects */
.timeline-item:focus-visible h4.text-secondary {
    color: var(--primary-color) !important;
}

.timeline-item:focus-visible h4.text-primary {
    color: var(--secondary-color) !important;
}

.dark .timeline-item:focus-visible h4.dark\:text-primary {
    color: var(--secondary-color) !important;
}

.dark .timeline-item:focus-visible h4.dark\:text-secondary {
    color: var(--primary-color) !important;
}

/* === PRINT STYLES === */
@media print {
    /* === RESET & BASICS === */
    * {
        margin: 0 !important;
        padding: 0 !important;
        color: black !important;
        background: none !important;
        box-shadow: none !important;
        text-shadow: none !important;
        border: none !important;
        transition: none !important;
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
        font-family: 'Space Grotesk', Arial, sans-serif !important;
    }

    /* === PAGE SETUP === */
    @page {
        margin: 0.5in 0.5in 0.5in 0.5in;
        size: letter portrait;
    }

    body {
        font-size: 10pt !important;
        line-height: 1.2 !important;
        width: 100% !important;
        background: white !important;
    }

    /* === HIDE ELEMENTS === */
    #theme-toggle,
    #back-to-top,
    #contact-section,
    footer,
    button[aria-label="Scroll to about section"],
    .absolute.left-1\/2.transform.-translate-x-1\/2.h-full.w-0\.5,
    .rounded-full.bg-secondary,
    .rounded-full.bg-primary,
    .w-3.h-3,
    .w-4.h-4 {
        display: none !important;
    }

    /* === HEADER LAYOUT === */
    header {
        min-height: 0 !important;
        padding-bottom: 0.2in !important;
    }

    /* Fix pills containers for print */
    .pills-container {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow: visible !important;
        padding-bottom: 0 !important;
    }

    .pills-container::after {
        display: none !important;
    }

    .pills-container > span {
        margin-bottom: 0.05in !important;
        margin-right: 0.05in !important;
        font-size: 9pt !important;
        padding: 0.05in 0.1in !important;
        min-width: auto !important;
    }

    /* Header row layout */
    header .flex.flex-col.lg\:flex-row {
        display: block !important;
    }

    /* Hide the right column in header */
    header .lg\:w-1\/2.mt-12 {
        display: none !important;
    }

    /* Make left column full width */
    header .lg\:w-1\/2:first-child {
        width: 100% !important;
    }

    /* === TYPOGRAPHY === */
    h1 {
        font-size: 24pt !important;
        line-height: 1.1 !important;
        margin-bottom: 0.05in !important;
        font-weight: bold !important;
    }

    h1 span {
        display: inline !important;
    }

    h2.text-3xl {
        font-size: 14pt !important;
        margin-bottom: 0.05in !important;
        font-weight: normal !important;
    }

    p.text-xl {
        font-size: 11pt !important;
        margin-bottom: 0.1in !important;
    }

    header .text-lg {
        font-size: 10pt !important;
        line-height: 1.3 !important;
        max-width: 100% !important;
        margin-top: 0.1in !important;
    }

    /* === MAIN CONTENT === */
    main {
        padding-top: 0 !important;
    }

    /* About me section heading */
    h2.text-5xl {
        font-size: 16pt !important;
        margin-top: 0 !important;
        margin-bottom: 0.1in !important;
    }

    /* Two-column layout */
    .grid.md\:grid-cols-2 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        column-gap: 0.3in !important;
    }

    /* Section headings */
    section > h3 {
        font-size: 14pt !important;
        margin-bottom: 0.1in !important;
        font-weight: bold !important;
    }

    /* === EXPERIENCE SECTION === */
    /* Remove timeline structure entirely */
    .relative.flex.items-center.justify-center {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Reset timeline containers */
    .space-y-12 {
        display: block !important;
        margin: 0 !important;
    }

    /* Hide all timeline decorative elements */
    .absolute.left-1\/2,
    .w-\[calc\(50\%-1rem\)\],
    .md\:w-1\/2,
    .pr-4,
    .md\:pr-8,
    .pl-4,
    .md\:pl-8,
    .timeline-item .relative::before,
    .timeline-item .relative::after {
        display: none !important;
    }

    /* Style timeline items exactly like competencies */
    .timeline-item {
        display: block !important;
        position: relative !important;
        padding-left: 0.15in !important;
        margin-bottom: 0.05in !important;
        line-height: 1.2 !important;
    }

    /* Add bullets to experience items - match competencies exactly */
    .timeline-item::before {
        content: "•" !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        font-size: 10pt !important;
    }

    /* Reset boxed styles and ensure inline display */
    .timeline-item .relative {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
        box-shadow: none !important;
        position: static !important;
    }

    /* Experience item text - match competencies */
    .timeline-item h4 {
        display: inline !important;
        font-size: 10pt !important;
        font-weight: normal !important;
    }

    .timeline-item p {
        display: inline !important;
        font-size: 10pt !important;
        font-weight: normal !important;
        margin-left: 0.05in !important;
    }

    /* === UNIFIED LIST STYLING === */
    /* Make all lists follow the same style */
    .timeline-item,
    #core-competencies-print li,
    #client-experience-print li {
        position: relative !important;
        padding-left: 0.15in !important;
        margin-bottom: 0.05in !important;
        line-height: 1.2 !important;
        page-break-inside: avoid !important;
    }

    /* Consistent bullet styling across all lists */
    .timeline-item::before,
    #core-competencies-print li::before,
    #client-experience-print li::before {
        content: "•" !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        font-size: 10pt !important;
    }

    /* Last items in all lists */
    .timeline-item:last-child,
    #core-competencies-print li:last-child,
    #client-experience-print li:last-child {
        margin-bottom: 0 !important;
    }

    /* === COMPETENCIES & CLIENT EXPERIENCE === */
    #core-competencies-print,
    #client-experience-print {
        display: block !important;
        margin-top: 0.1in !important;
        margin-bottom: 0.2in !important;
    }

    #core-competencies-print::before,
    #client-experience-heading-print {
        display: block !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        margin-bottom: 0.1in !important;
        margin-top: 0.2in !important;
    }

    #core-competencies-print::before {
        content: "Core Competencies" !important;
    }

    /* Approach section */
    #approach-intro {
        margin-bottom: 0.1in !important;
    }

    #approach-intro p.text-lg {
        font-size: 10pt !important;
        margin-bottom: 0.1in !important;
        font-weight: bold !important;
    }

    #approach-intro p.text-gray-600 {
        font-size: 10pt !important;
        margin-bottom: 0.1in !important;
        font-weight: normal !important;
    }

    /* Approach bullet points */
    .space-y-6 > div {
        position: relative !important;
        padding-left: 0.15in !important;
        margin-bottom: 0.05in !important;
        line-height: 1.2 !important;
    }

    /* Add bullet points */
    .space-y-6 > div::before {
        content: "•" !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        font-size: 10pt !important;
    }

    /* Hide original bullet markers */
    .space-y-6 > div .flex-shrink-0 {
        display: none !important;
    }

    /* Fix flex layout */
    .space-y-6 > div.flex {
        display: block !important;
    }

    /* Approach text */
    .space-y-6 > div p {
        font-size: 10pt !important;
        display: inline !important;
    }

    /* === SPACING & LAYOUT FIXES === */
    /* Page break control */
    .page-break-before {
        page-break-before: always !important;
    }

    /* Ensure consistent spacing */
    section {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    /* Remove any remaining animation effects */
    .opacity-0 {
        opacity: 1 !important;
    }

    .transform {
        transform: none !important;
    }

    /* Consistent margin for all list items */
    #core-competencies-print li,
    #client-experience-print li,
    .timeline-item,
    .space-y-6 > div {
        margin-bottom: 0.05in !important;
    }
}

/* Additional styles to fix highlight cutoff issues */
.pills-container > span.bg-primary,
.pills-container > span:hover,
.pills-container > span:active {
    /* Ensure the highlighted state is fully visible */
    overflow: visible !important;
    z-index: 10 !important;
    position: relative !important;
} 

/* Ensures smoother scrolling */
.pills-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; 
    scrollbar-width: none; /* Hide scrollbar in Firefox */
}
.pills-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar in Chrome/Safari */
}

.bg-layer {
    background-image: url('../assets/rancho-light.jpg');
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

.dark .bg-layer {
    background-image: url('../assets/rancho-dark.jpg');
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

/* Extended background for light mode */
.bg-layer {
    position: fixed !important;
    top: -10vh !important; /* Offset it higher to compensate for the increased height */
    left: 0 !important;
    width: 100vw !important;
    height: 130vh !important; /* Increase height to allow movement */
    z-index: -1;
    will-change: transform;
}
.competencies-container, .client-experience-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.competency-pill, .client-pill {
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.competency-pill {
    color: #4A90E2;
    background-color: rgba(74,144,226,0.08);
    text-align: left;
}
.client-pill {
    color: #E74C3C;
    background-color: rgba(231,76,60,0.08);
    text-align: right;
}

.competency-pill:hover {
    background-color: rgba(74,144,226,0.15);
    color: #3A7AD9;
}
.client-pill:hover {
    background-color: rgba(231,76,60,0.15);
    color: #D64532;
}

.dark .competency-pill {
    color: #E74C3C;
    background-color: rgba(231,76,60,0.12);
}
.dark .client-pill {
    color: #4A90E2;
    background-color: rgba(74,144,226,0.12);
}

/* Ensure they are aligned properly without stealing visual attention */
.competency-pill {
    text-align: left;
}

.client-pill {
    text-align: right;
}

/* Ensure mobile responsiveness */
@media (max-width: 768px) {
    .competency-pill, .client-pill {
        width: auto;
        text-align: center;
    }
}
.dark .competency-pill:hover {
    background-color: rgba(231,76,60,0.2);
    color: #C0392B;
}
.dark .client-pill:hover {
    background-color: rgba(74,144,226,0.2);
    color: #2C6BB2;
}

@media (max-width: 768px) {
    .competencies-container, .client-experience-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem; /* Add space for scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        scrollbar-width: thin;
    }

    .competency-pill, .client-pill {
        flex-shrink: 0;
        margin-right: 0.5rem;
    }
}

button[type="submit"] {
    background-color: #333333; /* Darker color for better contrast */
    color: #ffffff; /* White text for readability */
}