/* ============================================================
   Dario Scilla — academic portfolio
   ============================================================ */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f2f1ec;
  --border: #e4e2da;
  --text: #16181d;
  --text-muted: #5c6066;
  --text-faint: #8a8d92;
  --accent: #1f6f78;
  --accent-strong: #14535a;
  --accent-soft: #e4f1ef;
  --coauthor: #b5651d;
  --coauthor-soft: #f7ead9;
  --tag-agu: #2c5f9e;
  --tag-agu-soft: #e2ebf6;
  --tag-whispers: #7a3f9e;
  --tag-whispers-soft: #efe4f6;
  --tag-iac24: #b5651d;
  --tag-iac24-soft: #f7ead9;
  --tag-iac25: #1f6f78;
  --tag-iac25-soft: #e4f1ef;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 8px 24px -12px rgba(20, 20, 20, 0.12);
  --radius: 14px;
  --maxw: 1080px;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013;
    --surface: #16181d;
    --surface-2: #1c1f25;
    --border: #2a2d34;
    --text: #eceeef;
    --text-muted: #a3a8ae;
    --text-faint: #74787f;
    --accent: #4fb8ab;
    --accent-strong: #7ad0c4;
    --accent-soft: #163330;
    --coauthor: #e0a457;
    --coauthor-soft: #332616;
    --tag-agu: #7fb0e8;
    --tag-agu-soft: #1a2c40;
    --tag-whispers: #cf9ded;
    --tag-whispers-soft: #2e2038;
    --tag-iac24: #e0a457;
    --tag-iac24-soft: #332616;
    --tag-iac25: #4fb8ab;
    --tag-iac25-soft: #163330;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1013;
  --surface: #16181d;
  --surface-2: #1c1f25;
  --border: #2a2d34;
  --text: #eceeef;
  --text-muted: #a3a8ae;
  --text-faint: #74787f;
  --accent: #4fb8ab;
  --accent-strong: #7ad0c4;
  --accent-soft: #163330;
  --coauthor: #e0a457;
  --coauthor-soft: #332616;
  --tag-agu: #7fb0e8;
  --tag-agu-soft: #1a2c40;
  --tag-whispers: #cf9ded;
  --tag-whispers-soft: #2e2038;
  --tag-iac24: #e0a457;
  --tag-iac24-soft: #332616;
  --tag-iac25: #4fb8ab;
  --tag-iac25-soft: #163330;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
}

body { background: var(--bg); transition: background 0.2s ease, color 0.2s ease; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 20px;
}
.nav-brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-right: auto;
  margin-left: 28px;
}
.nav-links a { transition: color 0.15s ease; }
.nav-links a:hover, .nav-links a.active { color: var(--accent-strong); }

/* Projects dropdown */
.nav-dropdown { position: relative; }
.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.dropdown-trigger .chev { width: 11px; height: 11px; transition: transform 0.15s ease; }
.nav-dropdown:hover .dropdown-trigger .chev,
.nav-dropdown.open .dropdown-trigger .chev { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 14px);
  left: -14px;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 60;
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-menu a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--text);
  font-weight: 600;
}
.dropdown-menu a:hover { background: var(--surface-2); color: var(--accent-strong); }
.dropdown-menu a .role {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.dropdown-menu a:hover .role { color: var(--accent-strong); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.theme-toggle:hover { color: var(--accent-strong); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 88px 0 72px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 56px;
  align-items: center;
}
.hero-eyebrow {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 4vw, 3.1rem);
  line-height: 1.08;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}
.hero p.lede {
  font-size: 1.08rem;
  color: var(--text-muted);
  max-width: 52ch;
  margin: 0 0 28px;
  text-align: justify;
  text-align-last: left;
}
.hero-photo {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/5;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); color: #fff; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Section shell ---------- */
section { padding: 64px 0; }
.section-head { margin-bottom: 40px; }
.section-head .kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  font-weight: 600;
  margin-bottom: 8px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.section-head p { color: var(--text-muted); max-width: 60ch; margin: 0; text-align: justify; text-align-last: left; }

.bio-text { text-align: justify; text-align-last: left; }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}
.stat {
  background: var(--surface);
  padding: 26px 20px;
  text-align: center;
}
.stat .num {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--accent-strong);
  font-weight: 600;
}
.stat .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Filter tabs ---------- */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Project cards ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-3px); }
.card-media {
  aspect-ratio: 16/10;
  overflow: hidden;
  background: var(--surface-2);
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.card:hover .card-media img { transform: scale(1.04); }
.card-body {
  padding: 22px 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.first { background: var(--accent-soft); color: var(--accent-strong); }
.badge.co { background: var(--coauthor-soft); color: var(--coauthor); }
.badge.venue { background: var(--surface-2); color: var(--text-muted); font-weight: 600; }

.card h3 {
  font-family: var(--serif);
  font-size: 1.22rem;
  margin: 0;
  line-height: 1.3;
}
.card p.summary {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
  flex: 1;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-faint);
}
.card-foot .read-more {
  color: var(--accent-strong);
  font-weight: 700;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}
footer .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ---------- Project detail page ---------- */
.detail-hero {
  padding: 56px 0 40px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-weight: 600;
}
.back-link:hover { color: var(--accent-strong); }
.detail-hero h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1.15;
  margin: 14px 0 18px;
  letter-spacing: -0.01em;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 6px;
}
.detail-meta .dot::before { content: "\2022"; margin: 0 8px; color: var(--text-faint); }

