/* ==========================================================================
   Massimo Gaetano — pagina unica 3D
   Tema scuro fisso: la scena a particelle (js/site.js) vive dietro i contenuti.
   ========================================================================== */

@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/space-grotesk.woff2") format("woff2");
    font-weight: 300 700;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("../fonts/inter.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --bg: #0a0e1c;
    --bg-2: #111830;
    --ink: #e8ecf6;
    --ink-2: #b0b8cc;
    --ink-3: #7c86a1;
    --line: rgba(160, 180, 255, .17);
    --glass: rgba(22, 30, 56, .55);
    --glass-2: rgba(22, 30, 58, .7);
    --a1: #38bdf8;
    --a2: #818cf8;
    --a3: #c084fc;
    --grad: linear-gradient(120deg, var(--a1), var(--a2) 55%, var(--a3));
    --radius: 22px;
    --gutter: clamp(16px, 4vw, 48px);
    --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --ease: cubic-bezier(.22, 1, .36, 1);
    color-scheme: dark;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    background: radial-gradient(1200px 800px at 70% -10%, #18224a 0%, transparent 60%),
                radial-gradient(900px 700px at -10% 60%, #1d1540 0%, transparent 60%),
                var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    font: 400 1rem/1.65 var(--body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: rgba(129, 140, 248, .45); }
:focus-visible { outline: 2px solid var(--a1); outline-offset: 3px; border-radius: 8px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.08; letter-spacing: -.02em; margin: 0; }
em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--ink-2); }

/* ---------- scena 3D ---------- */
#scene {
    position: fixed; inset: 0;
    width: 100vw; height: 100vh;
    z-index: 0; pointer-events: none;
}
.scene-veil {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(10, 14, 28, .45) 100%);
}
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; }
.progress span { display: block; height: 100%; width: 100%; background: var(--grad); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- barra in alto ---------- */
.topbar {
    position: fixed; top: 14px; left: var(--gutter); right: var(--gutter); z-index: 50;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
    display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
    font: 600 1rem var(--display); letter-spacing: -.01em;
}
.dock {
    display: flex; gap: 2px; padding: 6px;
    background: rgba(10, 14, 30, .6); border: 1px solid var(--line); border-radius: 999px;
    backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.dock a {
    position: relative; padding: 8px 14px; border-radius: 999px;
    color: var(--ink-2); text-decoration: none; font-size: .88rem; font-weight: 500;
    transition: color .25s, background .25s;
}
.dock a:hover, .dock a.active { color: var(--ink); background: rgba(129, 140, 248, .14); }

@media (max-width: 860px) {
    .dock {
        position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); translate: -50% 0;
        max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none;
        background: rgba(10, 14, 30, .82);
    }
    .dock::-webkit-scrollbar { display: none; }
    .dock a { padding: 9px 12px; font-size: .82rem; white-space: nowrap; }
    .footer { padding-bottom: 96px; }
}

/* ---------- impaginazione ---------- */
main, .footer { position: relative; z-index: 2; }
main { overflow-x: clip; }
.section {
    max-width: 1200px; margin: 0 auto;
    padding: clamp(90px, 14vh, 160px) var(--gutter);
    min-height: 90vh;
}
.section-head { max-width: 760px; margin-bottom: clamp(32px, 6vh, 60px); }
.kicker {
    display: inline-block; margin-bottom: 14px;
    font: 500 .78rem/1 var(--display); letter-spacing: .18em; text-transform: uppercase; color: var(--a1);
}
.section-head h2 { font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 600; }
.hint { color: var(--ink-3); font-size: .9rem; margin: 14px 0 0; }

.glass {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 30px 60px -30px rgba(0, 0, 0, .6);
}

/* ---------- pulsanti ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px 24px; border-radius: 999px; border: 1px solid transparent;
    font: 600 .95rem var(--body); text-decoration: none; cursor: pointer;
    transition: transform .3s var(--ease), box-shadow .3s, background .3s, border-color .3s;
    will-change: transform;
}
.btn-primary { background: var(--grad); color: #05070f; box-shadow: 0 10px 40px -10px rgba(129, 140, 248, .7); }
.btn-primary:hover { box-shadow: 0 14px 50px -8px rgba(129, 140, 248, .95); }
.btn-ghost { background: rgba(255, 255, 255, .04); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: rgba(160, 180, 255, .4); background: rgba(255, 255, 255, .08); }
.btn.round { width: 52px; height: 52px; padding: 0; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- hero ---------- */
.hero {
    min-height: 100svh; max-width: 1200px; margin: 0 auto;
    padding: 120px var(--gutter) 90px;
    display: flex; flex-direction: column; justify-content: center; position: relative;
}
.hero-title {
    font-size: clamp(3.2rem, 11vw, 9.5rem); font-weight: 700; line-height: .92; letter-spacing: -.045em;
    display: flex; flex-wrap: wrap; column-gap: .25em;
}
.hero-title .word { display: inline-flex; white-space: nowrap; }
.hero-title .ch {
    display: inline-block;
    background: linear-gradient(180deg, #fff 30%, #b7c3e6);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    transition: transform .5s var(--ease), filter .5s;
    will-change: transform;
}
.hero-title .ch.hot { filter: drop-shadow(0 0 18px rgba(129, 140, 248, .8)); }

.hero-role { font: 500 clamp(1.25rem, 2.6vw, 1.9rem) var(--display); margin: 22px 0 0; min-height: 1.4em; }
.typer { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.typer::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 4px; vertical-align: -.12em; background: var(--a2); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero-lead { max-width: 600px; color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.12rem); margin: 18px 0 34px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.stats { display: flex; flex-wrap: wrap; gap: clamp(20px, 5vw, 64px); margin: 56px 0 0; }
.stats div { display: grid; grid-template-columns: auto 1fr; justify-content: start; align-items: baseline; }
.stats dt { grid-row: 2; grid-column: 1 / 3; color: var(--ink-3); font-size: .82rem; }
.stats dd { margin: 0; font: 600 clamp(2rem, 4vw, 2.8rem)/1 var(--display); }
.stats span { font: 600 1.6rem var(--display); color: var(--a2); }

.scroll-hint {
    position: absolute; bottom: 28px; left: 50%; translate: -50% 0;
    width: 26px; height: 42px; border: 2px solid var(--line); border-radius: 14px;
}
.scroll-hint span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--ink-2); animation: wheel 1.8s var(--ease) infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translateY(-4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

/* ---------- chi sono ---------- */
.about { display: grid; grid-template-columns: 1.35fr 1fr; gap: 24px; align-items: start; }
.about-text { padding: clamp(24px, 4vw, 40px); font-size: 1.04rem; color: #cfd6e8; }
.about-text p { margin: 0 0 1em; }
.about-text details p:last-child { margin-bottom: 0; }
.about-text summary {
    cursor: pointer; color: var(--a1); font-weight: 600; list-style: none; display: inline-flex; gap: 8px; align-items: center;
}
.about-text summary::-webkit-details-marker { display: none; }
.about-text summary::after { content: "+"; font-size: 1.2em; transition: transform .3s; }
.about-text details[open] summary { margin-bottom: 1em; }
.about-text details[open] summary::after { transform: rotate(45deg); }
.pillars { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.pillars li { padding: 22px 24px; position: relative; overflow: hidden; }
.pillars h3 { font-size: 1.2rem; margin: 6px 0 6px; }
.pillars p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.pillar-n { font: 700 .78rem var(--display); color: var(--a1); letter-spacing: .14em; }

/* ---------- tilt 3D condiviso ---------- */
.tilt { transform-style: preserve-3d; transition: transform .5s var(--ease), border-color .3s; will-change: transform; }
.tilt:hover { border-color: rgba(160, 180, 255, .35); }
.js .reveal.in.tilt { transition: transform .5s var(--ease), border-color .3s, opacity .9s var(--ease); }

/* ---------- stack: sfera di tag ---------- */
.stack { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: center; }
.orb-wrap {
    position: relative; aspect-ratio: 1; width: 100%; max-width: 560px; margin: 0 auto;
    perspective: 900px; cursor: grab; touch-action: pan-y; user-select: none;
}
.orb-wrap:active { cursor: grabbing; }
.orb-wrap::before {
    content: ""; position: absolute; inset: 18%; border-radius: 50%;
    background: radial-gradient(circle, rgba(129, 140, 248, .28), transparent 70%); filter: blur(20px);
}
.orb { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; transform-style: preserve-3d; }
.orb li { position: absolute; left: 50%; top: 50%; }
.orb-tag {
    position: absolute; translate: -50% -50%; white-space: nowrap;
    padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: rgba(14, 20, 40, .75); color: var(--ink);
    font: 600 .9rem var(--display); cursor: pointer;
    transition: background .25s, border-color .25s, color .25s;
}
.orb-tag[data-level="5"] { font-size: 1.05rem; }
.orb-tag[data-level="3"] { font-size: .82rem; }
.orb-tag:hover, .orb-tag.active { background: var(--grad); color: #05070f; border-color: transparent; }
.skill-panel { padding: 30px; min-height: 280px; display: flex; flex-direction: column; }
.skill-card h3 { font-size: 2rem; margin: 8px 0 10px; }
.skill-card p { color: var(--ink-2); margin: 0 0 20px; }
.skill-card:not([hidden]) { animation: rise .45s var(--ease); }
.skill-cat { font: 500 .75rem var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--a1); }
.meter { display: flex; gap: 6px; }
.meter span { width: 34px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); }
.meter span.on { background: var(--grad); }
.skill-cats { list-style: none; margin: auto 0 0; padding: 26px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.skill-cats li { font-size: .8rem; color: var(--ink-2); padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; }
.skill-cats b { color: var(--ink); margin-left: 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- progetti ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; perspective: 1400px; }
.project {
    --hue: 220;
    position: relative; overflow: hidden; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: 10px;
    padding: 26px; min-height: 290px; color: var(--ink); font: inherit;
}
.project::before {
    content: ""; position: absolute; inset: -40% -40% auto auto; width: 75%; aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(circle, hsla(var(--hue), 90%, 65%, .38), transparent 65%);
    transition: transform .6s var(--ease);
}
.project:hover::before { transform: scale(1.3); }
.project-glyph {
    position: absolute; right: 20px; top: 14px;
    font: 700 4.2rem/1 var(--display); letter-spacing: -.05em;
    color: transparent; -webkit-text-stroke: 1px hsla(var(--hue), 90%, 75%, .55);
    transform: translateZ(40px);
}
.project-n { font: 600 .8rem var(--display); color: hsl(var(--hue), 90%, 72%); letter-spacing: .14em; transform: translateZ(20px); }
.project-title { font: 600 1.4rem/1.15 var(--display); margin-top: 28px; transform: translateZ(30px); }
.project-sum { color: var(--ink-2); font-size: .93rem; flex: 1; transform: translateZ(20px); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: 500 .72rem var(--display); letter-spacing: .06em; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--ink-2); }
.project-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .88rem; color: hsl(var(--hue), 90%, 75%); transform: translateZ(25px); }
.project:hover .project-more .icon { transform: translateX(4px); }
.project-more .icon { transition: transform .3s var(--ease); }
.glare {
    position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
    background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .12), transparent 45%);
}
.project:hover .glare { opacity: 1; }

/* ---------- dialog progetto ---------- */
dialog {
    width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 900px);
    padding: clamp(26px, 5vw, 46px); border: 1px solid var(--line); border-radius: 26px;
    background: linear-gradient(160deg, #11183a, #0a0e20 60%); color: var(--ink);
    box-shadow: 0 40px 120px rgba(0, 0, 0, .7);
}
dialog[open] { animation: pop .5s var(--ease); }
dialog::backdrop { background: rgba(3, 5, 12, .7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
@keyframes pop { from { opacity: 0; transform: perspective(900px) rotateX(12deg) translateY(30px) scale(.96); } }
.dlg-close {
    position: absolute; top: 16px; right: 16px; width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center; cursor: pointer;
    border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink);
}
.dlg-close:hover { background: rgba(255, 255, 255, .12); }
.dlg-body h3 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 14px; padding-right: 40px; }
.dlg-body .tags { margin-bottom: 20px; }
.dlg-body p { color: #cfd6e8; }
.dlg-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
body.dlg-open { overflow: hidden; }

/* ---------- percorso ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 34px; position: relative; display: grid; gap: 22px; max-width: 860px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline::after {
    content: ""; position: absolute; left: 8px; top: 8px; width: 2px; height: calc((100% - 16px) * var(--tl, 0));
    background: var(--grad); box-shadow: 0 0 14px var(--a2);
}
.timeline li { padding: 24px 26px; position: relative; }
.timeline li::before {
    content: ""; position: absolute; left: -33px; top: 30px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--bg); border: 2px solid var(--a2);
}
.timeline li.current::before { background: var(--a1); border-color: var(--a1); box-shadow: 0 0 0 6px rgba(56, 189, 248, .18); }
.tl-period { font: 500 .82rem var(--display); color: var(--ink-3); letter-spacing: .05em; display: flex; gap: 8px; align-items: center; }
.tl-period b { font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: rgba(52, 211, 153, .15); color: #6ee7b7; text-transform: uppercase; letter-spacing: .1em; }
.timeline h3 { font-size: 1.35rem; margin: 8px 0 2px; }
.tl-company { color: var(--a1); font-weight: 600; font-size: .95rem; }
.timeline p { color: var(--ink-2); margin: 10px 0 0; }

/* ---------- foto: anello 3D ---------- */
.ring-stage {
    --r: 520px; --w: 230px;
    height: calc(var(--w) * 1.25 + 120px); perspective: 1600px;
    display: grid; place-items: center; cursor: grab; touch-action: pan-y; user-select: none;
    margin-top: 10px; border-radius: var(--radius); overflow: hidden;
}
.ring-stage:active { cursor: grabbing; }
.ring { position: relative; width: var(--w); height: calc(var(--w) * 1.25); transform-style: preserve-3d; }
.ring-item {
    position: absolute; inset: 0; margin: 0; border-radius: 18px; overflow: hidden;
    transform: rotateY(calc(var(--i) * var(--step, 30deg))) translateZ(var(--r));
    border: 1px solid var(--line); background: var(--bg-2);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8);
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    transition: filter .4s;
}
.ring-item img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ring-item figcaption {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 14px 12px;
    background: linear-gradient(transparent, rgba(3, 5, 12, .9));
    display: flex; flex-direction: column; font-size: .8rem; color: var(--ink-2);
}
.ring-item figcaption b { color: var(--ink); font: 600 .98rem var(--display); }
.ring-item.dim { filter: brightness(.45) saturate(.6); }
.ring-caption { text-align: center; color: var(--ink-2); min-height: 1.6em; margin: 6px auto 0; max-width: 520px; }
.ring-ctrl { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.ring-ctrl [data-dir="-1"] .icon { transform: scaleX(-1); }
@media (max-width: 700px) { .ring-stage { --r: 300px; --w: 170px; } }

/* ---------- footer ---------- */
.footer {
    max-width: 1200px; margin: 0 auto; padding: 40px var(--gutter) 50px;
    display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
    color: var(--ink-3); font-size: .88rem; border-top: 1px solid var(--line);
}
.footer nav { display: flex; gap: 8px; }
.footer nav a, .footer > a { color: var(--ink-2); text-decoration: none; }
.footer nav a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); transition: color .25s, border-color .25s; }
.footer nav a:hover, .footer > a:hover { color: var(--ink); border-color: rgba(160, 180, 255, .4); }

/* ---------- pagine testuali (privacy, 404) ---------- */
.doc { max-width: 760px; margin: 0 auto; padding: 90px var(--gutter) 80px; }
.doc h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); margin: 18px 0 6px; }
.doc h2 { font-size: 1.3rem; margin: 2.2em 0 .5em; }
.doc p { color: #cfd6e8; }
.doc a { color: var(--a1); }
.doc .back { text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.notfound { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.notfound .btn { color: #05070f; margin-top: 16px; }

.icon { flex: none; }

/* ---------- comparsa allo scroll (solo con JS attivo) ---------- */
.js .reveal { opacity: 0; transform: translateY(36px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }
.js .hero .reveal { transition-duration: 1.1s; }

@media (prefers-reduced-motion: reduce) {
    .js .reveal { opacity: 1; transform: none; transition: none; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .about, .stack { grid-template-columns: 1fr; }
    .orb-wrap { max-width: 440px; }
}
@media (max-width: 560px) {
    .hero { padding-top: 100px; }
    .section { min-height: 0; }
    .project { min-height: 0; }
    .orb-tag { font-size: .8rem; padding: 6px 11px; }
    .orb-tag[data-level="5"] { font-size: .9rem; }
}
