:root {
    color-scheme: dark;
    --bg: #09090b;
    --bg-elev: #18181b;
    --bg-elev-2: #27272a;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --line: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-ink: #ffffff;
    --accent: #8b5cf6;
    --max: 1080px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --header-offset: 106px;

    /* Glass morphism tokens */
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-offset);
}

body {
    margin: 0;
    font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    width: 360px;
    height: 360px;
    border-radius: 999px;
    filter: blur(70px);
    opacity: 0.18;
    pointer-events: none;
    z-index: -1;
}

body::before {
    background: var(--primary);
    top: -120px;
    left: -120px;
}

body::after {
    background: var(--accent);
    bottom: -140px;
    right: -120px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: none;
}

.container {
    width: min(92%, var(--max));
    margin: 0 auto;
}

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

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 1000;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
}

.page-loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 0.9rem;
    background: var(--bg);
    z-index: 2000;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.page-loader p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    letter-spacing: 0.03em;
}

.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 4px solid var(--bg-elev-2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(9, 9, 11, 0.8);
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 74px;
}

.brand {
    margin: 0;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 1.04rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 0.8rem;
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav a:hover,
.nav a:focus-visible,
.nav a.is-active {
    color: var(--primary);
    background: var(--surface);
}

main {
    width: min(92%, var(--max));
    margin: 2rem auto 4rem;
}

main section[id] {
    scroll-margin-top: var(--header-offset);
}

.hero,
.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

/* =========================
   HERO (AGGIORNATA)
   - rende compatibile la nuova hero tailwind (glow + overlay)
   - NON rompe le vecchie classi (.hero-layout ecc.)
========================= */
.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(1.5rem, 3vw, 2.4rem);

    /* Prima era un gradient fisso: ora lasciamo che sia il markup (tailwind) a gestire sfondi/glow */
    background: transparent;
}

#home.hero {
    padding: clamp(0.9rem, 1.8vw, 1.4rem);
}

/* Mantengo per compatibilità (se hai ancora pagine vecchie che lo usano) */
.hero-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
    align-items: center;
    gap: 1.2rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.76rem;
}

h1,
h2,
h3 {
    font-family: "DM Sans", system-ui, sans-serif;
}

h1 {
    margin: 0;
    line-height: 1.07;
    font-size: clamp(1.9rem, 3.2vw, 2.7rem);
}

.intro {
    max-width: 66ch;
    color: var(--muted);
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.2rem;
    flex-wrap: wrap;
}

.button {
    display: inline-block;
    border-radius: 10px;
    border: 1px solid transparent;
    padding: 0.62rem 0.96rem;
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover,
.button:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgb(0 0 0 / 28%);
}

.button.primary {
    background: var(--primary);
    color: var(--primary-ink);
}

.button.secondary {
    background: var(--bg-elev-2);
    border-color: var(--line);
    color: var(--text);
}

.button.secondary:hover,
.button.secondary:focus-visible {
    background: #3f3f46;
}

.button.tertiary {
    background: transparent;
    border-color: var(--border-hover);
    color: var(--accent);
}

.button.tertiary:hover,
.button.tertiary:focus-visible {
    background: var(--surface);
}

.button.danger {
    background: #5a2027;
    border-color: #7f2c37;
    color: #ffdce3;
}

.panel {
    margin-top: 1.25rem;
    padding: 1.2rem 1.25rem;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.panel:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.panel h2 {
    margin-top: 0;
    margin-bottom: 0.7rem;
}

.timeline {
    margin: 0;
    padding-left: 1rem;
}

.timeline h3 {
    margin-bottom: 0.35rem;
}

.timeline p {
    margin-top: 0;
    color: var(--muted);
}

.timeline-content {
    color: var(--muted);
}

.timeline-content p,
.timeline-content ul,
.timeline-content ol {
    margin-top: 0;
    margin-bottom: 0.6rem;
}

.timeline-content :last-child {
    margin-bottom: 0;
}

.profile-content p,
.profile-content ul,
.profile-content ol,
.profile-content blockquote {
    margin-top: 0;
    margin-bottom: 0.8rem;
}

.profile-content :last-child {
    margin-bottom: 0;
}

.profile-content a {
    color: var(--accent);
}

.profile-content code {
    background: var(--bg-elev);
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    padding: 0.05rem 0.35rem;
}

.profile-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 0.75rem;
    color: var(--muted);
}

.chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.62rem;
}

.chips li {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.38rem 0.78rem;
    font-weight: 600;
}

.contact-intro {
    color: var(--muted);
    margin-bottom: 0.7rem;
}

.contact-form {
    margin-top: 0.8rem;
}

