/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0d0e10;
  --bg-2: #141518;
  --panel: #17191d;
  --line: #262930;
  --line-2: #33373f;
  --ink: #ecebe6;
  --ink-2: #a9a8a2;
  --ink-3: #6f6e6a;
  --signal: #ff5b1f;          /* the one accent: detection-box orange */
  --signal-soft: rgba(255, 91, 31, 0.12);
  --ok: #7fd18b;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Geist", ui-sans-serif, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --radius: 4px;
  --max: 1180px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f2ec; --bg-2: #ecE9e1; --panel: #fbfaf6; --line: #dcd8cd; --line-2: #c9c4b6;
    --ink: #17181a; --ink-2: #4c4b47; --ink-3: #85837c; --signal: #e0480f;
    --signal-soft: rgba(224, 72, 15, 0.10); --ok: #2f8a3e; color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
  background-attachment: fixed;
}
body::before {                 /* fade the measurement grid toward the bottom */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(120% 80% at 50% 0%, transparent 30%, var(--bg) 75%);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.mono { font-family: var(--mono); letter-spacing: -0.01em; }
a { color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: var(--signal); color: #0d0e10; }

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px); backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); border-bottom: 1px solid var(--line);
}
.mark { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 14px; }
.mark-box { width: 16px; height: 16px; border: 2px solid var(--signal); position: relative; }
.mark-box::after { content: ""; position: absolute; inset: 3px; background: var(--signal); }
nav { display: flex; gap: clamp(12px, 2.5vw, 28px); font-size: 14px; }
nav a { text-decoration: none; color: var(--ink-2); transition: color .2s; }
nav a:hover { color: var(--ink); }
.nav-gh { color: var(--signal) !important; }

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  max-width: var(--max); margin: 0 auto; padding: clamp(80px, 14vh, 150px) clamp(16px, 4vw, 40px) 70px;
}
.eyebrow { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 10px; margin: 0 0 28px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.hero-name {
  position: relative; display: inline-block; margin: 0; padding: .12em .22em .02em;
  font: 400 clamp(56px, 11vw, 148px)/0.92 var(--serif); letter-spacing: -0.02em;
}
/* The detection box drawn around the name */
.bbox { position: absolute; inset: 0; border: 1.5px solid var(--signal); clip-path: inset(0 100% 100% 0);
  animation: draw 1.1s cubic-bezier(.7,0,.2,1) .55s forwards; }
.bbox-label {
  position: absolute; left: -1.5px; bottom: 100%; transform: translateY(-2px);
  background: var(--signal); color: #0d0e10; font-size: 13px; line-height: 1; padding: 6px 8px; white-space: nowrap;
}
.bbox-label b { font-weight: 500; }
.c { position: absolute; width: 14px; height: 14px; border: 3px solid var(--signal); }
.c.tl { top: -5px; left: -5px; border-right: 0; border-bottom: 0; }
.c.tr { top: -5px; right: -5px; border-left: 0; border-bottom: 0; }
.c.bl { bottom: -5px; left: -5px; border-right: 0; border-top: 0; }
.c.br { bottom: -5px; right: -5px; border-left: 0; border-top: 0; }
@keyframes draw {
  0% { clip-path: inset(0 100% 100% 0); }
  50% { clip-path: inset(0 0 100% 0); }
  100% { clip-path: inset(-40px -10px -10px -10px); }
}
.hero-focus { margin: 34px 0 0; font: italic 400 clamp(26px, 3.4vw, 40px)/1.15 var(--serif); color: var(--ink-2); }
.hero-focus em { color: var(--ink); font-style: italic; }
.hero-focus .sep { color: var(--signal); font-style: normal; margin: 0 .3em; }
.hero-tag { max-width: 640px; margin: 22px 0 0; font-size: 18px; color: var(--ink-2); }

.readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 56px 0 0;
  border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.readings div { padding: 18px 18px 16px; border-left: 1px solid var(--line); }
.readings div:first-child { border-left: 0; padding-left: 0; }
.readings dt { font: 400 11px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.readings dd { margin: 6px 0 0; font: 400 clamp(30px, 4vw, 44px)/1 var(--serif); }
.readings dd small { font: 400 13px var(--mono); color: var(--signal); margin-left: 4px; }
.machine { margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-2); }
.machine span { color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; margin-right: 12px; }

/* ─── Sections ───────────────────────────────────────────────────────────── */
.section { max-width: var(--max); margin: 0 auto; padding: 90px clamp(16px, 4vw, 40px) 20px; }
.section-head { display: grid; grid-template-columns: 56px 1fr; column-gap: 12px; align-items: baseline; margin-bottom: 38px; }
.idx { color: var(--signal); font-size: 13px; }
.section h2 { margin: 0; font: 400 clamp(38px, 5vw, 60px)/1 var(--serif); letter-spacing: -0.01em; }
.lede { grid-column: 2; margin: 12px 0 0; color: var(--ink-2); max-width: 620px; }
.depth-key { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ─── Featured ───────────────────────────────────────────────────────────── */
.featured { display: grid; gap: 22px; }
.feat {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.feat:nth-child(even) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.feat:nth-child(even) .feat-media { order: 2; border-left: 1px solid var(--line); border-right: 0; }
.feat-body { padding: clamp(24px, 3.5vw, 44px); display: flex; flex-direction: column; gap: 14px; }
.feat-kicker { font: 400 12px/1.4 var(--mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.feat h3 { margin: 0; font: 400 clamp(34px, 4vw, 52px)/1 var(--serif); }
.feat p { margin: 0; color: var(--ink-2); }
.feat-media { position: relative; min-height: 300px; background: var(--bg-2); border-right: 1px solid var(--line); overflow: hidden; }
.feat-media img { width: 100%; height: 100%; object-fit: cover; object-position: top left; filter: saturate(.9); transition: transform .6s ease; }
.feat:hover .feat-media img { transform: scale(1.03); }
.feat-media img[src$=".svg"] { object-fit: contain; object-position: center; background: #0d0e10; }
.diagram { height: 100%; display: flex; align-items: center; padding: 28px; overflow-x: auto; background:
  repeating-linear-gradient(0deg, transparent 0 27px, var(--line) 27px 28px); }
.diagram pre { margin: 0; font: 400 clamp(11px, 1.15vw, 14px)/1.9 var(--mono); color: var(--ink-2); white-space: pre; }
.diagram b { color: var(--signal); font-weight: 400; }

.reading { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--line-2); border-bottom: 1px dashed var(--line-2); }
.reading .v { font: 400 clamp(30px, 3.4vw, 42px)/1 var(--serif); color: var(--signal); }
.reading .u { font: 400 12px/1.35 var(--mono); color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: 400 12px/1 var(--mono); padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 2px; color: var(--ink-2); }
.links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: auto; padding-top: 6px; }
.links a { font: 500 14px var(--sans); text-decoration: none; border-bottom: 1px solid var(--signal); padding-bottom: 2px; }
.links a:hover { color: var(--signal); }

/* ─── Filters + grid ─────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 26px; }
.filter {
  font: 400 13px/1 var(--mono); padding: 9px 12px; background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: 2px; cursor: pointer; transition: all .15s;
}
.filter:hover { color: var(--ink); border-color: var(--ink-3); }
.filter[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: #0d0e10; }
.filter .count { opacity: .6; margin-left: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
/* "detected" corner brackets on hover */
.card::before, .card::after {
  content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--signal); opacity: 0;
  transition: opacity .2s, transform .25s; pointer-events: none;
}
.card::before { top: -6px; left: -6px; border-right: 0; border-bottom: 0; transform: translate(6px, 6px); }
.card::after { bottom: -6px; right: -6px; border-left: 0; border-top: 0; transform: translate(-6px, -6px); }
.card:hover::before, .card:hover::after { opacity: 1; transform: none; }
.card-media { aspect-ratio: 16 / 9; background: var(--bg-2); border-bottom: 1px solid var(--line); overflow: hidden; position: relative; }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.card-media.empty { display: grid; place-items: center; font: italic 400 26px var(--serif); color: var(--ink-3); }
.card-num { position: absolute; top: 10px; left: 10px; font: 500 12px var(--mono); background: var(--bg); color: var(--ink);
  padding: 4px 6px; border: 1px solid var(--line-2); }
.card-body { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card h3 { margin: 0; font: 500 18px/1.25 var(--sans); }
.depth { font: 400 11px var(--mono); color: var(--signal); white-space: nowrap; letter-spacing: 1px; }
.depth .off { color: var(--line-2); }
.card .reading { padding: 8px 0; }
.card .reading .v { font-size: 30px; }
.card p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.card .area { font: 400 11px var(--mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; }
.card .links { padding-top: 4px; }
.card.hide { display: none; }

/* ─── Skills ─────────────────────────────────────────────────────────────── */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.skill { padding: 24px; border-right: 1px solid var(--line); }
.skill:last-child { border-right: 0; }
.skill h3 { margin: 0 0 14px; font: 400 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--signal); }
.skill ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.skill li { font-size: 15px; color: var(--ink-2); padding-left: 16px; position: relative; }
.skill li::before { content: ""; position: absolute; left: 0; top: .62em; width: 7px; height: 7px; border: 1.5px solid var(--ink-3); }

/* ─── About ──────────────────────────────────────────────────────────────── */
.about { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 64px); }
.about-text p { margin: 0 0 16px; font-size: 18px; line-height: 1.65; color: var(--ink-2); }
.about-text p:first-child { color: var(--ink); font-size: 20px; }
.facts { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); align-self: start; }
.facts div { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--signal); }
.facts dd { margin: 4px 0 0; font-size: 15px; color: var(--ink); }

/* ─── More projects ──────────────────────────────────────────────────────── */
.sub-head { margin: 44px 0 14px; font-size: 12px; font-weight: 400; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.more { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.more-item { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); transition: border-color .2s; }
.more-item:hover { border-color: var(--signal); }
.more-item h4 { margin: 0; font: 400 24px/1.15 var(--serif); }
.more-item h4 span { color: var(--signal); font-size: 16px; }
.more-item p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.more-when, .more-stack { font-size: 11.5px; color: var(--ink-3); }
.more-stack { margin-top: auto; padding-top: 6px; }

/* ─── Hardware & coursework ──────────────────────────────────────────────── */
.hw { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.courses li { display: flex; flex-direction: column; }
.courses b { font-weight: 500; color: var(--ink); }
.courses span { font-size: 13.5px; color: var(--ink-3); }

/* ─── Contact + footer ───────────────────────────────────────────────────── */
.contact { padding-bottom: 110px; }
.contact h2 { font-size: clamp(54px, 9vw, 120px); }
.contact .lede { grid-column: auto; }
.cta { display: inline-flex; align-items: center; gap: 14px; margin-top: 26px; text-decoration: none;
  font: 400 clamp(22px, 3vw, 34px)/1 var(--mono); border: 1.5px solid var(--signal); padding: 18px 22px; transition: background .2s, color .2s; }
.cta span { color: var(--signal); transition: transform .2s, color .2s; }
.cta:hover { background: var(--signal); color: #0d0e10; }
.cta:hover span { color: #0d0e10; transform: translate(3px, -3px); }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; max-width: var(--max); margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 40px) 40px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }

/* ─── Motion ─────────────────────────────────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(14px); animation: rise .8s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--d) * 110ms); }
@keyframes rise { to { opacity: 1; transform: none; } }
.in-view { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .bbox { clip-path: inset(-40px -10px -10px -10px); }
}

/* ─── Small screens ──────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .feat, .feat:nth-child(even) { grid-template-columns: 1fr; }
  .feat-media, .feat:nth-child(even) .feat-media { order: -1; min-height: 220px; border: 0; border-bottom: 1px solid var(--line); }
  .readings { grid-template-columns: repeat(2, 1fr); }
  .readings div:nth-child(3) { border-left: 0; padding-left: 0; }
  .readings div { border-top: 1px solid var(--line); }
  .readings div:nth-child(-n+2) { border-top: 0; }
  .section-head { grid-template-columns: 1fr; }
  .lede { grid-column: 1; }
  .skill { border-right: 0; border-bottom: 1px solid var(--line); }
  .about, .hw { grid-template-columns: 1fr; }
  .about-text p, .about-text p:first-child { font-size: 17px; }
  nav a:not(.nav-gh) { display: none; }
}
