@font-face {
    font-family: 'Agency FB';
    src: url('Asset/font/AGENCYR.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Agency FB';
    src: url('Asset/font/AGENCYB.TTF') format('truetype');
    font-weight: bold;
    font-style: normal;
}

:root {
    /* Brand */
    --accent-color: #BB2525;
    --accent-hover: #991c1c;
    --accent-soft: rgba(187, 37, 37, 0.08);
    --accent-glow: rgba(187, 37, 37, 0.18);

    /* Surfaces */
    --bg-color: #fbfbfc;
    --bg-elevated: rgba(251, 251, 252, 0.8);
    --card-bg: #ffffff;
    --border-color: #ececf0;

    /* Text */
    --text-color: #1a1d24;
    --text-muted: #5c6270;

    /* Typography */
    --font-heading: 'Agency FB', 'Oswald', 'Arial Narrow', sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 2px 6px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 24px 48px rgba(17, 24, 39, 0.14);

    /* Shape & Motion */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --accent-color: #e23b3b;
    --accent-hover: #f15454;
    --accent-soft: rgba(226, 59, 59, 0.12);
    --accent-glow: rgba(226, 59, 59, 0.22);

    --bg-color: #181d26;
    --bg-elevated: rgba(24, 29, 38, 0.82);
    --card-bg: #232c39;
    --border-color: #333d4b;

    --text-color: #eceef2;
    --text-muted: #9aa3b2;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.5);
}

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

html {
    background-color: var(--bg-color);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    line-height: 1.15;
}

p {
    color: var(--text-muted);
}

/* Texture decorativa di sfondo: griglia di punti che sfuma verso il basso */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(color-mix(in srgb, var(--text-color) 9%, transparent) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black, transparent);
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, black, transparent);
}

/* Bagliore ambientale d'accento nell'angolo in alto a destra */
body::after {
    content: '';
    position: fixed;
    top: -220px;
    right: -220px;
    width: 640px;
    height: 640px;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(circle, var(--accent-glow), transparent 65%);
    filter: blur(70px);
    opacity: 0.45;
}

/* Text selection */
::selection {
    background-color: var(--accent-color);
    color: #fff;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 8px;
    border: 3px solid var(--bg-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Accessible focus ring */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Titoli di pagina (sottopagine) */
main > h1 {
    font-size: clamp(2.6rem, 5vw, 3.6rem);
    background: linear-gradient(180deg, var(--text-color) 60%, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Section heading accent */
main h2 {
    font-size: 2.4rem;
    position: relative;
    display: inline-block;
    padding-bottom: 0.7rem;
    margin-bottom: 0.5rem;
}

main h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 3rem;
    height: 4px;
    background: var(--accent-color);
    border-radius: 2px;
}

/* Header & Nav */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 5%;
    position: sticky;
    top: 0;
    background-color: var(--bg-elevated);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

header:hover {
    box-shadow: var(--shadow-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    text-decoration: none;
    color: var(--text-color);
}

#site-logo {
    height: 40px;
    width: auto;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    align-items: center;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.2s;
}

/* Underline animato sui link principali della nav (non nel dropdown) */
#nav-menu > ul > li > a {
    position: relative;
}

#nav-menu > ul > li > a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s var(--ease);
}

#nav-menu > ul > li > a:hover::after,
#nav-menu > ul > li > a.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

@media (max-width: 992px) {
    #nav-menu > ul > li > a::after {
        display: none;
    }
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

/* Freccina accanto a "Progetti": segnala il menu e si capovolge all'apertura */
.dropdown > a {
    padding-right: 1.05rem;
}

.dropdown > a::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-65%) rotate(45deg);
    transition: transform 0.3s var(--ease);
}

.dropdown:hover > a::before {
    transform: translateY(-35%) rotate(-135deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 14px);
    left: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 220px;
    padding: 0.55rem;
    display: none;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    list-style: none;
}

/* Ponte invisibile sopra il menu: mantiene l'hover mentre il cursore
   attraversa lo spazio tra il bottone Progetti e il menu */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 0;
    right: 0;
    height: 14px;
}

/* Filo luminoso d'accento sul bordo superiore, come nel footer */
.dropdown-menu::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.dropdown:hover .dropdown-menu {
    display: block;
    animation: menuFadeIn 0.3s ease;
}

.dropdown-menu li {
    display: block;
    width: 100%;
}

