/* 
 * GESTIONE EDILE S.R.L. - Main Stylesheet
 * Lead Front-End Architecture
 * Version: 2.0.0 - Production Ready
 */

/* ============================================
   FONTS & VARIABLES
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400;600;700&family=Libre+Franklin:wght@300;400;700;900&display=swap');

:root {
    --bg: #fafaf8;
    --bg-white: #ffffff;
    --text: #0f0f0f;
    --text-gray: #6b7280;
    --accent: #47ace0;
    --accent-dark: #3a8fb5;
    --border-light: #e5e7eb;
    
    /* Easing */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ============================================
   BASE RESET
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body { 
    background-color: var(--bg); 
    color: var(--text); 
    font-family: 'Libre Franklin', sans-serif; 
    overflow-x: hidden; 
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.modal-open,
body.detail-open,
body.mobile-nav-open {
    overflow: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

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

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* ============================================
   CUSTOM CURSOR
   ============================================ */

#cursor { 
    width: 14px; 
    height: 14px; 
    background: var(--accent); 
    border-radius: 50%; 
    position: fixed; 
    pointer-events: none; 
    z-index: 10000; 
    mix-blend-mode: difference;
    transition: transform 0.15s var(--ease-smooth);
    transform: translate(-50%, -50%);
}

#cursor.cursor-hover {
    transform: translate(-50%, -50%) scale(2.5);
}

.cursor-none {
    cursor: none;
}

/* Hide cursor on touch devices */
@media (hover: none) {
    #cursor {
        display: none;
    }
    .cursor-none {
        cursor: auto;
    }
}

/* ============================================
   NOISE TEXTURE
   ============================================ */

.noise { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="3.5" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)"/></svg>');
    opacity: 0.04; 
    pointer-events: none; 
    z-index: 9999; 
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.meta-text { 
    text-transform: uppercase; 
    letter-spacing: 0.25em; 
    font-size: 0.65rem; 
    font-weight: 700; 
    font-family: 'Libre Franklin', sans-serif;
}

.hero-title { 
    font-size: clamp(3rem, 10vw, 9rem); 
    letter-spacing: -0.04em; 
    line-height: 0.9; 
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
}

.display-serif {
    font-family: 'Cormorant Garamond', serif;
}

.section-title {
    font-size: clamp(2.5rem, 8vw, 7rem);
    letter-spacing: -0.03em;
    line-height: 1;
    font-weight: 900;
}

/* ============================================
   NAVIGATION
   ============================================ */

nav {
    transition: background-color 0.3s var(--ease);
}

nav.scrolled {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

nav.scrolled .meta-text,
nav.scrolled a {
    color: var(--text) !important;
}

nav.scrolled #logo-header {
    filter: brightness(1) invert(0);
}

/* ============================================
   MOBILE NAVIGATION (Hamburger Menu)
   ============================================ */

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    padding: 0;
    position: relative;
    z-index: 110;
    flex-shrink: 0;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.35s var(--ease-out-expo), opacity 0.25s var(--ease), width 0.25s var(--ease);
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    width: 100%;
    transform: translateY(-8px) rotate(-45deg);
}

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.45);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.35s var(--ease);
}

.nav-overlay.open {
    display: block;
    opacity: 1;
}

@media (max-width: 900px) {
    /* Force a solid, legible nav bar on mobile regardless of hero blend tricks */
    nav.fixed {
        background-color: rgba(250, 250, 248, 0.97) !important;
        mix-blend-mode: normal !important;
    }

    nav.fixed .meta-text,
    nav.fixed a,
    nav.fixed .nav-toggle {
        color: var(--text) !important;
    }

    nav.fixed #logo-header {
        filter: brightness(1) invert(0) !important;
        width: 110px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        height: 100dvh;
        width: min(80vw, 320px);
        background: var(--bg-white);
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center;
        gap: 2.25rem !important;
        margin: 0 !important;
        padding: 6rem 3rem 3rem;
        transform: translateX(100%);
        transition: transform 0.45s var(--ease-out-expo);
        z-index: 105;
        box-shadow: -20px 0 50px rgba(0, 0, 0, 0.12);
    }

    .nav-links.open {
        transform: translateX(0);
    }

    .nav-links a {
        color: var(--text) !important;
        font-size: 1.15rem;
        letter-spacing: 0.05em;
    }
}

@media (min-width: 901px) {
    .nav-overlay {
        display: none !important;
    }
}

#logo-header { 
    width: 140px; 
    transition: transform 0.6s var(--ease), filter 0.3s var(--ease); 
    filter: brightness(0) invert(1);
}

#logo-header:hover { 
    transform: scale(1.06) rotate(-2deg); 
}

