/* ==========================================================================
   thomashaaf.com — achromatic, one red signal, no script.

   One cloth:
   - Two faces. Geist (300 voice, 400 emphasis) for words; Geist Mono, one size,
     uppercase, for every label, date, place and control.
   - One emphasis rule: ink 400 for the lead phrase, mute 300 for the rest.
   - Hairlines only: 1px rules, 1px underlines, square corners.
   - Red is signal, never decoration: the full stop, "now", progress, hover.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #f2f2f2;
  --ink: #0b0b0b;
  --mute: #6e6e6e;
  --line: #d0d0d0;
  --red: #ff3b1f;

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Type scale: meta · body · m · l · xl · xxl */
  --fs-meta: .75rem;
  --fs-body: 1rem;
  --fs-m:   clamp(1.1rem, 1.65vw, 1.45rem);   /* lede, intro, work rows */
  --fs-l:   clamp(1.6rem, 3.3vw, 3.1rem);     /* statement, off-screen */
  --fs-xl:  clamp(2.2rem, 7.6vw, 8.25rem);    /* the address */
  --fs-xxl: clamp(3.5rem, 15.5vw, 17rem);     /* the name */

  /* Space: rule→content · row · block · section */
  --s-1: .9rem;
  --s-2: 1.35rem;
  --s-3: clamp(2rem, 4.5vw, 3.75rem);
  --s-4: clamp(5rem, 12vw, 11rem);

  --gut: clamp(1rem, 3.2vw, 2.75rem);
  --gap: clamp(.75rem, 2vw, 1.5rem);
  --rule: 1px solid var(--line);

  --ease: cubic-bezier(.2, .7, 0, 1);
  --dur: .4s;
  --dur-slow: .9s;

  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b;
    --ink: #ececec;
    --mute: #8a8a8a;
    --line: #2a2a2a;
    --red: #ff4a2e;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scrollbar-color: var(--mute) var(--bg); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, p, ol, ul, dl, dd, figure { margin: 0; padding: 0; }
h1, h2 { font-weight: inherit; }
ol, ul { list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
b { font-weight: 400; color: var(--ink); }
i { font-style: normal; color: var(--red); }

::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 1px solid var(--red); outline-offset: 4px; }

/* ---------- Shared voices ---------- */

/* Sans voice: everything set at m and above speaks in 300 */
.name, .lede, .statement, .work__org, .off, .contact__intro, .contact__mail { font-weight: 300; }

/* Mono: one size, one case, one tracking — every label, date, place and control */
.meta, .skip, .bar nav a, .label, .focus, .work__time, .work__loc, .links a {
  font: 400 var(--fs-meta)/1.4 var(--mono);
  letter-spacing: .02em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.meta { color: var(--mute); }

/* Numbers that index sections are quiet, wherever they appear */
.bar nav a span, .label span { color: var(--mute); margin-right: .6em; }

/* Links: hairline underline, red on hover — one behaviour everywhere */
.hero__mail, .contact__mail, .links a {
  text-decoration: underline 1px color-mix(in srgb, var(--ink) 30%, transparent);
  text-underline-offset: .35em;
  transition: color var(--dur) var(--ease), text-decoration-color var(--dur) var(--ease);
}
.contact__mail { text-underline-offset: .14em; }
.hero__mail:hover, .contact__mail:hover, .links a:hover,
.bar nav a:hover, .bar nav a:hover span, .foot a:hover {
  color: var(--red); text-decoration-color: var(--red);
}
.bar nav a, .bar nav a span, .foot a { transition: color var(--dur) var(--ease); }

/* Lists of content (not links): hovering one item quiets the rest */
.work > li, .off > span { transition: opacity var(--dur) var(--ease); }
@media (hover: hover) {
  .work:hover > li, .off:hover > span { opacity: .3; }
  .work > li:hover, .off > span:hover { opacity: 1; }
}

.skip {
  position: absolute; left: var(--gut); top: -100px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: .5rem .75rem;
}
.skip:focus { top: 1rem; }

/* ---------- Scroll progress (CSS scroll-driven, progressive) ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60;
  background: var(--red);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
@supports (animation-timeline: scroll()) {
  .progress { animation: grow linear both; animation-timeline: scroll(root); }
  @keyframes grow { to { transform: scaleX(1); } }
}

/* ---------- Header ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 1rem) var(--gut) 1rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.mark { font: 400 var(--fs-body)/1 var(--sans); letter-spacing: -.02em; }
.bar nav { display: flex; gap: clamp(.9rem, 2.5vw, 2.25rem); }
@media (max-width: 640px) {
  .bar nav a span { display: none; }
  .bar nav a:nth-child(3) { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 6.5rem var(--gut) var(--gut);
}
.hero__top {
  display: flex; flex-wrap: wrap;
  align-items: baseline; justify-content: space-between;
}
.coords { display: grid; justify-items: end; }

.name {
  align-self: end;
  font-size: var(--fs-xxl);
  line-height: .86;
  letter-spacing: -.055em;
  margin: 0 0 var(--s-3) -.06em;
}

.hero__foot {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap);
  align-items: end;
  padding-top: var(--s-1);
  border-top: 1px solid var(--ink);
}
.lede {
  grid-column: 1 / span 6;
  font-size: var(--fs-m); line-height: 1.3; letter-spacing: -.02em;
  max-width: 34ch;
}
.hero__mail {
  grid-column: 10 / -1; justify-self: end;
  padding: .75rem 0; margin: -.75rem 0; /* larger hit area, same layout */
  color: var(--ink);
}

