/* ============================================================
   John Fissel — johnfissel.com
   Monochrome editorial. No dependencies, no build step.
   ============================================================ */

/* ---------- Fonts (self-hosted, variable) ---------- */

@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/space-grotesk-var.06408904.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-var.3100e775.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Metric-matched fallbacks — prevent layout shift during font swap */
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial");
  size-adjust: 101%;
  ascent-override: 98%;
  descent-override: 29%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

/* ---------- Design tokens: the grayscale ramp ---------- */

:root {
  /* ramp: near-black → near-white */
  --g-ink:      #0a0a0a;
  --g-coal:     #161616;
  --g-graphite: #2e2e2e;
  --g-slate:    #555555;
  --g-steel:    #6b6b6b; /* muted text on light — 4.9:1 on paper */
  --g-silver:   #9a9a9a; /* muted text on dark  — 7.0:1 on ink   */
  --g-mist:     #d6d6d6;
  --g-fog:      #ededed;
  --g-paper:    #f6f6f6;

  /* semantic (light theme) */
  --bg: var(--g-paper);
  --ink: var(--g-ink);
  --muted: var(--g-steel);
  --hairline: var(--g-mist);
  --surface: var(--g-fog);

  --font-display: "Space Grotesk", "Space Grotesk Fallback", system-ui, sans-serif;
  --font-body: "Inter", "Inter Fallback", system-ui, sans-serif;

  --pad: clamp(1.25rem, 4vw, 4rem);
  --maxw: 84rem;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--g-ink);
    --ink: var(--g-paper);
    --muted: var(--g-silver);
    --hairline: var(--g-graphite);
    --surface: var(--g-coal);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: var(--g-ink);
  --ink: var(--g-paper);
  --muted: var(--g-silver);
  --hairline: var(--g-graphite);
  --surface: var(--g-coal);
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  overflow-x: clip;
}

img { max-width: 100%; height: auto; display: block; }

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

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

::selection { background: var(--ink); color: var(--bg); }

.skip {
  position: absolute;
  left: 1rem;
  top: -3.5rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  transition: top 0.2s;
}

.skip:focus-visible { top: 1rem; outline-color: var(--bg); }

/* ---------- Underline sweep ---------- */

.u-sweep {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 0 100%;
  transition: background-size 0.4s var(--ease-out);
}

a:hover .u-sweep,
a.u-sweep:hover,
a:focus-visible .u-sweep,
a.u-sweep:focus-visible { background-size: 100% 1px; }

/* ---------- Header / nav (transparent, overlays the hero) ---------- */

.site-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  color: var(--g-paper);
}

.site-head :focus-visible { outline-color: var(--g-paper); }

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 4.5rem;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 0.25rem var(--pad) 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.75rem 0.75rem 0.75rem 0;
  margin-right: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.25rem;
}

.nav-link {
  display: inline-block;
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-link.u-sweep {
  background-position: 0.875rem calc(100% - 0.5rem);
}

.nav-link.u-sweep:hover,
.nav-link.u-sweep:focus-visible {
  background-size: calc(100% - 1.75rem) 1px;
}

/* fixed control cluster, bottom-left — mirrors the scroll readout */
.ui-cluster {
  position: fixed;
  left: clamp(0.875rem, 2vw, 2rem);
  bottom: clamp(0.875rem, 2vw, 1.5rem);
  z-index: 50;
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.25s, transform 0.25s var(--ease-out);
}

.icon-btn:hover { border-color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }

/* both icons stacked in the same cell; the active one rotates/fades in */
.icon-btn svg { grid-area: 1 / 1; }

.theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.theme-toggle .icon-moon { opacity: 1; transform: none; }

/* marquee pause/play: pause shows while running, play while paused */
.marquee-toggle .icon-play { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.marquee-toggle .icon-pause { opacity: 1; transform: none; }

html.marquee-paused .marquee-toggle .icon-pause { opacity: 0; transform: rotate(90deg) scale(0.5); }
html.marquee-paused .marquee-toggle .icon-play { opacity: 1; transform: none; }

/* the ticker only animates for motion-OK users; hide the control otherwise */
@media (prefers-reduced-motion: reduce) {
  .marquee-toggle { display: none; }
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-toggle .icon-sun { opacity: 1; transform: none; }
  html:not([data-theme]) .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }
}

:root[data-theme="dark"] .theme-toggle .icon-sun { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }
:root[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: none; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  /* the 48vw term lets the hero grow with viewport width (~2:1 aspect cap),
     so huge screens don't crop the photo down to a face-filling strip */
  min-height: min(92svh, max(62rem, 48vw));
  display: flex;
  align-items: flex-end;
}

.hero-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.hero-media img {
  position: absolute;
  left: 0;
  top: -6%;
  width: 100%;
  height: 112%;
  object-fit: cover;
  /* subject sits right-of-center with his head near the top; keep both in
     frame when narrow viewports crop the sides or parallax crops the top */
  object-position: 65% 28%;
  /* no filter and no will-change here: grayscale is baked into the JPEG.
     A runtime filter on this parallaxed layer makes Safari flash gray and
     flicker while it re-rasterizes, and (with will-change) pins a second
     full-size GPU buffer that pushes Safari into its memory-kill reload */
}

/* film grain so the photo reads as texture, not a flat JPG.
   Plain low-opacity desaturated noise — mix-blend-mode here made Safari
   drop/re-apply the blend while the hero animates (gray wash, flicker)
   and forced an extra full-hero compositing buffer */
.hero-media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.07;
  pointer-events: none;
}

