
:root {
    --bg: #090c11;
    --bg-elev: #0e131b;
    --bg-card: #121826;
    --border: #1f2937;
    --border-soft: #1a2230;
    --text: #e9edf3;
    --text-dim: #8b96a8;
    --text-dimmer: #5a6478;
    --accent: #5eead4;
    --accent-2: #7dd3fc;
    --accent-dim: #2dd4bf2b;
    --danger: #fb7185;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --sans: 'Space Grotesk', system-ui, sans-serif;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --nav-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    width: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-h);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    }
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent-dim); color: var(--accent); }

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

@media (min-width: 640px) {
    .container { padding: 0 40px; }
}

/* ============ CURSOR SPOTLIGHT ============ */
#spotlight {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.4s ease;
    background: radial-gradient(600px circle at var(--x, 50%) var(--y, 50%),
    rgba(94, 234, 212, 0.06), transparent 70%);
}
#spotlight.active { opacity: 1; }
@media (hover: none) { #spotlight { display: none; } }

/* ============ SCROLL PROGRESS ============ */
#progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    z-index: 300;
    transition: width 0.1s linear;
}

/* ============ NAV ============ */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: var(--nav-h);
    background: rgba(9, 12, 17, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-soft);
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 210;
}

.logo .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: blink 2.4s ease-in-out infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.nav-links {
    display: none;
    align-items: center;
    gap: 36px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

@media (min-width: 780px) {
    .nav-links { display: flex; }
}

.nav-links a {
    position: relative;
    padding: 4px 0;
    transition: color 0.2s;
}
.nav-links a::after {
    content: "";
    position: absolute;
    left: 0; bottom: -2px;
    width: 0%;
    height: 1px;
    background: var(--accent);
    transition: width 0.25s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

.nav-cta {
    display: none;
}
@media (min-width: 780px) {
    .nav-cta {
    display: inline-flex;
    font-family: var(--mono);
    font-size: 0.82rem;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    transition: all 0.2s;
    }
    .nav-cta:hover { border-color: var(--accent); color: var(--accent); }
}

/* hamburger (mobile) */
.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    z-index: 210;
    background: none;
    border: none;
    cursor: pointer;
}
@media (min-width: 780px) { .nav-toggle { display: none; } }

.nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(9, 12, 17, 0.98);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.mobile-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.mobile-menu a {
    font-family: var(--mono);
    font-size: 1.4rem;
    color: var(--text-dim);
}
.mobile-menu a:hover { color: var(--accent); }
@media (min-width: 780px) { .mobile-menu { display: none; } }

/* ============ HERO / PARALLAX ============ */
.hero-wrap {
    position: relative;
    height: 100vh;
    height: 100svh;
    min-height: 560px;
    overflow: hidden;
}
#hero-parallax {
    position: absolute;
    inset: 0;
    background:
    radial-gradient(circle at 28% 22%, #142139 0%, transparent 45%),
    radial-gradient(circle at 76% 72%, #0f2b26 0%, transparent 50%),
    var(--bg);
}

#hero-parallax .layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.float-glyph {
    position: absolute;
    font-family: var(--mono);
    color: var(--accent);
    opacity: 0.14;
    white-space: nowrap;
    user-select: none;
}
.layer[data-depth="0.2"] .float-glyph { font-size: 0.85rem; }
.layer[data-depth="0.5"] .float-glyph { font-size: 1.05rem; opacity: 0.2; }
.layer[data-depth="0.9"] .float-glyph { font-size: 1.25rem; opacity: 0.28; }

@media (max-width: 640px) {
    .float-glyph { display: none; }
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
    linear-gradient(rgba(94, 234, 212, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 234, 212, 0.035) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black 40%, transparent 90%);
}

.hero-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 720px;
    z-index: 5;
    text-align: center;
    padding: 0 24px;
}

.hero-eyebrow {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    margin-bottom: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: rgba(94, 234, 212, 0.04);
    opacity: 0;
    animation: fadeUp 0.8s var(--ease) forwards 0.1s;
}

.hero-content h1 {
    font-size: clamp(2.1rem, 7vw, 4.2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 18px;
    opacity: 0;
    animation: fadeUp 0.8s var(--ease) forwards 0.25s;
}

.hero-content h1 .grad {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-content p {
    font-size: clamp(0.98rem, 2vw, 1.15rem);
    color: var(--text-dim);
    max-width: 540px;
    margin: 0 auto 36px;
    opacity: 0;
    animation: fadeUp 0.8s var(--ease) forwards 0.4s;
}

.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    opacity: 0;
    animation: fadeUp 0.8s var(--ease) forwards 0.55s;
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 26px;
    border-radius: 9px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s, color 0.25s;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #06110f; }
.btn-primary:hover { box-shadow: 0 10px 30px var(--accent-dim); }

.btn-ghost { border-color: var(--border); color: var(--text); background: rgba(255,255,255,0.02); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.scroll-hint {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dimmer);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: bounce 2.2s ease-in-out infinite;
    z-index: 5;
}
.scroll-hint::after {
    content: "";
    width: 1px;
    height: 26px;
    background: linear-gradient(var(--accent), transparent);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 8px); }
}