.translator-btn {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: all 0.3s var(--ease);
}

.translator-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hero-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 100%);
    z-index: 2;
}

.hero-content {
    position: relative;
    z-index: 3;
}

.reveal-wrap {
    overflow: hidden;
    display: inline-block;
}

.hero-reveal {
    display: inline-block;
}

/* ============================================
   PROJECT CARDS & HOVER EFFECTS
   ============================================ */

.project-card {
    cursor: pointer;
    transition: transform 0.6s var(--ease);
    will-change: transform;
}

.project-card:hover {
    transform: translateY(-8px);
}

.project-img {
    transition: transform 0.8s var(--ease);
    will-change: transform;
}

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

/* ============================================
   SERVICE CARDS
   ============================================ */

.service-card {
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.4s var(--ease);
    position: relative;
}

.service-card::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 0;
    height: 2px;
    background-color: var(--accent);
    transition: width 0.6s var(--ease);
}

.service-card:hover::before {
    width: 100%;
}

.service-card:hover {
    padding-left: 1rem;
}

.service-card:hover .service-title {
    color: var(--accent);
}

.service-number {
    transition: transform 0.4s var(--ease);
}

.service-card:hover .service-number {
    transform: translateX(8px);
}

/* ============================================
   MODAL
   ============================================ */

#image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.4s var(--ease);
}

#image-modal.active {
    display: flex;
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    color: white;
    z-index: 10;
    transition: transform 0.3s var(--ease);
}

.modal-close:hover {
    transform: rotate(90deg);
}

.modal-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
}

.modal-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    max-width: 1400px;
    width: 100%;
    animation: modalSlideUp 0.6s var(--ease-out-expo);
}

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

.modal-image-container {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 8px;
    position: relative;
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-caption {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    background-color: #ffffff;
    color: #0f0f0f;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    max-width: calc(100% - 2rem);
}

.modal-info {
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

.modal-title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 900;
    line-height: 1.1;
    font-family: 'Cormorant Garamond', serif;
    color: var(--accent);
}

.modal-meta {
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-description {
    font-size: 0.95rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   DETAIL VIEWS (SERVICES & WORKS)
   ============================================ */

.service-detail-view,
.works-detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg);
    z-index: 9997;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s var(--ease), visibility 0.5s;
}

.service-detail-view.active,
.works-detail-view.active {
    opacity: 1;
    visibility: visible;
}

.back-button {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 10;
    cursor: pointer;
    padding: 1rem 1.5rem;
    background-color: white;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s var(--ease);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.back-button:hover {
    transform: translateX(-8px);
    background-color: var(--accent);
    color: white;
}

/* ============================================
   PAGE HERO (Service & Work Detail Pages)
   ============================================ */

.page-hero {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 6rem 1.5rem 4rem;
    position: relative;
    overflow: hidden;
}

.page-hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.page-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);
}

.page-hero-content {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-hero-subtitle {
    color: var(--accent);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 1rem;
}

.page-hero-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 900;
    color: white;
    line-height: 0.95;
    letter-spacing: -0.02em;
}

/* ============================================
   CONTENT SECTIONS
   ============================================ */

.content-section {
    padding: 5rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 4rem;
    margin-top: 3rem;
}

.content-sidebar {
    position: sticky;
    top: 6rem;
    align-self: start;
}

.content-main {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
}

.content-main p {
    margin-bottom: 1.5rem;
}

.content-main h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 3rem 0 1rem;
    color: var(--accent);
}

/* ============================================
   IMAGE GALLERY
   ============================================ */

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 3rem 0;
}

.gallery-item {
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.4s var(--ease);
}

.gallery-item:hover {
    transform: scale(0.98);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease);
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* ============================================
   PLACEHOLDER IMAGES
   ============================================ */

.placeholder-img {
    background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-gray);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.placeholder-img::before {
    content: 'Image Coming Soon';
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-light);
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--accent);
    z-index: 10001;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.6s var(--ease-in-out);
}

.page-transition.active {
    transform: scaleY(1);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .modal-content-wrapper {
        grid-template-columns: 1fr;
        padding: 2rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .content-sidebar {
        position: static;
    }
    
    .image-gallery {
        grid-template-columns: 1fr;
    }
    
    .back-button {
        top: 1rem;
        left: 1rem;
        padding: 0.75rem 1.25rem;
        font-size: 0.75rem;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

.fade-in-up {
    animation: fadeInUp 0.8s var(--ease-out-expo) forwards;
}

/* Stagger animation for multiple elements */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-item.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

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

.container-narrow {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.text-balance {
    text-wrap: balance;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    #cursor,
    .noise,
    nav,
    footer,
    .back-button {
        display: none;
    }
}