.dropdown-menu a {
    display: block;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.dropdown-menu a:hover {
    background-color: var(--accent-soft);
    color: var(--accent-color);
    transform: translateX(3px);
}

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

/* Le voci del dropdown entrano in sequenza */
.dropdown:hover .dropdown-menu li {
    opacity: 0;
    animation: dropItemIn 0.3s var(--ease) forwards;
}

.dropdown:hover .dropdown-menu li:nth-child(1) { animation-delay: 0.05s; }
.dropdown:hover .dropdown-menu li:nth-child(2) { animation-delay: 0.1s; }
.dropdown:hover .dropdown-menu li:nth-child(3) { animation-delay: 0.15s; }
.dropdown:hover .dropdown-menu li:nth-child(4) { animation-delay: 0.2s; }
.dropdown:hover .dropdown-menu li:nth-child(5) { animation-delay: 0.25s; }

@keyframes dropItemIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}


/* Mobile Dropdown */
@media (max-width: 992px) {
    .dropdown-menu {
        display: none !important;
    }

    /* Su mobile il dropdown non esiste: niente freccina né padding extra */
    .dropdown > a {
        padding-right: 1rem;
    }

    .dropdown > a::before {
        display: none;
    }
}


nav a:hover,
nav a.active {
    color: var(--accent-color);
}

/* Theme Toggle */
.theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.3s var(--ease), border-color 0.3s var(--ease),
        background-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    background: var(--accent-soft);
    transform: rotate(20deg) scale(1.06);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Layout */
main {
    min-height: calc(100vh - 160px);
    padding: 4rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.85rem 2.2rem;
    background-color: var(--accent-color);
    color: white;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 10px;
    box-shadow: 0 6px 18px var(--accent-glow);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background-color 0.2s var(--ease);
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
}

.btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 26px var(--accent-glow);
}

.btn:active {
    transform: translateY(0);
}

/* Variante "ghost": bordo sottile, si accende all'hover */
.btn--ghost {
    background: transparent;
    color: var(--text-color);
    border: 1.5px solid var(--border-color);
    box-shadow: none;
}

.btn--ghost:hover {
    background: var(--accent-soft);
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: none;
}

/* Hero Section */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
    margin-bottom: 5rem;
    padding: 3rem 1rem 1rem;
    position: relative;
}

/* Soft radial glow behind the hero */
.hero::before {
    content: '';
    position: absolute;
    top: -10%;
    left: 50%;
    transform: translateX(-50%);
    width: min(820px, 110%);
    height: 420px;
    background: radial-gradient(ellipse at center, var(--accent-glow), transparent 70%);
    opacity: 0.7;
    z-index: -1;
    pointer-events: none;
    filter: blur(8px);
}

/* Badge introduttivo sopra il titolo */
.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1.2rem;
    border-radius: 50px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, var(--border-color));
    background: var(--accent-soft);
    color: var(--accent-color);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hero h1 {
    font-size: clamp(2.8rem, 6vw, 4.5rem);
    line-height: 1.05;
    margin-bottom: 0.5rem;
    background: linear-gradient(180deg, var(--text-color) 60%, var(--text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Parola evidenziata nel titolo, con shimmer lento sul gradiente */
.hero h1 .accent {
    background: linear-gradient(120deg, var(--accent-color), var(--accent-hover), var(--accent-color));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: accentShimmer 6s ease-in-out infinite;
}

@keyframes accentShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero p {
    font-size: 1.2rem;
    max-width: 620px;
    color: var(--text-muted);
}

.hero-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Grid Layouts */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.grid--services {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 992px) {
    .grid--services {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    z-index: 1;
}


.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-color));
    z-index: 10;
}

/* Barra d'accento che si rivela in cima alla card all'hover */
.card:not(.team-card)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-hover));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s var(--ease);
    z-index: 2;
}

.card:not(.team-card):hover::before {
    transform: scaleX(1);
}

.card h3 {
    transition: color 0.3s var(--ease);
}

.card:not(.team-card):hover h3 {
    color: var(--accent-color);
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--border-color);
    transition: transform 0.5s var(--ease);
}

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

.card-content {
    padding: 1.5rem;
}

.card h3 {
    font-size: 1.7rem;
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    font-family: var(--font-heading);
}

.status-completed {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid #2ecc71;
}

.status-in-progress {
    background: rgba(241, 196, 15, 0.15);
    color: #f1c40f;
    border: 1px solid #f1c40f;
}

