/* ---------- Fonts (self-hosted, SIL Open Font License, Latin subset) ---------- */
@font-face {
  font-family: "Bodoni Moda";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/bodoni-moda-roman.woff2") format("woff2");
}
@font-face {
  font-family: "Bodoni Moda";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/bodoni-moda-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("assets/fonts/hanken-grotesk.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  --paper: #F3F4F0;
  --surface: #FAFBF8;
  --frame: #E6E8E2;
  --ink: #16181D;
  --muted: #555B66;
  --rule: #D2D5CD;
  --accent: #2338C8;
  --accent-hover: #1A2A9E;
  --accent-ink: #FFFFFF;
  --shadow: rgba(22, 24, 29, 0.28);

  /* Ultramarine band and inverted blocks */
  --band: #2338C8;
  --band-ink: #F4F5FF;
  --inv-accent: #6F87FF;

  --serif: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --step-3: clamp(2.75rem, 1.5rem + 5.5vw, 6.5rem);

  --nav-h: 3.75rem;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111318;
    --surface: #171A20;
    --frame: #1D2129;
    --ink: #ECEDE7;
    --muted: #A1A6B0;
    --rule: #2D313A;
    --accent: #6F87FF;
    --accent-hover: #93A6FF;
    --accent-ink: #0E1330;
    --shadow: rgba(0, 0, 0, 0.6);
    --band: #1E2B9C;
    --band-ink: #F4F5FF;
    --inv-accent: #2338C8;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #111318;
  --surface: #171A20;
  --frame: #1D2129;
  --ink: #ECEDE7;
  --muted: #A1A6B0;
  --rule: #2D313A;
  --accent: #6F87FF;
  --accent-hover: #93A6FF;
  --accent-ink: #0E1330;
  --shadow: rgba(0, 0, 0, 0.6);
  --band: #1E2B9C;
  --band-ink: #F4F5FF;
  --inv-accent: #2338C8;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, video { display: block; max-width: 100%; height: auto; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

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

.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: -3rem; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: .6rem 1rem; border-radius: 6px; text-decoration: none;
}
.skip:focus { top: 1rem; }

.wrap {
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease;
}
@supports (backdrop-filter: blur(8px)) {
  .nav {
    background: color-mix(in srgb, var(--paper) 86%, transparent);
    backdrop-filter: blur(12px) saturate(1.2);
  }
}
.nav.is-scrolled { border-bottom-color: var(--rule); }

.nav-inner {
  height: var(--nav-h);
  display: flex; align-items: center; gap: 1rem;
}

.monogram {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.375rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  margin-right: auto;
}

.nav-links { display: flex; gap: clamp(.9rem, 3vw, 2rem); }
.nav-links a {
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: none;
  padding-block: .4rem;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .25s ease;
}
.nav-links a:hover { background-size: 100% 1px; }

.theme-toggle {
  display: grid; place-items: center;
  width: 2.5rem; height: 2.5rem;
  margin-right: -.5rem;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--frame); }
.theme-toggle svg { transition: transform .4s ease; }
:root[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(2rem, 6vw, 4.5rem) clamp(4rem, 9vw, 7rem); }

.hero-grid {
  display: grid;
  grid-template-areas: "name" "body" "proof";
  gap: clamp(2rem, 5vw, 3.5rem);
}

.name {
  grid-area: name;
  font-family: var(--serif);
  font-weight: 500;
  /* A text-size optical cut keeps the hairlines solid at display sizes. */
  font-variation-settings: "opsz" 28;
  font-size: clamp(4.25rem, 18vw, 15rem);
  line-height: 0.84;
  letter-spacing: -0.025em;
  margin-left: -0.04em;
}

/* Each line is a specimen row: letters rise from below a drawn baseline. */
.name-line {
  position: relative;
  display: block;
  width: fit-content;
  padding: 0.06em 0.08em 0.2em 0;
  overflow: hidden;
  white-space: nowrap;
}
.name-line > span:not(.bl):not(.xh) { display: inline-block; }

