:root {
    --color-bg: #0a0a0a;
    --color-text: #ffffff;
    --color-accent: #cda45e;
    --color-surface: #1a1a1a;
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;
    --transition-speed: 0.8s;
    --transition-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    overflow-x: hidden;
    line-height: 1.6;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-serif);
    font-weight: 400;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Skeleton Loading Background for Lazy Images */
img[loading="lazy"] {
    background: linear-gradient(90deg, #111 25%, #2a2a2a 50%, #111 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 2s infinite ease-in-out;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 4rem;
}

/* HEADER */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Ensure vertical centering */
    z-index: 1000;
    transition: all 0.5s var(--transition-ease);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#main-header.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#main-header.show #header-logo {
    opacity: 1;
}

#main-header.scrolled {
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(20px);
    padding: 0.5rem 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

#header-logo {
    height: 40px;
    width: auto;
    display: block;
    opacity: 0;
    /* Reset transforms to ensure perfect centering as requested */
    translate: none;
    rotate: none;
    scale: none;
    transform: none;
}

/* HERO */
#hero {
    position: relative;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.bg-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.4);
}

.hero-bg .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 20%, rgba(10, 10, 10, 0.8) 100%);
}

#hero-logo-composite {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    opacity: 0;
    transform: scale(0.8);
}

#logo-part-m {
    height: 120px;
    width: auto;
}

#logo-part-emarm {
    height: 120px;
    width: auto;
    margin-left: -20px;
    /* Slight overlap or adjustment based on visual test */
}

/* MOBILE OPTIMIZATION */
@media (max-width: 768px) {
    #header-logo {
        height: 30px;
    }

    #logo-part-m {
        height: 80px;
    }

    #logo-part-emarm {
        height: 80px;
        margin-left: -14px;
        /* Scaled down from -20px */
    }
}

/* WORK SECTIONS - COLUMN FOCUS */
#work-pinned-container {
    background: var(--color-bg);
    overflow: hidden;
}

.work-columns-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
}

.work-column {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: flex 0.8s var(--transition-ease);
}

.work-column:last-child {
    border-right: none;
}

.work-bg-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.work-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.5) grayscale(100%);
    transition: filter 0.8s ease;
}

.work-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
    opacity: 0.8;
}

.work-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 4rem;
    z-index: 10;
    opacity: 0;
    transform: translateY(50px);
    pointer-events: none;
    transition: all 0.8s var(--transition-ease);
}

.work-num {
    display: block;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.work-title {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.work-desc {
    font-size: 1.1rem;
    max-width: 400px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
}

ul.work-desc {
    padding-left: 1.5rem;
    list-style-position: outside;
}

/* Class added by JS for active state */
.work-column.active {
    flex: 5;
}

.work-column.active .work-bg {
    filter: brightness(0.7) grayscale(0%);
}

.work-column.active .work-content {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.btn-cta {
    display: inline-block;
    padding: 1.2rem 3rem;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.9rem;
    transition: all 0.4s var(--transition-ease);
    border-radius: 2px;
}

.btn-cta:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

/* CHI SIAMO */
#chi-siamo {
    padding: 10rem 0;
    background: #0d0d0d;
}

.split-layout {
    display: flex;
    align-items: center;
    gap: 6rem;
}

.image-col {
    flex: 1;
    height: 600px;
    border-radius: 4px;
    position: relative;
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Collage Layout */
.collage-layout .main-img {
    width: 75%;
    height: 80%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.collage-layout .sub-img {
    width: 60%;
    height: 60%;
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 2;
    border: 8px solid #0d0d0d;
    border-radius: 12px;
    box-shadow: -10px -10px 30px rgba(0, 0, 0, 0.4);
    transition: transform 0.4s ease;
}

.collage-layout .sub-img:hover {
    transform: scale(1.05);
}

/* Stacked Layout */
.stacked-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.stacked-layout .img-wrapper {
    flex: 1;
    width: 100%;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.location-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(5px);
    color: var(--color-accent);
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid rgba(205, 164, 94, 0.3);
    border-radius: 2px;
    z-index: 10;
    pointer-events: none;
}

.stacked-layout .img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.stacked-layout .img-wrapper:hover img {
    transform: scale(1.05);
}

.text-col {
    flex: 1;
}

.section-title {
    font-size: 3.5rem;
    margin-bottom: 2rem;
    color: var(--color-accent);
}

.section-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 3rem;
    color: rgba(255, 255, 255, 0.7);
}

.btn-text {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--color-accent);
    padding-bottom: 5px;
    transition: color 0.3s;
}

.btn-text:hover {
    color: var(--color-accent);
}

/* TERZI */
#terzi {
    padding: 10rem 0;
}

.terzi-card {
    display: flex;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.terzi-content {
    flex: 1.2;
    padding: 6rem;
}

.terzi-image {
    flex: 1;
}

.terzi-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
}

.terzi-features {
    list-style: none;
    margin-bottom: 3rem;
}

.terzi-features li {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.terzi-features li::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
}

/* CONTATTI */
#contatti {
    padding: 10rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.contact-info {
    flex: 1;
}

.info-block {
    margin-bottom: 3rem;
}

.info-block h4 {
    color: var(--color-accent);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
}

.info-block p,
.info-block a {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.8);
}

