/* ==========================================================================
   Fabio Mercorio — Il Sole 24 Ore palette (teal + deep purple on cream, dark ink)
   Fraunces (display) + Inter (body) + JetBrains Mono (meta)
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* paper — warm cream, exact Sole 24 Ore tone */
  --paper:        #F6E5D5;
  --paper-2:      #E5D2BE;
  --paper-3:      #D2BCA2;

  /* ink — Sole's neutral dark (#242424) */
  --ink:          #242424;
  --ink-2:        #3D3D3D;
  --ink-soft:     #5A5A5A;
  --ink-faint:    #8A8A8A;
  --rule:         rgba(36, 36, 36, 0.10);
  --rule-strong:  rgba(36, 36, 36, 0.22);

  /* brand colors — Sole's teal (primary) + deep purple (secondary).
     Legacy var names kept as aliases:
       indigo → teal  (the "primary" slot, links, italic accent)
       coral  → purple (the "secondary" slot, hover, contrast)
       yellow → pale purple (highlighter role)
       teal/grass → teal
       plum → purple */
  --indigo:       #007880;     /* Sole teal — primary, links, italic accent */
  --indigo-light: #3DA8AE;     /* lighter teal — chart Conference */
  --indigo-soft:  #D5EBED;     /* pale teal — soft accent bg */
  --coral:        #30164D;     /* deep purple — secondary, hover, contrast */
  --coral-soft:   #E5DEEC;     /* pale purple */
  --yellow:       #E5DEEC;     /* alias → pale purple (highlighter role) */
  --yellow-soft:  #F2EDF3;
  --teal:         #007880;     /* alias → teal (the actual primary color) */
  --teal-soft:    #D5EBED;
  --plum:         #30164D;     /* alias → deep purple */
  --plum-soft:    #E5DEEC;
  --grass:        #007880;     /* alias → teal */
  --grass-soft:   #D5EBED;

  /* semantic */
  --bg:           var(--paper);
  --bg-elev:      #FFF5EC;     /* warm off-white (replaces pure white) — Sole 24 Ore tone */
  --bg-soft:      var(--paper-2);
  --line:         var(--rule);
  --line-strong:  var(--rule-strong);
  --accent:       var(--indigo);
  --accent-soft:  var(--indigo-soft);

  /* type */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* layout */
  --max-w:        920px;
  --max-w-wide:   1180px;
  --gutter:       clamp(20px, 4vw, 48px);
  --radius:       10px;
  --radius-lg:    14px;
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --paper:        #1A1612;     /* warm dark cream */
  --paper-2:      #2A241D;
  --paper-3:      #3C342A;
  --ink:          #F6E5D5;     /* cream → ink in dark mode (inverted) */
  --ink-2:        #DDC9B8;
  --ink-soft:     #A8957F;
  --ink-faint:    #756558;
  --line:         rgba(246, 229, 213, 0.10);
  --line-strong:  rgba(246, 229, 213, 0.22);

  --indigo:       #5BBDC4;     /* teal → light teal on dark */
  --indigo-light: #7BD3D9;
  --indigo-soft:  #1A3F42;
  --coral:        #B5A0CC;     /* deep purple → lavender on dark */
  --coral-soft:   #2A1F3A;
  --yellow:       #2A1F3A;     /* alias → dark coral-soft (lavender) */
  --yellow-soft:  #1A1326;
  --teal:         #5BBDC4;     /* alias → light teal */
  --teal-soft:    #1A3F42;
  --plum:         #B5A0CC;     /* alias → lavender */
  --plum-soft:    #2A1F3A;
  --grass:        #5BBDC4;     /* alias → light teal */
  --grass-soft:   #1A3F42;

  --bg:           var(--paper);
  --bg-elev:      var(--paper-2);
  --bg-soft:      var(--paper-3);
  --accent:       var(--indigo);
  --accent-soft:  var(--indigo-soft);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  /* compensate for the fixed nav (70px) + iOS safe-area-inset-top (notch) */
  padding-top: calc(70px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
img { max-width: 100%; display: block; }
a { color: var(--indigo); text-decoration: none; transition: color 0.15s var(--ease), background 0.15s var(--ease); }
a:hover { color: var(--coral); }

::selection { background: var(--yellow); color: var(--ink); }

/* ---------- Container ---------- */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: var(--max-w-wide); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Nav ---------- */
.nav {
  /* fixed positioning — definitive fix for iOS Chrome/Safari mobile bug where
     the nav got clipped during scroll. Body has padding-top to compensate.
     No backdrop-filter / color-mix here: both cause rendering glitches on
     iOS WebKit during fast scroll. Solid bg, GPU-accelerated. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  /* push the nav content down by safe-area-inset-top so it stays out from
     under iOS Chrome / Safari URL bar */
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(70px + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.nav-inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 16px;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: 'opsz' 36, 'SOFT' 30;
  font-size: 19px;
  letter-spacing: -0.012em;
}
.nav-brand:hover { color: var(--ink); }
.nav-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--indigo);
  box-shadow: 3px 3px 0 0 var(--coral);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.nav-links a {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  position: relative;
  padding: 6px 2px;
}
.nav-links a:hover { color: var(--indigo); }
.nav-links a[aria-current="page"] {
  color: var(--ink);
  background: linear-gradient(transparent 65%, var(--yellow) 65%, var(--yellow) 95%, transparent 95%);
}
.theme-toggle {
  background: var(--bg-elev);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s var(--ease);
  box-shadow: 2px 2px 0 0 var(--ink);
}
.theme-toggle:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--ink); }
.theme-toggle:active { transform: translate(2px, 2px); box-shadow: 0 0 0 0 var(--ink); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.nav-toggle {
  display: none;
  background: var(--bg-elev);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  width: 38px; height: 38px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 0 var(--ink);
  transition: all 0.18s var(--ease);
}
.nav-toggle:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--ink); }
.nav-toggle:active { transform: translate(2px, 2px); box-shadow: 0 0 0 0 var(--ink); }
.nav-toggle svg { width: 18px; height: 18px; }
/* Sotto i 920px: collassa il menu in hamburger.
   La soglia generosa (non solo 760) cattura anche iPhone in landscape (~932px),
   iPad (~768-1024), e finestre browser stretto / split-screen. */
