/* ============================================================
   Luca Vedovelli — personal site
   Sober, editorial, with a quiet biostatistics motif.
   ============================================================ */

:root {
  --bg:        #f4f1e9;
  --bg-soft:   #efeadf;
  --surface:   #fbf9f4;
  --surface-2: #f2eee4;
  --ink:       #1a1c20;
  --ink-soft:  #4c4f57;
  --muted:     #74767f;
  --line:      rgba(26, 28, 32, 0.13);
  --line-soft: rgba(26, 28, 32, 0.07);
  --accent:    #1f6f5f;
  --accent-ink:#175649;
  --accent-2:  #b1552c;
  --shadow:    0 1px 2px rgba(26,28,32,.04), 0 10px 30px rgba(26,28,32,.06);
  --radius:    14px;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --maxw: 1080px;
}

html[data-theme="dark"] {
  --bg:        #0f1115;
  --bg-soft:   #12151a;
  --surface:   #161a20;
  --surface-2: #1b1f26;
  --ink:       #e9e6dd;
  --ink-soft:  #bcbcb4;
  --muted:     #8b8d94;
  --line:      rgba(233, 230, 221, 0.14);
  --line-soft: rgba(233, 230, 221, 0.06);
  --accent:    #5cb6a1;
  --accent-ink:#7cc7b5;
  --accent-2:  #d98a5b;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 14px 40px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .4s ease, color .4s ease;
}

/* ---------- language switching ---------- */
[data-l] { display: none; }
html[data-lang="en"] [data-l="en"],
html[data-lang="it"] [data-l="it"] { display: inline; }

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

::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

section { padding: clamp(64px, 9vw, 120px) 0; }
section + section { border-top: 1px solid var(--line-soft); }

.eyebrow {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow .num { color: var(--accent); font-weight: 600; }

.sec-head { margin-bottom: 44px; max-width: 720px; }
.sec-head h2 {
  font-family: var(--serif);
  font-weight: 460;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 16px 0 0;
}
.sec-head p { color: var(--ink-soft); margin: 14px 0 0; max-width: 60ch; }

/* ============================================================
   Header / nav
   ============================================================ */
header.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 18px;
  letter-spacing: -0.01em; color: var(--ink); margin-right: auto;
  display: inline-flex; align-items: center; gap: 10px;
}
.brand .mono { font-family: var(--mono); font-weight: 700; font-size: 14px;
  color: var(--bg); background: var(--accent); border-radius: 7px;
  width: 30px; height: 30px; display: grid; place-items: center; letter-spacing: 0; }
.nav-links { display: flex; gap: 22px; }
.nav-links a {
  font-size: 14.5px; color: var(--ink-soft); font-weight: 500;
  position: relative; padding: 4px 0;
}
.nav-links a:hover { color: var(--ink); }
.nav-tools { display: flex; align-items: center; gap: 8px; }
.tbtn {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: .04em;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 9px; height: 34px; min-width: 40px;
  padding: 0 10px; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; transition: border-color .2s, color .2s, background .2s;
}
.tbtn:hover { color: var(--ink); border-color: var(--accent); }
.tbtn svg { width: 16px; height: 16px; }
@media (max-width: 760px) { .nav-links { display: none; } }

/* ============================================================
   Hero
   ============================================================ */