.social-links {
    display: flex;
    gap: 2rem;
    margin-top: 4rem;
}

.social-links a {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.3s;
}

.social-links a:hover {
    color: var(--color-accent);
}

.contact-form-wrapper {
    flex: 1;
    background: #111;
    padding: 4rem;
    border-radius: 8px;
}

.form-group {
    position: relative;
    margin-bottom: 3rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 0;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-bottom-color: var(--color-accent);
}

.form-group label {
    position: absolute;
    top: 1rem;
    left: 0;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transition: all 0.3s var(--transition-ease);
}

.form-group input:focus~label,
.form-group input:not(:placeholder-shown)~label,
.form-group textarea:focus~label,
.form-group textarea:not(:placeholder-shown)~label {
    top: -1.5rem;
    font-size: 0.8rem;
    color: var(--color-accent);
}

.btn-submit {
    width: 100%;
    padding: 1.2rem;
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s;
}

.btn-submit:hover {
    background: #b58d4a;
}

#form-response-message {
    margin-top: 2rem;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.4s ease;
    display: none;
    /* Controlled by JS or "hidden" class if preferred */
}

#form-response-message.success {
    display: block;
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

#form-response-message.error {
    display: block;
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* --- SERVIZI FEATURES --- */
.servizi-features {
    list-style: none;
    margin-bottom: 3rem;
}

.servizi-features li {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
}

.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(205, 164, 94, 0.1);
    border: 1px solid rgba(205, 164, 94, 0.3);
    border-radius: 50%;
    color: var(--color-accent);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.servizi-features li:hover .icon-wrapper {
    background: var(--color-accent);
    color: var(--color-bg);
    transform: scale(1.1);
}

.icon-wrapper svg {
    width: 20px;
    height: 20px;
}

/* --- SWIPER GALLERY --- */
.mySwiper {
    width: 100%;
    padding-bottom: 4rem;
    /* Space for pagination */
    overflow: hidden;
    position: relative;
}

.swiper-slide {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    overflow: hidden;
    height: 450px;
    background: #111;
}

.swiper-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.8);
    transition: filter 0.4s ease, transform 0.4s ease;
}

.swiper-slide:hover img {
    filter: brightness(1);
    transform: scale(1.05);
}

.swiper-pagination-bullet {
    background: transparent !important;
    border: 1px solid var(--color-accent) !important;
    opacity: 0.6 !important;
    width: 10px !important;
    height: 10px !important;
    transition: all 0.3s ease !important;
}

.swiper-pagination-bullet-active {
    background: var(--color-accent) !important;
    transform: scale(1.3);
    opacity: 1 !important;
}