@media (max-width: 920px) {
  .nav-toggle { display: inline-flex; }
  .nav-inner { position: relative; } /* positioning context for the absolute menu below */
  .nav-links {
    position: absolute;
    top: 70px; left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 16px var(--gutter);
    gap: 16px;
    /* hide ABOVE the viewport: -100% (own height) + -70px (offset of top:70)
       Senza i 70px extra, il bottom dell'ultimo link sbucava dentro l'header
       quando il menu e' alto piu' di ~73px (cosa che succede sempre con
       4 link verticali + padding). */
    transform: translateY(calc(-100% - 70px));
    transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
    z-index: 49;
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    /* hide aggressivo: anche se il calc nel transform fallisse per qualche
       motivo, visibility:hidden + pointer-events:none impediscono la
       visualizzazione e i click sul menu collassato. */
    visibility: hidden;
    pointer-events: none;
  }
  .nav-links.is-open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.3s var(--ease), visibility 0s linear 0s;
  }
}
@media (max-width: 420px) {
  /* su schermi davvero stretti accorciamo il nome del brand */
  .nav-brand span { font-size: 16px; }
}

/* ---------- Hero ---------- */
.hero {
  padding: clamp(56px, 10vh, 110px) 0 clamp(40px, 6vh, 72px);
  position: relative;
  overflow: hidden;
}
/* Logic gates — NAND (top-right) + NOR (bottom-left) as background decoration.
   Pastel fill (matches ex-balls' transparency), thin soft stroke, no animation.
   Markup lives in index.html as inline SVG. */
.gate{ position: absolute; z-index: 0; pointer-events: none; }
.gate svg{ width: 100%; height: 100%; overflow: visible; }
.gate .body, .gate .bubble{
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-opacity: 0.30;
  stroke-linejoin: round;
}
.gate .ln{
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-opacity: 0.30;
  fill: none;
  stroke-linecap: round;
}
.gate.tr .body, .gate.tr .bubble{ fill: var(--coral);  fill-opacity: 0.32; } /* terracotta NAND */
.gate.bl .body, .gate.bl .bubble{ fill: var(--indigo); fill-opacity: 0.22; } /* indigo NOR */

.gate.tr{ top: -10px; right: -110px; width: 380px; height: 200px; }
.gate.bl{ bottom:  0px; left:  -110px; width: 380px; height: 200px; }