.status-prototyping {
    background: rgba(149, 165, 166, 0.15);
    color: #95a5a6;
    border: 1px solid #95a5a6;
}

/* Pallino "live" pulsante sui progetti in corso.
   Pulsazione su opacity/transform: animare il box-shadow con currentColor
   nelle keyframes non funziona in modo affidabile su tutti i browser. */
.status-in-progress::before,
.status-prototyping::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 0.45rem;
    vertical-align: 1px;
    animation: statusPulse 1.4s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.7); }
}

.status-cancelled {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.status-paused {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid #f39c12;
}

.category-badge {
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    font-family: var(--font-heading);
    background: rgba(52, 152, 219, 0.15);
    color: #3498db;
    border: 1px solid #3498db;
}


/* Team Specific */
.team-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.team-card {
    text-align: center;
    padding: 2rem;
}

.team-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    object-fit: cover;
}

/* Team Interactive Cards */
.team-grid {
    position: relative;
}

.team-card {
    cursor: pointer;
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    position: relative;
}

.team-card:hover:not(.active) {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-color));
}

.team-img {
    border: 3px solid var(--border-color);
    transition: border-color 0.3s var(--ease), transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.team-card:hover:not(.active) .team-img {
    border-color: var(--accent-color);
    transform: scale(1.06) rotate(-2deg);
    box-shadow: 0 8px 24px var(--accent-glow);
}

/* Nasconde le altre card quando una è attiva */
.team-grid.has-expanded .team-card:not(.active) {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

/* Layout Main Info (Comune) */
.card-main-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 1.5rem;
}

.team-img-container {
    flex-shrink: 0;
}

.team-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

.team-text-info {
    text-align: center;
}

.team-text-info h3 {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
}

.team-role {
    font-size: 1rem;
    opacity: 0.8;
}

/* Stato Attivo (Modal) - Layout Adattivo + Scroll Funzionante */
.team-card.active {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    /* Rimosso scale(1.4) per evitare problemi di scroll */
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 2000;
    cursor: default;
    padding: 3.5rem 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

/* Ingrandimento mirato degli elementi invece dello scale globale */
.active .team-img {
    width: 180px;
    height: 180px;
    margin-bottom: 0.5rem;
}

.active .team-text-info h3 {
    font-size: 2.8rem;
    color: var(--accent-color);
}

.active .team-role {
    font-size: 1.3rem;
    font-weight: 600;
}

.card-extra-content {
    display: none;
    width: 100%;
    opacity: 0;
}

.active .card-extra-content {
    display: block;
    animation: fadeInContent 0.5s ease forwards 0.2s;
}

@keyframes fadeInContent {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.expanded-bio {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.03);
    border-left: 4px solid var(--accent-color);
    border-radius: 4px;
    text-align: left;
}

[data-theme="dark"] .expanded-bio {
    background: rgba(255, 255, 255, 0.03);
}

.expanded-social {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    padding-bottom: 1rem;
    flex-wrap: wrap;
}

.expanded-social a {
    width: 110px;
    /* Più largo per ospitare il testo */
    height: 100px;
    display: flex;
    flex-direction: column;
    /* Disposizione verticale: icona sopra, testo sotto */
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    border-radius: 12px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expanded-social a i {
    font-size: 2.2rem;
    /* Icona prominente */
    transition: transform 0.3s ease;
}

.expanded-social a span {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Brand Colors & Glow Effects (Stile social.html potenziato) */
.expanded-social a:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.expanded-social .instagram:hover {
    border-color: #E1306C;
    color: #E1306C;
}

.expanded-social .linkedin:hover {
    border-color: #0077B5;
    color: #0077B5;
}

.expanded-social .artstation:hover {
    border-color: #13BBFF;
    color: #13BBFF;
}

.expanded-social .youtube:hover {
    border-color: #FF0000;
    color: #FF0000;
}

.expanded-social .facebook:hover {
    border-color: #1877F2;
    color: #1877F2;
}

.expanded-social .threads:hover {
    border-color: #000000;
    color: #000000;
}

.expanded-social .website:hover {
    border-color: #2d5af0;
    color: #2d5af0;
}

.expanded-social a:hover i {
    transform: scale(1.1);
}

/* Overlay */
.team-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease;
}

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

/* Tasto Chiudi - Design Minimale e Sticky */
.close-card {
    position: sticky;
    top: 1rem;
    align-self: flex-end;
    background: none;
    border: none;
    font-size: 2.5rem;
    line-height: 1;
    color: var(--text-color);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    z-index: 100;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.active .close-card {
    opacity: 0.5;
    visibility: visible;
}

.close-card:hover {
    opacity: 1;
    color: var(--accent-color);
    transform: rotate(90deg);

}


.expanded .close-card {
    opacity: 0.6;
    visibility: visible;
}

.close-card:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 5%;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--bg-color);
    position: relative;
}

/* Filo luminoso d'accento al centro del bordo superiore */
footer::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: min(420px, 60%);
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-social a {
    color: var(--text-color);
    font-size: 1.3rem;
    transition: all 0.3s ease;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.footer-social a:hover {
    transform: translateY(-4px);
    border-color: currentColor;
    box-shadow: var(--shadow-md);
}

/* Brand Colors for Footer */
.footer-social .instagram:hover {
    color: #E1306C;
}

.footer-social .x:hover {
    color: #1DA1F2;
}

.footer-social .facebook:hover {
    color: #1877F2;
}

.footer-social .youtube:hover {
    color: #FF0000;
}

.footer-social .tiktok:hover {
    color: #00f2fe;
}

.footer-social .threads:hover {
    color: #000000;
}

/* In dark mode il nero di Threads sarebbe invisibile */
[data-theme="dark"] .footer-social .threads:hover,
[data-theme="dark"] .expanded-social .threads:hover {
    color: #ffffff;
    border-color: #ffffff;
}

[data-theme="dark"] .social-card.threads:hover {
    border-color: #ffffff;
}

.footer-social .email:hover {
    color: var(--accent-color);
}

footer p {
    font-size: 0.9rem;
    opacity: 0.6;
}

/* Timeline Layout */
.timeline {
    position: relative;
    max-width: 900px;
    margin: 5rem auto;
    padding: 0;
}

/* Linea tratteggiata totale (sfondo) */
.timeline::before {
    content: '';
    position: absolute;
    width: 0;
    border-left: 4px dashed var(--accent-color);
    top: -60px;
    bottom: -60px;
    left: 50%;
    margin-left: -2px;
    opacity: 0.4;
    z-index: 1;
}

/* Linea solida centrale FISSA (non anima con AOS) */
.timeline::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: var(--accent-color);
    top: var(--solid-line-top, 34px);
    bottom: var(--solid-line-bottom, 34px);
    left: 50%;
    margin-left: -2px;
    z-index: 2;
    border-radius: 2px;
}

.timeline-item {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 50%;
    box-sizing: border-box;
    z-index: 3;
}

.timeline-item.left {
    left: 0;
}

.timeline-item.right {
    left: 50%;
}



/* Pallini centrati sulla linea */
.timeline-item::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: var(--bg-color);
    border: 4px solid var(--accent-color);
    top: 20px;
    border-radius: 50%;
    z-index: 20; /* Sopra le card (z-index 10) */
    transition: all 0.3s ease;
    pointer-events: none;
    transform: translateZ(0); /* Forza il layer hardware per evitare glitch di fine animazione */
}

.timeline-item.left::after {
    right: -14px;
    /* Centra 20px+bordo su linea 4px */
}

.timeline-item.right::after {
    left: -14px;
}

.timeline-content {
    padding: 1.6rem;
    background-color: var(--card-bg);
    position: relative;
    z-index: 10;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.timeline-content:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--accent-color) 35%, var(--border-color));
}