.mySwiper .swiper-button-next,
.mySwiper .swiper-button-prev {
    color: var(--color-accent);
    background: rgba(10, 10, 10, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(205, 164, 94, 0.5);
    transition: all 0.3s ease;
}

.mySwiper .swiper-button-next:hover,
.mySwiper .swiper-button-prev:hover {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

.mySwiper .swiper-button-next::after,
.mySwiper .swiper-button-prev::after {
    font-size: 1.2rem;
    font-weight: bold;
}

/* FOOTER */
#main-footer {
    padding: 6rem 0 2rem;
    background: #050505;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
}

.footer-logo img {
    height: 40px;
}

.footer-nav ul {
    display: flex;
    list-style: none;
    gap: 3rem;
}

.footer-nav a {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.3s;
}

.footer-nav a:hover {
    color: white;
}

.footer-social {
    display: flex;
    gap: 1.5rem;
}

.social-icon {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.social-icon:hover {
    background: white;
    color: black;
}

.footer-bottom {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
}

/* --- PRODUCT MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s var(--transition-ease);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.product-modal {
    position: absolute;
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: all 0.4s var(--transition-ease);
}

.product-modal.active {
    display: flex;
    transform: scale(1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    background: none;
    border: none;
    color: var(--color-accent);
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s;
}

.close-modal:hover {
    transform: scale(1.1);
}

.modal-content {
    display: flex;
    flex: 1;
    height: 100%;
}

.modal-thumbnails {
    width: 250px;
    height: 100%;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-thumbnails::-webkit-scrollbar {
    width: 6px;
}

.modal-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.modal-thumbnails::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 4px;
}

.thumb-img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    filter: brightness(0.5);
    transition: all 0.3s;
    border: 2px solid transparent;
}

.thumb-img:hover {
    filter: brightness(0.8);
}

.thumb-img.active {
    filter: brightness(1);
    border-color: var(--color-accent);
}

.modal-main-img {
    flex: 1;
    height: 100%;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.modal-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10, 10, 10, 0.5);
    color: var(--color-accent);
    border: 1px solid rgba(205, 164, 94, 0.5);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s;
    font-size: 1.2rem;
}

.modal-arrow:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

.prev-arrow {
    left: 20px;
}

.next-arrow {
    right: 20px;
}

.modal-main-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* --- RESPONSIVE DESIGN --- */

@media (max-width: 1200px) {
    .container {
        padding: 0 3rem;
    }

    .work-title {
        font-size: 3.5rem;
    }
}

@media (max-width: 1024px) {
    .hero-tagline {
        font-size: 2.5rem;
    }

    .split-layout {
        gap: 4rem;
    }

    .terzi-content {
        padding: 4rem;
    }

    .work-title {
        font-size: 3rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 2rem;
    }

    /* Header */
    #main-header {
        padding: 1.5rem 0;
    }

    #header-logo {
        height: 35px;
    }

    /* Hero */
    .hero-tagline {
        font-size: 1.8rem;
        padding: 0 2rem;
    }

    #hero-logo-main {
        max-height: 100px;
    }

    /* Work Columns (Vertical Stack on Mobile) */
    .work-columns-wrapper {
        flex-direction: column;
        height: auto;
    }

    /* Modal Responsive Adjustments */
    .modal-content {
        flex-direction: column-reverse;
    }

    .modal-thumbnails {
        width: 100%;
        height: 130px;
        flex-direction: row;
        overflow-y: hidden;
        overflow-x: auto;
        padding: 15px;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .thumb-img {
        width: 130px;
        height: 100%;
        flex-shrink: 0;
    }

    /* Allow natural height */

    .work-column {
        width: 100%;
        height: 400px;
        /* Base height for mobile tiles */
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        flex: none !important;
        /* Disable flex-grow on mobile */
        transition: height 0.8s var(--transition-ease);
    }

    .work-column.active {
        height: 600px;
        /* Expand height on mobile when active */
    }

    .work-title {
        font-size: 2rem;
        white-space: normal;
        line-height: 1.2;
    }

    .work-content {
        padding: 2rem 1.5rem;
    }

    /* Layout Sections */
    .split-layout {
        flex-direction: column;
        text-align: center;
        gap: 3rem;
    }

    .image-col {
        height: 400px;
        width: 100%;
        order: 1;
    }

    .text-col {
        order: 2;
    }

    .section-title {
        font-size: 2.2rem;
        line-height: 1.2;
        word-wrap: break-word;
    }

    /* Terzi */
    .terzi-card {
        flex-direction: column;
    }

    .terzi-content {
        padding: 3rem 1.5rem;
    }

    .terzi-image {
        height: 300px;
    }

    /* Contacts */
    .social-links {
        flex-wrap: wrap;
        gap: 1rem;
        margin-top: 2rem;
        justify-content: center;
    }

    .contact-form-wrapper {
        padding: 3rem 1rem;
        width: 90% !important;
        margin: 0 auto;
    }

    .info-block p,
    .info-block a {
        font-size: 1.1rem;
    }

    /* Footer */
    .footer-layout {
        flex-direction: column;
        gap: 3rem;
        text-align: center;
    }

    .footer-nav ul {
        flex-direction: column;
        gap: 1.5rem;
    }

    .footer-social {
        justify-content: center;
    }

    /* Servizi Mobile Layout */
    #servizi {
        padding: 5rem 0 !important;
    }

    .servizi-features {
        display: inline-block;
        text-align: left;
        margin: 0 auto;
    }

    .servizi-features li {
        justify-content: flex-start;
    }

    /* Gallery Mobile Layout */
    #gallery {
        padding: 5rem 0 !important;
    }

    .mySwiper {
        padding-bottom: 4rem;
    }

    .mySwiper .swiper-pagination {
        bottom: 0 !important;
    }

    .swiper-slide {
        height: 350px;
    }

    .mySwiper .swiper-button-next,
    .mySwiper .swiper-button-prev {
        display: none !important;
        /* Hide arrows on mobile to save space */
    }
}

@media (max-width: 480px) {
    .hero-tagline {
        font-size: 1.5rem;
    }

    .work-title {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .work-column {
        height: 350px;
    }

    .work-column.active {
        height: 500px;
    }

    .container {
        padding: 0 1.5rem;
    }
}