@media (max-width: 1180px) {
  .gate.tr{ width: 320px; height: 170px; top: -10px; right: -130px; }
  .gate.bl{ width: 320px; height: 170px; bottom: -10px; left: -130px; }
}
@media (max-width: 980px) {
  .gate.tr{ width: 260px; height: 140px; top: -20px; right: -150px; }
  .gate.bl{ width: 260px; height: 140px; bottom: -20px; left: -150px; }
}
@media (max-width: 760px) {
  .gate { display: none; }
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 48px;
  align-items: center;
}
.hero-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 18px;
  background: var(--bg-elev);
  border: 1.5px solid var(--ink);
  padding: 5px 12px;
  border-radius: 99px;
  display: inline-block;
  box-shadow: 3px 3px 0 0 var(--indigo);
}
.hero-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 30, 'WONK' 0;
  font-size: clamp(48px, 8vw, 92px);
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero-title .accent {
  font-style: italic;
  font-weight: 400;
  font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1;
  color: var(--indigo);
}
.hero-sub {
  font-family: var(--font-display);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 400;
  font-style: italic;
  font-variation-settings: 'opsz' 36, 'SOFT' 50;
  line-height: 1.35;
  color: var(--ink-2);
  margin: 0 0 24px;
  max-width: 56ch;
}
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s var(--ease);
  text-decoration: none;
  box-shadow: 3px 3px 0 0 var(--ink);
}
.btn:hover { color: var(--ink); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 var(--ink); }
.btn-indigo { background: var(--indigo); color: #FFFFFF; box-shadow: 3px 3px 0 0 var(--ink); }
.btn-indigo:hover { color: #FFFFFF; }
.btn-coral  { background: var(--coral); color: #FFFFFF; box-shadow: 3px 3px 0 0 var(--ink); }
.btn-coral:hover  { color: #FFFFFF; }
.btn-yellow { background: var(--yellow); color: var(--ink); box-shadow: 3px 3px 0 0 var(--ink); }
.btn-yellow:hover { color: var(--ink); }

.hero-photo {
  position: relative;
  width: 200px;
  height: 200px;
  justify-self: end;
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--ink);
  position: relative;
  z-index: 2;
  box-shadow: 8px 8px 0 0 var(--indigo);
}
.hero-photo::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px dashed var(--coral);
  z-index: 1;
  animation: spin 60s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hero-photo::before { animation: none; } }
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero-photo { width: 140px; height: 140px; justify-self: start; order: -1; }
  .hero-photo img { box-shadow: 6px 6px 0 0 var(--indigo); }
}

/* ---------- Section ---------- */
.section { padding: clamp(56px, 8vh, 88px) 0; }
.section + .section { border-top: 1px solid var(--line); }

.s-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 28px;
  position: relative;
}
.s-num {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
}
.s-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 72, 'SOFT' 30;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0;
  color: var(--ink);
}
.s-title em { font-style: italic; font-weight: 500; color: var(--indigo); }
.s-sub {
  margin: -8px 0 24px;
  color: var(--ink-soft);
  font-size: 16px;
  max-width: 64ch;
}

.sub-head {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--coral);
  font-weight: 500;
  margin: 36px 0 14px;
}

/* color variants for section number */
.s-num.c-coral { background: var(--coral); }
.s-num.c-teal  { background: var(--teal); }
.s-num.c-yellow{ background: var(--yellow); color: var(--ink); }
.s-num.c-plum  { background: var(--plum); }
.s-num.c-grass { background: var(--grass); }
.s-num.c-indigo{ background: var(--indigo); }