/* Il pallino si accende quando si passa sopra la voce della timeline */
.timeline-item:hover::after {
    background-color: var(--accent-color);
    box-shadow: 0 0 0 8px var(--accent-glow);
}

.timeline-date {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

/* Social Cards */
.social-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .social-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .social-grid {
        grid-template-columns: 1fr;
    }
}

.social-card {
    text-decoration: none;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 1rem;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    border: 2px solid var(--border-color);
}

.social-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
    color: var(--text-color);
}

.social-card i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    transition: transform 0.3s ease;
}

.social-card:hover i {
    transform: scale(1.1);
}

.social-card p {
    color: var(--text-color);
    opacity: 0.8;
}

.social-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* Brand Colors on Hover */
.social-card.instagram:hover {
    border-color: #E1306C;
}

.social-card.x:hover {
    border-color: #1DA1F2;
}

.social-card.facebook:hover {
    border-color: #1877F2;
}

.social-card.youtube:hover {
    border-color: #FF0000;
}

.social-card.tiktok:hover {
    border-color: #00f2fe;
}

.social-card.linkedin:hover {
    border-color: #0077B5;
}

.social-card.threads:hover {
    border-color: #000000;
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Animazione Hamburger aperto */
.hamburger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

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

.hamburger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Responsive */
@media (max-width: 992px) {
    header {
        padding: 1rem 5%;
    }

    .hamburger {
        display: flex;
    }

    nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        height: 100dvh; /* su mobile 100vh ignora la barra del browser */
        background: var(--bg-color);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
        transition: right 0.5s cubic-bezier(0.77, 0, 0.175, 1);
        padding-top: 100px;
        padding-bottom: 2.5rem;
        z-index: 1000;
        backdrop-filter: blur(15px);
        visibility: hidden;
        /* Schermi bassi (es. telefono in landscape): le voci scorrono
           invece di finire tagliate fuori dal pannello */
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
    }

    nav.active {
        right: 0;
        visibility: visible;
    }

    /* Overlay dietro al pannello: oscura il resto della pagina
       (stesso linguaggio dell'overlay delle team card) */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.4s var(--ease), visibility 0.4s var(--ease);
    }

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

    nav ul {
        flex-direction: column;
        gap: 1.5rem;
        align-items: center;
    }

    /* Animazione bottoni che "entrano" nel menu */
    nav ul li {
        opacity: 0;
        transform: translateX(50px);
        transition: all 0.4s ease;
    }

    nav.active ul li {
        opacity: 1;
        transform: translateX(0);
    }

    /* Delay sequenziale per i bottoni */
    nav.active ul li:nth-child(1) {
        transition-delay: 0.1s;
    }

    nav.active ul li:nth-child(2) {
        transition-delay: 0.2s;
    }

    nav.active ul li:nth-child(3) {
        transition-delay: 0.3s;
    }

    nav.active ul li:nth-child(4) {
        transition-delay: 0.4s;
    }

    nav.active ul li:nth-child(5) {
        transition-delay: 0.5s;
    }

    nav.active ul li:nth-child(6) {
        transition-delay: 0.6s;
    }

    nav a {
        font-size: 1.8rem;
        display: block;
        width: 100%;
        text-align: center;
        padding: 1rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    #site-logo {
        height: 35px;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 3rem;
    }

    .timeline::before {
        left: 22px;
    }

    .timeline-item.left::before,
    .timeline-item.right::before {
        left: 22px;
        right: auto;
        margin-left: -2px;
    }

    .timeline-item {
        width: 100%;
        padding-left: 50px;
        padding-right: 0;
    }

    .timeline-item.right {
        left: 0;
    }

    .timeline-item.left::after,
    .timeline-item.right::after {
        left: 8px;
    }
}

