:root {
    --md-sys-color-primary: #5f8b2c;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-surface: #fffdf4;
    --md-sys-color-surface-container: #f7f1d7;
    --md-sys-color-surface-container-high: #f0e8c1;
    --md-sys-color-surface-container-highest: #e8deb0;
    --md-sys-color-secondary-container: #e8efb8;
    --md-sys-color-tertiary-container: #f5e08e;
    --md-sys-color-outline-variant: #d4c88f;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-on-surface-variant: #66614a;
    --shape-xl: 28px;
    --shape-l: 22px;
    --shape-m: 18px;
    --top-app-bar-height: 80px;
    --drawer-width: 300px;
    --drawer-width-collapsed: 92px;
    --pane-gap: 20px;
    --page-padding: 20px;
    --active-size: 50px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html,
body {
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Google Sans Flex", "Inter", sans-serif;
    color: var(--md-sys-color-on-surface);
    background:
        radial-gradient(circle at top left, rgba(95, 139, 44, 0.14), transparent 22%),
        linear-gradient(180deg, #fffef9 0%, var(--md-sys-color-surface) 100%);
}

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

/* Le sezioni ancorate non finiscono nascoste sotto la top bar fissa. */
section[id] {
    scroll-margin-top: calc(var(--top-app-bar-height) + 16px);
}

button {
    font: inherit;
}

.top-app-bar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 30;
    height: var(--top-app-bar-height);
    display: flex;
    align-items: center;
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid rgba(102, 97, 74, 0.08);
}

.top-app-bar__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    height: var(--top-app-bar-height);
    box-sizing: border-box;
    padding: 0 var(--page-padding);
}

.top-app-bar__start,
.top-app-bar__end {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 12px;
    min-height: 44px;
}

.top-app-bar__menu-button,
.top-app-bar__home-button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-primary);
    border: 0;
}

.top-app-bar__menu-button {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

/* Doppio glyph sovrapposto: hamburger ☰ e chiusura ✕.
   Animati in crossfade+rotazione quando lo stato cambia. */
.top-app-bar__menu-button .material-symbols-outlined.top-app-bar__icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 22px;
    line-height: 1;
    transition: transform 240ms cubic-bezier(0.2, 0, 0, 1), opacity 200ms ease;
}

.top-app-bar__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.3);
}

.top-app-bar__menu-button[aria-expanded="true"] .top-app-bar__icon--menu {
    opacity: 0;
    transform: rotate(90deg) scale(0.3);
}

.top-app-bar__menu-button[aria-expanded="true"] .top-app-bar__icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.top-app-bar__home-button {
    font-weight: 700;
}

.top-app-bar__title {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0;
    font-family: "Google Sans Flex", "Inter", sans-serif;
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--md-sys-color-primary);
}

.top-app-bar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-primary);
    font-weight: 700;
    line-height: 1;
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.top-app-bar__action .material-symbols-outlined,
.top-app-bar__menu-button .material-symbols-outlined {
    display: block;
    font-size: 22px;
    line-height: 1;
}

.top-app-bar__action span:last-child {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 20px;
    top: 16px;
    z-index: 40;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.layout-shell {
    padding-top: var(--top-app-bar-height);
}

.layout-shell__body {
    display: flex;
    min-height: calc(100vh - var(--top-app-bar-height));
}

.layout-shell__sidebar-slot {
    position: relative;
    flex: 0 0 var(--drawer-width);
    min-width: var(--drawer-width);
    transition: min-width 260ms cubic-bezier(0.2, 0, 0, 1), flex-basis 260ms cubic-bezier(0.2, 0, 0, 1);
}

.layout-shell__scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(29, 27, 32, 0.34);
    z-index: 20;
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 200ms ease;
}

