/* ==========================================================================
   Base — structure and components for every page on the site.

   Holds no colour values of its own: each one is a token supplied by a
   theme in css/themes/. Add a page by linking base.css, one theme per
   appearance, and js/appearance.js.
   ========================================================================== */

/* ==========================================================================
   Base
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* A single wash of light behind the hero, nothing more */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: 70vh;
  background: var(--glow);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.15; letter-spacing: -0.025em; }
h1 { font-size: clamp(2.6rem, 6.4vw, 4.4rem); }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); }
h3 { font-size: 1.1875rem; letter-spacing: -0.015em; }
p  { margin: 0; }

a { color: inherit; text-decoration: none; }

.numeral {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

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

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus {
  left: 20px; top: 14px; z-index: 30;
  background: var(--bg-elevated); color: var(--text-primary);
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--card-border);
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-name { font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.01em; }

.nav-links { display: flex; gap: 26px; margin-left: auto; }

.nav-links a {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.nav-links a:hover { color: var(--text-primary); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.2s ease, background-color 0.2s ease,
              border-color 0.2s ease, color 0.2s ease;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-quiet { border-color: var(--card-border); color: var(--text-primary); }
.btn-quiet:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  text-align: center;
  padding: clamp(72px, 13vh, 132px) 0 clamp(56px, 9vh, 96px);
}

.hero h1 { margin-top: 4px; }

.hero-eyebrow {
  margin-top: 14px;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.hero-lede {
  margin: 24px auto 0;
  max-width: 60ch;
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.hero-actions {
  margin-top: 34px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

/* Avatar */
.hero-avatar {
  width: 132px;
  height: 132px;
  margin: 0 auto 28px;
  border-radius: 50%;
  padding: 4px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.hero-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Contact line and social row */
.hero-contact {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 26px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.hero-contact a { border-bottom: 1px solid transparent; transition: border-color 0.2s ease, color 0.2s ease; }
.hero-contact a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.hero-social {
  margin-top: 26px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.hero-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.hero-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ==========================================================================
   Signal field — the noisy waveform behind every page
   ========================================================================== */

.signal-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--field-opacity, 0.16);
  transition: opacity 0.4s ease;
  /* Fade the traces out at all four edges so they never hard-cut on the
     viewport boundary. */
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 9%, #000 91%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent 0%, #000 14%, #000 86%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 9%, #000 91%, transparent 100%);
  mask-composite: intersect;
}

/* Film grain: a static noise floor over the whole page, so the signal
   traces read as signal against it. Technique borrowed from the reference kit. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--grain-opacity, 0);
  background-repeat: repeat;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Drift the pattern, not the element: an oversized transformed layer widens
     the document and causes horizontal scroll on narrow screens. */
  animation: grain-drift 0.6s steps(3) infinite;
  transition: opacity 0.4s ease;
}

@keyframes grain-drift {
  0%   { background-position: 0 0; }
  33%  { background-position: -14px 7px; }
  66%  { background-position: 9px -12px; }
  100% { background-position: 0 0; }
}
  66%  { transform: translate(1%, -2%); }
  100% { transform: translate(0, 0); }
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section { padding: clamp(64px, 11vh, 118px) 0; }

.section-head { max-width: 62ch; }

.section-head h2::before {
  content: '';
  display: block;
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin-bottom: 18px;
}

.section-head p {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 1.0625rem;
}

.section-body { margin-top: 44px; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 30px;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.card:hover { transform: translateY(-3px); border-color: var(--accent); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

/* Two up: for cards carrying enough copy that three across would crowd them. */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* A number a card has earned the right to show. */
.work-metric {
  margin-top: 16px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
}

/* Figures */
.figure-value {
  font-size: clamp(1.9rem, 3.6vw, 2.5rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.figure-label {
  margin-top: 12px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* Capability cards */
.card h3 { margin-bottom: 16px; }

.card ul { margin: 0; padding: 0; list-style: none; }

.card li {
  padding: 8px 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--hairline);
}

.card li:first-child { border-top: none; }

/* Work cards */
.work-kind {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.work-desc { margin-top: 12px; color: var(--text-secondary); font-size: 0.9375rem; }

.work-tools { margin-top: 16px; font-size: 0.875rem; color: var(--text-tertiary); }

.work-links { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 18px; }

.work-links a {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.work-links a:hover { border-bottom-color: var(--accent); }

/* ==========================================================================
   Writing
   ========================================================================== */

.writing { border-top: 1px solid var(--hairline); }

.writing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 24px;
  padding: 22px 4px;
  border-bottom: 1px solid var(--hairline);
  transition: padding-left 0.25s ease, color 0.25s ease;
}

.writing-row:hover { padding-left: 14px; }
.writing-row:hover .writing-title { color: var(--accent); }

.writing-title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  transition: color 0.25s ease;
}

.writing-sub { margin-top: 6px; font-size: 0.9375rem; color: var(--text-secondary); }

.writing-date { font-size: 0.875rem; color: var(--text-tertiary); white-space: nowrap; }

.writing-flag {
  margin-left: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact { text-align: center; }
.contact .section-head { margin: 0 auto; }
.contact .section-head h2::before { margin-left: auto; margin-right: auto; }

.contact-actions {
  margin-top: 34px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

.contact-meta { margin-top: 26px; font-size: 0.9375rem; color: var(--text-tertiary); }

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--hairline);
  padding: 30px 0 52px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.appearance { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.appearance-set {
  display: flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card-bg);
}

.appearance-set button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.appearance-set button:hover { color: var(--text-primary); }

.appearance-set button[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ==========================================================================
   Reveal — one gentle entrance, JS-gated so content is never lost
   ========================================================================== */

html.js .reveal { opacity: 0; transform: translateY(18px); }

html.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}


/* ==========================================================================
   Motion
   Hero entrance, section reveals, and the typed role line. Every rule here is
   disabled wholesale by the reduced-motion block at the end of this file.
   ========================================================================== */

/* One orchestrated entrance on load. Expo-out: fast departure, soft landing. */
html.js .enter {
  opacity: 0;
  transform: translateY(26px);
  animation: enter-up 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes enter-up {
  to { opacity: 1; transform: none; }
}

html.js .enter-scale {
  opacity: 0;
  transform: scale(0.88);
  animation: enter-scale 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes enter-scale {
  to { opacity: 1; transform: none; }
}

/* These must outrank `html.js .enter`, whose `animation` shorthand resets
   animation-delay to 0 — hence the matching html.js prefix. */
html.js .delay-1 { animation-delay: 0.05s; }
html.js .delay-2 { animation-delay: 0.16s; }
html.js .delay-3 { animation-delay: 0.27s; }
html.js .delay-4 { animation-delay: 0.38s; }
html.js .delay-5 { animation-delay: 0.49s; }
html.js .delay-6 { animation-delay: 0.60s; }

/* The typed role line */
.typed-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: cursor-blink 1.1s steps(1) infinite;
}

@keyframes cursor-blink { 50% { opacity: 0; } }

.typed-cursor.done { animation: cursor-blink 1.1s steps(1) 3; opacity: 0; }

/* Section reveals, with children staggering in after their container */
html.js .reveal-up   { opacity: 0; transform: translateY(22px); }
html.js .reveal-left { opacity: 0; transform: translateX(-26px); }
html.js .reveal-right{ opacity: 0; transform: translateX(26px); }

html.js .reveal-up.in,
html.js .reveal-left.in,
html.js .reveal-right.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

html.js .stagger > * {
  opacity: 0;
  transform: translateY(20px);
}

html.js .stagger.in > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

html.js .stagger.in > *:nth-child(1) { transition-delay: 0.00s; }
html.js .stagger.in > *:nth-child(2) { transition-delay: 0.08s; }
html.js .stagger.in > *:nth-child(3) { transition-delay: 0.16s; }
html.js .stagger.in > *:nth-child(4) { transition-delay: 0.24s; }
html.js .stagger.in > *:nth-child(5) { transition-delay: 0.32s; }
html.js .stagger.in > *:nth-child(6) { transition-delay: 0.40s; }

/* Counting figures hold their width so the layout never jitters */
.figure-value { font-variant-numeric: tabular-nums; }

/* Cards lift toward the pointer rather than straight up */
.card { will-change: transform; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 980px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 660px) {
  body { font-size: 16px; }
  .wrap, .nav-inner { padding-left: 20px; padding-right: 20px; }
  .nav-links { gap: 18px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 24px; }
  .writing-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .appearance { margin-left: 0; }
  .appearance-set button { padding: 6px 12px; font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html.js .reveal { opacity: 1; transform: none; }
  html.js .enter, html.js .enter-scale,
  html.js .reveal-up, html.js .reveal-left, html.js .reveal-right,
  html.js .stagger > * { opacity: 1 !important; transform: none !important; animation: none !important; }
  .typed-cursor { display: none; }
}

@media print {
  .nav, .appearance, .signal-field { display: none; }
  body::before { display: none; }
}