/* ---------- Lists ---------- */
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean > li {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.55;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: baseline;
}
.list-clean > li:last-child { border-bottom: 1px solid var(--line); }
.list-clean > li strong { color: var(--ink); font-weight: 600; }
.list-clean > li em { color: var(--indigo); font-style: italic; }
.list-clean .when {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
@media (max-width: 720px) { .list-clean > li { grid-template-columns: 1fr; gap: 4px; } }

/* news list — works for raw <ul class="news"> AND markdown-rendered <div class="news md"><ul>...</ul></div> */
.news { list-style: none; padding: 0; margin: 0; }
.news ul { list-style: none; padding: 0; margin: 0; max-width: none; }
.news > li,
.news ul > li {
  padding: 18px 0 18px 22px !important;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  position: relative;
  font-size: 15.5px;
  line-height: 1.55;
  margin: 0;
  display: block;
}
.news > li:last-child,
.news ul > li:last-child { border-bottom: 1px solid var(--line); }
.news > li::marker,
.news ul > li::marker { content: ''; }
.news > li::before,
.news ul > li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 27px;
  width: 8px; height: 8px;
  background: var(--indigo);
  transform: rotate(45deg);
}
/* alternating bullet rhythm: indigo → terracotta → indigo → terracotta … */
.news > li:nth-child(even)::before, .news ul > li:nth-child(even)::before { background: var(--coral); }
.news.md-rendered { font-size: 15.5px; }
.news.md-rendered p { margin: 0; }

/* ---------- Tags ---------- */
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 99px;
  display: inline-block;
  vertical-align: 1px;
  margin-right: 6px;
  white-space: nowrap;
  border: 1.5px solid var(--ink);
}
.tag-publication { background: var(--grass-soft); color: var(--grass); border-color: var(--grass); }
.tag-tool        { background: var(--teal); color: #FFFFFF; border-color: var(--teal); }
.tag-press       { background: var(--coral-soft); color: var(--coral); border-color: var(--coral); }
.tag-speech      { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.tag-teaching    { background: var(--plum-soft); color: var(--plum); border-color: var(--plum); }

/* ---------- Tools cards ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.tool {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  background: var(--bg-elev);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  position: relative;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  color: var(--ink);
  box-shadow: 4px 4px 0 0 var(--ink);
}
.tool:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 0 var(--indigo);
  color: var(--ink);
}
/* alternating hover shadow: indigo / terracotta */
.tool:nth-child(odd):hover  { box-shadow: 6px 6px 0 0 var(--indigo); }
.tool:nth-child(even):hover { box-shadow: 6px 6px 0 0 var(--coral); }
.tool-name {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36, 'SOFT' 30;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.tool-name em { font-style: italic; font-weight: 500; color: var(--indigo); }
.tool:nth-child(even) .tool-name em { color: var(--coral); }
.tool-arrow { font-size: 14px; color: var(--ink-soft); transition: transform 0.18s var(--ease), color 0.18s var(--ease); }
.tool:hover .tool-arrow { color: var(--indigo); transform: translate(2px, -2px); }
.tool-desc { font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); margin: 0; flex: 1; }
.tool-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tool-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ---------- Team ---------- */
.team {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.team-card {
  padding: 16px 14px 16px 0;
  border-bottom: 1px solid var(--line);
}
.team-name { font-weight: 600; font-size: 15px; color: var(--ink); margin: 0 0 2px; }
.team-name a { color: var(--ink); }
.team-name a:hover { color: var(--indigo); background: linear-gradient(transparent 70%, var(--yellow) 70%); }
.team-role { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Pills (events) ---------- */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  transition: all 0.15s var(--ease);
  box-shadow: 2px 2px 0 0 var(--ink);
}
.pill:hover {
  color: #FFFFFF;
  background: var(--indigo);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 0 var(--ink);
}
/* alternating hover: indigo (default) / terracotta */
.pill:nth-child(even):hover { background: var(--coral); }

/* ---------- Page intro ---------- */
.page-intro {
  padding: clamp(72px, 12vh, 120px) 0 clamp(36px, 6vh, 56px);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
/* page-intro hosts the same NAND/NOR gate decoration as the homepage hero —
   markup lives in each page's HTML. */
.page-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--yellow);
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-block;
  margin: 0 0 16px;
  border: 1.5px solid var(--ink);
}
.page-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 40;
  font-size: clamp(44px, 7vw, 80px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  color: var(--ink);
  position: relative;
}
.page-title em { font-style: italic; font-weight: 400; color: var(--indigo); font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1; }
.page-lead {
  color: var(--ink-soft);
  font-size: 17px;
  max-width: 64ch;
  margin: 0;
  line-height: 1.55;
}

/* ---------- Footer ---------- */
.footer {
  padding: 32px 0 40px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
}
.footer-socials { display: inline-flex; gap: 8px; margin-bottom: 14px; }
.footer-socials a {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--bg-elev);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: all 0.15s var(--ease);
  box-shadow: 2px 2px 0 0 var(--ink);
}
.footer-socials a:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 0 var(--indigo);
  color: var(--indigo);
}
.footer-socials a:nth-child(even):hover { box-shadow: 3px 3px 0 0 var(--coral); color: var(--coral); }
.footer-socials svg { width: 16px; height: 16px; }
.footer-meta { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Markdown ---------- */
.md, [data-md] { display: block; }
.md-rendered { font-size: 16px; line-height: 1.7; color: var(--ink); }
.md-rendered h1 { font-family: var(--font-display); font-variation-settings: 'opsz' 144, 'SOFT' 30; font-size: clamp(34px, 4.5vw, 52px); font-weight: 700; letter-spacing: -0.025em; line-height: 1.02; margin: 1.4em 0 0.4em; }
.md-rendered h2 { font-family: var(--font-display); font-variation-settings: 'opsz' 72, 'SOFT' 30; font-size: clamp(24px, 3vw, 32px); font-weight: 600; letter-spacing: -0.018em; margin: 1.3em 0 0.4em; }
.md-rendered h3 { font-family: var(--font-display); font-variation-settings: 'opsz' 36, 'SOFT' 30; font-size: 20px; font-weight: 600; margin: 1.2em 0 0.3em; }
.md-rendered h4 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--coral); margin: 1.4em 0 0.4em; font-weight: 500; }
.md-rendered p { margin: 0 0 1em; max-width: 70ch; }
.md-rendered ul, .md-rendered ol { padding-left: 1.4em; margin: 0 0 1em; max-width: 70ch; }
.md-rendered li { margin: 0.3em 0; }
.md-rendered ul li::marker { color: var(--indigo); }
.md-rendered blockquote { border-left: 4px solid var(--coral); padding: 6px 16px; margin: 1.2em 0; font-style: italic; color: var(--ink-soft); max-width: 60ch; background: var(--bg-soft); }
.md-rendered code { font-family: var(--font-mono); font-size: 0.92em; background: var(--yellow-soft); padding: 2px 6px; border-radius: 3px; color: var(--ink); border: 1px solid var(--yellow); }
.md-rendered pre { background: var(--bg-soft); padding: 16px; border-radius: 8px; overflow-x: auto; margin: 1em 0; border: 1px solid var(--line); }
.md-rendered pre code { background: transparent; padding: 0; border: 0; }
.md-rendered hr { border: 0; border-top: 2px dashed var(--line-strong); margin: 2em 0; }
.md-rendered a { color: var(--indigo); border-bottom: 2px solid var(--yellow); }
.md-rendered a:hover { color: var(--coral); border-bottom-color: var(--coral); }
.md-rendered strong { color: var(--ink); font-weight: 600; }
.md-rendered em { color: var(--indigo); font-style: italic; }

