/* www.federicoperini.info
   Personal brand: cool paper, ink, racing-red accent.
   FRESCO sections use the product's own palette (charcoal + cyan), set on .fresco. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202b;
  --muted: #52606d;
  --accent: #a3231c;
  --accent-strong: #7f1712;
  --accent-soft: #f4e3e1;
  --steel: #2f5d7c;
  --line: #dfe3e8;
  --figure-bg: #ffffff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1d2126;
    --ink: #eceae6;
    --muted: #a3acb5;
    --accent: #f0766a;
    --accent-strong: #f59a90;
    --accent-soft: #331d1b;
    --steel: #8fc1dc;
    --line: #2f353c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--surface); padding: 8px 12px; z-index: 20; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.15rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 1em; }
.kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.lede { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand {
  font-family: var(--serif); font-weight: 700; font-size: 1.2rem;
  color: var(--ink); text-decoration: none; margin-right: auto; white-space: nowrap;
}
.brand span { color: var(--accent); }
.site-header nav { display: flex; align-items: center; gap: 20px; }
.site-header nav a {
  color: var(--muted); text-decoration: none; font-size: 0.94rem; font-weight: 500; white-space: nowrap;
}
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--ink); }
.site-header nav a[aria-current]:not(.cta) { box-shadow: 0 2px 0 var(--accent); }
.site-header nav a.cta {
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 6px; font-weight: 600;
}
.site-header nav a.cta:hover { background: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .site-header nav a.cta, .btn.primary { color: #15181c; } }
@media (max-width: 860px) {
  .site-header .wrap { flex-wrap: wrap; gap: 0 16px; padding-top: 10px; }
  .site-header nav {
    order: 3; width: 100%; overflow-x: auto; gap: 20px; padding: 8px 0 12px;
    scrollbar-width: none;
  }
  .site-header .wrap { position: relative; }
  .site-header nav { padding-right: 0; }
  .site-header nav a.cta { position: absolute; right: 24px; top: 8px; }
}

/* ---------- buttons ---------- */
.btns { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 7px;
  text-decoration: none; font-weight: 600; font-size: 0.98rem; border: 1.5px solid transparent;
  cursor: pointer; font-family: inherit;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn.ghost:hover { border-color: var(--ink); }

/* ---------- sections ---------- */
section.block { padding: 72px 0; }
section.block.tight { padding: 48px 0; }
section.alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 62ch; margin-bottom: 36px; }
.section-head p { color: var(--muted); margin-top: 14px; }

.hero { padding: 72px 0 56px; }
.hero .wrap { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; }
.hero.single .wrap { display: block; }
.hero h1 { max-width: 18ch; }
.hero.single h1 { max-width: 24ch; }
.hero .lede { margin-top: 22px; }
@media (max-width: 860px) { .hero .wrap { grid-template-columns: 1fr; } .hero { padding: 48px 0 40px; } }

figure { margin: 0; }
figure.plate {
  background: var(--figure-bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  box-shadow: 0 18px 40px -28px rgb(28 39 51 / 0.45);
}
figure.plate img { border-radius: 6px; width: 100%; }
figcaption { font-size: 0.82rem; color: #55636f; margin-top: 10px; line-height: 1.45; }

/* proof strip */
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-block: 1px solid var(--line); }
.facts div { padding: 22px 20px; border-left: 1px solid var(--line); }
.facts div:first-child { border-left: 0; padding-left: 0; }
.facts strong { display: block; font-family: var(--serif); font-size: 1.9rem; line-height: 1.1; }
.facts span { color: var(--muted); font-size: 0.9rem; }
@media (max-width: 720px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
  .facts div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .facts div:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px;
  display: flex; flex-direction: column; gap: 10px; color: var(--ink); text-decoration: none;
}
section.alt .card { background: var(--bg); }
a.card { transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--ink); }
.card .tag {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--steel);
}
.card p { color: var(--muted); font-size: 0.96rem; margin: 0; flex: 1; }
.card .more { font-size: 0.9rem; font-weight: 600; color: var(--accent); }
.card ul { margin: 0; padding-left: 1.1em; color: var(--muted); font-size: 0.95rem; }
.card li { margin: 4px 0; }