.name-line .bl,
.name-line .xh {
  position: absolute; left: 0; right: -0.25em;
  height: 0; pointer-events: none;
  transform-origin: left center;
}
.name-line .bl { bottom: 0.2em; border-top: 2px solid var(--accent); }
.name-line .xh { bottom: 0.66em; border-top: 1px dashed var(--rule); }

@media (prefers-reduced-motion: no-preference) {
  .name-line > span:not(.bl):not(.xh) {
    transform: translateY(115%);
    animation: rise .9s cubic-bezier(.2, .7, .1, 1) forwards;
    animation-delay: calc(350ms + var(--i) * 55ms);
  }
  .name-line .bl,
  .name-line .xh {
    transform: scaleX(0);
    animation: draw 1.1s cubic-bezier(.6, 0, .2, 1) forwards;
  }
  .name-line .xh { animation-delay: 150ms; }
  .name-line + .name-line .bl { animation-delay: 220ms; }
  .name-line + .name-line .xh { animation-delay: 300ms; }

  .hero-body, .proof {
    opacity: 0;
    animation: fade .8s ease forwards;
    animation-delay: 1.15s;
  }
  .proof { animation-delay: 1.3s; }
}

@keyframes rise { to { transform: translateY(0); } }
@keyframes draw { to { transform: scaleX(1); } }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-body { grid-area: body; display: grid; gap: 1.5rem; }
.status {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  line-height: 1.12;
  font-weight: 500;
  letter-spacing: -0.01em;
  max-width: 16em;
}
.intro { color: var(--muted); max-width: 32em; }
.aside { margin-top: .5rem; color: var(--muted); }
.hero .actions { margin-top: 1.75rem; }

/* Shipped: a colophon beside the name */
.proof { grid-area: proof; border-top: 1px solid var(--ink); padding-top: 1rem; }
.proof-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--step-1);
  margin-bottom: .5rem;
}
.proof-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding-block: .6rem;
  border-bottom: 1px solid var(--rule);
}
.proof-list a {
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.2;
  text-decoration: none;
  transition: color .2s ease;
}
.proof-list a:hover { color: var(--accent); font-style: italic; }
.proof-list span { color: var(--muted); font-size: var(--step--1); text-align: right; }

@media (min-width: 900px) {
  .hero-body { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
}

@media (min-width: 1180px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr) 19rem;
    grid-template-areas: "name proof" "body body";
    column-gap: 3rem;
  }
  .name { font-size: clamp(10rem, 14.5vw, 14.5rem); }
  .proof { align-self: start; margin-top: 1.4rem; }
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.875rem;
  padding: .7rem 1.35rem;
  border-radius: 6px;
  font-weight: 600; font-size: 1rem; line-height: 1.2;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--ink); color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }

/* ---------- Sections ---------- */
.section { padding-block: clamp(4rem, 10vw, 8rem); }

.section-head {
  display: grid; gap: 1.25rem;
  margin-bottom: clamp(2.5rem, 6vw, 4.5rem);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--ink);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-3);
  line-height: 0.92;
  letter-spacing: -0.02em;
}
.section-head p { color: var(--muted); max-width: 30em; }

@media (min-width: 900px) {
  .section-head { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: end; }
}

/* ---------- Frames and screenshots ---------- */
.frame {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 30px 60px -40px var(--shadow);
  transition: transform .35s cubic-bezier(.2, .7, .1, 1), box-shadow .35s ease, border-color .35s ease;
}
.frame-bar {
  display: flex; align-items: center; gap: .75rem;
  height: 2.25rem;
  padding-inline: .85rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}