/* Refined status / category badges */
.status-badge,
.category-badge {
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(2px);
}

/* ===========================================================
   Animazioni aggiuntive
   =========================================================== */

/* Barra di avanzamento dello scroll (in alto) */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    transform: scaleX(0);
    transform-origin: 0 50%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-hover));
    z-index: 9998;
    will-change: transform;
    pointer-events: none;
}

/* Bottone "torna su" */
.back-to-top {
    position: fixed;
    bottom: 1.6rem;
    right: 1.6rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px var(--accent-glow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease),
        visibility 0.3s var(--ease), background-color 0.2s var(--ease);
    /* Sotto header/nav (1000) e overlay del menu (999): il menu mobile
       aperto deve coprire anche questo bottone */
    z-index: 990;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-4px) scale(1.06);
}

/* Hero: il bagliore "respira" */
@keyframes heroGlowPulse {
    0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.85; transform: translateX(-50%) scale(1.08); }
}

.hero::before {
    animation: heroGlowPulse 7s ease-in-out infinite;
}

/* Bottoni: riflesso che scorre all'hover */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s var(--ease);
    pointer-events: none;
}

.btn:hover::after {
    left: 130%;
}

/* Card: leggero bagliore accento all'hover */
.card:hover {
    box-shadow: var(--shadow-lg), 0 12px 32px var(--accent-glow);
}

/* Logo: micro-interazione all'hover */
#site-logo {
    transition: transform 0.35s var(--ease);
}

