/* --- self-hosted font ---
   Inter variable, latin subset (one file covers every weight), same-origin
   with immutable caching (_headers) and preloaded from index.html.

   "Inter Fallback" is a metric-adjusted system font so font-display: swap
   cannot shift layout: size-adjust scales it to Inter's advance widths and the
   ascent/descent overrides are Inter's em ratios divided by that factor. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/inter-v20-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter Fallback";
  font-style: normal;
  font-weight: 100 900;
  src: local("Arial"), local("Liberation Sans"), local("Helvetica Neue"),
    local("Helvetica");
  size-adjust: 106.6%;
  ascent-override: 90.9%;
  descent-override: 22.6%;
  line-gap-override: 0%;
}

/* nichfoster.com — hand-crafted, no build step.
   Quiet by design: neutral near-black (warm paper in light mode), Inter for
   everything, mono for labels, one teal accent. Motion lives in the 3D
   figures; the page itself stays still. */

:root {
  color-scheme: dark;

  --bg: #0a0b0d;
  --surface: #111317;
  --ink: #ececec;
  --muted: #8b919a;
  --faint: #5c626b;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #5ee6cc;
  --accent-2: #6c8cff;
  --violet: #b4a1ff;
  --nav-bg: rgba(10, 11, 13, 0.7);

  --container: 72rem;
  --radius: 14px;

  --font-body: "Inter", "Inter Fallback", ui-sans-serif, system-ui,
    -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono",
    Menlo, Consolas, monospace;

  --dur-quick: 160ms;
  --dur-scene: 800ms;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Keep this palette identical in both blocks — the media query follows the
   OS, and [data-theme] is the hook for a manual toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #fafaf9;
    --surface: #ffffff;
    --ink: #111214;
    --muted: #5f656e;
    --faint: #9aa0a8;
    --line: rgba(0, 0, 0, 0.08);
    --accent: #0f766e;
    --accent-2: #4338ca;
    --violet: #7c3aed;
    --nav-bg: rgba(250, 250, 249, 0.75);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fafaf9;
  --surface: #ffffff;
  --ink: #111214;
  --muted: #5f656e;
  --faint: #9aa0a8;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0f766e;
  --accent-2: #4338ca;
  --violet: #7c3aed;
  --nav-bg: rgba(250, 250, 249, 0.75);
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

/* A faint engineering grid, fading out below the fold. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 70% 0%, #000 10%, transparent 70%);
  mask-image: radial-gradient(ellipse 90% 70% at 70% 0%, #000 10%, transparent 70%);
  opacity: 0.6;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
  transition: color var(--dur-quick) var(--ease-out),
    text-decoration-color var(--dur-quick) var(--ease-out);
}

a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

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

.container {
  max-width: var(--container);
  margin-inline: auto;
}

.eyebrow {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.idx {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 30;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.skip-link:focus {
  left: 0.5rem;
}

/* --- nav --- */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem max(1.25rem, (100% - var(--container)) / 2);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

.nav-brand {
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.nav-brand:hover {
  color: var(--ink);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links a:hover,
.nav-links a[aria-current="true"] {
  color: var(--ink);
}

.nav-links {
  align-items: center;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-left: -0.35rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-quick) var(--ease-out), border-color var(--dur-quick) var(--ease-out);
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--line);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
}

@media (max-width: 420px) {
  .nav-links {
    gap: 0.8rem;
  }

  /* Room for the brand on phones: About sits right under the hero anyway. */
  .nav-links .nav-optional {
    display: none;
  }

  .nav-links a {
    font-size: 0.72rem;
  }
}

/* --- hero --- */
#hero {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6rem 1.25rem 3rem;
}

h1 {
  font-weight: 600;
}

#hero h1 {
  font-size: clamp(3rem, 8.5vw, 6.25rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
  margin: 0 0 1.5rem;
}

#hero .eyebrow {
  justify-content: center;
}

.hero-tagline {
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  max-width: 30rem;
  margin: 0 auto 2.25rem;
  text-wrap: pretty;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 0.55rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--dur-quick) var(--ease-out),
    background-color var(--dur-quick) var(--ease-out),
    color var(--dur-quick) var(--ease-out);
}

.btn:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--ink) 35%, transparent);
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.btn-primary:hover {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* --- sections --- */
section {
  padding: clamp(5rem, 14vh, 9rem) clamp(1.25rem, 5vw, 2rem);
}

h2 {
  font-weight: 600;
}

.statement {
  margin: 0;
  max-width: 34rem;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  line-height: 1.45;
  letter-spacing: -0.02em;
  text-wrap: pretty;
}

.split {
  display: grid;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 4rem;
  }
}

/* --- work: hairline rows --- */
.work-grid {
  display: grid;
  gap: 3.5rem;
  align-items: start;
}