@media (max-width: 760px) {
  .hero__top span:nth-child(2) { display: none; }
  .lede { grid-column: 1 / -1; margin-bottom: var(--s-2); }
  .hero__mail { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  /* "Thomas" fills the column instead of floating in an empty viewport */
  .name { font-size: 26vw; }
}

/* Load-in: name rises once, no JS */
@media (prefers-reduced-motion: no-preference) {
  .name, .hero__foot, .hero__top { animation: rise 1.1s var(--ease) both; }
  .hero__top  { animation-delay: .05s; }
  .name       { animation-delay: .12s; }
  .hero__foot { animation-delay: .3s; }
  @keyframes rise { from { opacity: 0; transform: translateY(1.25rem); } }
}

/* ---------- Sections ---------- */
.section {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap);
  padding: var(--s-4) var(--gut) 0;
  scroll-margin-top: 2rem;
}
/* Every section: a label column (ink rule) beside a content column (hairline rule) */
.label {
  grid-column: 1 / span 3;
  padding-top: var(--s-1); border-top: 1px solid var(--ink);
  align-self: start;
  position: sticky; top: 4.5rem;
}
.about, .portrait, .off, .contact__body { padding-top: var(--s-1); border-top: var(--rule); }

@media (max-width: 760px) {
  .label { grid-column: 1 / -1; position: static; margin-bottom: var(--s-2); }
}

/* Reveal on scroll, CSS-only (progressive) */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .statement, .about__cols, .work li, .off, .contact__mail, .portrait {
      animation: fade-up linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
    @keyframes fade-up { from { opacity: 0; transform: translateY(2rem); } }
  }
}

/* ---------- 01 About ---------- */
.about { grid-column: 4 / span 6; }
.statement {
  font-size: var(--fs-l); line-height: 1.15; letter-spacing: -.035em;
  text-wrap: balance;
}
.about__cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  margin-top: var(--s-3);
  color: var(--mute);
  line-height: 1.6;
}
.about__cols p { text-wrap: pretty; }

/* Same voice as the hero's top line: mono, slash-separated */
.focus { display: flex; flex-wrap: wrap; margin-top: var(--s-3); color: var(--ink); }
.focus li + li::before { content: "/"; color: var(--mute); margin: 0 .75em; }

.portrait { grid-column: 10 / -1; align-self: start; }
.portrait .frame {
  position: relative;
  background: var(--line);
  filter: grayscale(1) contrast(1.08);
  transition: filter var(--dur-slow) var(--ease);
}
.portrait:hover .frame { filter: grayscale(0) contrast(1); }
.portrait img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 30%;
}
/* Pixel layers: tiny copies of the photo blown up with hard edges, coarsest on top.
   They drop away one by one as the photo scrolls in, leaving the sharp image. */
