:root {
    /* Theme colors and variables */
    --primary-color: #45612c;
    --secondary-color: #333;
    --text-color: #222222;
    --background-color: #ffffff;
    --shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    --icon-fill: var(--text-color);
    --icon-fill-hover: var(--primary-color);
    --hover-bg: rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(to right, var(--secondary-color), var(--primary-color));
    
    /* Animation variables */
    --ease-elastic-3: cubic-bezier(0.5, 1.25, 0.75, 1.25);
    --ease-elastic-4: cubic-bezier(0.5, 1.5, 0.75, 1.25);
    --ease-3: cubic-bezier(0.25, 0, 0.3, 1);
    --ease-out-5: cubic-bezier(0, 0, 0, 1);
}

/* Dark theme */
[data-theme="dark"] {
    --primary-color: #7da861;
    --secondary-color: #1a1a1a;
    --text-color: #ffffff;
    --background-color: #121212;
    --shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    --icon-fill: var(--text-color);
    --icon-fill-hover: var(--primary-color);
    --hover-bg: rgba(255, 255, 255, 0.1);
}

/* Base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    margin: 5px;
    padding: 5px;
    background-color: var(--background-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; 
    transition: background-color 0.3s ease;
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
}

/* Header and footer */
header, footer {
    position: relative; 
    text-align: center;
    box-shadow: var(--shadow);
    background: var(--gradient);
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    padding: 25px;
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    color: white;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-text {
    flex: 1;
}

.profilepic {
    max-width: 150px;
    max-height: 150px;
    height: auto;
    border-radius: 50%; 
}

/* Typography */
h1, h2 {
    color: var(--primary-color);
}

h3 {
    color: #292929;
    font-size: 1.25em;
}

p, li {
    color: var(--text-color);
}

h1 { font-size: 2.5em; }
h2 { font-size: 1.5em; }

header h1, header h2, footer p {
    color: #ffffff;
}

/* Sections */
.container {
    margin: auto;
}

.section {
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    padding: 25px;
    background-color: var(--background-color);
    box-shadow: var(--shadow);
    opacity: 0; 
    transform: translateY(20px); 
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease; 
    will-change: opacity, transform;
}

.section.visible {
    opacity: 1;
    transform: translateY(0); 
}

/* Lists */
ul.bullets {
    list-style-type: circle;
    padding-left: 40px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

ul li::marker {
    color: var(--primary-color);
}

li {
    margin-bottom: 10px;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none; 
}

a:hover {
    color: #0c47a1;
    text-decoration: underline; 
}

/* Company Logo */
.title-and-logo {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.company-logo {
    width: 80px; 
    height: 80px;
    margin: 0 10px;
}

/* Car Animation */
.road, .road-line {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    height: 100vh;
    animation: fadeIn 2s ease-in-out;
    will-change: transform;
    z-index: 1;
    display: none; /* Hidden by default */
}

.road {
    left: 10%;
    right: auto;
    background-color: var(--primary-color);
    box-shadow: var(--shadow);
    border-radius: 2px;
    background-image: none;
    width: 8px;
    transform-origin: center;
    animation: fadeIn 2s ease-in-out, roadPerspective 8s ease-in-out infinite;
}

.road-line {
    left: 5%;
    right: auto;
    background-image: repeating-linear-gradient(
        to bottom,
        var(--primary-color), 
        var(--primary-color) 10px, 
        transparent 10px, 
        transparent 40px 
    );
    border-radius: 0;
    width: 3px;
    transform-origin: center;
    animation: fadeIn 2s ease-in-out, roadPerspective 8s ease-in-out infinite;
}

/* Revised perspective animation */
@keyframes roadPerspective {
    0% { 
        clip-path: polygon(0% 0%, 100% 0%, 70% 100%, 30% 100%);
        transform: scaleY(1);
    }
    50% { 
        clip-path: polygon(10% 0%, 90% 0%, 65% 100%, 35% 100%);
        transform: scaleY(0.98);
    }
    100% { 
        clip-path: polygon(0% 0%, 100% 0%, 70% 100%, 30% 100%);
        transform: scaleY(1);
    }
}

.car {
    position: fixed;
    left: 5.1%;
    top: 5%; 
    width: 5%; 
    z-index: 1000;
    transform: translateY(0);
    transition: transform 0.1s ease-out;
    background-color: transparent !important;
    cursor: grab;
    animation: fadeIn 2s ease-in-out;
    display: none; /* Hidden by default */
}

.car.dragging {
    cursor: grabbing; /* Change cursor when actively dragging */
    transition: none; /* Remove transition during drag for responsiveness */
}

.car img {
    width: 100%;
    height: auto;
    animation: fadeIn 3s ease-in-out;
    background-color: transparent !important;
    /* Add subtle hover effect */
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
    transition: filter 0.3s ease, transform 0.3s ease;
    pointer-events: none; /* Ensure drag events go to parent */
}

/* Add hover effect to car */
.car:hover img {
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
    transform: scale(1.05);
}

/* Add pulsing effect to car when page loads to indicate it's interactive */
@keyframes carPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.car img {
    animation: fadeIn 2s ease-in-out, carPulse 2s ease-in-out 2s;
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline-offset: 5px;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    color: var(--text-color);
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
}

.theme-toggle > svg {
    inline-size: 100%;
    block-size: 100%;
    stroke-linecap: round;
}

/* Sun and Moon animations */
.sun-and-moon > :is(.moon, .sun, .sun-beams) {
    transform-origin: center;
}

.sun-and-moon > :is(.moon, .sun) {
    fill: var(--icon-fill);
}

.theme-toggle:is(:hover, :focus-visible) > .sun-and-moon > :is(.moon, .sun) {
    fill: var(--icon-fill-hover);
}

.sun-and-moon > .sun-beams {
    stroke: var(--icon-fill);
    stroke-width: 2px;
}

[data-theme="dark"] .sun-and-moon > .sun {
    transform: scale(1.75);
}

[data-theme="dark"] .sun-and-moon > .sun-beams {
    opacity: 0;
}

[data-theme="dark"] .sun-and-moon > .moon > circle {
    transform: translateX(-7px);
}

/* Dark mode text overrides */
[data-theme="dark"] p,
[data-theme="dark"] li,
[data-theme="dark"] h3 {
    color: rgba(255, 255, 255, 0.87) !important;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2 {
    color: var(--primary-color) !important;
}

[data-theme="dark"] a {
    color: #9dc183;
}

[data-theme="dark"] a:hover {
    color: #b8d4a3;
}

[data-theme="dark"] .section {
    background-color: var(--secondary-color);
}

/* Accessibility */
:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Ensure tooltips are visible */
.theme-toggle[title]:hover::after,
.print-button[title]:hover::after,
.car-toggle-button[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    margin-top: 0.5rem;
}

/* Add arrow to tooltips */
.theme-toggle[title]:hover::before,
.print-button[title]:hover::before,
.car-toggle-button[title]:hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 0.25rem solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.8);
    margin-top: 0.25rem;
    z-index: 10000;
    pointer-events: none;
}

/* Loading states */
.image-loading {
    filter: blur(5px);
    transition: filter 0.3s;
    background-color: #f0f0f0;
}

.image-loaded {
    filter: none;
}

.loading {
    background: linear-gradient(90deg, 
        #f0f0f0 0%, 
        #f8f8f8 50%, 
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Animations */
@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Projects Section */
.project-item {
    margin-bottom: 30px; /* Ensure consistent spacing between project items */
    border: none; /* Remove lines between projects */
}

.project-toggle {
    width: 100%;
    padding: 20px;
    background: var(--background-color);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    transition: background-color 0.3s ease;
    color: var(--text-color);
}

.project-toggle:hover {
    background-color: var(--hover-bg);
}

.project-toggle:focus {
    outline: none;
}

.project-title {
    font-size: 1.25em;
    font-weight: normal;
    color: var(--text-color);
    flex: 1;
}

/* Bold project title when actively selected/expanded */
.project-toggle[aria-expanded="true"] .project-title {
    font-weight: bold;
}

.project-date {
    color: var(--text-color);
    font-style: italic;
    margin: 0 15px;
}

.expand-icon {
    color: var(--primary-color);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.project-toggle[aria-expanded="true"] .expand-icon {
    transform: rotate(180deg);
}

.project-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: var(--background-color);
}

.project-content.expanded {
    max-height: 2000px; /* Large enough to accommodate content */
}

.project-description {
    padding: 5px 20px 20px 20px;
}

.project-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 0 20px 20px 20px;
}

.project-image {
    border: none; /* Remove border */
    border-radius: 0; /* Remove rounded corners */
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow); /* Retain box shadow */
}

.project-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Enhance shadow on hover */
}

.project-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* Single photo projects - double the height and maintain full width */
/* Fixed invalid pseudo-class usage in :has() */
.project-gallery .project-image:only-child {
    border-radius: 8px;
    overflow: hidden;
}

.project-gallery:has(.project-image:only-child) .project-image img {
    height: 400px;
    object-fit: contain;
    border-radius: 8px;
}

.project-image:hover img {
    transform: scale(1.05);
}

/* Dark theme adjustments for projects */
[data-theme="dark"] .project-item {
    border-color: var(--primary-color);
}

[data-theme="dark"] .project-toggle {
    background-color: var(--background-color);
    color: var(--text-color);
}

[data-theme="dark"] .project-toggle:hover {
    background-color: var(--hover-bg);
}


/* Responsive design for projects */
@media (max-width: 600px) {
    .header, .footer, .section {
        padding: 10px;
        margin: 5px auto;
    }
    
    .theme-toggle {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .print-button {
        top: 0.5rem;
        right: 3.5rem;
    }
    
    .car-toggle-button {
        top: 0.5rem;
        right: 6.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-toggle,
    .project-content,
    .expand-icon,
    .project-image,
    .project-image img {
        transition: none;
    }
}

/* Media Queries */
@media (max-width: 1200px) {
    .car, .road, .road-line {
        display: none !important;
    }
    
    .profilepic {
        display: none !important;
    }
    
    .print-button {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px), (max-width: 600px) {
    .header, .footer, .section {
        padding: 15px;
        margin: 10px auto; 
        max-width: 100%;
        box-sizing: border-box; 
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .header, .footer, .section {
        padding: 10px;
        margin: 5px auto;
    }
    
    .theme-toggle {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .print-button {
        top: 0.5rem;
        right: 3.5rem;
    }
    
    .car-toggle-button {
        top: 0.5rem;
        right: 6.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .car, .section {
        transition: none !important;
        animation: none !important;
    }
    
    html {
        scroll-behavior: auto !important;
    }
}

@supports (animation-timeline: view-timeline) {
    @media (prefers-reduced-motion: no-preference) {
        .sun-and-moon > .sun {
            transition: transform .5s var(--ease-elastic-3);
        }

        .sun-and-moon > .sun-beams {
            transition: transform .5s var(--ease-elastic-4), opacity .5s var(--ease-3);
        }

        .sun-and-moon .moon > circle {
            transition: transform .25s var(--ease-out-5);
        }

        [data-theme="dark"] .sun-and-moon > .sun {
            transition-timing-function: var(--ease-3);
            transition-duration: .25s;
        }

        [data-theme="dark"] .sun-and-moon > .sun-beams {
            transition-duration: .15s;
            transform: rotateZ(-25deg);
        }
    }
}

/* Anti-scraping CSS - simplified */
.experience .position {
    user-select: none;
}

.experience .position:hover {
    user-select: text;
}

/* Print-only elements */
.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block;
    }
    
    /* Remove all watermarks */
    body::after {
        content: none;
    }
    
    /* Remove background watermark */
    @page {
        background: none !important;
    }
    
    /* Hide elements that shouldn't be printed */
    .theme-toggle, .print-button, .car, .road, .road-line {
        display: none !important;
    }
}

/* Print button styles */
.print-button {
    background: none;
    border: none;
    padding: 0.5rem;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline-offset: 5px;
    position: fixed;
    top: 1rem;
    right: 4rem; /* Position to the left of theme toggle */
    z-index: 1001;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.print-button:hover {
    background-color: var(--hover-bg);
    transform: scale(1.1);
}

.print-button svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: var(--text-color);
    transition: fill 0.3s ease;
}

.print-button:hover svg {
    fill: var(--primary-color);
}

/* Hide print button when printing */
@media print {
    .print-button {
        display: none;
    }
}

/* Make URLs clickable */
.auto-link {
    position: relative;
    display: inline-block;
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

/* For specific text containing a URL */
.url-text {
    color: var(--primary-color);
    text-decoration: underline;
    cursor: pointer;
}

/* For a specific element that contains a URL you want clickable */
.contains-url {
    position: relative;
}

.contains-url[data-url]::after {
    content: attr(data-url);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

/* Print watermark styling */
.print-only-text {
  display: none; /* Hide by default */
}

@media print {
  .print-only-text {
    display: block; /* Show only when printing */
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 10px;
    color: #999;
    margin: 0;
    padding: 0;
    opacity: 0.7;
  }
}

/* Footer print text - hide on screen, show only when printing */
.print-footer-text {
    display: none !important; /* Hide by default on the webpage */
}

@media print {
    .print-footer-text {
        display: block !important; /* Show when printing */
        color: #999;
        font-size: 10px;
        opacity: 0.7;
    }
}

.car-toggle-button {
    background: none;
    border: none;
    padding: 0.5rem;
    inline-size: 2.5rem;
    block-size: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline-offset: 5px;
    position: fixed;
    top: 1rem;
    right: 7rem; /* To the left of print and theme buttons */
    z-index: 1001;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.car-toggle-button:hover {
    background-color: var(--hover-bg);
    transform: scale(1.1);
}

.car-toggle-button svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: var(--text-color);
    transition: fill 0.3s ease;
}

.car-toggle-button[aria-pressed="true"] svg {
    fill: var(--primary-color);
}

@media (max-width: 1200px) {
    .car-toggle-button {
        display: none !important;
    }
}