/* davidpiccinato.com — shared styles. Light and dark themes, no build step. */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Theme ---------- */

:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --surface: #fffdf8;
  --text: #14181a;
  --muted: #59615e;
  --line: #e0dcd0;
  --accent: #0f766e;
  --accent-2: #c2660a;
  --accent-soft: rgb(15 118 110 / 0.1);
  --on-accent: #ffffff;
  --glow: 0.5;
  --shadow: 0 1px 2px rgb(20 24 26 / 0.04), 0 12px 32px -16px rgb(20 24 26 / 0.18);

  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #090e0f;
    --surface: #10181a;
    --text: #e9eeec;
    --muted: #95a29e;
    --line: #1e2a2c;
    --accent: #5eead4;
    --accent-2: #fbbf24;
    --accent-soft: rgb(94 234 212 / 0.1);
    --on-accent: #04201d;
    --glow: 0.32;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -18px rgb(0 0 0 / 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090e0f;
  --surface: #10181a;
  --text: #e9eeec;
  --muted: #95a29e;
  --line: #1e2a2c;
  --accent: #5eead4;
  --accent-2: #fbbf24;
  --accent-soft: rgb(94 234 212 / 0.1);
  --on-accent: #04201d;
  --glow: 0.32;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 16px 40px -18px rgb(0 0 0 / 0.7);
}

@view-transition { navigation: auto; }

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

main { flex: 1; }

::selection { background: var(--accent); color: var(--on-accent); }

a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

.wrap { width: 100%; max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 0.5rem 1rem; border-radius: 999px; text-decoration: none; font-weight: 500;
}
.skip:focus { top: 0.75rem; }

/* ---------- Backdrop: aurora + grid ---------- */

.aurora {
  position: absolute;
  inset: 0 0 auto 0;
  height: 52rem;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  --mx: -999px;
  --my: -999px;
}
.aurora.is-short { height: 30rem; }

.aurora .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: var(--glow);
  will-change: transform;
}
.aurora .b1 {
  width: 38rem; height: 26rem; left: -8rem; top: -10rem;
  background: radial-gradient(closest-side, var(--accent), transparent);
  animation: drift-a 22s ease-in-out infinite alternate;
}
.aurora .b2 {
  width: 30rem; height: 24rem; right: -6rem; top: -6rem;
  background: radial-gradient(closest-side, var(--accent-2), transparent);
  opacity: calc(var(--glow) * 0.7);
  animation: drift-b 26s ease-in-out infinite alternate;
}
.aurora .b3 {
  width: 34rem; height: 22rem; left: 30%; top: 10rem;
  background: radial-gradient(closest-side, var(--accent), transparent);
  opacity: calc(var(--glow) * 0.45);
  animation: drift-c 30s ease-in-out infinite alternate;
}

@keyframes drift-a { to { transform: translate3d(10rem, 5rem, 0) scale(1.15); } }
@keyframes drift-b { to { transform: translate3d(-9rem, 7rem, 0) scale(0.9); } }
@keyframes drift-c { to { transform: translate3d(-6rem, -5rem, 0) scale(1.2); } }