.detail-media {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 32px auto 40px;
  background: var(--surface-2);
}
.detail-media img {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  object-position: center;
}

.detail-body {
  font-size: 1.02rem;
  color: var(--text);
  max-width: 74ch;
}
.detail-body p { margin: 0 0 20px; text-align: justify; text-align-last: left; }
.detail-body .lede {
  font-size: 1.12rem;
  color: var(--text-muted);
  font-family: var(--serif);
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding-left: 18px;
  margin-bottom: 32px;
  text-align: justify;
  text-align-last: left;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 36px 0;
}
.figure-grid figure {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.figure-grid figure img { width: 100%; }
.figure-grid.full { grid-template-columns: 1fr; }

.citation-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-family: "SF Mono", ui-monospace, monospace;
  margin: 36px 0;
  line-height: 1.7;
}
.citation-box .label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-bottom: 10px;
  display: block;
}

.next-project {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding-top: 40px;
}

/* ---------- Responsive ---------- */
/* ---------- Citations panel ---------- */
.citations-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 8px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin: 0 0 4px;
}
.chart-card .chart-sub {
  font-size: 0.82rem;
  color: var(--text-faint);
  margin: 0 0 20px;
}
.bar-row {
  display: grid;
  grid-template-columns: 108px 1fr 30px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.bar-row:last-child { margin-bottom: 0; }
.bar-row .bar-label {
  color: var(--text-muted);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  width: 0%;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-row .bar-value { text-align: right; font-weight: 700; color: var(--text); }
.chart-card.in .bar-fill { width: var(--w); }

.citation-source {
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-faint);
}
.citation-source a { color: var(--accent-strong); font-weight: 600; }

/* ---------- Conference tags ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-agu { background: var(--tag-agu-soft); color: var(--tag-agu); }
.tag-whispers { background: var(--tag-whispers-soft); color: var(--tag-whispers); }
.tag-iac24 { background: var(--tag-iac24-soft); color: var(--tag-iac24); }
.tag-iac25 { background: var(--tag-iac25-soft); color: var(--tag-iac25); }

/* ---------- Conference list ---------- */
.conf-list { display: flex; flex-direction: column; gap: 12px; }
.conf-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 18px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.conf-main h3 {
  font-family: var(--serif);
  font-size: 1.02rem;
  margin: 0 0 4px;
  line-height: 1.35;
  font-weight: 600;
}
.conf-main .conf-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}
.conf-main .conf-abstract {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 6px 0 0;
  max-width: 68ch;
}
.conf-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

@media (max-width: 700px) {
  .conf-row { grid-template-columns: 1fr; }
  .conf-side { flex-direction: row; align-items: center; }
}

/* ---------- Conference summary strip (homepage) ---------- */
.conf-mini-list { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; }
.conf-mini-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
}
.conf-mini-row .conf-mini-title {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conf-mini-row .badge { flex-shrink: 0; }
.conf-mini-row .tag { flex-shrink: 0; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-photo { max-width: 320px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .project-grid { grid-template-columns: 1fr; }
  .figure-grid { grid-template-columns: 1fr; }
  .nav-links { gap: 14px; font-size: 0.85rem; margin-left: 14px; }
  .dropdown-menu { left: -80px; }
  .citations-panel { grid-template-columns: 1fr; }
  .conf-mini-row { flex-wrap: wrap; }
  .conf-mini-row .conf-mini-title { white-space: normal; }
}
