/* ============================================================
   Angelo Rizzieri — portfolio
   Plain CSS, no build step. Tokens first, then layout.
   ============================================================ */

/* ---------- tokens: light ---------- */
:root {
  --bg:        #efece4;
  --surface:   #f7f5f0;
  --raised:    #e6e2d8;
  --text:      #14171a;
  --text-2:    #545c63;
  --text-3:    #838a91;
  --border:    #d8d3c8;
  --border-2:  #bfb9ac;
  --accent:    #1d4e89;
  --accent-2:  #143a68;
  --accent-bg: rgba(29, 78, 137, 0.07);
  --on-accent: #ffffff;
  --shadow:    0 1px 2px rgba(20, 22, 25, 0.04), 0 6px 20px -12px rgba(20, 22, 25, 0.18);

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

  --measure: 44rem;
  --gutter:  clamp(1.25rem, 5vw, 2.5rem);
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0b0e10;
    --surface:   #12161a;
    --raised:    #191e23;
    --text:      #e8e5e0;
    --text-2:    #9aa1a7;
    --text-3:    #6c7379;
    --border:    #222830;
    --border-2:  #313943;
    --accent:    #8fb6e8;
    --accent-2:  #a9c8f0;
    --accent-bg: rgba(143, 182, 232, 0.10);
  --on-accent: #0b0e10;
    --shadow:    0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px -12px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  --bg:        #0b0e10;
  --surface:   #12161a;
  --raised:    #191e23;
  --text:      #e8e5e0;
  --text-2:    #9aa1a7;
  --text-3:    #6c7379;
  --border:    #222830;
  --border-2:  #313943;
  --accent:    #8fb6e8;
  --accent-2:  #a9c8f0;
  --accent-bg: rgba(143, 182, 232, 0.10);
  --on-accent: #0b0e10;
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px -12px rgba(0, 0, 0, 0.7);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* class-based display rules below would otherwise beat the UA [hidden] rule */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
  font-feature-settings: "cv05" 1, "ss03" 1;  /* single-storey l, curved r: fewer look-alikes */
}

h1, h2, h3 {
  font-family: var(--serif); font-weight: 600; line-height: 1.2;
  margin: 0; letter-spacing: -0.01em;
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 20, "WONK" 1;
}
p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--text);
  padding: 0.6rem 1rem; border: 1px solid var(--border); z-index: 100;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.topbar.scrolled { border-bottom-color: var(--border); }

.topbar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex; align-items: center; gap: 1.25rem;
}

.mark {
  font-family: var(--serif); font-size: 1.05rem; font-weight: 600;
  letter-spacing: 0.06em; margin-right: auto;
}
.mark:hover { color: var(--accent); }

.navlinks { display: flex; gap: 1.35rem; }
.navlinks a {
  font-size: 0.845rem; color: var(--text-2);
  letter-spacing: 0.01em; transition: color 0.15s ease;
}
.navlinks a:hover { color: var(--text); }
@media (max-width: 620px) { .navlinks { display: none; } }

.theme-toggle {
  width: 30px; height: 30px; padding: 0; flex: none;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-2); cursor: pointer;
  font-size: 0.8rem; line-height: 1;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-2); }

/* ---------- sections ---------- */
main { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }

section { padding: 3.75rem 0; border-top: 1px solid var(--border); }
section:first-child { border-top: 0; }

.section-title {
  font-size: 0.78rem; font-family: var(--sans); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--text-2); margin-bottom: 2.25rem;
  display: flex; align-items: baseline; gap: 0.7rem;
}
.idx { font-family: var(--mono); font-size: 0.72rem; color: var(--accent); letter-spacing: 0; }

/* ---------- hero ---------- */
.hero { padding-top: 4.5rem; padding-bottom: 3.5rem; }

.eyebrow {
  font-size: 0.78rem; letter-spacing: 0.06em; color: var(--text-2);
  text-transform: uppercase; margin-bottom: 1rem;
}
.hero h1 {
  font-size: clamp(2.6rem, 8vw, 3.9rem);
  letter-spacing: -0.028em;
  margin-bottom: 1.15rem;
}
.lede {
  font-size: 1.075rem; color: var(--text-2);
  max-width: 38rem; margin-bottom: 2rem;
}
.lede strong { color: var(--text); font-weight: 600; }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-size: 0.855rem; font-weight: 500;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border-2); border-radius: 999px;
  color: var(--text-2); background: var(--surface);
  cursor: pointer; font-family: inherit;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.btn span { font-size: 0.75em; opacity: 0.6; }
.btn:hover {
  color: var(--text); border-color: var(--text-3);
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--text); color: var(--bg); border-color: var(--text);
}
.btn-primary:hover {
  background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent);
}
.btn-primary span { opacity: 0.75; }

/* ---------- projects ---------- */
.projects { display: flex; flex-direction: column; gap: 2.6rem; }

.project {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1.6rem 1.7rem 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.project:hover { border-color: var(--border-2); }

.project-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.project-head h3 { font-size: 1.35rem; }

.when {
  font-family: var(--mono); font-size: 0.735rem;
  color: var(--text-3); letter-spacing: 0.01em; white-space: nowrap;
}

.project-sub {
  font-size: 0.9rem; color: var(--text-3);
  margin: 0.25rem 0 0.9rem;
}
.project-body { color: var(--text-2); font-size: 0.955rem; }

.tags {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 1.15rem 0 1.15rem;
}
.tags li {
  font-family: var(--mono); font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--raised); color: var(--text-2);
}