/* scrim so the name passes contrast over any future photo */
.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgb(10 10 10 / 0.45) 0%, rgb(10 10 10 / 0.12) 45%, rgb(10 10 10 / 0.74) 100%);
}

/* axis baseline with upward ticks — the ticker reads as a chart axis */
.hero::after {
  content: "";
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: clamp(0.625rem, 2vh, 1.375rem);
  z-index: 1;
  height: 7px;
  border-bottom: 1px solid rgb(246 246 246 / 0.45);
  background-image: linear-gradient(90deg, rgb(246 246 246 / 0.35) 0 1px, transparent 1px);
  background-size: 6rem 100%;
  background-repeat: repeat-x;
  pointer-events: none;
}

/* one enormous line, drifting horizontally like a slow ticker */
.hero-line {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  padding-bottom: clamp(1.25rem, 4vh, 3rem);
  overflow: hidden;
  white-space: nowrap;
  color: var(--g-paper);
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(3.75rem, 16vw, 17rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

.hero-line-in { display: inline-block; }

/* no will-change: the running animation already promotes the track, and a
   permanent hint kept this huge text layer resident even while paused,
   feeding Safari's out-of-memory page reload */
.marquee-track {
  display: inline-block;
}

.marquee-item { display: inline-block; }

/* ---------- Sections: label rail + content ---------- */

.section {
  position: relative;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: clamp(3.5rem, 9vh, 7rem) var(--pad);
  border-top: 1px solid var(--hairline);
}

/* axis ticks along each section's top rule — the chart-grid signature */
.section::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--pad);
  right: var(--pad);
  height: 7px;
  background-image: linear-gradient(90deg, var(--hairline) 0 1px, transparent 1px);
  background-size: 6rem 100%;
  background-repeat: repeat-x;
}

/* the hero's axis baseline already divides it from the first section */
.hero + .section { border-top: 0; }
.hero + .section::before { content: none; }

#about, #contact, .error-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.rail {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.label {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede {
  margin: 0;
  max-width: 34ch;
  font-family: var(--font-display);
  font-weight: 420;
  font-size: clamp(1.375rem, 1.05rem + 1.6vw, 2.125rem);
  line-height: 1.4;
  letter-spacing: -0.008em;
  text-wrap: pretty;
}

/* ---------- Contact ---------- */

.contact-list {
  list-style: none;
  margin: -0.5rem 0 0;
  padding: 0;
}

.contact-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.125rem 0;
  border-bottom: 1px solid var(--hairline);
}

.contact-label {
  flex: 0 0 6.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.25s;
}

a.contact-row:hover .contact-label { color: var(--ink); }

.contact-value {
  font-family: var(--font-display);
  font-weight: 480;
  font-size: clamp(1.125rem, 1rem + 0.9vw, 1.625rem);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  transition: transform 0.35s var(--ease-out);
}

a.contact-row:hover .contact-value { transform: translateX(-0.375rem); }

.ext {
  display: inline-block;
  margin-left: 0.4em;
  font-size: 0.7em;
  color: var(--muted);
  transition: transform 0.3s var(--ease-out), color 0.25s;
}

a.contact-row:hover .ext {
  transform: translate(0.15em, -0.15em);
  color: var(--ink);
}

/* ---------- CTA ---------- */

.cta { padding-block: clamp(5rem, 14vh, 10rem); }

.cta-line {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.375rem, 1rem + 7vw, 7.25rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

.cta-quiet {
  display: block;
  color: var(--muted);
}

.cta-link {
  display: inline-block;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 100% 0.045em;
  background-position: 0 96%;
  transition: background-size 0.4s var(--ease-out);
}

.cta-link:hover,
.cta-link:focus-visible { background-size: 0% 0.045em; }

.cta-arrow {
  display: inline-block;
  margin-left: 0.12em;
  transition: transform 0.35s var(--ease-out);
}

.cta-link:hover .cta-arrow { transform: translate(0.08em, -0.08em); }

/* ---------- Footer ---------- */

.site-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin-inline: auto;
  /* extra bottom padding clears the fixed control cluster and readout */
  padding: 1.75rem var(--pad) 5.75rem;
  border-top: 1px solid var(--hairline);
}

