/* Fonts: self-hosted variable fonts, latin subset */
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* Tokens */
:root {
  color-scheme: light dark;

  --bg: #fafafa;
  --text: #16181d;
  --muted: #565c69;
  --line: #e2e4e9;
  --surface: #ffffff;
  --accent: #2650d9;
  --on-accent: #ffffff;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* modular scale, ratio ~1.25, fluid */
  --step--1: 0.875rem;
  --step-0: clamp(1.0625rem, 1.03rem + 0.17vw, 1.1875rem);
  --step-1: clamp(1.25rem, 1.18rem + 0.35vw, 1.5rem);
  --step-2: clamp(1.6rem, 1.4rem + 1vw, 2.25rem);
  --step-3: clamp(2.3rem, 1.5rem + 4vw, 4.1rem);

  --gutter: clamp(1.25rem, 5vw, 2rem);
  --measure: 65ch;
  --space-section: clamp(3.5rem, 9vw, 7rem);
  --tap: 2.75rem; /* 44px */
  --nav-h: 3.5rem;
}
:root[data-theme="dark"] {
  --bg: #101114;
  --text: #eceef2;
  --muted: #a3a9b6;
  --line: #272a31;
  --surface: #16181d;
  --accent: #8caaff;
  --on-accent: #0b0d14;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101114;
    --text: #eceef2;
    --muted: #a3a9b6;
    --line: #272a31;
    --surface: #16181d;
    --accent: #8caaff;
    --on-accent: #0b0d14;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 1rem); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; text-wrap: balance; }
p { margin: 0; max-width: var(--measure); text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
ul { margin: 0; padding: 0; list-style: none; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: var(--gutter); top: 0.75rem; z-index: 50; background: var(--text); color: var(--bg); padding: 0.75rem 1rem; border-radius: 6px; }

.wrap { width: min(100% - 2 * var(--gutter), 44rem); margin-inline: auto; }
.wrap-wide { width: min(100% - 2 * var(--gutter), 70rem); margin-inline: auto; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: var(--nav-h); width: min(100% - 2 * var(--gutter), 70rem); margin-inline: auto; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.125rem; color: var(--text); text-decoration: none; letter-spacing: -0.01em; min-height: var(--tap); display: inline-flex; align-items: center; }
.nav-right { display: flex; align-items: center; gap: 0.25rem; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 0.85rem;
  color: var(--muted); text-decoration: none; font-size: 1rem; border-radius: 8px;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  background: transparent; border: 0; border-radius: 8px; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.icon-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}

/* Phones: links collapse into a menu (only when JS is available) */
@media (max-width: 639px) {
  .js .menu-btn { display: inline-grid; }
  .js .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; gap: 0; padding: 0.5rem var(--gutter) 1rem;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .js .nav-links.open { display: flex; }
  .js .nav-links a { min-height: 3rem; font-size: 1.125rem; padding: 0; color: var(--text); border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-links { display: none; }
  html:not(.js) .nav-inner { flex-wrap: wrap; padding: 0.25rem 0; }
  html:not(.js) .nav-links { display: flex; width: 100%; order: 3; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: 0 1.5rem; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 1rem;
  text-decoration: none; border: 0; transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
:root[data-theme="dark"] .btn:hover { filter: brightness(0.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:hover { filter: brightness(0.92); } }

/* Hero */
.hero { padding-block: clamp(3.5rem, 12vw, 8rem) var(--space-section); }
.hero h1 { font-size: var(--step-3); line-height: 1.08; letter-spacing: -0.025em; font-weight: 500; max-width: 17ch; }
.hero p { margin-top: 1.5rem; font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 38ch; }
.hero .btn { margin-top: 2rem; }

/* Sections */
.section { padding-block: var(--space-section); border-top: 1px solid var(--line); }
.section > .wrap > h2, .section > .wrap-wide > h2 { font-size: var(--step-2); line-height: 1.15; letter-spacing: -0.015em; margin-bottom: 2rem; }

/* Work */
.work-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: clamp(1.25rem, 3vw, 1.75rem); transition: border-color 0.15s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.card h3 { font-size: var(--step-1); line-height: 1.25; letter-spacing: -0.01em; }
.card .outcome { margin-top: 0.5rem; font-weight: 500; }
.card .body { margin-top: 0.5rem; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.tag { font-size: var(--step--1); line-height: 1; padding: 0.4rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
@media (min-width: 760px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .card.wide { grid-column: 1 / -1; }
  .card.wide .outcome, .card.wide .body { max-width: 60ch; }
}

/* About */
.about-text { display: grid; gap: 1.25rem; }
.about-text p { color: var(--text); }
.about-detail { margin-top: 1.25rem; color: var(--muted); }
.currently { margin-top: 1.25rem; padding-left: 1rem; border-left: 3px solid var(--accent); }
.currently strong { font-weight: 600; }
h3.sub { font-size: var(--step-1); letter-spacing: -0.01em; margin: 3rem 0 1rem; }
.timeline li { display: grid; gap: 0.1rem; padding: 0.9rem 0; border-top: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: var(--step--1); }
@media (min-width: 640px) { .timeline li { grid-template-columns: 11rem 1fr; gap: 1.5rem; align-items: baseline; } .timeline .when { font-size: 1rem; } }
.stack { display: grid; gap: 0.25rem 1.5rem; margin: 0; }
.stack dt { font-weight: 600; margin-top: 0.9rem; }
.stack dd { margin: 0; color: var(--muted); max-width: var(--measure); }
@media (min-width: 640px) { .stack { grid-template-columns: 11rem 1fr; } .stack dt, .stack dd { margin-top: 0; padding: 0.7rem 0; } }

/* Contact */
.contact p { color: var(--muted); }
.mail { display: inline-block; margin-top: 1.25rem; font-family: var(--serif); font-size: clamp(1.4rem, 5.2vw, 2.4rem); font-weight: 500; letter-spacing: -0.015em; color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 2px; overflow-wrap: anywhere; min-height: var(--tap); }
.mail:hover { color: var(--accent); }
.elsewhere { margin-top: 1rem; }

/* Footer */
.footer { padding-block: 2rem 6rem; color: var(--muted); font-size: var(--step--1); border-top: 1px solid var(--line); }
@media (min-width: 640px) { .footer { padding-bottom: 3rem; } }

/* 404 */
.notfound { padding-block: clamp(5rem, 20vw, 10rem); }
.notfound h1 { font-size: var(--step-3); line-height: 1.08; letter-spacing: -0.025em; }
.notfound p { margin-top: 1rem; color: var(--muted); }
.notfound .btn { margin-top: 2rem; }

/* Thumb bar on phones: appears once the hero button has scrolled away */
.thumb { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: none; }
.thumb .btn { width: 100%; min-height: 3rem; }
@media (max-width: 639px) { .js .thumb.show { display: block; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* Diagrams and photos */
.flow { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.flow li { position: relative; padding: 0.55rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 0.9375rem; line-height: 1.3; }
.flow li:not(:last-child)::after { content: ""; position: absolute; left: 1.2rem; bottom: -0.55rem; width: 0.45rem; height: 0.45rem; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); background: transparent; }
.flow li:not(:last-child) { margin-bottom: 0.15rem; }
@media (min-width: 760px) {
  .card.wide .flow { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1.4rem; align-items: center; }
  .card.wide .flow li:not(:last-child) { margin-bottom: 0; }
  .card.wide .flow li:not(:last-child)::after { left: auto; right: -1.05rem; bottom: auto; top: 50%; margin-top: -0.225rem; transform: rotate(-45deg); }
}

.portrait { display: block; width: 11rem; height: 11rem; object-fit: cover; border-radius: 14px; margin-bottom: 1.75rem; border: 1px solid var(--line); }
.shots { display: grid; gap: 0.75rem; }
.shots img { display: block; width: 100%; height: auto; border: 1px solid var(--line); background: var(--bg); }
.shots.phones { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; max-width: 30rem; }
.shots.phones img { border-radius: 14px; }
.shots.desk { grid-template-columns: 1fr; margin-top: 1.5rem; }
.shots.desk img { border-radius: 8px; }
@media (min-width: 760px) { .shots.desk { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.caption { margin-top: 0.75rem; font-size: var(--step--1); color: var(--muted); }
.card.split { display: grid; gap: 1.5rem; }
@media (min-width: 900px) { .card.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 2.5rem; } .card.split .card-media { justify-self: end; width: 100%; max-width: 30rem; } }
.figure { margin: 1.75rem 0 0; max-width: 100%; }
.figure img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.figure figcaption { margin-top: 0.6rem; font-size: var(--step--1); color: var(--muted); }