@media (min-width: 960px) {
  .work-grid {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 4rem;
  }

  .work-grid .viewer {
    position: sticky;
    top: 5.5rem;
  }
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.row {
  border-bottom: 1px solid var(--line);
}

.row-link {
  display: grid;
  grid-template-columns: 13.5rem minmax(0, 1fr) auto;
  gap: 0.25rem 1.5rem;
  align-items: baseline;
  padding: 1.15rem 0.25rem;
  color: inherit;
  text-decoration: none;
}

a.row-link {
  transition: background-color var(--dur-quick) var(--ease-out),
    padding var(--dur-quick) var(--ease-out);
}

a.row-link:hover {
  color: inherit;
  padding-inline: 0.75rem;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.row-title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.row-desc {
  color: var(--muted);
  font-size: 0.95rem;
}

.row-meta {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

a.row-link:hover .row-meta {
  color: var(--accent);
}

.rows-compact .row-link {
  padding-block: 0.85rem;
}

.rows-compact .row-title {
  font-weight: 500;
}

.sub {
  margin: 4rem 0 1rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .row-link {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .row-desc {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Screenshot card that follows the pointer over a work row (main.js). */
.row-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 15;
  width: min(24rem, 40vw);
  aspect-ratio: 8 / 5;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.55), 0 0 0 1px color-mix(in srgb, var(--ink) 4%, transparent);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-quick) var(--ease-out);
}

.row-preview.is-shown {
  opacity: 1;
}

.row-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}

/* --- cv: a dated timeline beside an education/awards/skills rail --- */
.cv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cv-head .eyebrow {
  margin-bottom: 0;
}

.cv-grid {
  display: grid;
  gap: 3.5rem;
  align-items: start;
  margin-top: 2.5rem;
}

@media (min-width: 960px) {
  .cv-grid {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 4rem;
  }

  .cv-side {
    position: sticky;
    top: 5.5rem;
  }
}

.cv-main > .sub:first-child {
  margin-top: 0;
}

.cv-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.cv-item {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.35rem 1.5rem;
  padding: 1.35rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.cv-when {
  margin: 0.2rem 0 0;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cv-org {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cv-where {
  margin-left: 0.4rem;
  color: var(--faint);
  font-weight: 400;
}

.cv-role {
  margin: 0.15rem 0 0;
  color: var(--accent);
  font-size: 0.9rem;
}

.cv-desc {
  margin: 0.5rem 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 0.95rem;
  text-wrap: pretty;
}

@media (max-width: 640px) {
  .cv-item {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cv-also {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-wrap: pretty;
}

.cv-also-label {
  margin-right: 0.6rem;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-side {
  display: grid;
  gap: 1rem;
}

.cv-card {
  padding: 1.25rem 1.3rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.cv-card .sub {
  margin: 0 0 0.85rem;
}

.cv-card .cv-role {
  margin-top: 0.3rem;
  line-height: 1.45;
}

.cv-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.9rem 0 0;
}

.cv-facts span {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.cv-awards {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}

.cv-place {
  display: inline-block;
  min-width: 2.2rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cv-skills {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  font-size: 0.9rem;
}

.cv-skills dt {
  margin-top: 0.55rem;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-skills dt:first-child {
  margin-top: 0;
}

.cv-skills dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

/* --- contact --- */
.contact-email {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6em;
  font-size: clamp(1.6rem, 5.5vw, 3.75rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.contact-email span {
  color: var(--faint);
  transition: transform var(--dur-quick) var(--ease-out), color var(--dur-quick) var(--ease-out);
}

.contact-email:hover span {
  color: var(--accent);
  transform: translateX(6px);
}

.contact-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
}

.contact-links a {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur-quick) var(--ease-out),
    background-color var(--dur-quick) var(--ease-out);
}

.contact-links a:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.contact-k {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-v {
  font-weight: 500;
}

.contact-links a:hover .contact-v {
  color: var(--accent);
}

/* --- footer --- */
footer {
  padding: 0 clamp(1.25rem, 5vw, 2rem) 2.5rem;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

/* --- motion: hero entrance + scroll reveals ---
   Hiding and animation only apply when the user allows motion; the `.js`
   gate keeps reveals visible without JavaScript. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  #hero .container > * {
    animation: rise var(--dur-scene) var(--ease-out) both;
  }

  #hero .container > :nth-child(2) {
    animation-delay: 0.07s;
  }

  #hero .container > :nth-child(3) {
    animation-delay: 0.14s;
  }

  #hero .container > :nth-child(4) {
    animation-delay: 0.21s;
  }

  .js [data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--dur-scene) var(--ease-out),
      transform var(--dur-scene) var(--ease-out);
  }

  .js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
  }

  .js .row[data-reveal]:nth-child(2) {
    transition-delay: 0.05s;
  }

  .js .row[data-reveal]:nth-child(3) {
    transition-delay: 0.1s;
  }

  .js .row[data-reveal]:nth-child(n + 4) {
    transition-delay: 0.15s;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-quick: 0ms;
    --dur-scene: 0ms;
  }

  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