/* two-column prose + aside */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.split.top { align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; gap: 28px; } }
.prose { max-width: 68ch; }
.prose h2 { margin: 1.6em 0 0.5em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin: 1.4em 0 0.4em; }
.prose p, .prose li { color: var(--muted); }
.prose strong { color: var(--ink); }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 6px 0; }

ul.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
ul.checks li { padding-left: 30px; position: relative; color: var(--muted); }
ul.checks li::before {
  content: ""; position: absolute; left: 0; top: 0.42em; width: 16px; height: 9px;
  border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent);
  transform: rotate(-45deg) scale(0.8);
}
ul.checks strong { color: var(--ink); }

ol.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; counter-reset: step; }
ol.steps li { counter-increment: step; border-top: 2px solid var(--ink); padding-top: 14px; }
ol.steps li::before { content: "0" counter(step); font-family: var(--mono); font-size: 0.8rem; color: var(--accent); }
ol.steps h3 { margin: 6px 0 8px; }
ol.steps p { color: var(--muted); font-size: 0.96rem; margin: 0; }

.topics { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.topics li {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 13px; font-size: 0.88rem; color: var(--muted);
}

/* confidentiality panel */
.assurance {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--surface); border-radius: 10px; padding: 32px 36px;
}
.assurance h2 { margin-bottom: 12px; }
.assurance > p { color: var(--muted); max-width: 66ch; }
.assurance ul.checks { margin-top: 22px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 32px; }
@media (max-width: 600px) { .assurance { padding: 24px 22px; } }

/* call to action band */
.cta-band { text-align: center; padding: 72px 0; }
.cta-band p { color: var(--muted); max-width: 54ch; margin: 14px auto 0; }
.cta-band .btns { justify-content: center; }