.aurora .grid,
.aurora .grid-glow {
  position: absolute;
  inset: 0;
  background-size: 56px 56px;
  background-position: center top;
}
.aurora .grid {
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, #000 25%, transparent 75%);
  mask-image: radial-gradient(ellipse 75% 70% at 50% 0%, #000 25%, transparent 75%);
  opacity: 0.8;
}
/* Grid lines light up near the pointer. */
.aurora .grid-glow {
  background-image:
    linear-gradient(to right, var(--accent) 1px, transparent 1px),
    linear-gradient(to bottom, var(--accent) 1px, transparent 1px);
  -webkit-mask-image: radial-gradient(260px circle at var(--mx) var(--my), #000, transparent 70%);
  mask-image: radial-gradient(260px circle at var(--mx) var(--my), #000, transparent 70%);
  opacity: 0.55;
}
.aurora::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to bottom, transparent, var(--bg));
}

/* ---------- Header ---------- */

header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .mark {
  width: 2rem; height: 2rem; flex: none;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  display: grid; place-items: center;
  transition: transform 0.4s var(--ease);
}
.brand:hover .mark { transform: rotate(-6deg) scale(1.06); }
.brand .mark svg { width: 1.3rem; height: 1.3rem; }

.site-nav { display: flex; align-items: center; gap: 0.15rem; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: color 0.2s, background-color 0.2s;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }

.theme-toggle {
  margin-left: 0.4rem;
  width: 2.4rem; height: 2.4rem; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.4s var(--ease);
}
.theme-toggle:hover { border-color: var(--accent); transform: rotate(18deg); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

@media (max-width: 540px) {
  .brand .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .site-nav a { padding: 0.4rem 0.65rem; }
}
@media (max-width: 26rem) {
  header.site .wrap { gap: 0.5rem; }
  .site-nav { gap: 0; }
  .site-nav a { padding: 0.4rem 0.5rem; font-size: 0.88rem; }
  .theme-toggle { margin-left: 0.15rem; }
}

/* ---------- Hero ---------- */

.hero { padding-block: clamp(3.5rem, 10vw, 7.5rem) clamp(3rem, 7vw, 5rem); }
.hero.is-page { padding-bottom: clamp(2rem, 5vw, 3.5rem); }

.hero-grid { display: grid; gap: 2rem; }
.portrait { margin: 0; order: -1; width: 9.5rem; }
.portrait img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: 1.25rem; border: 1px solid var(--line); box-shadow: var(--shadow);
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr) 19rem; gap: 4rem; align-items: center; }
  .portrait { order: 0; width: 100%; }
  .portrait img { border-radius: 1.75rem; }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.9rem 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.eyebrow .dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  100% { box-shadow: 0 0 0 0.6rem transparent; }
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.2rem, 11vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 1.5rem 0 1.5rem;
}
.hero.is-page h1 { font-size: clamp(2.7rem, 8vw, 5.25rem); line-height: 1; }
h1 em { font-style: italic; color: var(--accent); }