.logo:hover #site-logo {
    transform: rotate(-8deg) scale(1.08);
}

/* Header: entrata allo scroll/caricamento */
@keyframes headerSlideDown {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}

header {
    animation: headerSlideDown 0.5s var(--ease);
}

/* Hero: entrata a cascata degli elementi (badge → titolo → testo → bottoni) */
@keyframes heroRise {
    from { opacity: 0; transform: translateY(26px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero > * {
    animation: heroRise 0.7s var(--ease) both;
}

.hero > *:nth-child(1) { animation-delay: 0.05s; }
.hero > *:nth-child(2) { animation-delay: 0.18s; }
.hero > *:nth-child(3) { animation-delay: 0.32s; }
.hero > *:nth-child(4) { animation-delay: 0.46s; }

/* La stellina del badge brilla a intermittenza */
.hero-eyebrow i {
    display: inline-block;
    animation: twinkle 2.6s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.25) rotate(18deg); opacity: 0.65; }
}

/* Card: riflesso che attraversa la card all'hover (come i bottoni) */
.card:not(.team-card)::after {
    content: '';
    position: absolute;
    top: 0;
    left: -80%;
    width: 50%;
    height: 100%;
    background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.16), transparent);
    transform: skewX(-18deg);
    transition: left 0.7s var(--ease);
    pointer-events: none;
    z-index: 3;
}

.card:not(.team-card):hover::after {
    left: 140%;
}

/* Back to top: la freccia "saltella" all'hover */
.back-to-top svg {
    transition: transform 0.3s var(--ease);
}

.back-to-top:hover svg {
    animation: arrowBob 0.6s ease-in-out infinite alternate;
}

@keyframes arrowBob {
    from { transform: translateY(1.5px); }
    to { transform: translateY(-2.5px); }
}

/* Theme toggle: giravolta al cambio tema (classe aggiunta da JS) */
.theme-toggle--spin {
    animation: toggleSpin 0.5s var(--ease);
}

@keyframes toggleSpin {
    from { transform: rotate(0deg) scale(0.5); }
    to { transform: rotate(360deg) scale(1); }
}

/* Navigazione SPA: la vecchia pagina sfuma verso l'alto, la nuova sale da sotto.
   La classe .page-transition viene aggiunta dal JS solo durante il cambio pagina,
   così l'espansione delle team card (che usa anch'essa le View Transitions)
   non muove l'intera pagina. */
@media (prefers-reduced-motion: no-preference) {
    html.page-transition::view-transition-old(root) {
        animation: pageOut 0.22s var(--ease) both;
    }

    html.page-transition::view-transition-new(root) {
        animation: pageIn 0.32s var(--ease) both;
    }
}

@keyframes pageOut {
    to { opacity: 0; transform: translateY(-14px); }
}

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

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .card:hover,
    .team-card:hover:not(.active),
    .timeline-content:hover,
    .btn:hover {
        transform: none;
    }
}

/* Project Media Gallery */
.project-gallery {
    margin-top: 4rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border-color);
}

.project-gallery h2 {
    margin-bottom: 2rem;
    font-size: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    background-color: var(--card-bg);
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}

.gallery-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease);
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

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

/* Lightbox Modal */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    /* Larghezza fissa: tutte le foto vengono portate alla stessa dimensione,
       ingrandendo quelle a bassa risoluzione. object-fit preserva le proporzioni. */
    width: min(92vw, 1000px);
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s var(--ease);
}

.lightbox.active .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 3rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.3s var(--ease), color 0.3s var(--ease);
    opacity: 0.7;
}

.lightbox-close:hover {
    opacity: 1;
    color: var(--accent-color);
    transform: rotate(90deg);
}

/* Lightbox navigation arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.9rem;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.8;
    z-index: 2;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
        opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-nav:hover {
    opacity: 1;
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-counter {
    position: absolute;
    bottom: 1.6rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.45);
    padding: 0.4rem 1.1rem;
    border-radius: 50px;
    z-index: 2;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Responsive adjust */
@media (max-width: 576px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .gallery-item img {
        height: 110px;
    }

    .lightbox-close {
        top: 1rem;
        right: 1rem;
        font-size: 2.5rem;
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .lightbox-prev {
        left: 0.6rem;
    }

    .lightbox-next {
        right: 0.6rem;
    }

    .lightbox-counter {
        bottom: 1rem;
    }
}