.site-foot p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.foot-top {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: color 0.25s;
}

.foot-top:hover { color: var(--ink); }

.foot-top-arrow {
  display: inline-block;
  margin-left: 0.35em;
  transition: transform 0.3s var(--ease-out);
}

.foot-top:hover .foot-top-arrow { transform: translateY(-0.15em); }

/* ---------- The index: scroll-position readout ---------- */

.readout {
  position: fixed;
  right: clamp(0.875rem, 2vw, 2rem);
  bottom: clamp(0.875rem, 2vw, 1.5rem);
  z-index: 50;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  pointer-events: none;
}

html:not(.js) .readout { display: none; }
html:not(.js) .ui-cluster { display: none; }

/* ---------- Error page (404.html) ---------- */

.page-error .site-head {
  position: static;
  color: var(--ink);
}

.page-error .site-head :focus-visible { outline-color: var(--ink); }

.error-hero {
  min-height: 62svh;
  align-content: center;
  border-top: 0;
}

.error-hero::before { content: none; }

.error-cta {
  margin: 2.25rem 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 1rem + 1.2vw, 1.875rem);
  letter-spacing: -0.01em;
}

/* ---------- Cursor dot (fine pointers only, added by JS) ---------- */

.cursor-dot {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, width 0.25s, height 0.25s, margin 0.25s;
}

.cursor-dot.on { opacity: 0.9; }

.cursor-dot.grow {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  opacity: 0.45;
}

/* ============================================================
   Motion. Everything below is skipped for reduced-motion users
   (they get instant, static rendering) and all animations touch
   only transform + opacity.
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {

  /* -- page-load sequence: pure CSS, runs with or without JS -- */

  .hero-media {
    animation: hero-zoom 1.6s var(--ease-out) both;
  }

  @keyframes hero-zoom {
    from { transform: scale(1.055); }
    to { transform: none; }
  }

  .hero-line-in {
    animation: rise 0.9s var(--ease-out) 0.15s both;
  }

  @keyframes rise {
    from { transform: translateY(110%); }
    to { transform: none; }
  }

  /* slow endless drift; track holds two copies, so -50% loops seamlessly */
  .marquee-track {
    animation: marquee 90s linear infinite;
  }

  /* WCAG 2.2.2 — the pause button freezes the ticker in place. JS pins the
     live transform inline and kills the animation (Safari's compositor-thread
     animations snap to a stale position when play-state pauses them); this
     rule is only the fallback if that freeze throws */
  html.marquee-paused .marquee-track {
    animation-play-state: paused;
  }

  @keyframes marquee {
    to { transform: translateX(-50%); }
  }

  /* toggle buttons: icons rotate/fade through the switch */
  .icon-btn svg {
    transition: transform 0.5s var(--ease-out), opacity 0.3s linear;
  }

  .brand { animation: fade-in 0.6s ease 0.1s both; }
  .nav-links li:nth-child(1) { animation: fade-in 0.6s ease 0.3s both; }
  .nav-links li:nth-child(2) { animation: fade-in 0.6s ease 0.42s both; }
  .ui-cluster { animation: fade-in 0.6s ease 0.54s both; }

  @keyframes fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
  }

  /* -- scroll reveals: only when JS is present to add .in -- */

  html.js [data-reveal] .reveal-group > *,
  html.js .cta .cta-line {
    opacity: 0;
    transform: translateY(1.75rem);
    transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  }

  html.js [data-reveal] .rail {
    opacity: 0;
    transition: opacity 0.8s var(--ease-out);
  }

  html.js [data-reveal] .reveal-group > *:nth-child(2) { transition-delay: 0.09s; }
  html.js [data-reveal] .reveal-group > *:nth-child(3) { transition-delay: 0.18s; }
  html.js [data-reveal] .reveal-group > *:nth-child(4) { transition-delay: 0.27s; }
  html.js [data-reveal] .reveal-group > *:nth-child(5) { transition-delay: 0.36s; }

  html.js [data-reveal].in .reveal-group > *,
  html.js [data-reveal].in .rail,
  html.js .cta.in .cta-line {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Wider screens: the two-column editorial grid ---------- */

@media (min-width: 48rem) {
  #about, #contact, .error-hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
    gap: var(--pad);
  }

  .rail {
    flex-direction: column;
    gap: 0.5rem;
  }
}