.dots { display: flex; gap: 6px; flex-shrink: 0; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); }
.address {
  flex: 1; min-width: 0;
  max-width: 24rem; margin-inline: auto;
  padding: .15rem .8rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-size: .75rem; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Empty state: a large Bodoni italic initial until the real screenshot arrives. */
.shot {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--frame);
  overflow: hidden;
  container-type: inline-size;
}
.shot::before {
  content: attr(data-glyph);
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15rem;
  font-size: 56cqi;
  line-height: 1;
  color: var(--rule);
}
.shot img, .shot video {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
  color: transparent; /* hides alt text while the file is missing */
}
.js .shot img:not(.is-loaded) { visibility: hidden; }
.band .shot { aspect-ratio: 1898 / 925; }
.shot-contain img { object-fit: contain; background: var(--shot-bg, var(--frame)); }
.shot-empty {
  position: absolute; left: 1rem; bottom: 1rem; z-index: 0;
  color: var(--muted);
  font-size: .8125rem;
}

/* ---------- InstallerQuote band ---------- */
.band {
  background: var(--band);
  color: var(--band-ink);
  padding-block: clamp(3.5rem, 9vw, 7rem);
  margin-bottom: clamp(4.5rem, 10vw, 7rem);
  --ink: var(--band-ink);
  --muted: color-mix(in srgb, var(--band-ink) 78%, var(--band));
  --accent: var(--band-ink);
  --accent-ink: var(--band);
  --accent-hover: #FFFFFF;
}
.band .frame {
  --rule: #D2D5CD;
  --surface: #FAFBF8;
  --paper: #F3F4F0;
  --frame: #E6E8E2;
  --muted: #555B66;
  border-color: transparent;
  box-shadow: 0 50px 90px -40px rgba(5, 8, 40, 0.6);
}
.band .btn-ghost:hover { background: var(--band-ink); color: var(--band); }
.band .facts { border-color: color-mix(in srgb, var(--band-ink) 30%, transparent); }

.feature { display: grid; gap: 2.5rem; }
.feature-text { display: grid; gap: 1rem; align-content: start; }
.feature-text h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.75rem, 1.6rem + 4vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.kind { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: var(--step-1); line-height: 1.3; }
.feature-text .actions { margin-top: .75rem; }

@media (min-width: 960px) {
  .feature {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: clamp(2.5rem, 5vw, 4.5rem);
    align-items: center;
  }
}

.facts { display: grid; gap: .4rem; padding-block: .9rem; border-block: 1px solid var(--rule); }
.facts div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; font-size: .9375rem; }
.facts dt { color: var(--muted); }

/* ---------- Other featured ---------- */
.pair { display: grid; gap: 4.5rem; }
.project { display: grid; gap: 1rem; align-content: start; }
.project .frame { margin-bottom: .75rem; }
.project h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 1.5rem + 1.8vw, 3rem);
  line-height: 1;
  letter-spacing: -0.015em;
}
.project .actions { margin-top: .25rem; }
.private-note { color: var(--muted); font-size: .9375rem; }

@media (min-width: 760px) {
  .pair { grid-template-columns: 1fr 1fr; gap: clamp(2rem, 4vw, 3.5rem); }
  .pair > :nth-child(2) { margin-top: clamp(4rem, 9vw, 8rem); }
}

@media (hover: hover) {
  .feature:hover .frame,
  .project:hover .frame {
    transform: translateY(-6px) rotate(-0.4deg);
    box-shadow: 0 50px 80px -40px var(--shadow);
  }
  .project:hover h3 { font-style: italic; }
}

/* ---------- Everything else ---------- */
.more { margin-top: clamp(5rem, 11vw, 8rem); }
.more-title {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: var(--step-2);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ink);
}

.index li { border-bottom: 1px solid var(--rule); }
.row {
  position: relative;
  display: grid; gap: .35rem;
  padding: 1.25rem 0;
  text-decoration: none;
  isolation: isolate;
}
.row::before {
  content: "";
  position: absolute; inset: 0 -1rem; z-index: -1;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform .3s cubic-bezier(.2, .7, .1, 1);
}
.row-title {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: transform .3s cubic-bezier(.2, .7, .1, 1);
}
.row-desc { color: var(--muted); max-width: 40em; }
.row-stack { font-size: var(--step--1); color: var(--muted); }

