/* Section Order Control */
main {
    display: flex;
    flex-direction: column;
}

.section-1 {
    order: 1;
}

.pattern-bottom-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 497px;
    height: 482px;
    background-image: url('images/bottom-right.jpg');
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: contain;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.6s;
    transition: transform 0.3s ease-out;
    will-change: transform;
    pointer-events: none;
}

.section-3 {
    order: 3;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 50px;
}

/* General Styles */
:root {
    --main-color: #d19670;
    --highlight-bg: #ffeb3b;
    --text-dark: #333;
    --bg-light: #eeeeee;
    --transition-slow: all 0.5s ease-in-out;
    --transition-medium: all 0.3s ease;
    
    /* Font variables */
    --font-heading: 'Satoshi-Bold', sans-serif;
    --font-body: 'Satoshi-Regular', sans-serif;
    --font-highlight: 'Satoshi-Black', sans-serif;
    --font-medium: 'Satoshi-Medium', sans-serif;
}

/* Font family setup */
body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
    position: relative;
    overflow-x: hidden;
    padding: 40px 0;
    min-height: 100vh;
}

/* Add smooth scrolling */
html {
    scroll-behavior: smooth;
}

.container {
    max-width: 1140px;
    margin-left: 7%;
    padding: 0 15px;
    position: relative;
    z-index: 10;
    overflow: visible; /* Ensure visible overflow for pattern positioning */
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .container {
        margin-left: 0;
        width: 100%;
    }
}

/* Main layout control - ensure correct section order */
main {
    display: grid;
    grid-template-areas: 
        "experience"
        "services"
        "contact";
}

.experience-section {
    grid-area: experience;
}

.services-section {
    grid-area: services;
    margin-bottom: 20px; /* Reduced from 70px to reduce space between sections */
    position: relative;
    opacity: 0; /* Start hidden */
    transition: opacity 0.8s ease, transform 0.8s ease;
    transform: translateY(30px); /* Start slightly below */
}

.services-section.fade-active {
    opacity: 1;
    transform: translateY(0);
}

.contact-section {
    grid-area: contact;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    padding-top: 20px;
    opacity: 0; /* Start hidden */
    transition: opacity 0.8s ease, transform 0.8s ease;
    transform: translateY(30px); /* Start slightly below */
}

.contact-section.fade-active {
    opacity: 1;
    transform: translateY(0);
}

/* Background Patterns */
.pattern-top-right {
    position: absolute;
    top: 0;
    right: 0;
    width: 377px;
    height: 364px;
    background-image: url('images/right_top.jpg');
    background-repeat: no-repeat;
    background-position: top right;
    background-size: contain;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.3s;
    transition: transform 0.3s ease-out;
    will-change: transform;
}

.pattern-bottom-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 469px;
    height: 203px;
    background-image: url('images/bottom-right.jpg');
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: auto;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.6s;
    transition: transform 0.3s ease-out;
    will-change: transform;
    pointer-events: none;
}

.pattern-bottom-left {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 469px;
    height: 203px;
    background-image: url('images/bottom_left.jpg');
    background-repeat: no-repeat;
    background-position: bottom left;
    background-size: auto;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.6s;
    transition: transform 0.3s ease-out;
    will-change: transform;
    pointer-events: none; /* Allow clicking through the image */
}

.pattern-top-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 318px;
    height: 315px;
    background-image: url('images/left_top.jpg');
    background-repeat: no-repeat;
    background-position: top left;
    background-size: auto;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.9s;
    transition: transform 0.3s ease-out;
    will-change: transform;
}

.pattern-bottom-right {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 377px;
    height: 203px;
    background-image: url('images/bottom-right.jpg');
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: auto;
    z-index: 1;
    opacity: 0;
    animation: fadePattern 1.2s ease-in-out forwards;
    animation-delay: 0.6s;
    transition: transform 0.3s ease-out;
    will-change: transform;
    pointer-events: none; /* Allow clicking through the image */
}

@keyframes fadePattern {
    from { opacity: 0; }
    to { opacity: 0.8; }
}

/* Logo Styles */
.logo {
    margin-bottom: 50px;
    transition: var(--transition-medium);
}

.logo:hover {
    transform: scale(1.02);
}

.logo img {
    height: auto;
    max-width: 200px;
}

/* Heading Styles */
h1, h2 {
    margin-bottom: 25px;
    font-family: var(--font-heading);
    font-weight: normal;
}

/* Experience Section */
.experience-section {
    margin-top: 70px;
    margin-bottom: 30px;
    width: 60%;
    box-sizing: border-box;
    max-width: 60%;
}

.highlight-text h1 {
    display: block;
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 40px;
    font-family: var(--font-highlight);
    font-weight: normal;
}

.highlight-line {
    display: block;
    overflow: visible; /* Ensure highlight text is not cut off */
    position: relative; /* Establish positioning context */
}

