:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --text: #1c1917;
    --muted: #57534e;
    --border: #e7e5e4;
    --accent: #6d28d9;
    --accent-soft: #ede9fe;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0a09;
        --surface: #1c1917;
        --text: #f5f5f4;
        --muted: #a8a29e;
        --border: #292524;
        --accent: #a78bfa;
        --accent-soft: #2e1065;
    }
}

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

html { scroll-behavior: smooth; }

body {
    margin: 0;
    -webkit-text-size-adjust: 100%;
    overflow-wrap: break-word;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.65 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }

section { padding: 56px 0; border-top: 1px solid var(--border); }

h2 {
    margin: 0 0 24px;
    font-size: .8rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent);
}

h3 { margin: 0; font-size: 1.05rem; }

p { margin: 0 0 14px; }

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

/* Menu */
.nav {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.nav ul { display: flex; gap: 22px; margin: 0; padding: 0; list-style: none; }
.nav a { color: var(--muted); font-size: .93rem; font-weight: 500; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav ul a[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); padding-bottom: 4px; }
.nav .brand { color: var(--text); font-weight: 700; }

.page-head { padding: 64px 0 40px; }
.page-head h1 { margin: 0 0 8px; font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.1; letter-spacing: -.02em; }
.page-head p { margin: 0; font-size: 1.1rem; }

/* Hero */
.hero { padding: 64px 0 56px; border: 0; }
.hero img {
    width: 112px; height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-soft);
}
.hero h1 { margin: 24px 0 4px; font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.1; letter-spacing: -.02em; }
.hero .role { font-size: 1.2rem; color: var(--muted); margin: 0 0 4px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: .95rem; font-weight: 500;
    cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Cards */
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.card p { margin: 8px 0 0; font-size: .95rem; color: var(--muted); }

/* Progetti */
.projects { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.projects .card { display: flex; flex-direction: column; gap: 10px; }
.projects .card p { margin: 0; }
.projects .kind { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.projects .card > a, .card-links { margin-top: auto; font-size: .92rem; font-weight: 500; }
.card-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.play-badge { display: inline-block; margin: -8px 0 -8px -10px; }
.play-badge img { display: block; width: auto; height: 62px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tags li { padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); font-size: .8rem; }
code { font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Stack */
.stack { display: grid; gap: 14px; }
.stack div { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: baseline; }
.stack dt { color: var(--muted); font-size: .9rem; }
.stack dd { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--text);
    font-size: .88rem;
}

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 32px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
    content: "";
    position: absolute; left: -7px; top: 6px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
}
.timeline .meta { font-size: .88rem; color: var(--muted); margin: 2px 0 10px; }
.timeline p { color: var(--muted); font-size: .97rem; }

footer { padding: 32px 0 48px; border-top: 1px solid var(--border); font-size: .88rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; }
.footer-links { display: flex; gap: 16px; }

@media (max-width: 520px) {
    body { font-size: 16px; }
    .wrap { padding: 0 16px; }
    section { padding: 40px 0; }
    .nav-inner { flex-wrap: wrap; gap: 4px 16px; padding-top: 10px; padding-bottom: 10px; }
    .nav ul { gap: 16px; overflow-x: auto; }
    .nav a { font-size: .88rem; }
    .page-head { padding: 40px 0 24px; }
    .hero { padding: 40px 0 40px; text-align: center; }
    .hero img { width: 96px; height: 96px; }
    .links { justify-content: center; }
    .links .btn { flex: 1 1 100%; justify-content: center; min-height: 44px; }
    .stack div { grid-template-columns: 1fr; gap: 6px; }
    .card { padding: 16px; }
    .projects { grid-template-columns: 1fr; }
    .timeline li { padding-left: 20px; }
}

@media (prefers-reduced-motion: no-preference) {
    section, .hero, .page-head { animation: rise .6s ease both; }
    @keyframes rise { from { opacity: 0; transform: translateY(12px); } }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* Easter egg */
.egg {
    padding: 0; border: 0; background: none;
    font: inherit; color: inherit;
    cursor: pointer;
    text-decoration: underline dotted var(--accent);
    text-underline-offset: 3px;
}

#term {
    position: fixed; right: 16px; bottom: 16px; z-index: 100;
    display: flex; flex-direction: column;
    width: min(560px, calc(100% - 32px)); height: 320px;
    background: #0d1117; color: #c9d1d9;
    border: 1px solid #30363d; border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
    font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#term[hidden] { display: none; }
.term-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid #30363d; color: #8b949e; }
.term-bar button { border: 0; background: none; color: inherit; font-size: 20px; cursor: pointer; }
#term-out { flex: 1; margin: 0; padding: 10px 12px 0; overflow: auto; white-space: pre-wrap; font: inherit; }
#term-form label { display: flex; gap: 8px; padding: 6px 12px 10px; color: #a78bfa; font-size: inherit; }
#term-in { padding: 0; border: 0; border-radius: 0; background: none; color: #c9d1d9; font: inherit; outline: none; }

.moto {
    position: fixed; top: 50%; left: 100%; z-index: 101;
    margin-top: -.6em; /* centrata in verticale senza toccare il transform dell'animazione */
    font-size: clamp(56px, 12vw, 120px); white-space: nowrap; pointer-events: none;
    animation: ride 3s linear forwards;
}
@keyframes ride { to { transform: translateX(calc(-100vw - 100%)); } }