.hero { position: relative; padding-top: clamp(46px, 7vw, 84px); padding-bottom: clamp(40px,6vw,72px); overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; }
.hero-kicker { margin-bottom: 22px; }
.hero h1 {
  font-family: var(--serif); font-weight: 450;
  font-size: clamp(40px, 7.2vw, 74px);
  line-height: 1.02; letter-spacing: -0.025em; margin: 0 0 10px;
}
.hero h1 .accent { font-style: italic; color: var(--accent); }
.hero .role {
  font-size: clamp(18px, 2.2vw, 21px); color: var(--ink); font-weight: 500;
  margin: 0 0 18px; max-width: 30ch; line-height: 1.4;
}
.hero .lede { color: var(--ink-soft); font-size: 17px; max-width: 46ch; margin: 0 0 12px; }
.hero .affil { color: var(--muted); font-size: 15px; max-width: 46ch; margin: 0 0 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 14.5px; font-weight: 550; padding: 11px 18px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  transition: transform .15s ease, border-color .2s, background .2s, color .2s;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .btn.primary { color: #0f1115; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
html[data-theme="dark"] .btn.primary:hover { color: #0f1115; }

/* portrait + motif */
.hero-visual { position: relative; }
.portrait {
  width: 132px; height: 132px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--surface); box-shadow: var(--shadow);
  position: absolute; right: 8%; top: 4%; z-index: 2;
}
.scatter { display: block; width: 100%; height: auto; }
.scatter .grid line { stroke: var(--line-soft); stroke-width: 1; }
.scatter .axis  { stroke: var(--line); stroke-width: 1.2; }
.scatter .band  { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.scatter .reg   { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round;
  stroke-dasharray: 460; stroke-dashoffset: 460; animation: draw 1.6s .3s ease forwards; }
.scatter .pts circle {
  fill: color-mix(in srgb, var(--accent) 78%, var(--ink));
  opacity: 0; transform-box: fill-box; transform-origin: center;
  animation: pop .5s ease forwards; animation-delay: calc(var(--i) * 34ms + .2s);
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop  { from { opacity: 0; transform: scale(.2); } to { opacity: .9; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .scatter .reg { animation: none; stroke-dashoffset: 0; }
  .scatter .pts circle { animation: none; opacity: .9; }
}

.tools-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 24px; padding: 17px 22px; border-radius: 14px;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-weight: 600; font-size: 16.5px; letter-spacing: -0.01em;
  box-shadow: var(--shadow); transition: transform .16s ease, background .2s;
}
html[data-theme="dark"] .tools-cta { color: #0f1115; }
.tools-cta:hover { transform: translateY(-2px); background: var(--accent-ink); color: #fff; }
html[data-theme="dark"] .tools-cta:hover { color: #0f1115; }
.tools-cta .tc-badge { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .8; display: block; margin-bottom: 3px; font-weight: 600; }
.tools-cta svg { width: 24px; height: 24px; flex: none; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-visual { order: -1; max-width: 420px; }
  .portrait { width: 96px; height: 96px; right: 2%; top: -6%; }
}

/* ============================================================
   Metrics
   ============================================================ */
.metrics { border-top: 1px solid var(--line-soft); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.metric {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 24px 22px;
}
.metric .n { font-family: var(--serif); font-size: clamp(30px, 4vw, 42px); font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
.metric .n small { font-size: .5em; color: var(--muted); font-family: var(--mono); font-weight: 500; margin-left: 3px; }
.metric .k { font-family: var(--mono); font-size: 11.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); margin-top: 12px; }
@media (max-width: 760px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   Prose / About
   ============================================================ */
.prose p { color: var(--ink-soft); max-width: 68ch; margin: 0 0 20px; }
.prose p strong { color: var(--ink); font-weight: 600; }
.prose em { color: var(--ink); font-style: italic; }

.tags { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.tag {
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  padding: 7px 13px; border-radius: 999px;
}
html[data-theme="dark"] .tag { background: var(--surface); }

/* ============================================================
   Timeline (experience + education)
   ============================================================ */
.two-col { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; gap: 40px; } }
.col-title { font-family: var(--mono); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 24px; }

.tl { position: relative; margin: 0; padding: 0; list-style: none; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line); }
.tl li { position: relative; padding: 0 0 26px 30px; }
.tl li:last-child { padding-bottom: 0; }
.tl li::before {
  content: ""; position: absolute; left: 0; top: 6px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--bg); border: 2.5px solid var(--accent);
}
.tl .when { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.tl .what { font-weight: 600; color: var(--ink); margin: 3px 0 2px; }
.tl .where { color: var(--ink-soft); font-size: 15px; }
.tl .note { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ============================================================
   Cards (software / publications-selected)
   ============================================================ */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 26px 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: transform .18s ease, border-color .2s;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card .ct { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card h3 { font-family: var(--serif); font-weight: 520; font-size: 21px; margin: 0 0 8px; letter-spacing: -0.01em; }
.card h3 .mono { font-family: var(--mono); font-weight: 600; font-size: 17px; }
.card p { color: var(--ink-soft); font-size: 15px; margin: 0 0 18px; flex: 1; }
.card .pill { font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 13%, transparent);
  padding: 4px 9px; border-radius: 6px; white-space: nowrap; }
.card .clink { font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; margin-top: auto; }
.card .clink svg { width: 15px; height: 15px; }

/* ============================================================
   Publications
   ============================================================ */
.pub-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
@media (max-width: 900px) { .pub-cols { grid-template-columns: 1fr; gap: 44px; } }

.pub-list { margin: 0; padding: 0; list-style: none; }
.pub-list li { padding: 18px 0; border-top: 1px solid var(--line-soft); }
.pub-list li:first-child { border-top: none; padding-top: 0; }
.pub-t { font-weight: 600; color: var(--ink); line-height: 1.4; display: block; }
a.pub-t:hover { color: var(--accent); }
.pub-m { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 6px; letter-spacing: .02em; }
.pub-m .j { color: var(--accent-ink); }
.pub-a { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.pub-role { font-size: 12px; color: var(--accent-ink); font-weight: 600; }

#feed .load { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.feed-foot { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; }

/* ============================================================
   Skills strip
   ============================================================ */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
@media (max-width: 760px) { .skills-grid { grid-template-columns: 1fr; gap: 24px; } }
.skill-block h4 { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.skill-block p { color: var(--ink-soft); font-size: 15px; margin: 0; }

/* ============================================================
   Contact / footer
   ============================================================ */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 760px) { .contact-grid { grid-template-columns: 1fr; gap: 28px; } }
.contact-links { display: flex; flex-direction: column; gap: 2px; }
.contact-links a, .contact-item {
  display: flex; align-items: center; gap: 13px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft); color: var(--ink); font-weight: 500;
}
.contact-links a:hover { color: var(--accent); }
.contact-links svg, .contact-item svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.contact-item { color: var(--ink-soft); font-weight: 400; }

footer.foot { padding: 34px 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13.5px; }
.foot-inner { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.foot .mono { font-family: var(--mono); font-size: 12px; }

/* ---------- scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