.highlight-span {
    display: inline-block;
    padding: 8px 15px;
    margin-bottom: 0;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    opacity: 0;
    font-family: var(--font-highlight);
    font-weight: normal;
    position: relative;
    color: transparent; /* Start with invisible text */
    background-color: transparent;
    transition: opacity 0.3s ease, color 0.6s ease;
    overflow: hidden; /* Hide overflow to prevent white lines */
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Text reveal mask - slides from left to right */
.highlight-span::before {
    content: '';
    position: absolute;
    top: 0;
    left: -101%;
    width: 102%; /* Slightly wider to prevent edge gaps */
    height: 100%;
    background-color: #eeeeee; /* Background color to match body */
    z-index: 2; /* Ensure it's above the text */
    transition: left 0.6s cubic-bezier(0.77, 0, 0.175, 1);
}

/* Background highlight - moves from right to left */
.highlight-span::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--highlight-bg);
    z-index: -1;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    transition-delay: 0.3s; /* Start after text reveal begins */
    will-change: transform; /* Optimize for animation performance */
}

/* Hidden text class that keeps the text invisible until animation completes */
.highlight-span .text-content {
    opacity: 0;
    transition: opacity 0.4s ease;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.highlight-span.visible {
    opacity: 1;
    color: #000; /* Text becomes visible after animation */
    transition-delay: 0.2s; /* Reduced to ensure proper sequencing */
}

.highlight-span.visible .text-content {
    opacity: 1;
    transition-delay: 0.7s; /* Show text only after animations complete */
}

.highlight-span.visible::before {
    left: 101%; /* Mask slides completely off-screen to avoid edge artifacts */
}

.highlight-span.visible::after {
    transform: scaleX(1); /* Background highlight expands from right to left */
    transform-origin: right;
}

.highlight-span:hover {
    transform: translateY(-2px);
    transition: transform 0.3s ease;
}

.highlight-span:hover::after {
    background-color: #ffe100;
    box-shadow: 0 4px 12px rgba(255, 235, 59, 0.4);
}

.about-text {
    font-size: 1.1rem;
    max-width: 100%;
    line-height: 1.7;
    font-family: var(--font-body);
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
}

.about-text p {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.about-text p.text-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Services Section */
.services-section {
    margin-bottom: 30px; /* Reduced from 70px to reduce space between sections */
    position: relative;
    opacity: 0; /* Start hidden */
    transition: opacity 0.8s ease, transform 0.8s ease;
    transform: translateY(30px); /* Start slightly below */
}

.services-section.fade-active {
    opacity: 1;
    transform: translateY(0);
}

.services-section h2 {
    font-size: 1.3rem;
    margin-bottom: 30px;
    font-family: var(--font-heading);
    position: relative;
    padding-bottom: 12px;
}

.services-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: #000;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.8s ease;
}

.services-section.fade-active h2::after {
    transform: scaleX(1);
}

.services-section ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.services-section li {
    margin-bottom: 7px; /* Reduced from 16px */
    padding-left: 24px;
    position: relative;
    font-size: 1.1rem;
    font-family: var(--font-body);
    transition: transform 0.3s ease, color 0.3s ease;
}


.services-section li::before {
    content: "–";
    position: absolute;
    left: 0;
    color: var(--main-color);
    font-family: var(--font-medium);
}

/* Contact Section */
.contact-section {
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    padding-top: 20px;
    opacity: 0; /* Start hidden */
    transition: opacity 0.8s ease, transform 0.8s ease;
    transform: translateY(30px); /* Start slightly below */
    position: relative;

    margin-bottom: 50px; /* Add bottom margin to ensure enough space */
    box-sizing: border-box;
}

@media (max-width: 992px) {
    .contact-section {
        margin-left: 0;
        width: 100%;
    }
    
    .contact-left {
        display: flex;
        gap: 30px;
        align-items: center;
        width: 100%;
        max-width: 600px;
    }
    
    .logo-footer {
        flex: 0 0 160px;
        margin: 0;
    }
    
    .contact-info {
        flex: 1;
        min-width: 0;
    }
}

.contact-section.fade-active {
    opacity: 1;
    transform: translateY(0);
}

.contact-section h2 {
    font-size: 1.3rem;
    width: 100%;
    margin-bottom: 30px;
    font-family: var(--font-heading);
    position: relative;
    padding-bottom: 12px;
}

.contact-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: #000;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.8s ease;
}

.contact-section.fade-active h2::after {
    transform: scaleX(1);
}

.contact-info {
    flex: 1;
}

.contact-info p {
    margin-bottom: 12px;
    font-size: 1.05rem;
    font-family: var(--font-body);
}

/* Removed hover effect and transitions for paragraph elements */