.row:hover::before, .row:focus-visible::before { transform: scaleY(1); }
.row:hover, .row:focus-visible { color: var(--accent-ink); }
.row:hover .row-desc, .row:hover .row-stack,
.row:focus-visible .row-desc, .row:focus-visible .row-stack { color: inherit; }
.row:hover .row-title, .row:focus-visible .row-title { font-style: italic; transform: translateX(.5rem); }

@media (min-width: 860px) {
  .row {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) 10rem;
    gap: 2rem;
    align-items: baseline;
    padding-block: 1.5rem;
  }
  .row-stack { text-align: right; }
}

.github-line { margin-top: 2rem; }
.github-line a {
  font-family: var(--serif);
  font-size: var(--step-2);
  font-style: italic;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}
.github-line a:hover { color: var(--accent); }

/* ---------- Education ---------- */
.timeline li {
  display: grid; gap: .5rem;
  padding-block: 2rem;
  border-bottom: 1px solid var(--rule);
}
.when { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: var(--step-1); }
.yr {
  display: block;
  font-style: normal;
  font-weight: 500;
  font-size: clamp(3rem, 2rem + 4vw, 5.5rem);
  line-height: 0.9;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.timeline h3 { font-family: var(--serif); font-weight: 500; font-size: var(--step-2); line-height: 1.15; }
.timeline p { max-width: 40em; }
.timeline .note { margin-top: .5rem; color: var(--muted); }
.timeline .note a:hover { color: var(--accent); }

@media (min-width: 760px) {
  .timeline li { grid-template-columns: minmax(14rem, 1fr) 2fr; gap: 2.5rem; align-items: start; }
}

/* ---------- Contact and footer (inverted) ---------- */
.inverse {
  background: var(--ink);
  color: var(--paper);
}
.contact {
  padding-block: clamp(4.5rem, 11vw, 9rem) clamp(3rem, 7vw, 5rem);
  --accent: var(--inv-accent);
}
.contact .section-head { border-bottom-color: color-mix(in srgb, var(--paper) 35%, transparent); }
.contact .section-head p { color: color-mix(in srgb, var(--paper) 72%, var(--ink)); }

.mail {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 0.4rem + 7.4vw, 7.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.mail a {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.14em;
  transition: color .2s ease;
}
.mail a:hover { color: var(--accent); font-style: italic; }

.elsewhere { display: flex; flex-wrap: wrap; gap: .75rem 2.5rem; margin-top: 2.5rem; }
.elsewhere a {
  font-family: var(--serif);
  font-size: var(--step-2);
  text-decoration-color: color-mix(in srgb, var(--paper) 40%, transparent);
}
.elsewhere a:hover { color: var(--accent); font-style: italic; text-decoration-color: currentColor; }

.footer {
  padding-block: 1.5rem 2rem;
  font-size: var(--step--1);
  color: color-mix(in srgb, var(--paper) 70%, var(--ink));
}
.footer-inner {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--paper) 25%, transparent);
}

.contact :focus-visible, .band :focus-visible { outline-color: currentColor; }

/* ---------- 404 ---------- */
.notfound { padding-block: clamp(3rem, 10vw, 7rem) clamp(4rem, 12vw, 9rem); }
.notfound-code {
  font-family: var(--serif);
  font-weight: 500;
  font-variation-settings: "opsz" 28;
  font-size: clamp(7rem, 30vw, 20rem);
  line-height: 0.8;
  letter-spacing: -0.03em;
  width: fit-content;
  padding-bottom: 0.08em;
  border-bottom: 2px solid var(--accent);
}
.notfound h1 {
  margin-top: 2.5rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-3);
  line-height: 1;
  letter-spacing: -0.02em;
}
.notfound h1 + p { margin-top: 1.25rem; color: var(--muted); max-width: 32em; }
.notfound .actions { margin-top: 2rem; }

/* ---------- Scroll reveal (only when JS runs and motion is welcome) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .1, 1);
  }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
