/* Marcos Da Silveira — prototype stylesheet.
   Tokens first; light theme by default, dark from the system or the toggle. */

:root {
  --ink: #13203a;
  --paper: #f3f5f8;
  --surface: #ffffff;
  --text: #13203a;
  --muted: #56617a;
  --line: #d6dce6;
  --accent: #2b57c9;
  --accent-ink: #ffffff;
  --warm: #d9961a;
  --warm-soft: #fbe9c4;
  --theme-evolving-knowledge: #2b57c9;
  --theme-health: #17806a;
  --theme-language-skills: #c07d0c;
  --theme-systems: #6b7590;
  --focus: #2b57c9;

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* 1.25 scale on a 17px base */
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.33rem;
  --step-2: 1.66rem;
  --step-3: 2.07rem;
  --step-4: clamp(2.2rem, 1.6rem + 2.4vw, 3.25rem);
  --step-5: clamp(2.8rem, 1.8rem + 4.2vw, 5.1rem);

  --measure: 65ch;
  --wide: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --space: clamp(4rem, 9vw, 7.5rem);
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1830;
    --surface: #16213d;
    --text: #e7ecf5;
    --muted: #a6b1c7;
    --line: #2a3758;
    --accent: #8eaeff;
    --accent-ink: #0f1830;
    --warm: #f2b544;
    --warm-soft: #3a3020;
    --theme-evolving-knowledge: #8eaeff;
    --theme-health: #4fc7a6;
    --theme-language-skills: #f2b544;
    --theme-systems: #9aa5bf;
    --focus: #f2b544;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1830;
  --surface: #16213d;
  --text: #e7ecf5;
  --muted: #a6b1c7;
  --line: #2a3758;
  --accent: #8eaeff;
  --accent-ink: #0f1830;
  --warm: #f2b544;
  --warm-soft: #3a3020;
  --theme-evolving-knowledge: #8eaeff;
  --theme-health: #4fc7a6;
  --theme-language-skills: #f2b544;
  --theme-systems: #9aa5bf;
  --focus: #f2b544;
  color-scheme: dark;
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 var(--step-0)/1.6 var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); line-height: 1.3; }
p { margin: 0 0 1em; max-width: var(--measure); text-wrap: pretty; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.6rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto; }
.section { padding-block: var(--space); }
.section + .section { padding-top: 0; }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; min-height: 4rem; }
.site-name {
  font-family: var(--serif); font-weight: 600; font-size: 1.2rem;
  color: var(--text); text-decoration: none; margin-right: auto;
  view-transition-name: site-name;
}
.site-nav ul { display: flex; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 0.45rem 0.7rem; border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500;
}
.site-nav a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.site-nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--warm); border-radius: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem;
  border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.menu-btn { display: none; }