.project-links { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.project-links a {
  font-size: 0.875rem; font-weight: 500; color: var(--accent);
  border-bottom: 1px solid transparent; transition: border-color 0.15s ease;
}
.project-links a:hover { border-bottom-color: currentColor; }

.note {
  margin-top: 1.1rem; padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
  font-size: 0.83rem; color: var(--text-3); line-height: 1.55;
}

/* ---------- inline diagrams ----------
   Deliberately plain: square corners, monospace labels, hairline rules. */
.diagram { margin: 1.5rem 0 0; }
.diagram svg { width: 100%; height: auto; display: block; overflow: visible; }

.diagram .node rect { fill: var(--raised); stroke: var(--border-2); stroke-width: 1; }
.diagram .node text {
  fill: var(--text-2); font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.04em; text-anchor: middle; dominant-baseline: middle;
}
.diagram .node.accent rect { fill: var(--accent-bg); stroke: var(--accent); }
.diagram .node.accent text { fill: var(--accent); }

.diagram .edge { fill: none; stroke: var(--border-2); stroke-width: 1.25; }
.diagram .edge.dash { stroke-dasharray: 4 3; }
.diagram .ah { fill: var(--border-2); }
.diagram .edgelabel,
.diagram .cap {
  fill: var(--text-3); font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-anchor: middle;
}

/* page mock, used by the Site Memory diagram */
.diagram .page { fill: var(--surface); stroke: var(--border-2); stroke-width: 1; }
.diagram .textline { fill: var(--border-2); }
.diagram .mark { fill: var(--accent); opacity: 0.45; }

.diagram figcaption {
  margin-top: 0.75rem; font-size: 0.8rem; color: var(--text-3); line-height: 1.5;
}

/* ---------- research ---------- */
.papers { display: flex; flex-direction: column; gap: 2.4rem; }

.paper { padding-left: 1.15rem; border-left: 2px solid var(--border); }
.paper-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.paper-head h3 { font-size: 1.16rem; line-height: 1.35; }

.badge {
  font-family: var(--mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0.18rem 0.5rem; border-radius: 4px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  white-space: nowrap;
}
.paper-meta {
  font-size: 0.83rem; color: var(--text-3);
  margin: 0.4rem 0 0.7rem;
}
.paper-body { font-size: 0.94rem; color: var(--text-2); margin-bottom: 0.85rem; }

/* ---------- experience ---------- */
.timeline { display: flex; flex-direction: column; gap: 2.4rem; }

.entry-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.85rem;
}
.entry-head h3 { font-size: 1.1rem; }
.role { font-size: 0.885rem; color: var(--text-2); margin-top: 0.1rem; }

.bullets { display: flex; flex-direction: column; gap: 0.55rem; }
.bullets li {
  position: relative; padding-left: 1.1rem;
  font-size: 0.93rem; color: var(--text-2);
}
.bullets li::before {
  content: ""; position: absolute; left: 0; top: 0.62em;
  width: 4px; height: 4px; border-radius: 50%; background: var(--border-2);
}

/* ---------- background grid ---------- */
.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 620px) { .grid { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); padding: 1.35rem 1.4rem;
}
.card.wide { grid-column: 1 / -1; }
.card h3 {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-3); margin-bottom: 0.9rem;
}
.card-lead { font-size: 0.95rem; font-weight: 500; }
.card-sub { font-size: 0.89rem; color: var(--text-2); margin-top: 0.2rem; }
.card-meta { font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); margin: 0.45rem 0 0.7rem; }
.card-body { font-size: 0.87rem; color: var(--text-2); line-height: 1.6; }

.plain { display: flex; flex-direction: column; gap: 0.7rem; }
.plain li { font-size: 0.89rem; color: var(--text-2); }
.plain strong { color: var(--text); font-weight: 600; }
.when-inline { font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); }

.skills { display: flex; flex-direction: column; gap: 0.7rem; margin: 0; }
.skills > div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.75rem; }
@media (max-width: 620px) { .skills > div { grid-template-columns: 1fr; gap: 0.15rem; } }
.skills dt {
  font-family: var(--mono); font-size: 0.73rem; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.15em;
}
.skills dd { margin: 0; font-size: 0.885rem; color: var(--text-2); }

/* ---------- contact ---------- */
.contact-lede { font-size: 1rem; color: var(--text-2); max-width: 34rem; margin-bottom: 1.5rem; }

.contact-row {
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; margin-bottom: 1.5rem;
}
.email {
  font-family: var(--mono); font-size: clamp(0.9rem, 3.2vw, 1.08rem);
  color: var(--text); letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border-2); padding-bottom: 0.15rem;
}
a.email:hover { color: var(--accent); border-bottom-color: var(--accent); }
.btn-copy { padding: 0.32rem 0.7rem; font-size: 0.78rem; }

/* ---------- footer ---------- */
footer {
  max-width: var(--measure); margin: 0 auto;
  padding: 2rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-3);
}

/* ---------- reveal on scroll ----------
   Scoped to html.js so the page is fully visible if JS never runs. */
.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.in {
  opacity: 1; transform: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
  .js .reveal.in { transition: none; }
  .btn:hover { transform: none; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .theme-toggle, .actions, .btn-copy { display: none; }
  body { background: #fff; color: #000; }
  section { break-inside: avoid; }
}