body.drawer-open-mobile .layout-shell__scrim {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.nav-drawer {
    position: sticky;
    top: calc(var(--top-app-bar-height) + var(--page-padding));
    width: var(--drawer-width);
    margin: var(--page-padding) 0 0 var(--page-padding);
    border-radius: var(--shape-xl);
    background: var(--md-sys-color-surface-container);
    border: 1px solid rgba(102, 97, 74, 0.08);
    overflow: hidden;
    transition: width 260ms cubic-bezier(0.2, 0, 0, 1), transform 260ms cubic-bezier(0.2, 0, 0, 1);
}

.nav-drawer__scroll {
    min-height: calc(100vh - var(--top-app-bar-height) - (var(--page-padding) * 2));
    padding: 24px 18px;
}

.nav-drawer__toggle {
    position: relative;
    overflow: hidden;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    margin: 0 0 22px;
    border: 0;
    border-radius: 16px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-primary);
    cursor: pointer;
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

/* Doppio glyph sovrapposto anche nel toggle del drawer: stesso
   crossfade+rotazione dell'hamburger nell'header. */
.nav-drawer__toggle .material-symbols-outlined.nav-drawer__icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 24px;
    line-height: 1;
    transition: transform 240ms cubic-bezier(0.2, 0, 0, 1), opacity 200ms ease;
}

.nav-drawer__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.3);
}

.nav-drawer__toggle[aria-expanded="true"] .nav-drawer__icon--menu {
    opacity: 0;
    transform: rotate(90deg) scale(0.3);
}

.nav-drawer__toggle[aria-expanded="true"] .nav-drawer__icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.nav-drawer__close {
    display: none;
    width: 44px;
    height: 44px;
    place-items: center;
    margin: 0 0 18px;
    border: 0;
    border-radius: 16px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-primary);
    cursor: pointer;
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.nav-drawer__close:hover,
.nav-drawer__close:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(95, 139, 44, 0.12);
}