.contact-info a {
    color: var(--main-color);
    text-decoration: none;
    transition: var(--transition-medium);
    font-family: var(--font-medium);
    font-weight: normal;
}

.contact-info a:hover {
    color: #b07c5a;
    text-decoration: underline;
}

.email-container {
    display: inline-block;
    position: relative;
}

.contact-info a.protected-email {
    cursor: pointer;
    color: var(--main-color);
    text-decoration: none;
    transition: var(--transition-medium);
    background-color: rgba(209, 150, 112, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    position: relative;
    font-style: normal;
    font-family: var(--font-medium);
    overflow: hidden;
}

.contact-info a.protected-email::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(209, 150, 112, 0.2);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: -1;
}

.contact-info a.protected-email::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--main-color);
    transition: width 0.3s ease;
}

.contact-info a.protected-email:hover {
    background-color: rgba(209, 150, 112, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(209, 150, 112, 0.3);
}

.contact-info a.protected-email:hover::before {
    transform: translateX(0);
}

.contact-info a.protected-email:hover::after {
    width: 100%;
}

.logo-footer {
    margin-left: auto;
    position: relative;
}

.logo-footer img {
    height: auto;
    max-width: 270px; /* Increased by 50% from 180px */
}

/* Animation helper classes */
.fade-in {
    opacity: 0;
    animation: fadeIn 1s ease forwards;
}

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

/* New section fade animations */
.services-section, .contact-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.services-section.fade-active, .contact-section.fade-active {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animation for list items */
.services-section li {
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.services-section.fade-active li {
    opacity: 1;
    transform: translateX(0);
}

.services-section.fade-active li:nth-child(1) { transition-delay: 0.1s; }
.services-section.fade-active li:nth-child(2) { transition-delay: 0.2s; }
.services-section.fade-active li:nth-child(3) { transition-delay: 0.3s; }
.services-section.fade-active li:nth-child(4) { transition-delay: 0.4s; }
.services-section.fade-active li:nth-child(5) { transition-delay: 0.5s; }

/* Responsive adjustments */
@media (max-width: 992px) {
    .experience-section {
        width: 100%;
        max-width: 100%;
    }

    .highlight-text h1 {
        font-size: 1.8rem;
        word-break: break-word;
    }
    
    .about-text {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix for the services-section on tablet */
    .services-section li {
        word-break: break-word;
    }

    /* Contact section fixes for tablet */
    .contact-section {
        margin-left: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .contact-wrapper {
        width: 100%;
        max-width: 100%;
    }

    .contact-left {
        gap: 30px;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
    }

    .logo-footer {
        width: auto;
        max-width: 160px;
        flex-shrink: 0;
    }

    .contact-info {
        flex: 1;
        min-width: 0;
    }

    .pattern-top-right {
        width: 300px;
        height: 290px;
    }

    .pattern-top-left {
        width: 250px;
        height: 248px;
    }
    
    .pattern-bottom-right {
        width: 380px;
        height: 165px;
    }

    .pattern-bottom-right {
        width: 300px;
        height: 162px;
    }
}

@media (max-width: 768px) {
    .highlight-text h1 {
        font-size: 1.5rem;
    }
        
    .highlight-span {
        padding: 6px 12px;
    }
    
    .logo-footer {
        margin-top: 30px;
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
    
    .pattern-top-right,
    .pattern-bottom-left,
    .pattern-top-left,
    .pattern-bottom-right {
        opacity: 0.3;
    }
    
    .pattern-top-right {
        width: 250px;
        height: 241px;
    }

    .pattern-top-left {
        width: 200px;
        height: 198px;
    }
    
    .pattern-bottom-left {
        width: 335px;
        height: 145px;
    }
    
    .contact-section {

    }

    body {
        padding: 20px 0;
    }
    
    .services-section li {
        margin-bottom: 6px; /* Reduced from 12px */
    }

    .section-3 {
        display: block; /* Stack on smaller screens */
    }

    .pattern-bottom-right {
        width: 250px;
        height: 135px;
        opacity: 0.3;
    }
}

@media (max-width: 576px) {
    .highlight-span {
        display: inline;
    }
    
    .logo img, .logo-footer img {
        height: auto;
        max-width: 100%;
    }
    
    .contact-section {
        flex-direction: column;
        margin-left: 0; /* Reset margin for small screens */
        padding-top: 220px; /* Add top padding to account for the pattern-bottom-left */
    }
    
    .pattern-top-right {
        width: 180px;
        height: 174px;
    }

    .pattern-top-left {
        width: 150px;
        height: 149px;
    }
    
    .pattern-bottom-left {
        width: 235px;
        height: 102px;
    }
    
    .pattern-bottom-right {
        width: 180px;
        height: 97px;
    }

    .pattern-bottom-right {
        width: 180px;
        height: 97px;
    }
}
