:root {
    /* MD3 Color Palette - Primary (Blu Bandiera Ucraina) */
    --md-sys-color-primary: #0057B7;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #d6e4ff;
    --md-sys-color-on-primary-container: #001945;

    /* MD3 Color Palette - Secondary/Tertiary (Giallo Bandiera Ucraina) */
    --md-sys-color-tertiary: #FFD700;
    --md-sys-color-on-tertiary: #332a00;
    --md-sys-color-tertiary-container: #ffe234;
    --md-sys-color-on-tertiary-container: #211b00;

    /* Surface Colors */
    --md-sys-color-background: #fdfbff;
    --md-sys-color-on-background: #1a1c1e;
    --md-sys-color-surface: #fdfbff;
    --md-sys-color-on-surface: #1a1c1e;
    --md-sys-color-surface-variant: #dfe2eb;
    --md-sys-color-on-surface-variant: #43474e;
    --md-sys-color-surface-container-low: #f3f3f7;
    --md-sys-color-surface-container: #ededf1;
    --md-sys-color-surface-container-high: #e7e8ec;

    /* Shadows / Elevation */
    --md-sys-elevation-1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);

    /* Shapes */
    --md-sys-shape-corner-medium: 16px;
    --md-sys-shape-corner-full: 9999px;

    /* Hero gradient */
    --hero-gradient-start: var(--md-sys-color-primary-container);
    --hero-gradient-end: var(--md-sys-color-background);

    /* Top bar background */
    --top-bar-bg: rgba(253, 251, 255, 0.9);

    /* Card glow on hover */
    --card-hover-glow: rgba(0, 87, 183, 0.08);
    --card-hover-border: rgba(0, 87, 183, 0.18);
    --card-active-border: rgba(0, 87, 183, 0.22);
}

/* =========================================
   DARK MODE
   Colori bandiera ucraina, WCAG AA compliant
   ========================================= */
[data-theme="dark"] {
    --md-sys-color-primary: #8ab4f8;
    --md-sys-color-on-primary: #002d6e;
    --md-sys-color-primary-container: #003f9e;
    --md-sys-color-on-primary-container: #d6e4ff;

    --md-sys-color-tertiary: #FFD700;
    --md-sys-color-on-tertiary: #332a00;
    --md-sys-color-tertiary-container: #4d4000;
    --md-sys-color-on-tertiary-container: #ffe76a;

    --md-sys-color-background: #0e1117;
    --md-sys-color-on-background: #e2e2e6;
    --md-sys-color-surface: #0e1117;
    --md-sys-color-on-surface: #e2e2e6;
    --md-sys-color-surface-variant: #1e2430;
    --md-sys-color-on-surface-variant: #c3c7cf;
    --md-sys-color-surface-container-low: #141820;
    --md-sys-color-surface-container: #1a1f2a;
    --md-sys-color-surface-container-high: #222835;

    --md-sys-elevation-1: 0px 1px 3px 0px rgba(0, 0, 0, 0.6), 0px 1px 4px 1px rgba(0, 0, 0, 0.3);
    --md-sys-elevation-2: 0px 2px 4px 0px rgba(0, 0, 0, 0.6), 0px 3px 8px 2px rgba(0, 0, 0, 0.3);

    --hero-gradient-start: #0a1628;
    --hero-gradient-end: #0e1117;

    --top-bar-bg: rgba(14, 17, 23, 0.92);

    --card-hover-glow: rgba(138, 180, 248, 0.06);
    --card-hover-border: rgba(138, 180, 248, 0.22);
    --card-active-border: rgba(138, 180, 248, 0.30);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* =========================================
   REALISTIC CSS SOAP BUBBLES (Background)
   ========================================= */
.bubble-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* Above base background, below content */
    pointer-events: none;
    overflow: hidden;
}