/* ---------- FRESCO (product palette) ---------- */
.fresco {
  --f-bg: #1c1e22; --f-panel: #25272d; --f-line: #3a3d44; --f-ink: #eceef2; --f-muted: #a0a4ac;
  --f-accent: #4dc9f6; --f-blue: #2a7cf0;
  background: radial-gradient(120% 140% at 15% 0%, #2a2d33 0%, var(--f-bg) 60%);
  color: var(--f-ink);
}
.fresco .kicker { color: var(--f-accent); }
.fresco p, .fresco li { color: var(--f-muted); }
.fresco a { color: var(--f-accent); }
.fresco h1, .fresco h2, .fresco h3 { font-family: var(--sans); letter-spacing: 0.01em; color: var(--f-ink); }
.fresco .wordmark { margin: 0; line-height: 1; display: flex; align-items: center; gap: 18px; }
.fresco .wordmark svg:not(.flame) { height: clamp(2.2rem, 5.5vw, 3.4rem); width: auto; display: block; color: #f2f4f7; }
.fresco .wordmark .flame { width: clamp(3rem, 7vw, 4.4rem); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fresco .motto { font-family: var(--serif); font-style: italic; color: #a6dcff; margin-top: 12px; }
.fresco .btn.primary { background: var(--f-accent); color: #10222b; }
.fresco .btn.primary:hover { background: #7bd7f8; }
.fresco .btn.ghost { border-color: var(--f-line); color: var(--f-ink); }
.fresco .btn.ghost:hover { border-color: var(--f-accent); }
.fresco .card { background: var(--f-panel); border-color: var(--f-line); color: var(--f-ink); }
.fresco .card .tag { color: var(--f-accent); }
.fresco .card p, .fresco .card ul { color: var(--f-muted); }
.fresco figure.plate { background: #0e1013; border-color: var(--f-line); box-shadow: none; }
.fresco figcaption { color: var(--f-muted); }
.fresco hr { border: 0; border-top: 1px solid var(--f-line); margin: 0; }
.fresco .status {
  display: inline-block; border: 1px solid var(--f-line); border-radius: 999px; padding: 4px 12px;
  font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.06em; color: var(--f-accent); margin-bottom: 18px;
}
.fresco-band { border-radius: 16px; padding: 44px 48px; }
@media (max-width: 600px) { .fresco-band { padding: 30px 24px; } }
.flame { width: 84px; height: auto; color: var(--f-accent); }
/* The FRESCO page wears the product palette from header to footer. */
body.fresco-page {
  --bg: #1c1e22; --surface: #25272d; --ink: #eceef2; --muted: #a0a4ac; --line: #3a3d44;
  --accent: #4dc9f6; --accent-strong: #7bd7f8; --steel: #4dc9f6;
  background: #1c1e22;
}
body.fresco-page .site-header nav a.cta { color: #10222b; }
body.fresco-page .site-footer { margin-top: 0; }

/* ---------- publications ---------- */
.pub-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.pub-toc a {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-size: 0.88rem;
  text-decoration: none; color: var(--muted); background: var(--surface);
}
.pub-toc a:hover { border-color: var(--accent); color: var(--accent); }
.pub-section { margin-bottom: 52px; scroll-margin-top: 90px; }
.pub-section h2 { font-size: 1.5rem; padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
.pub-section .count { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); vertical-align: middle; margin-left: 6px; }
ol.pubs { list-style: none; margin: 0; padding: 0; }
ol.pubs li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.pub-year { font-family: var(--mono); font-size: 0.85rem; color: var(--steel); padding-top: 3px; }
.pub-title { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.08rem; line-height: 1.35; }
.pub-authors, .pub-venue { display: block; color: var(--muted); font-size: 0.92rem; }
.pub-venue { font-style: italic; overflow-wrap: anywhere; }
.pub-links { display: flex; gap: 14px; margin-top: 6px; font-size: 0.86rem; font-weight: 600; }
@media (max-width: 560px) { ol.pubs li { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- contact ---------- */
form.contact { display: grid; gap: 18px; }
form.contact .row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 600px) { form.contact .row { grid-template-columns: 1fr; } }
form.contact label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
form.contact input, form.contact textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #b3bac3; border-radius: 7px; padding: 11px 13px; width: 100%;
}
form.contact textarea { min-height: 170px; resize: vertical; }
form.contact input:focus, form.contact textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
form.contact .hp { position: absolute; left: -9999px; }
form.contact .note { font-size: 0.86rem; color: var(--muted); margin: 0; }
.contact-aside { border-left: 1px solid var(--line); padding-left: 36px; }
.contact-aside h2 { font-size: 1.2rem; margin: 24px 0 6px; }
.contact-aside h2:first-child { margin-top: 0; }
.contact-aside p { color: var(--muted); font-size: 0.96rem; }
@media (max-width: 860px) { .contact-aside { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 28px; } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 48px 0 36px; color: var(--muted); font-size: 0.92rem; background: var(--bg); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.footer-grid h2 { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-weight: 500; }
.footer-grid a { display: block; color: var(--ink); text-decoration: none; padding: 3px 0; }
.footer-grid a:hover { color: var(--accent); }
.footer-grid p { margin-top: 10px; }
.legal { border-top: 1px solid var(--line); padding-top: 20px; margin: 0; font-size: 0.85rem; }
.legal a { color: var(--muted); }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.fresco-band { border: 1px solid #3a3d44; }

/* ---------- books, open source ---------- */
.book { display: grid; grid-template-columns: 300px 1fr; gap: 48px; align-items: start; }
.book img { border-radius: 4px; box-shadow: 0 24px 48px -24px rgb(23 32 43 / 0.55); border: 1px solid var(--line); }
.book dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 20px 0 0; font-size: 0.94rem; }
.book dt { color: var(--muted); }
.book dd { margin: 0; }
@media (max-width: 720px) { .book { grid-template-columns: 1fr; } .book img { max-width: 240px; } }
.repo-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 40px; list-style: none; padding: 0; margin: 0; }
.repo-list li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.repo-list a { font-family: var(--mono); font-size: 0.95rem; font-weight: 600; text-decoration: none; }
.repo-list a:hover { text-decoration: underline; }
.repo-list span { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 2px; }
.repo-list em { font-style: normal; font-family: var(--mono); font-size: 0.72rem; color: var(--steel); margin-left: 8px; }
figure.shot { background: #1c1e22; padding: 0; overflow: hidden; }
figure.shot img { border-radius: 0; }
figure.shot figcaption { padding: 10px 14px 12px; margin: 0; color: #a0a4ac; }
.shots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.shots figure.plate { display: flex; flex-direction: column; }
.shots img { aspect-ratio: 4 / 3; object-fit: cover; object-position: top left; border: 1px solid #dfe3e8; }
@media (max-width: 720px) { .shots { grid-template-columns: 1fr; } }