/* ============ REVEAL ON SCROLL ============ */
.reveal {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* stagger: i figli diretti con questa classe ritardano in sequenza */
.stagger > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.stagger.in-view > * { opacity: 1; transform: translateY(0); }
.stagger.in-view > *:nth-child(1) { transition-delay: 0.05s; }
.stagger.in-view > *:nth-child(2) { transition-delay: 0.12s; }
.stagger.in-view > *:nth-child(3) { transition-delay: 0.19s; }
.stagger.in-view > *:nth-child(4) { transition-delay: 0.26s; }
.stagger.in-view > *:nth-child(5) { transition-delay: 0.33s; }
.stagger.in-view > *:nth-child(6) { transition-delay: 0.4s; }

/* ============ SECTIONS ============ */
section { padding: 88px 0; position: relative; }
@media (min-width: 780px) { section { padding: 140px 0; } }

.section-label {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-label::before {
    content: "";
    width: 20px;
    height: 1px;
    background: var(--accent);
}

h2 {
    font-size: clamp(1.6rem, 4vw, 2.3rem);
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

.lead {
    color: var(--text-dim);
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    max-width: 620px;
    margin-bottom: 8px;
}

/* ============ TICKER ============ */
.ticker-wrap {
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-elev);
    overflow: hidden;
    padding: 22px 0;
}
.ticker-track {
    display: flex;
    width: max-content;
    gap: 48px;
    animation: scroll-left 28s linear infinite;
}
.ticker-wrap:hover .ticker-track { animation-play-state: paused; }
@keyframes scroll-left {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}
.ticker-track span {
    font-family: var(--mono);
    font-size: 0.95rem;
    color: var(--text-dimmer);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 48px;
}
.ticker-track span::after {
    content: "//";
    color: var(--border);
}

/* ============ ABOUT ============ */
#about { border-top: 1px solid var(--border-soft); }

.about-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    align-items: start;
    margin-top: 40px;
}
@media (min-width: 780px) {
    .about-grid { grid-template-columns: 1.3fr 1fr; gap: 60px; }
}

.stack-list { display: flex; flex-wrap: wrap; gap: 10px; }

.stack-tag {
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-dim);
    transition: all 0.2s;
}
.stack-tag:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 40px;
}
.stat {
    padding: 20px;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: var(--bg-card);
    text-align: center;
}
.stat .num {
    font-family: var(--mono);
    font-size: clamp(1.5rem, 4vw, 2.1rem);
    font-weight: 600;
    color: var(--accent);
    display: block;
}
.stat .label {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ============ FEATURED PROJECT ============ */
#project { background: var(--bg-elev); border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }

.project-card {
    margin-top: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.3s, transform 0.3s;
}
.project-card:hover { border-color: var(--border-soft); }

.project-terminal {
    background: #06090d;
    padding: 20px 22px;
    font-family: var(--mono);
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.term-dots { display: flex; gap: 6px; margin-bottom: 16px; }
.term-dots span { width: 10px; height: 10px; border-radius: 50%; background: #232d3d; flex-shrink: 0; }

.project-terminal .line {
    color: var(--text-dim);
    margin-bottom: 4px;
    white-space: pre;
}
.project-terminal .prompt { color: var(--accent); }
.project-terminal .comment { color: #4a5568; }
.project-terminal .caret {
    display: inline-block;
    width: 7px; height: 14px;
    background: var(--accent);
    margin-left: 2px;
    animation: caret-blink 1s step-end infinite;
    vertical-align: -2px;
}
@keyframes caret-blink { 50% { opacity: 0; } }

.project-body { padding: 28px 24px; }
@media (min-width: 640px) { .project-body { padding: 32px; } }

.project-body h3 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 600;
    margin-bottom: 12px;
}
.project-body p { color: var(--text-dim); margin-bottom: 20px; }

.feature-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
@media (min-width: 560px) {
    .feature-list { grid-template-columns: 1fr 1fr; }
}
.feature-list li {
    font-size: 0.9rem;
    color: var(--text-dim);
    position: relative;
    padding-left: 20px;
}
.feature-list li::before {
    content: "▸";
    color: var(--accent);
    position: absolute;
    left: 0;
    top: 0;
}
.feature-list code {
    font-family: var(--mono);
    background: rgba(94, 234, 212, 0.08);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

.project-meta {
    font-size: 0.82rem;
    color: var(--text-dimmer);
    margin-bottom: 20px;
    font-family: var(--mono);
}

.project-links { display: flex; flex-wrap: wrap; gap: 12px; }

.link-pill {
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}
.link-pill:hover { border-color: var(--accent); color: var(--accent); }

.badge-beta {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    vertical-align: middle;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--accent-2);
    background: rgba(125, 211, 252, 0.08);
    border: 1px solid var(--accent-2);
    border-radius: 6px;
}

/* ============ CAROSELLO PROGETTI ============ */
.carousel { margin-top: 40px; }

.carousel-viewport {
    overflow: hidden;
    /* l'altezza viene impostata via JS in base alla card attiva,
    cosi' il carosello non lascia spazio vuoto quando le card
    hanno contenuti di lunghezza diversa */
    transition: height 0.4s var(--ease);
}

.carousel-track {
    display: flex;
    align-items: flex-start;
    transition: transform 0.5s var(--ease);
}

.carousel-track .project-card {
    flex: 0 0 100%;
    min-width: 100%;
    margin-top: 0;
}

.carousel-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-top: 28px;
}

.carousel-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.carousel-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.carousel-btn:disabled { opacity: 0.3; cursor: default; }

.carousel-dots {
    display: flex;
    align-items: center;
    gap: 8px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: all 0.25s var(--ease);
}
.carousel-dot.active { background: var(--accent); width: 22px; border-radius: 4px; }

.carousel-counter {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text-dimmer);
    min-width: 46px;
    text-align: center;
}

/* ============ CONTACT ============ */
#contact { text-align: center; height: 100vh }

.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 32px;
}

footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-dimmer);
    font-family: var(--mono);
    font-size: 0.78rem;
    border-top: 1px solid var(--border-soft);
}

footer p + p { margin-top: 6px; }

footer a {
    color: var(--text-dim);
    border-bottom: 1px dotted var(--text-dimmer);
}

footer a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}