.soap-bubble {
    position: absolute;
    border-radius: 50%;
    /* Layered gradients for a complex soap film look */
    background: 
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 25%),
        radial-gradient(circle at 70% 70%, rgba(138, 180, 248, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 30% 70%, rgba(255, 215, 0, 0.15) 0%, transparent 40%),
        radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 60%, rgba(0, 87, 183, 0.25) 85%, rgba(255, 215, 0, 0.25) 100%);
    box-shadow: 
        inset 0 0 25px rgba(255, 255, 255, 0.4),
        inset 5px 5px 35px rgba(255, 255, 255, 0.2),
        inset -5px -5px 30px rgba(138, 180, 248, 0.2),
        0 0 15px rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(1.5px);
    animation: float-bubble linear infinite;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.soap-bubble.popping {
    animation: pop-animation 0.3s ease-out forwards !important;
    pointer-events: none;
}

@keyframes pop-animation {
    0% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.4); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Primary Highlight (Reflected Light) */
.soap-bubble::before {
    content: '';
    position: absolute;
    top: 12%;
    left: 12%;
    width: 35%;
    height: 25%;
    border-radius: 50%;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 80%);
    filter: blur(1px);
    transform: rotate(-35deg);
    z-index: 2;
}

/* Iridescent Soap Film Rim (Blue/Yellow Focus) */
.soap-bubble::after {
    content: '';
    position: absolute;
    inset: 2%;
    border-radius: 50%;
    border: 2px solid transparent;
    background: linear-gradient(135deg, 
        rgba(0, 87, 183, 0.5) 0%, 
        transparent 30%, 
        transparent 70%, 
        rgba(255, 215, 0, 0.5) 100%
    ) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
    opacity: 0.9;
}

/* Secondary Reflection (Bottom-right) */
.soap-bubble-secondary-highlight {
    position: absolute;
    bottom: 15%;
    right: 15%;
    width: 25%;
    height: 18%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    filter: blur(2.5px);
    transform: rotate(145deg);
    pointer-events: none;
}

@keyframes float-bubble {
    0% {
        transform: translateY(110vh) translateX(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    50% {
        transform: translateY(50vh) translateX(20px) scale(1.05);
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(-20vh) translateX(-10px) scale(1.1);
        opacity: 0;
    }
}

/* Specific Bubble Variations */
.bubble-1 { width: 80px; height: 80px; left: 10%; animation-duration: 25s; animation-delay: 0s; }
.bubble-2 { width: 40px; height: 40px; left: 25%; animation-duration: 30s; animation-delay: -5s; }
.bubble-3 { width: 120px; height: 120px; left: 45%; animation-duration: 35s; animation-delay: -15s; }
.bubble-4 { width: 60px; height: 60px; left: 70%; animation-duration: 28s; animation-delay: -10s; }
.bubble-5 { width: 90px; height: 90px; left: 85%; animation-duration: 32s; animation-delay: -2s; }
.bubble-6 { width: 30px; height: 30px; left: 15%; animation-duration: 22s; animation-delay: -8s; }

[data-theme="dark"] .soap-bubble {
    background: radial-gradient(circle at 30% 30%, 
        rgba(255, 255, 255, 0.15) 0%, 
        rgba(255, 255, 255, 0.05) 60%, 
        rgba(138, 180, 248, 0.2) 80%, 
        rgba(255, 215, 0, 0.2) 100%);
    box-shadow: 
        inset 0 0 25px rgba(255, 255, 255, 0.5),
        inset 5px 5px 30px rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, rgba(10, 22, 40, 0.85) 0%, rgba(14, 17, 23, 0.85) 100%);
}

[data-theme="dark"] .contacts {
    background-color: rgba(20, 24, 32, 0.85);
}

[data-theme="dark"] footer {
    background-color: rgba(14, 17, 23, 0.85);
}

/* Stile per il focus da tastiera (Accessibilita' W3C) */
:focus-visible {
    outline: 3px solid var(--md-sys-color-primary);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Typography MD3 (Fluid/Responsive) */
.display-large {
    font-size: clamp(2.5rem, 5vw + 1rem, 4.5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.25px;
}

.display-medium {
    font-size: clamp(2rem, 4vw + 0.5rem, 3.5rem);
    font-weight: 500;
    line-height: 1.2;
}

.title-large {
    font-size: 1.375rem;
    font-weight: 500;
    line-height: 1.3;
}

.body-large {
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.5px;
}

.body-medium {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.25px;
}

.body-small {
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.3;
}

/* Global Utilities */
.text-center {
    text-align: center;
}

/* Scroll Reveal Class */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
}

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

/* =========================
   DARK MODE TOGGLE
   ========================= */
.theme-toggle {
    position: relative;
    width: 56px;
    height: 32px;
    border-radius: 9999px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    background-color: var(--md-sys-color-surface-variant);
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 4px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--md-sys-color-primary);
}

.theme-toggle-thumb {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease, width 0.3s ease, height 0.3s ease;
    left: 3px;
}

.theme-toggle-thumb .material-symbols-rounded {
    font-size: 14px;
    color: var(--md-sys-color-surface);
    transition: color 0.3s ease;
}

[data-theme="dark"] .theme-toggle {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(24px);
    background-color: var(--md-sys-color-on-primary-container);
    width: 24px;
    height: 24px;
}

[data-theme="dark"] .theme-toggle-thumb .material-symbols-rounded {
    color: var(--md-sys-color-primary-container);
}

/* Top App Bar */
.top-app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 5%;
    background-color: var(--top-bar-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 101;
    border-bottom: 1px solid var(--md-sys-color-surface-container-high);
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
    transition: color 0.4s ease;
}

.logo-icon {
    font-size: 28px;
    color: var(--md-sys-color-primary);
    transition: color 0.4s ease;
}

nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--md-sys-color-primary);
}