.nav-drawer__close .material-symbols-outlined {
    display: block;
    font-size: 24px;
    line-height: 1;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-group__label {
    margin: 0 0 10px;
    padding: 0 12px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: opacity 180ms ease;
}

.nav-divider {
    height: 1px;
    margin: 22px 10px;
    background: var(--md-sys-color-outline-variant);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 0 14px;
    border-radius: var(--shape-m);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1rem;
    font-weight: 500;
    transition: transform 180ms ease, color 180ms ease;
}

.nav-item .material-symbols-outlined {
    position: relative;
    z-index: 1;
    flex: 0 0 24px;
    width: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: "Material Symbols Outlined";
    font-size: 24px;
    line-height: 1;
    font-weight: normal;
    font-style: normal;
    font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
    transition: color 180ms ease, transform 180ms ease;
}

.nav-item__label {
    position: relative;
    z-index: 1;
    white-space: nowrap;
    transition: opacity 180ms ease;
}

.nav-item__active-shape {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
    border-radius: inherit;
    opacity: 0;
    background: rgba(95, 139, 44, 0.14);
    transform: scale(0.92);
    transform-origin: left center;
    transition: opacity 180ms ease, width 260ms cubic-bezier(0.2, 0, 0, 1), transform 220ms cubic-bezier(0.2, 0, 0, 1);
}

.nav-item--active {
    color: var(--md-sys-color-primary);
    font-weight: 700;
}

.nav-item.nav-item--active > .material-symbols-outlined {
    font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.nav-item--active .nav-item__active-shape {
    opacity: 1;
    transform: scale(1);
}

.nav-item:hover,
.nav-item:focus-visible,
.top-app-bar__menu-button:hover,
.top-app-bar__menu-button:focus-visible,
.top-app-bar__action:hover,
.top-app-bar__action:focus-visible,
.nav-drawer__toggle:hover,
.nav-drawer__toggle:focus-visible {
    transform: translateY(-1px);
}

.top-app-bar__menu-button:hover,
.top-app-bar__menu-button:focus-visible,
.top-app-bar__action:hover,
.top-app-bar__action:focus-visible,
.nav-drawer__toggle:hover,
.nav-drawer__toggle:focus-visible {
    box-shadow: 0 10px 22px rgba(95, 139, 44, 0.12);
}

.top-app-bar__title,
.top-app-bar__home-button,
.top-app-bar__action,
.nav-drawer,
.content-pane {
    animation: shell-fade-up 420ms cubic-bezier(0.2, 0, 0, 1) both;
}

.nav-item {
    animation: nav-item-enter 320ms cubic-bezier(0.2, 0, 0, 1) both;
}

.nav-item:nth-of-type(1) { animation-delay: 40ms; }
.nav-item:nth-of-type(2) { animation-delay: 80ms; }
.nav-item:nth-of-type(3) { animation-delay: 120ms; }

.layout-shell__panes {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--page-padding);
}

.content-pane {
    height: calc(100vh - var(--top-app-bar-height) - (var(--page-padding) * 2));
    background: var(--md-sys-color-surface);
    border: 1px solid rgba(102, 97, 74, 0.08);
    border-radius: var(--shape-xl);
    overflow: auto;
}

.content-pane__scroll {
    min-height: 100%;
    padding: 24px;
}

.content-pane__content {
    width: 100%;
    max-width: 1760px;
    margin: 0 auto;
}

.hero-section {
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
    gap: 18px;
}

.surface-card {
    border-radius: var(--shape-xl);
    overflow: hidden;
    border: 1px solid rgba(102, 97, 74, 0.06);
}

.surface-card--soft {
    background: var(--md-sys-color-surface-container);
}

.surface-card--accent {
    background: linear-gradient(180deg, #fff1a6 0%, #d4d85e 100%);
}

.hero-card {
    min-height: 520px;
    padding: 64px 52px;
}

.eyebrow {
    margin: 0 0 18px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero-card h1,
.spotlight-section h2,
.info-card h3,
body > header:not(.top-app-bar) h1,
.presentazione h2 {
    margin: 0;
    font-family: "Google Sans Flex", "Inter", sans-serif;
    letter-spacing: -0.06em;
    line-height: 0.95;
}

.hero-card h1 {
    max-width: 8ch;
    font-size: clamp(3.8rem, 7vw, 6rem);
}

.supporting-text {
    max-width: 48rem;
    margin: 24px 0 0;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1.125rem;
    line-height: 1.55;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

.pill-button,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 700;
}

.pill-button--primary,
.btn-link {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.pill-button--secondary {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-primary);
}

.hero-visual {
    position: relative;
    min-height: 520px;
}

.hero-visual__shape {
    position: absolute;
    background: linear-gradient(180deg, #fff8d6 0%, #e7dd62 44%, #b8c74b 100%);
}

.hero-visual__shape--a {
    top: -28px;
    right: 84px;
    width: 280px;
    height: 110px;
    border-radius: 0 0 120px 120px;
}

.hero-visual__shape--b {
    inset: 56px auto auto 120px;
    width: 330px;
    height: 420px;
    border-radius: 200px;
}

.hero-visual__shape--c {
    left: -40px;
    bottom: -16px;
    width: 120px;
    height: 180px;
    border-radius: 96px 96px 0 0;
}

.spotlight-section {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 20px;
    margin-top: 18px;
    padding: 40px;
}

.spotlight-section h2 {
    font-size: clamp(2.6rem, 5vw, 4rem);
}

.spotlight-section__media {
    position: relative;
    min-height: 220px;
    border-radius: var(--shape-l);
    background: var(--md-sys-color-tertiary-container);
    overflow: hidden;
}

.spotlight-section__media span {
    position: absolute;
    display: block;
    background: var(--md-sys-color-primary);
    border-radius: 999px;
}

.spotlight-section__media span:nth-child(1) {
    top: 20px;
    left: 24px;
    width: 120px;
    height: 180px;
}

.spotlight-section__media span:nth-child(2) {
    top: 40px;
    left: 48%;
    width: 96px;
    height: 160px;
}

.spotlight-section__media span:nth-child(3) {
    top: -22px;
    right: -16px;
    width: 160px;
    height: 240px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.info-card {
    min-height: 240px;
    padding: 28px;
    background: var(--md-sys-color-surface-container-high);
}

.info-card h3 {
    margin-bottom: 14px;
    font-size: 2rem;
}

.info-card p {
    margin: 0;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.55;
}

body > header:not(.top-app-bar) {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 40px 48px 0;
}

body > header:not(.top-app-bar) h1 {
    font-size: clamp(2.8rem, 5vw, 4rem);
}

.header-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

body > main {
    padding: 24px 48px 48px;
}

.presentazione {
    max-width: 980px;
    padding: 40px 0 0;
}

.presentazione h2 {
    font-size: clamp(2.4rem, 4vw, 3.2rem);
    margin-bottom: 16px;
}

.presentazione ul {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

body.drawer-collapsed .layout-shell__sidebar-slot {
    flex-basis: var(--drawer-width-collapsed);
    min-width: var(--drawer-width-collapsed);
}

body.drawer-collapsed .nav-drawer {
    width: var(--drawer-width-collapsed);
}

body.drawer-collapsed .nav-drawer__toggle {
    margin-left: 0;
}

body.drawer-collapsed .nav-group__label {
    opacity: 0;
}

/* Le voci mantengono il padding di default (14px): così le icone
   restano ferme nella stessa posizione quando il drawer collassa. */
body.drawer-collapsed .nav-item__label {
    position: absolute;
    left: 100%;
    width: 0;
    overflow: hidden;
    opacity: 0;
}

body.drawer-collapsed .nav-item__active-shape {
    inset: 0 auto 0 0;
    transform: scale(1);
    width: var(--active-size);
}

@media (max-width: 1200px) {
    .top-app-bar__menu-button {
        display: grid;
    }

    .nav-drawer__toggle {
        display: none;
    }

    .nav-drawer__close {
        display: grid;
    }

    .layout-shell__sidebar-slot {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 21;
        flex: none;
        min-width: 0;
        width: 0;
    }

    .nav-drawer {
        position: fixed;
        top: calc(var(--top-app-bar-height) + 8px);
        left: calc(16px + env(safe-area-inset-left, 0px));
        width: min(300px, calc(100vw - 96px));
        max-height: calc(100vh - var(--top-app-bar-height) - 16px);
        max-height: calc(100dvh - var(--top-app-bar-height) - 16px);
        margin: 0;
        transform: translateX(calc(-100% - 24px));
        box-shadow: 0 18px 44px rgba(29, 27, 32, 0.18);
    }

    .nav-drawer__scroll {
        min-height: 0;
        height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .layout-shell__panes {
        width: 100%;
    }

    .content-pane {
        height: auto;
        min-height: calc(100vh - var(--top-app-bar-height) - (var(--page-padding) * 2));
    }

    .hero-section,
    .spotlight-section,
    .card-grid {
        grid-template-columns: 1fr;
    }

    body.drawer-collapsed .layout-shell__sidebar-slot {
        min-width: 0;
        width: 0;
    }

    body.drawer-collapsed .nav-drawer {
        width: min(320px, calc(100vw - 32px));
    }

    body.drawer-collapsed .nav-group__label,
    body.drawer-collapsed .nav-item__label {
        position: static;
        width: auto;
        overflow: visible;
        opacity: 1;
    }

    body.drawer-collapsed .nav-item__active-shape {
        inset: 0;
        width: auto;
    }

    body.drawer-open-mobile .nav-drawer {
        transform: translateX(0);
    }

    body.drawer-open-mobile {
        overflow: hidden;
    }
}

@media (min-width: 1201px) {
    .top-app-bar__menu-button {
        display: none;
    }
}

@media (max-width: 720px) {
    :root {
        --top-app-bar-height: 74px;
        --page-padding: 14px;
    }

    .top-app-bar__title {
        font-size: 1.1rem;
    }

    .top-app-bar__action span:last-child {
        display: none;
    }

    .top-app-bar__content,
    .top-app-bar__start,
    .top-app-bar__end {
        gap: 8px;
    }

    .content-pane__scroll {
        padding: 16px;
    }

    .hero-card,
    .spotlight-section {
        padding: 28px 22px;
    }

    .hero-visual {
        min-height: 340px;
    }

    .info-card {
        min-height: 0;
    }

    body > header:not(.top-app-bar),
    .header-nav {
        flex-direction: column;
        align-items: flex-start;
    }

    body > header:not(.top-app-bar),
    body > main {
        padding-left: 22px;
        padding-right: 22px;
    }

    .presentazione ul {
        flex-direction: column;
        align-items: flex-start;
    }
}

@keyframes shell-fade-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes nav-item-enter {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Accessibilità: riduce le animazioni per chi le preferisce disattivate. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