/* =========================
   PROFILE CARD (AGGIORNATA)
   - non rompe la nuova card tailwind (contenitori interni)
   - evita overlay ::before che ora sarebbe “sbagliato”
========================= */
.profile-card {
    margin: 0;
    justify-self: center;
    width: min(100%, 320px);

    /* Prima: border/box-shadow/overflow/overlay.
       Ora: lasciamo che sia la struttura interna (tailwind) a gestire ring e shadow. */
    border: 0;
    box-shadow: none;
    overflow: visible;
    background: transparent;
    position: relative;
}

/* Disattiva l’overlay vecchio (con la nuova struttura non serve) */
.profile-card::before {
    content: none;
}

/* Mantengo compatibilità se in altre pagine usi ancora img diretto sotto .profile-card */
.profile-card > img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* =========================
   EXPORT / ADMIN (invariato)
========================= */
.export-shell {
    width: min(94%, var(--max));
    margin: 2rem auto 4rem;
}

.export-hero-panel {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.export-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.export-metrics {
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.export-metrics li {
    border: 1px solid var(--border-hover);
    background: var(--surface);
    border-radius: 12px;
    padding: 0.7rem 0.8rem;
}

.export-metrics span {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.export-metrics strong {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.05rem;
    color: var(--text);
}

.export-preview-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.export-preview-top h2 {
    margin: 0;
}

.export-preview-frame {
    width: 100%;
    height: min(72vh, 760px);
    margin-top: 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--border-hover);
    background: var(--bg);
}

.export-summary-panel p {
    margin: 0;
    color: var(--muted);
}

.button[data-copy-target].is-copied {
    border-color: var(--primary);
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
}

.admin-shell {
    width: min(94%, var(--max));
    margin: 2rem auto 4rem;
}

.admin-panel {
    margin-top: 1rem;
}

.admin-auth {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.admin-links a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    text-decoration: none;
    color: var(--accent);
    background: var(--surface);
}

.alert {
    margin: 1rem 0 0;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    font-size: 0.95rem;
}

.alert.success {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}

.alert.error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #fca5a5;
}

.form-grid {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.form-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.form-grid .wide {
    grid-column: 1 / -1;
}

.form-grid label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.form-grid label small {
    color: #7f96b8;
    font-size: 0.78rem;
    line-height: 1.4;
}

.form-grid input,
.form-grid textarea,
.inline-form input,
.inline-form textarea,
.inline-form select {
    width: 100%;
    border: 1px solid var(--border-hover);
    border-radius: 9px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    padding: 0.5rem 0.6rem;
}

.form-grid input:focus,
.form-grid textarea:focus,
.inline-form input:focus,
.inline-form textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.checkbox-label {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.2rem;
}

.checkbox-label input {
    width: auto;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 0.45rem;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.inline-form {
    display: grid;
    gap: 0.35rem;
}

.actions-cell {
    display: grid;
    gap: 0.45rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.4rem 0;
    color: var(--muted);
    background: rgba(9, 9, 11, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.footer-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-layout p {
    margin: 0;
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.footer-cv-export {
    white-space: nowrap;
}

.social-share {
    display: flex;
    gap: 0.5rem;
}

.social-link {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.social-link:hover,
.social-link:focus-visible {
    transform: translateY(-3px) scale(1.03);
    border-color: var(--border-hover);
    box-shadow: 0 12px 24px rgb(0 0 0 / 25%);
    color: #fff;
}

.social-link:nth-child(1):hover,
.social-link:nth-child(1):focus-visible {
    border-color: #3b82f6;
    color: #93c5fd;
}

.social-link:nth-child(2):hover,
.social-link:nth-child(2):focus-visible {
    border-color: #d4d4d8;
    color: #f4f4f5;
}

.social-link:nth-child(3):hover,
.social-link:nth-child(3):focus-visible {
    border-color: #38bdf8;
    color: #7dd3fc;
}

.social-link:nth-child(4):hover,
.social-link:nth-child(4):focus-visible {
    border-color: #34d399;
    color: #6ee7b7;
}

.social-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.js-enabled main section[id] {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.js-enabled main section[id].is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 760px) {
    :root {
        --header-offset: 136px;
    }

    .site-header .container {
        flex-direction: column;
        justify-content: center;
        padding: 0.75rem 0;
    }

    .nav {
        justify-content: center;
    }

    main {
        margin-top: 1.6rem;
    }

    .hero-layout {
        grid-template-columns: 1fr;
    }

    .footer-layout,
    .footer-actions {
        justify-content: center;
    }

    .export-preview-frame {
        height: 62vh;
    }
}