/* Buttons */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 32px;
    height: 56px;
    border-radius: var(--md-sys-shape-corner-full);
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    letter-spacing: 0.1px;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
    border: none;
    cursor: pointer;
    overflow: hidden;
}

.btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-filled:hover {
    filter: brightness(0.85);
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-2px);
}

/* Shine Effect (Like a clean mirror) */
.shine-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-20deg);
    transition: all 0.5s ease;
}

.shine-effect:hover::after {
    animation: shine 1s;
}

@keyframes shine {
    100% {
        left: 200%;
    }
}

/* Main Content - Above Bubbles */
main {
    position: relative;
    z-index: 1; /* Above bubbles (z-index 0) */
}

/* Hero Section Minimal */
.hero {
    position: relative;
    background: linear-gradient(135deg, rgba(232, 240, 254, 0.85) 0%, rgba(253, 251, 255, 0.85) 100%);
    padding: 120px 5% 100px 5%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-radius: 0 0 32px 32px;
    overflow: hidden;
    transition: background 0.4s ease;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.hero h1 {
    color: var(--md-sys-color-on-primary-container);
    transition: color 0.4s ease;
}

.hero p {
    color: var(--md-sys-color-on-surface-variant);
    max-width: 650px;
    transition: color 0.4s ease;
}

/* Services */
.services {
    padding: 100px 5%;
    max-width: 1400px;
    margin: 0 auto;
}

.services h2 {
    text-align: center;
    margin-bottom: 56px;
    color: var(--md-sys-color-primary);
    transition: color 0.4s ease;
}

.services-grid {
    display: flex;
    flex-direction: column;
    gap: 48px;
    /* Increased from 32px for more vertical separation */
    align-items: center;
}

.services-row {
    display: flex;
    justify-content: center;
    gap: 48px;
    /* Increased from 32px for more horizontal separation */
    width: 100%;
    flex-wrap: nowrap;
}

.services-row-3 .md-card {
    flex: 0 1 calc((100% - 96px) / 3);
    max-width: 400px;
}

.services-row-2 .md-card {
    flex: 0 1 calc((100% - 48px) / 2);
    max-width: 560px;
}

.services-row-1 .md-card {
    flex: 0 1 min(100%, 560px);
    max-width: 560px;
}

.services-row-1,
.services-row-2,
.services-row-3 {
    justify-content: center;
}

/* ===========================================
   CARD - New glassmorphism hover/tilt effect
   =========================================== */
.md-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition:
        background-color 0.35s ease,
        transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.35s ease;
    border: 1.5px solid transparent;
    transform-origin: center;
    will-change: transform, box-shadow;
    perspective: 600px;
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay on hover */
.md-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.06) 0%,
            transparent 60%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