/* In-section markdown adjustments — make h4 act like our sub-head */
.section .md-rendered h4 {
  margin-top: 28px;
  margin-bottom: 10px;
}
.section .md-rendered h4:first-child { margin-top: 0; }
.section .md-rendered ul {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  border-top: 1px solid var(--line);
}
.section .md-rendered ul li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  position: relative;
  margin: 0;
  font-size: 15.5px;
  line-height: 1.55;
}
.section .md-rendered ul li::marker { content: ''; }

/* CTA grid (two-column on desktop, single on mobile) */
.cta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 720px) { .cta-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   PUBLICATIONS PAGE
   ========================================================================== */

.pub-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.stat {
  padding: 18px 18px;
  background: var(--bg-elev);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 0 var(--ink);
  position: relative;
  overflow: hidden;
}
.stat:nth-child(odd)  { box-shadow: 3px 3px 0 0 var(--indigo); }
.stat:nth-child(even) { box-shadow: 3px 3px 0 0 var(--coral); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px;
}
.stat-value {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 72, 'SOFT' 30;
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
}
.stat-extra { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); margin-top: 4px; }
@media (max-width: 760px) {
  .pub-stats { grid-template-columns: repeat(2, 1fr); }
}

.chart-card {
  background: var(--bg-elev);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 26px 26px 18px;
  margin-bottom: 40px;
  box-shadow: 5px 5px 0 0 var(--ink);
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}
.chart-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36, 'SOFT' 30;
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
}
.chart-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.chart-canvas-wrap {
  position: relative;
  height: 340px;
}
@media (max-width: 760px) { .chart-canvas-wrap { height: 280px; } }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  position: sticky;
  top: 70px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
}
.search {
  flex: 1;
  min-width: 200px;
  border: 2px solid var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: box-shadow 0.15s var(--ease);
}
.search:focus { box-shadow: 3px 3px 0 0 var(--indigo); }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.f-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 7px 13px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.f-btn:hover { background: var(--yellow); }
.f-btn.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.f-btn.is-active:hover { background: var(--ink); }
.f-btn .c { opacity: 0.55; margin-left: 6px; }