.portrait .px {
  display: none;
  position: absolute; inset: 0;
  background: 50% 30% / cover no-repeat;
  image-rendering: pixelated;
}
.portrait .px1 { z-index: 4; background-image: url("../img/th-px10.png"); }
.portrait .px2 { z-index: 3; background-image: url("../img/th-px18.png"); }
.portrait .px3 { z-index: 2; background-image: url("../img/th-px32.png"); }
.portrait .px4 { z-index: 1; background-image: url("../img/th-px56.png"); }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .portrait .frame { view-timeline: --portrait block; }
    .portrait .px {
      display: block;
      animation: linear both;
      animation-timeline: --portrait;
      animation-range: entry 50% cover 60%;
    }
    .portrait .px1 { animation-name: px-off-1; }
    .portrait .px2 { animation-name: px-off-2; }
    .portrait .px3 { animation-name: px-off-3; }
    .portrait .px4 { animation-name: px-off-4; }
  }
}
@keyframes px-off-1 { 0%, 20% { opacity: 1; } 20.1%, 100% { opacity: 0; } }
@keyframes px-off-2 { 0%, 40% { opacity: 1; } 40.1%, 100% { opacity: 0; } }
@keyframes px-off-3 { 0%, 60% { opacity: 1; } 60.1%, 100% { opacity: 0; } }
@keyframes px-off-4 { 0%, 80% { opacity: 1; } 80.1%, 100% { opacity: 0; } }
.portrait figcaption {
  display: flex; justify-content: space-between; margin-top: var(--s-1);
}

@media (max-width: 1000px) {
  .about { grid-column: 4 / -1; }
  .portrait { grid-column: 4 / span 5; margin-top: var(--s-3); }
}
@media (max-width: 760px) {
  .about { grid-column: 1 / -1; }
  .about__cols { grid-template-columns: 1fr; }
  .portrait { grid-column: 1 / span 9; }
}

/* ---------- 02 Work ---------- */
.work { grid-column: 4 / -1; border-top: var(--rule); }
.work li {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gap);
  align-items: baseline;
  padding: var(--s-2) 0;
  border-bottom: var(--rule);
}
.work__time, .work__loc { color: var(--mute); }
.work__time { grid-column: span 3; }
.work__role { grid-column: span 4; }
.work__org  { grid-column: span 3; }
.work__loc  { grid-column: span 2; text-align: right; }
.work__time b { color: var(--red); }
.work__role, .work__org { font-size: var(--fs-m); line-height: 1.3; letter-spacing: -.02em; }
.work__role { font-weight: 400; }
.work__org  { color: var(--mute); }

.is-now .work__time b::before {
  content: ""; display: inline-block; width: .45em; height: .45em; margin-right: .45em;
  border-radius: 50%; background: var(--red); vertical-align: .1em;
}
@media (prefers-reduced-motion: no-preference) {
  .is-now .work__time b::before { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .25; } }
}

@media (max-width: 1000px) {
  /* Location tucks under the dates so role and org keep room for one line */
  .work li { row-gap: .15rem; }
  .work__time { grid-column: 1 / span 3; grid-row: 1; }
  .work__loc  { grid-column: 1 / span 3; grid-row: 2; text-align: left; }
  .work__role { grid-column: 4 / span 5; grid-row: 1; }
  .work__org  { grid-column: 9 / -1; grid-row: 1; }
}
@media (max-width: 760px) {
  .work { grid-column: 1 / -1; }
  .work li { grid-template-columns: 1fr auto; row-gap: .25rem; }
  .work__time { grid-column: 1; grid-row: 1; }
  .work__loc  { grid-column: 2; grid-row: 1; text-align: right; }
  .work__role { grid-column: 1 / -1; grid-row: 2; }
  .work__org  { grid-column: 1 / -1; grid-row: 3; }
}

/* ---------- 03 Off-screen ---------- */
/* One run-in paragraph at the statement's size; verbs carry the weight */
.off {
  grid-column: 4 / -1;
  font-size: var(--fs-l); line-height: 1.15; letter-spacing: -.035em;
  color: var(--mute);
  text-wrap: pretty;
}
@media (max-width: 760px) {
  .off { grid-column: 1 / -1; }
}

/* ---------- 04 Contact ---------- */
.contact { padding-bottom: var(--s-4); }
.contact__body { grid-column: 4 / -1; }
.contact__intro {
  color: var(--mute);
  font-size: var(--fs-m); line-height: 1.3; letter-spacing: -.02em;
  max-width: 34ch;
}
.contact__mail {
  display: inline-block;
  margin-top: var(--s-2);
  font-size: var(--fs-xl);
  line-height: 1.05; letter-spacing: -.055em;
}
.links { display: flex; gap: 2rem; margin-top: var(--s-3); }
.links a { display: inline-block; padding: .5rem 0; }

@media (max-width: 760px) {
  .contact__body { grid-column: 1 / -1; }
}

/* ---------- Footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem 2rem;
  padding: var(--s-2) var(--gut) calc(env(safe-area-inset-bottom, 0px) + var(--s-2));
  border-top: var(--rule);
}
@media (max-width: 640px) {
  /* Copyright and "Top" share a line; the tagline gets its own */
  .foot span:nth-child(2) { order: 3; flex-basis: 100%; }
}