[data-theme="dark"] .md-card::before {
    background: linear-gradient(135deg,
            rgba(138, 180, 248, 0.05) 0%,
            transparent 60%);
}

@media (hover: hover) and (pointer: fine) {
    .md-card:hover {
        transform: translateY(-6px) scale(1.018);
        box-shadow:
            var(--md-sys-elevation-2),
            0 8px 32px var(--card-hover-glow);
        border-color: var(--card-hover-border);
    }

    .md-card:hover::before {
        opacity: 1;
    }

    .md-card:hover .card-icon {
        transform: scale(1.08) rotate(-3deg);
    }
}

.md-card:focus-visible,
.md-card:active {
    transform: translateY(-2px) scale(0.99);
    box-shadow:
        var(--md-sys-elevation-2),
        0 4px 20px var(--card-hover-glow);
    border-color: var(--card-active-border);
}

.md-card:focus-visible::before,
.md-card:active::before {
    opacity: 1;
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease, color 0.4s ease;
}

.card-icon span {
    font-size: 36px;
}

.md-card h3 {
    transition: color 0.4s ease;
}

.md-card p {
    transition: color 0.4s ease;
}

/* Contacts */
.contacts {
    padding: 100px 5%;
    background-color: rgba(247, 242, 250, 0.85); /* Semi-transparent surface-container-low */
    border-radius: 40px 40px 0 0;
    transition: background-color 0.4s ease;
}

.contacts-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.contacts-container h2 {
    color: var(--md-sys-color-primary);
    transition: color 0.4s ease;
}

.contact-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

.contact-fab {
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface);
    padding: 20px;
    border-radius: var(--md-sys-shape-corner-medium);
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-1);
    transition: all 0.3s ease;
}

.contact-fab:hover {
    box-shadow: var(--md-sys-elevation-2);
    transform: scale(1.02);
}

.contact-fab:hover .arrow {
    transform: translateX(5px);
    color: var(--md-sys-color-primary);
}

/* Subtle Pulse for Primary Contact (Call) rimosso per sobrietà */

.fab-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.fab-icon.primary-container {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.fab-icon.secondary-container {
    background-color: #d7e3f8;
    color: #001c37;
}

[data-theme="dark"] .fab-icon.secondary-container {
    background-color: #1a2d44;
    color: #b8cce6;
}

.fab-icon.tertiary-container {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}

.fab-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.fab-text .label {
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
    transition: color 0.4s ease;
}

.fab-text strong {
    font-size: 18px;
    font-weight: 500;
    transition: color 0.4s ease;
}

.contact-fab .arrow {
    color: var(--md-sys-color-on-surface-variant);
    transition: transform 0.3s, color 0.3s;
}

/* Footer */
footer {
    padding: 32px;
    text-align: center;
    background-color: rgba(247, 242, 250, 0.85); /* Semi-transparent surface-container-low */
    color: var(--md-sys-color-on-surface-variant);
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Rendering per schermi molto grandi (Smart TV/Ultra-wide PC) */
@media (min-width: 1600px) {
    .hero {
        padding: 160px 10%;
    }

    .display-large {
        font-size: 72px;
        line-height: 80px;
    }

    .services-row-3 .md-card {
        max-width: 420px;
    }
}

/* Responsive constraints (Tablet/Smartphone) */
@media (max-width: 768px) {
    .display-large {
        font-size: clamp(2.5rem, 8vw, 3.5rem);
        line-height: 1.1;
    }

    .display-medium {
        font-size: clamp(2rem, 6vw, 2.8rem);
        line-height: 1.2;
    }

    .hero {
        padding: 80px 5%;
    }

    .services {
        padding: 80px 5%;
    }

    .services-grid {
        gap: 28px;
    }

    .services-row {
        flex-direction: column;
        align-items: center;
        gap: 28px;
    }

    .services-row .md-card {
        width: 100%;
        max-width: 560px;
    }

    .contact-fab {
        padding: 16px;
    }

    .fab-icon {
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    html {
        scroll-behavior: auto;
    }
}