@media (max-width: 760px) {
  .menu-btn { display: inline-grid; }
  .site-nav {
    position: absolute; inset: 100% 0 auto 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    display: none;
  }
  .site-nav[data-open="true"] { display: block; }
  .site-nav ul { flex-direction: column; padding: 0.5rem var(--gutter) 1rem; }
  .site-nav a { padding: 0.8rem 0.25rem; font-size: 1.05rem; }
  .site-nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--warm); padding-left: 0.8rem; }
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.8rem 1.3rem; border-radius: 999px;
  font: 600 0.98rem/1 var(--sans); text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--text); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-graph { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero .wrap {
  position: relative; z-index: 1;
  min-height: min(88vh, 46rem);
  display: flex; flex-direction: column; justify-content: center;
  padding-block: 5rem 4rem;
  pointer-events: none;
}
.hero .wrap > * { pointer-events: auto; max-width: 34rem; }
.hero h1 {
  font-size: var(--step-5); font-weight: 600; letter-spacing: -0.025em; line-height: 1.02;
  font-variation-settings: "opsz" 60;
  margin-bottom: 0.4em;
}
.hero .role { font-size: var(--step-1); font-weight: 500; line-height: 1.4; margin-bottom: 1rem; }
.hero .pitch { color: var(--muted); font-size: 1.1rem; }
.hero-legend {
  position: absolute; z-index: 1; right: var(--gutter); bottom: 1.25rem;
  display: flex; align-items: center; gap: 0.75rem;
  font-size: var(--step--1); color: var(--muted);
}
.hero-legend .year {
  font-family: var(--serif); font-size: 1.6rem; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.hero-legend p { margin: 0; max-width: 22ch; line-height: 1.35; }
.hero-legend .icon-btn { width: 2.2rem; height: 2.2rem; background: var(--paper); }

@media (max-width: 860px) {
  .hero { display: flex; flex-direction: column; }
  .hero .wrap { order: 1; min-height: 0; padding-block: 3rem 0; }
  .hero-graph { position: relative; order: 2; height: 20rem; margin-top: 1rem; }
  .hero-legend { position: static; order: 3; padding: 0 var(--gutter) 1.25rem; justify-content: space-between; }
}

@media (min-width: 861px) {
  .hero-graph { left: max(44%, calc(var(--gutter) + 35rem)); width: auto; right: 0; }
}

/* ---------- Themes ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1.5rem, 3vw, 3rem); margin-top: 2.5rem; }
.theme h3 { display: flex; align-items: baseline; gap: 0.6rem; }
.dot {
  flex: none; width: 0.7rem; height: 0.7rem; border-radius: 50%;
  background: var(--c, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--accent)) 22%, transparent);
  transform: translateY(-0.1em);
}
.theme p { color: var(--muted); font-size: 1rem; }
.theme ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.95rem; }
@media (max-width: 900px) { .themes { grid-template-columns: 1fr; } }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.section-head a { font-weight: 600; }

/* ---------- Publication list ---------- */
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub {
  display: grid; grid-template-columns: 5rem 1fr; gap: 0 1.5rem;
  padding: 1.25rem 0; border-top: 1px solid var(--line);
}
.pub .year { font-family: var(--serif); font-size: 1.15rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pub .year.repeat { visibility: hidden; }
.pub h3 { text-wrap: pretty; font-size: 1.15rem; margin: 0 0 0.35rem; font-weight: 600; }
.pub h3 a { color: var(--text); text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.pub h3 a:hover { color: var(--accent); }
.pub .authors { font-size: 0.95rem; color: var(--muted); margin: 0 0 0.2rem; }
.pub .authors strong { color: var(--text); font-weight: 600; }
.pub .venue { font-size: 0.95rem; margin: 0; }
.pub .venue em { font-style: italic; }
.pub .cites { margin-left: 0.75rem; font-size: 0.9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 0.12rem 0.5rem; border-radius: 999px; margin-right: 0.5rem;
  background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 40%, transparent);
}
@media (max-width: 600px) {
  .pub { grid-template-columns: 1fr; }
  .pub .year.repeat { display: none; }
}

/* ---------- Project rows ---------- */
.project-list { list-style: none; margin: 0; padding: 0; }
.project {
  display: grid; grid-template-columns: 7rem 1fr; gap: 1.5rem 2rem; align-items: start;
  padding: 2rem 0; border-top: 1px solid var(--line);
}
.logo-box {
  width: 7rem; aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; padding: 0.6rem; overflow: hidden;
}
.logo-box img { max-height: 100%; width: auto; object-fit: contain; filter: grayscale(1); opacity: 0.85; transition: filter 0.3s, opacity 0.3s; }
.project:hover .logo-box img, .project:focus-within .logo-box img { filter: none; opacity: 1; }
.logo-box .mono { font-family: var(--serif); font-weight: 600; color: var(--ink); font-size: 1.1rem; }
.project h3 { margin-bottom: 0.1rem; font-size: var(--step-1); }
.project .subtitle { margin: 0 0 0.35rem; font-weight: 500; }
.project .meta { color: var(--muted); font-size: 0.95rem; margin: 0 0 0.75rem; }
.project .summary { margin-bottom: 0.75rem; }
.project details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.95rem; width: fit-content; }
.project details p { margin-top: 0.75rem; color: var(--muted); }
@media (max-width: 600px) {
  .project { grid-template-columns: 1fr; gap: 1rem; }
  .logo-box { width: 6rem; }
}

/* ---------- Filters ---------- */
.filters { display: grid; gap: 1rem; margin-block: 2rem 1rem; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.filter-row > .label { font-size: 0.9rem; color: var(--muted); min-width: 4.5rem; }
.chip {
  font: 500 0.9rem/1 var(--sans); padding: 0.5rem 0.85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.chip .dot { width: 0.55rem; height: 0.55rem; box-shadow: none; transform: none; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count { color: inherit; opacity: 0.75; }
.search {
  width: min(100%, 26rem); font: inherit; font-size: 1rem;
  padding: 0.7rem 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.search::placeholder { color: var(--muted); }
select.search { width: auto; padding-right: 2rem; }
.result-count { color: var(--muted); font-size: 0.95rem; margin: 0; }
.empty { padding: 2rem 0; border-top: 1px solid var(--line); }

.topic-graph-wrap {
  display: flex; flex-direction: column; margin-top: 2rem; height: 28rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.topic-graph-wrap canvas { flex: 1; min-height: 0; width: 100%; display: block; }
.topic-graph-wrap .note { margin: 0; padding: 0.75rem 1rem; border-top: 1px solid var(--line); font-size: var(--step--1); color: var(--muted); max-width: none; }

/* ---------- Contact ---------- */
.contact {
  display: grid; grid-template-columns: auto 1fr; gap: 1.5rem 2rem; align-items: center;
  padding: 2.5rem; border-radius: calc(var(--radius) * 2);
  background: var(--ink); color: #e7ecf5;
}
:root[data-theme="dark"] .contact { background: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .contact { background: var(--surface); } }
.contact h2 { color: #fff; font-size: var(--step-2); margin-bottom: 0.3rem; }
.contact p { margin: 0; color: #b8c2d8; }
.contact .portrait { width: 6rem; height: 6rem; border-radius: 50%; object-fit: cover; view-transition-name: portrait; }
/* About has its own large portrait: only that one morphs between pages. */
body:has(.bio) .contact .portrait { view-transition-name: none; }
.contact .email-row { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.contact .btn { --accent: #f2b544; --accent-ink: #13203a; }
.contact .btn.secondary { color: #fff; border-color: #44527a; }
.contact .btn.secondary:hover { border-color: #fff; }
.profiles { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; list-style: none; padding: 0; margin: 0.9rem 0 0; font-size: 0.95rem; }
.contact .profiles a { color: #fff; }
@media (max-width: 860px) {
  .contact { grid-template-columns: 1fr; padding: 2rem 1.5rem; }
  .contact .email-row { grid-column: 1; }
}
.copied-msg { font-size: 0.9rem; color: #f2b544; min-width: 6rem; }

/* ---------- Page heads ---------- */
.page-head { padding-block: clamp(3rem, 7vw, 5rem) 1rem; }
.page-head h1 { view-transition-name: page-title; }

/* ---------- About ---------- */
.bio { display: grid; grid-template-columns: 16rem 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.bio .portrait { border-radius: calc(var(--radius) * 2); aspect-ratio: 3 / 4; object-fit: cover; view-transition-name: portrait; }
.bio .facts { margin-top: 1.5rem; font-size: 0.95rem; color: var(--muted); }
.bio .facts dt { font-weight: 600; color: var(--text); }
.bio .facts dd { margin: 0 0 0.8rem; }
@media (max-width: 760px) { .bio { grid-template-columns: 1fr; } .bio .portrait { width: 12rem; } }

.interests { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 1.5rem 0 0; }

.timeline { list-style: none; margin: 2.5rem 0 0; padding: 0 0 0 2.25rem; position: relative; max-width: 46rem; }
.timeline::before {
  content: ""; position: absolute; left: 0.45rem; top: 0.4rem; bottom: 0.4rem; width: 2px;
  background: var(--accent); transform-origin: top;
}
.timeline::after {
  content: ""; position: absolute; left: 0.45rem; top: 0.4rem; bottom: 0.4rem; width: 2px;
  background: var(--line); z-index: -1;
}
.timeline li { position: relative; padding-bottom: 2.25rem; }
.timeline li::before {
  content: ""; position: absolute; left: -2.25rem; top: 0.35rem;
  width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--accent);
}
.timeline li.now::before { background: var(--warm); border-color: var(--warm); box-shadow: 0 0 0 5px var(--warm-soft); }
.timeline .when { font-family: var(--serif); color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline h3 { margin: 0.1rem 0 0.35rem; }
.timeline p { margin: 0; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4rem); }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.7rem 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; }
.plain-list li span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding-block: 2rem 3rem; color: var(--muted); font-size: 0.95rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 1.2rem; list-style: none; padding: 0; margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Motion ---------- */
.reveal { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
    .timeline::before { animation: draw linear both; animation-timeline: view(); animation-range: entry 40% cover 70%; }
  }
  @supports not (animation-timeline: view()) {
    .js .reveal { opacity: 0; transform: translateY(12px); transition: opacity 0.6s ease, transform 0.6s ease; }
    .js .reveal.in { opacity: 1; transform: none; }
  }
  .pub, .project { transition: opacity 0.25s ease; }
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes draw { from { transform: scaleY(0); } to { transform: scaleY(1); } }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.25s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