/* publication list */
.year-block { margin-bottom: 40px; }
.year-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0 0 8px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
}
.year-num {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 144, 'SOFT' 30;
  font-size: clamp(40px, 5vw, 60px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.year-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  background: var(--yellow);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
}

.pub {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.pub:last-child { border-bottom: 0; }

.pub-cat {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  width: fit-content;
  margin-top: 2px;
  white-space: nowrap;
  border: 1.5px solid var(--ink);
}
.cat-Journal     { background: var(--indigo); color: #FFFFFF; border-color: var(--ink); }
.cat-Conference  { background: var(--bg-elev); color: var(--indigo); border-color: var(--indigo); }
.cat-Preprint    { background: var(--coral-soft); color: var(--coral); border-color: var(--coral); }
.cat-Book        { background: var(--ink); color: var(--bg); }
.cat-Other       { background: var(--bg-soft); color: var(--ink-soft); }

.pub-info { min-width: 0; }
.pub-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 24, 'SOFT' 30;
  font-size: 17.5px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.005em;
  margin: 0 0 4px;
  color: var(--ink);
}
.pub-authors { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 4px; }
/* nessuno stile speciale per il proprio nome — appare come gli altri co-autori */
.pub-venue { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.03em; color: var(--ink-faint); }

.pub-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pub-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s var(--ease);
}
.pub-btn:hover { background: var(--yellow); color: var(--ink); }
.pub-btn-cite { background: var(--ink); color: var(--bg); }
.pub-btn-cite:hover { background: var(--coral); border-color: var(--ink); color: #FFFFFF; }

@media (max-width: 760px) {
  .pub { grid-template-columns: 1fr; gap: 6px; }
  .filters { position: static; }
}

#pub-empty {
  display: none;
  padding: 60px 0;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- Modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 20, 0.55);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}
.modal-back.is-open { display: flex; opacity: 1; }
.modal {
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(14px);
  transition: transform 0.22s var(--ease);
  box-shadow: 6px 6px 0 0 var(--indigo);
}
.modal-back.is-open .modal { transform: none; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0;
  font-weight: 600;
}
.modal-cite-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 24, 'SOFT' 30;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin: 4px 0 0;
  line-height: 1.3;
}
.modal-close {
  background: var(--bg-elev);
  border: 1.5px solid var(--ink);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--coral); color: #FFFFFF; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-body pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-soft);
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  border: 1px solid var(--line);
}
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Projects (granted) ---------- */
.proj-list { list-style: none; padding: 0; margin: 0; }
.proj {
  padding: 22px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: start;
}
.proj:last-child { border-bottom: 1px solid var(--line); }
.proj-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.proj-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
  width: fit-content;
}
.proj:nth-child(odd)  .proj-code { background: var(--indigo); color: #FFF; }
.proj:nth-child(even) .proj-code { background: var(--coral);  color: #FFF; }
.proj-period {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.proj-role {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  font-style: italic;
}
.proj-body { min-width: 0; }
.proj-title {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 36, 'SOFT' 30;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--ink);
}
.proj-funder {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.proj-desc { font-size: 14.5px; line-height: 1.55; margin: 0 0 10px; }
.proj-pubs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.proj-pub-link {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--yellow-soft);
  color: var(--ink);
  border: 1px solid var(--yellow);
}
.proj-pub-link:hover { background: var(--yellow); color: var(--ink); }

@media (max-width: 760px) { .proj { grid-template-columns: 1fr; gap: 8px; } }

/* ---------- Calendly badge override ---------- */
.calendly-badge-widget { font-family: var(--font-sans) !important; font-size: 12px !important; }
