body { 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

/* Global button reset to prevent layout issues */
button {
    border: none;
    margin: 0;
    padding: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Ensure buttons in grid/flex containers behave properly */
button.work-card {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    flex-shrink: 0 !important;
    flex-grow: 1 !important;
    align-self: stretch !important;
    justify-self: stretch !important;
}

.glass-morphism { 
    background: rgba(255, 255, 255, 0.5); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px); 
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); 
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: background, border-color;
    contain: layout style;
}
.dark .glass-morphism { background: rgba(17, 24, 39, 0.5); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.header-logo { font-family: 'Inter', sans-serif; font-weight: 300; font-size: 1.125rem; letter-spacing: 0.15em; color: #1f2937; position: relative; padding-bottom: 4px; transition: color 0.3s ease; }
.dark .header-logo { color: #f3f4f6; }
.header-logo::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 1px; background: linear-gradient(90deg, #6B8CAE, #8D7BAE); transition: width 0.4s ease-out; }
.dark .header-logo::after { background: linear-gradient(90deg, #9BB5D6, #B5A0D6); }
.header-logo:hover::after { width: 100%; }
.nav-link { font-size: 0.9rem; color: #4b5563; transition: color 0.3s ease; }
.dark .nav-link { color: #d1d5db; }
.nav-link:hover { color: #6B8CAE; }
.dark .nav-link:hover { color: #9BB5D6; }
.dark-mode-toggle { width: 48px; height: 24px; background-color: #e5e7eb; border-radius: 9999px; position: relative; transition: background-color 0.3s ease; cursor: pointer; }
.dark .dark-mode-toggle { background-color: #6B8CAE; }
.dark-mode-toggle-circle { width: 20px; height: 20px; background-color: white; border-radius: 9999px; position: absolute; top: 2px; left: 2px; transition: transform 0.3s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.dark .dark-mode-toggle-circle { transform: translateX(24px); }
.mobile-menu-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }
.mobile-menu { position: fixed; top: 0; right: -100%; width: 280px; height: 100vh; background: white; z-index: 50; transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94); padding: 1.5rem; }
.dark .mobile-menu { background: #1a202c; }
.mobile-menu.active { right: 0; }
.mobile-menu-link { display: block; font-size: 1.125rem; padding: 0.5rem 0; transition: color 0.3s ease; }
.mobile-menu-link:hover { color: #6B8CAE; }
.dark .mobile-menu-link:hover { color: #9BB5D6; }

#hero { position: relative; overflow: hidden; }
.hero-content { position: relative; z-index: 1; }
.hero-background-svg { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; transform: translate(-50%, -50%); z-index: 0; max-width: 960px; opacity: 0.9; }

.hero-text-block { display: inline-block; padding: 0.5rem 3rem; border-radius: 0.25rem; background: linear-gradient(135deg, #6B8CAE 0%, #8D7BAE 100%); }
.dark .hero-text-block { background: linear-gradient(135deg, #9BB5D6 0%, #B5A0D6 100%); }

.cta-button { 
    background: linear-gradient(135deg, #6B8CAE 0%, #8D7BAE 100%); 
    color: white; 
    border: none; 
    padding: 1rem 2.5rem; 
    border-radius: 50px; 
    font-weight: 500; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    box-shadow: 0 4px 15px rgba(107, 140, 174, 0.3); 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    will-change: transform, background, box-shadow;
    transform: translate3d(0, 0, 0);
    contain: layout style;
}
.cta-button:hover { 
    transform: translate3d(0, -3px, 0); 
    background: linear-gradient(135deg, #5A7A9B 0%, #7A689B 100%); 
    box-shadow: 0 8px 25px rgba(107, 140, 174, 0.4); 
}
.dark .cta-button { 
    background: linear-gradient(135deg, #9BB5D6 0%, #B5A0D6 100%); 
    box-shadow: 0 0 25px -5px rgba(155, 181, 214, 0.5); 
}
.dark .cta-button:hover { 
    transform: translate3d(0, -3px, 0) scale3d(1.03, 1.03, 1); 
    background: linear-gradient(135deg, #8AA4C5 0%, #A48FC5 100%); 
    box-shadow: 0 0 35px -5px rgba(165, 195, 225, 0.6); 
}
.section-title { font-size: 2.5rem; font-weight: 200; margin-bottom: 0.75rem; }
.section-subtitle { color: #6b7280; font-family: 'Noto Sans JP', sans-serif; font-size: 1.125rem; }
.dark .section-subtitle { color: #9ca3af; }
.service-item { 
    opacity: 0; 
    text-align: left; 
    background: #fff; 
    padding: 2.5rem; 
    border-radius: 0.75rem; 
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.05); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
    transform: translate3d(0, 0, 0);
    contain: layout style;
}
.dark .service-item { background: #374151; box-shadow: none; }
.service-item:hover { 
    transform: translate3d(0, -6px, 0); 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); 
}
.dark .service-item:hover { 
    transform: translate3d(0, -6px, 0); 
}
.work-card { 
    opacity: 0; 
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: box-shadow;
    contain: layout style;
    /* Complete button reset to behave like a div */
    margin: 0;
    padding: 0;
    border: none;
    background: inherit;
    font: inherit;
    text-align: inherit;
    display: block;
    width: 100%;
    box-sizing: border-box;
    line-height: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: inherit;
    text-decoration: none;
    outline: none;
}
.work-card:hover { 
    box-shadow: 0 20px 40px rgba(0,0,0,0.1); 
}
.dark .work-card:hover { 
    box-shadow: 0 20px 40px rgba(0,0,0,0.2); 
}
.work-image-wrapper { 
    position: relative; 
    overflow: hidden; 
    border-radius: 0.75rem; 
    background-color: #f3f4f6; 
}
.dark .work-image-wrapper { background-color: #374151; }
.work-image { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }




.work-tag { font-size: 0.75rem; padding: 0.25rem 0.75rem; background-color: #e5e7eb; color: #4b5563; border-radius: 9999px; }
.dark .work-tag { background-color: #374151; color: #d1d5db; }
.about-content-block { 
    border-left: 2px solid #6B8CAE; 
    padding-left: 2rem; 
    opacity: 0;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    contain: layout style;
}
.dark .about-content-block { border-left-color: #9BB5D6; }
.about-content-title { 
    font-size: 1.25rem; 
    font-weight: 500; 
    margin-bottom: 1rem; 
    color: #1f2937; 
}
.dark .about-content-title { color: #f3f4f6; }
.about-list-icon { color: #6B8CAE; }
.dark .about-list-icon { color: #9BB5D6; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: #4b5563; }
.dark .form-label { color: #d1d5db; }
.form-input { width: 100%; padding: 0.875rem 1.25rem; border: 1px solid #d1d5db; border-radius: 0.5rem; background-color: white; transition: border-color 0.3s, box-shadow 0.3s; }
.dark .form-input { background-color: #1f2937; border-color: #4b5563; color: #f3f4f6; }
.form-input:focus { outline: none; border-color: #6B8CAE; box-shadow: 0 0 0 2px rgba(107, 140, 174, 0.3); }
.dark .form-input:focus { border-color: #9BB5D6; box-shadow: 0 0 0 2px rgba(155, 181, 214, 0.3); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 0.5rem center; background-repeat: no-repeat; background-size: 1.5em 1.5em; padding-right: 2.5rem; }
.dark select.form-input { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23d1d5db' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); }
.dark .form-input::placeholder { color: #6b7280; }

#toTopBtn { 
    position: fixed; 
    bottom: 1.5rem; 
    right: 1.5rem; 
    width: 3rem; 
    height: 3rem; 
    border-radius: 50%; 
    background: linear-gradient(135deg, #6B8CAE 0%, #8D7BAE 100%); 
    color: white; 
    border: none; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    opacity: 0; 
    visibility: hidden; 
    transform: translate3d(0, 20px, 0); 
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    z-index: 100;
    will-change: transform, opacity;
    contain: layout style;
}
.dark #toTopBtn { background: linear-gradient(135deg, #9BB5D6 0%, #B5A0D6 100%); }
#toTopBtn:hover { transform: translate3d(0, -3px, 0) scale3d(1.05, 1.05, 1); }
#toTopBtn.show { opacity: 1; visibility: visible; transform: translate3d(0, 0, 0); }

/* --- Golden Ratio SVG Styles --- */
.svg-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    opacity: 0.9;
    contain: layout style;
    will-change: transform;
}

.construction-line { 
    stroke: #9ca3af; 
    stroke-width: 0.75;
    will-change: stroke-dashoffset;
} /* Updated light mode color */
.dark .construction-line { stroke: #4b5563; }
.spiral-line { 
    stroke: #9BB5D6; 
    stroke-width: 1.5;
    will-change: stroke-dashoffset;
}
.dark .spiral-line { stroke: #B5A0D6; }

@keyframes draw { 
    to { 
        stroke-dashoffset: 0; 
    } 
}

.drawing-path {
    stroke-dasharray: 3000; /* Adjusted for better animation completion */
    stroke-dashoffset: 3000;
    animation: draw 3.0s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform: translate3d(0, 0, 0); /* Force GPU acceleration */
}

/* Hero Section Animation Delays */
#hero #construction-group { animation-delay: 0.2s; }
#hero #spiral-group { animation-delay: 1.2s; }
#hero #construction-group-mobile { animation-delay: 0.2s; }
#hero #spiral-group-mobile { animation-delay: 1.2s; }

/* Services Section Animation Delays */
#services .construction-group { animation-delay: 0.1s; }
#services .spiral-group { animation-delay: 0.8s; }

/* Works Section Animation Delays */
#works .construction-group { animation-delay: 0.2s; }
#works .spiral-group { animation-delay: 0.9s; }

/* About Section Animation Delays */
#about .construction-group { animation-delay: 0.1s; }
#about .spiral-group { animation-delay: 0.7s; }

/* Contact Section Animation Delays */
#contact .construction-group { animation-delay: 0.3s; }
#contact .spiral-group { animation-delay: 1.0s; }

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    .drawing-path {
        animation-duration: 2.5s; /* Adjusted for mobile completion */
    }
    
    .svg-background {
        opacity: 0.8; /* Slightly increased for better visibility */
    }
    
    /* Simplify hover effects on mobile */
    .service-item:hover,
    .work-card:hover,
    .cta-button:hover {
        transform: none;
    }
}

/* Accessibility: Respect user's motion preferences */
@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;
    }
    
    .drawing-path {
        animation: none;
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }
    
    .service-item,
    .work-card,
    .about-content-block {
        opacity: 1;
        transform: none;
    }
}

/* Battery saving mode detection */
@media (prefers-reduced-data: reduce) {
    .svg-background {
        display: none;
    }
}

/* Modal Styles */
#workModal {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#workModal.show {
    display: flex !important;
}

#workModal.show #modalContent {
    transform: scale(1);
}

#modalContent {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Screen reader utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Modal responsive design */
@media (max-width: 768px) {
    /* Adjust modal container to properly fit screen */
    #workModal .fixed.inset-0.flex.items-center.justify-center.p-4 {
        padding: 0;
        align-items: flex-start;
        justify-content: center;
        flex-direction: column;
    }
    
    /* Position buttons above modal content - not overlapping */
    #workModal .absolute.top-8.right-8 {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        z-index: 30;
        margin-top: 8vh;
        margin-bottom: 12px;
        align-self: flex-end;
        margin-right: 2.5vw;
    }
    
    /* Tighter spacing between buttons on mobile - override Tailwind */
    #workModal .absolute.top-8.right-8.z-20.flex.items-center.space-x-3 {
        gap: 8px !important;
    }
    
    #workModal .absolute.top-8.right-8.z-20.flex.items-center.space-x-3 > * {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Make buttons compact but still usable on mobile */
    #workModal .modal-glass-button {
        padding: 10px;
        font-size: 0.8rem;
        min-height: 40px;
        min-width: 40px;
    }
    
    #workModal .modal-glass-button.inline-flex {
        padding: 8px 14px;
        min-width: auto;
    }
    
    /* Modal content sizing for mobile - now without overlapping buttons */
    #modalContent {
        max-width: 95vw;
        max-height: 65vh;
        margin: 0 2.5vw 4vh 2.5vw;
        width: 95vw;
    }
    
    /* Adjust modal body container for mobile */
    .modal-body-container {
        height: calc(65vh - 40px);
        min-height: 260px;
    }
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Modal iframe responsive */
#modalIframe {
    min-height: 400px;
}

/* Modal accessibility */
#workModal:focus-within {
    outline: none;
}

/* Smooth transitions for modal elements */
#modalLoading {
    transition: opacity 0.3s ease-in-out;
}

#modalLoading.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Glass morphism buttons for modal */
.modal-glass-button {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-glass-button:hover {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.dark .modal-glass-button {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.dark .modal-glass-button:hover {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Modal body container height control */
.modal-body-container {
    height: 90vh;
}



/* Keyboard focus styles for work-card divs acting as buttons */
.work-card[role="button"]:focus {
    outline: 2px solid #6B8CAE;
    outline-offset: 2px;
}

.dark .work-card[role="button"]:focus {
    outline-color: #9BB5D6;
}