.lede {
  max-width: 38rem;
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 1.25rem;
}
.intro { max-width: 38rem; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 0.98rem;
  text-decoration: none;
  transition: transform 0.3s var(--ease), border-color 0.2s, box-shadow 0.3s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.btn svg { width: 1rem; height: 1rem; transition: transform 0.3s var(--ease); }
.btn:hover svg { transform: translateX(3px); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { border-color: var(--text); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: clamp(3rem, 7vw, 4.5rem) 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.stats > div { padding: 1.5rem 1rem 0 0; }
.stats > div + div { padding-left: clamp(0.9rem, 3vw, 2rem); border-left: 1px solid var(--line); }
.stats dt {
  font-family: var(--serif);
  font-size: clamp(2.3rem, 7vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats dt .plus { color: var(--accent); }
.stats dd { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.4; }

/* Hero entrance: CSS only, so it never depends on the script loading. */
.rise { animation: rise 0.9s var(--ease) both; animation-delay: calc(var(--d, 0) * 90ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ---------- Sections ---------- */

.section {
  display: grid;
  gap: 1.5rem;
  padding: clamp(2.75rem, 7vw, 4.5rem) 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 880px) {
  .section { grid-template-columns: 15rem minmax(0, 1fr); gap: 3.5rem; }
  .section > h2 { position: sticky; top: 6rem; align-self: start; }
}

h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 4vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
}
h2 .kicker {
  display: block;
  margin-bottom: 0.6rem;
  font: 500 0.78rem/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.prose { max-width: 42rem; }
.prose > * + .cards, .prose > * + .timeline { margin-top: 2rem; }

/* ---------- Articles ---------- */
.hero.is-page h1.is-article { font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.04; max-width: 20ch; }
.eyebrow a { color: inherit; }
.article { max-width: 42rem; padding-bottom: clamp(3rem, 8vw, 6rem); font-size: 1.08rem; }
.article h2 { font-size: clamp(1.6rem, 3.4vw, 2rem); margin: 2.6rem 0 0.9rem; }
.article ul { margin: 0 0 1.1em; padding-left: 1.25rem; }
.article li { margin-bottom: 0.5em; }
.article li::marker { color: var(--accent); }
.article-end { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.95rem; }

/* ---------- Cards (pointer spotlight) ---------- */

.cards { display: grid; gap: 1rem; list-style: none; padding: 0; margin: 0; }
@media (min-width: 640px) {
  .cards.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .cards.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

.card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.4s var(--ease), border-color 0.25s, box-shadow 0.4s;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity 0.35s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
a.card { display: block; height: 100%; color: inherit; text-decoration: none; }
a.card:hover { transform: translateY(-3px); }

.card h3 { font: 600 1.05rem/1.3 var(--sans); letter-spacing: -0.01em; margin-bottom: 0.5rem; }
.card p { color: var(--muted); font-size: 0.97rem; line-height: 1.6; }
.card .icon {
  width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  margin-bottom: 1.1rem;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card .icon svg { width: 1.25rem; height: 1.25rem; }
.card .num {
  display: block;
  margin-bottom: 0.9rem;
  font: 400 1.5rem/1 var(--serif);
  color: var(--accent);
}

/* Link cards */
.link-card { display: flex !important; align-items: center; gap: 1rem; padding: 1.15rem 1.25rem; }
.link-card .icon { margin: 0; flex: none; }
.link-card .label { display: block; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.link-card .sub { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 0.15rem; }
.link-card .go { margin-left: auto; flex: none; width: 1.1rem; height: 1.1rem; color: var(--muted); transition: transform 0.3s var(--ease), color 0.2s; }
.link-card:hover .go { transform: translate(3px, -3px); color: var(--accent); }

/* Feature card with a travelling border beam */
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.feature {
  position: relative;
  padding: clamp(1.6rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 55%),
    var(--surface);
  box-shadow: var(--shadow);
}
.feature::after {
  content: "";
  position: absolute;
  inset: -1px;
  padding: 1.5px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), transparent 0 68%, var(--accent) 86%, var(--accent-2) 96%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: beam 7s linear infinite;
  pointer-events: none;
}
@keyframes beam { to { --angle: 360deg; } }

.feature .tag {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.78rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent);
}
.feature h3 { font: 400 clamp(2rem, 5vw, 2.75rem)/1.05 var(--serif); letter-spacing: -0.015em; margin-bottom: 0.9rem; }
.feature p { max-width: 36rem; color: var(--muted); }
.feature .btn { margin-top: 1.5rem; }

/* ---------- Timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 0.42rem; top: 0.6rem; bottom: 0.6rem;
  width: 1px;
  background: linear-gradient(to bottom, var(--accent), var(--line) 30%, var(--line));
}
.timeline li { position: relative; padding: 0 0 2rem 2.25rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.5rem;
  width: 0.9rem; height: 0.9rem;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline li.now::before { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.timeline .when {
  display: block;
  font: 500 0.8rem/1.9 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.timeline h3 { font: 600 1.12rem/1.35 var(--sans); letter-spacing: -0.01em; margin-bottom: 0.4rem; }
.timeline p { color: var(--muted); }

/* ---------- Scroll reveal (only applied by the script, to off-screen items) ---------- */

.pre { opacity: 0; transform: translateY(18px); filter: blur(6px); }
.pre, .pre.is-in {
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease), filter 0.8s var(--ease);
  transition-delay: calc(var(--d, 0) * 80ms);
}
.pre.is-in { opacity: 1; transform: none; filter: none; }

/* ---------- Footer ---------- */

footer.site {
  border-top: 1px solid var(--line);
  padding: 2rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
footer.site .wrap {
  display: flex; flex-wrap: wrap; gap: 0.75rem 2rem;
  align-items: center; justify-content: space-between;
}
footer.site nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--text); }

/* ---------- 404 ---------- */

.lost { text-align: center; padding: clamp(5rem, 16vw, 10rem) 0; }
.lost .code { font: 400 clamp(6rem, 24vw, 13rem)/0.9 var(--serif); color: var(--accent); letter-spacing: -0.04em; }
.lost h1 { font-size: clamp(2rem, 6vw, 3.25rem); margin: 1rem 0; }
.lost p { color: var(--muted); }
.lost .actions { justify-content: center; }

/* ---------- Motion and print ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .pre { opacity: 1; transform: none; filter: none; }
  @view-transition { navigation: none; }
}

@media print {
  .aurora, header.site, footer.site nav, .theme-toggle, .actions { display: none; }
  body { background: #fff; color: #000; }
}
