@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  /* asphalt and track paint, plus the tyre compound colours Formula Analyst uses */
  --asphalt: #2e3035;
  --asphalt-deep: #25272b;
  --paint: #f4f4f0;
  --paint-dim: #c3c6cc;
  --line: rgb(244 244 240 / 0.18);
  --soft: #da291c;
  --medium: #ffd12e;
  --hard: #f0f0ec;
  --event: #43b02a;
  --gantry: #101113;
  --ferrari: #e8002d;
  --months: 48; /* Jan 2024 to Dec 2027 */
  --now: 34.5; /* months from Jan 2024: mid November 2026 */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--asphalt);
  color: var(--paint);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 70rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 6rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

a { color: inherit; text-decoration-thickness: 0.09em; text-underline-offset: 0.2em; }
a:hover { color: var(--medium); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--medium); outline-offset: 3px; }

p { margin: 0 0 1em; max-width: 62ch; }
ul, ol, dl { margin: 0; padding: 0; }

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* headings: one family, the wide cut for names and titles */
h1, h2, h3 { margin: 0; font-stretch: 125%; line-height: 1.05; }

h1 {
  font-size: clamp(2.9rem, 14.5vw, 11.4rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.88;
  margin-left: -0.04em;
}
h1 span { display: block; }

h2 {
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }

main > section, main > footer { margin-top: clamp(4rem, 9vw, 7.5rem); }

/* hero */
.hero { display: grid; gap: 2rem; }
.tagline { margin: -0.75rem 0 0; max-width: none; font-stretch: 125%; font-weight: 700; font-size: clamp(1.15rem, 2.3vw, 1.7rem); line-height: 1.2; letter-spacing: -0.01em; }
.lede { font-size: clamp(1.15rem, 1.9vw, 1.45rem); line-height: 1.42; max-width: 46ch; margin: 0; }
.links { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-weight: 600; }

@media (min-width: 60rem) {
  .hero { grid-template-columns: 1fr auto; align-items: end; column-gap: 3rem; }
  .hero h1, .hero .tagline { grid-column: 1 / -1; }
  .hero .links { flex-direction: column; gap: 0.35rem; text-align: right; }
}

/* stint chart */
.stints { margin-top: clamp(3rem, 6vw, 5rem); }
.stints h2 { margin-bottom: 0.75rem; }

.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 2rem; margin-bottom: 1.5rem; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; color: var(--paint-dim); font-size: 0.95rem; }
.legend li { display: flex; align-items: center; gap: 0.5rem; }

.is-work { --c: var(--medium); }
.is-study { --c: var(--hard); }
.is-build { --c: var(--soft); }
.is-event { --c: var(--event); }

.tyre { width: 1rem; height: 1rem; border-radius: 50%; border: 0.25rem solid var(--c); background: var(--asphalt-deep); }

/* start lights: only shown when the script runs the chart animation */
/* a gantry: a beam with five pods, two lights in each */
.lights { display: none; gap: 0.3rem; padding: 0 0.4rem; border-top: 0.35rem solid var(--gantry); }
.motion .lights { display: flex; }
.lights i { display: grid; gap: 0.24rem; padding: 0.28rem; border-radius: 0 0 0.55rem 0.55rem; background: var(--gantry); }
.lights i::before, .lights i::after { content: ""; width: 0.95rem; height: 0.95rem; border-radius: 50%; background: #3a1614; }
.lights i.on::before, .lights i.on::after { background: #ff2a1a; box-shadow: 0 0 0.55rem 0.1rem rgb(255 42 26 / 0.65); }

.chart { --pad: clamp(1rem, 3vw, 2.25rem); background: var(--asphalt-deep); padding: 1.75rem var(--pad) 2.25rem; overflow: hidden; }

.years { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); color: var(--paint-dim); font-size: 1rem; font-weight: 600; }
.years li { padding-left: 0.5rem; border-left: 1px solid var(--line); }

.rows {
  position: relative;
  padding-top: 2.4rem;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: 25% 100%;
}

.row + .row { margin-top: 1.9rem; }
.row .label, .row .detail {
  /* each label is a block in the panel colour, so the Now line never runs through the text */
  position: relative; z-index: 1; width: fit-content; max-width: 100%; margin: 0; padding: 0 0.5rem;
  background: var(--asphalt-deep);
}
.row .label { margin-bottom: 0.55rem; font-size: 1.2rem; line-height: 1.3; }
.row .label strong { font-weight: 650; padding-right: 0.3rem; }
.row .label span { color: var(--paint-dim); }
.row .detail { margin-top: 0.6rem; color: var(--paint-dim); font-size: 1rem; }
.row .detail a + a { margin-left: 0.75rem; }

/* the script turns each label into a button that opens the detail line */
.js .row { cursor: pointer; }
.row button { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.row button::after { content: "+"; content: "+" / ""; padding-left: 0.5rem; color: var(--paint-dim); font-weight: 600; }
.row button[aria-expanded="true"]::after { content: "\2212"; content: "\2212" / ""; }

.track { position: relative; height: 1.3rem; }
.bar {
  position: absolute; top: 0; bottom: 0;
  left: calc(var(--from) / var(--months) * 100%);
  width: calc(var(--len) / var(--months) * 100%);
  min-width: 0.5rem;
  border-radius: 0.25rem;
  background: var(--c);
}
.bar.to-now { width: calc((var(--now) - var(--from)) / var(--months) * 100%); }
.bar.ahead {
  /* the part of the degree that hasn't happened yet: it runs off the panel edge */
  left: calc(var(--now) / var(--months) * 100%);
  right: calc(-1 * var(--pad));
  width: auto;
  background: repeating-linear-gradient(-45deg, var(--hard) 0 3px, transparent 3px 9px);
  border-radius: 0;
  opacity: 0.75;
}
.bar.point {
  width: 1.3rem; min-width: 0; margin-left: calc(-0.65rem + var(--nudge, 0rem));
  border-radius: 50%; background: var(--asphalt-deep);
  border: 0.34rem solid var(--c);
}

.now { position: absolute; top: 0; bottom: 0; left: calc(var(--now) / var(--months) * 100%); border-left: 2px solid var(--paint); }
.now span { position: absolute; top: 0; left: 0.45rem; font-size: 0.9rem; font-weight: 700; line-height: 1; }

/* projects */
.project { display: grid; gap: 1.75rem; padding-top: 2.5rem; margin-top: 2.5rem; border-top: 2px solid var(--paint); }
h2 + .project { margin-top: 0; }
.project h3 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 750; margin-bottom: 1rem; letter-spacing: -0.02em; }
.project figure { margin: 0; display: grid; gap: 0.75rem; align-content: start; }
.project img { display: block; width: 100%; height: auto; border: 1px solid var(--line); }
.project figcaption { color: var(--paint-dim); font-size: 0.9rem; }

@media (min-width: 60rem) {
  .project { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: 3.5rem; }
  .project.plain { grid-template-columns: 1fr 1fr; }
}

.facts { display: grid; gap: 0; margin: 1.5rem 0; border-top: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 8.5rem 1fr; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--paint-dim); }
.facts dd { margin: 0; font-weight: 600; }

.go { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-weight: 600; margin: 0; }

/* results */
table { width: 100%; border-collapse: collapse; }
.results th { text-align: left; font-weight: 600; color: var(--paint-dim); font-size: 0.95rem; padding: 0 1rem 0.6rem 0; border-bottom: 2px solid var(--paint); }
.results td { padding: 0.9rem 1rem 0.9rem 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.results td.pos { font-stretch: 125%; font-weight: 800; font-size: clamp(1.25rem, 2.4vw, 1.75rem); letter-spacing: -0.02em; white-space: nowrap; width: 1%; padding-right: clamp(1rem, 4vw, 3rem); }
.results td:last-child { color: var(--paint-dim); }

@media (max-width: 40rem) {
  .results thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .results tr { display: grid; padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
  .results tbody tr:first-child { border-top: 2px solid var(--paint); }
  .results td, .results td.pos { padding: 0; border: 0; width: auto; }
}

/* two-column text sections */
.columns { display: grid; gap: 3rem; }
@media (min-width: 60rem) { .columns { grid-template-columns: 1fr 1fr; column-gap: 3.5rem; } }
.columns h3 { margin-top: 1.75rem; }
.columns h2 + h3 { margin-top: 0; }
.columns ul { list-style: none; margin-top: 0.6rem; }
.columns li { padding: 0.5rem 0; border-top: 1px solid var(--line); max-width: 62ch; }
.columns h3 + p { margin-top: 0.6rem; }
.when { color: var(--paint-dim); margin: 0.25rem 0 0; }

/* languages */
.langs { list-style: none; display: grid; gap: 1.75rem; }
.langs li { padding-top: 1rem; border-top: 2px solid var(--paint); }
.langs strong { display: block; font-stretch: 125%; font-weight: 800; font-size: clamp(2.4rem, 4.4vw, 3rem); letter-spacing: -0.025em; line-height: 1.05; }
.langs span { display: block; margin-top: 0.45rem; color: var(--paint-dim); }
@media (min-width: 56rem) { .langs { grid-template-columns: repeat(3, 1fr); column-gap: 2.5rem; } }

/* tools table: a ring where a tool was used, a dot where it was not */
.matrix { table-layout: fixed; }
.matrix th, .matrix td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.matrix th:first-child { width: 34%; padding-left: 0; text-align: left; }
.matrix thead th { padding-bottom: 0.6rem; border-bottom: 2px solid var(--paint); color: var(--paint-dim); font-size: 0.95rem; font-weight: 600; line-height: 1.2; vertical-align: bottom; }
.matrix tbody th { font-weight: 600; }
.matrix tr.group > * { padding-top: 1.9rem; }
.matrix thead th:focus-visible { outline-offset: -3px; }
.ring, .dot { display: inline-block; border-radius: 50%; vertical-align: middle; }
.ring { width: 1.05rem; height: 1.05rem; border: 0.26rem solid var(--medium); background: var(--asphalt-deep); }
.dot { width: 0.3rem; height: 0.3rem; background: var(--paint-dim); opacity: 0.55; }
.matrix .on .ring { background: var(--medium); }
.matrix .dim { opacity: 0.4; }

.also-title { margin: 3rem 0 0.9rem; }
.also { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); column-gap: 2rem; }
.also li { padding: 0.55rem 0; border-top: 1px solid var(--line); font-weight: 600; }

@media (max-width: 40rem) {
  .matrix th:first-child { width: 44%; }
  .matrix th, .matrix td { padding-left: 0.15rem; padding-right: 0.15rem; }
  .matrix thead th:not(:first-child) span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
}

/* off the clock: some words show a favourite on hover, focus or tap */
.off { position: relative; }
.reveal { position: relative; white-space: nowrap; cursor: help; text-decoration: underline dotted var(--medium); text-decoration-thickness: 0.12em; text-underline-offset: 0.22em; }
.tip {
  display: none;
  position: absolute; left: 0; bottom: calc(100% + 0.35rem); z-index: 2;
  padding: 0.35rem 0.6rem;
  background: var(--asphalt-deep); border: 1px solid var(--line); color: var(--paint);
  font-stretch: 125%; font-style: normal; font-weight: 700; font-size: 0.85rem; line-height: 1.2; white-space: nowrap;
  animation: tip 0.12s ease-out;
}
.reveal:hover .tip, .reveal:focus .tip, .point:hover .tip, .point:focus .tip { display: inline-block; }
.tip.ferrari { background: var(--ferrari); border-color: var(--ferrari); color: #fff; }

/* chart dots: the label hangs off the dot, to the left once the dot is past the middle */
.point { cursor: pointer; }
.point .tip { left: -0.34rem; bottom: calc(100% + 0.7rem); }
.point.flip .tip { left: auto; right: -0.34rem; }
@media (max-width: 40rem) { .point .tip { width: max-content; max-width: 10rem; white-space: normal; } }
@keyframes tip { from { opacity: 0; } }

/* narrow screens: start the label at the left edge of the text, on the line above the word, so it stays on screen */
@media (max-width: 40rem) {
  .reveal { position: static; }
  .reveal .tip { left: 0; bottom: auto; transform: translateY(calc(-100% - 0.25rem)); }
}

/* where the browser can do it, pin the label to the word and move it when it would leave the column */
@supports (anchor-scope: --word) {
  .reveal { position: static; anchor-name: --word; anchor-scope: --word; }
  .reveal .tip { position-anchor: --word; left: anchor(left); bottom: calc(anchor(top) + 0.35rem); transform: none; position-try-fallbacks: --from-right, --column-left; }
  @position-try --from-right { left: auto; right: anchor(right); }
  @position-try --column-left { left: 0; right: auto; }
}

footer { border-top: 2px solid var(--paint); padding-top: 2.5rem; }
footer p { font-size: 1.15rem; }
.sign { margin: 2.5rem 0 0; }
.sign strong { font-stretch: 125%; font-weight: 800; letter-spacing: -0.01em; }
.sign [lang="ko"] { margin-left: 0.6rem; font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; font-weight: 600; }
.small { color: var(--paint-dim); font-size: 0.9rem; margin-top: 2.5rem; }
.sign + .small { margin-top: 0.3rem; }

/* motion: motion.js adds .motion to <html> unless reduced motion is set */
.motion h1 { animation: widen 0.5s ease-out both; }
@keyframes widen { from { font-stretch: 62%; } }

.motion .chart .bar { clip-path: inset(0 0 0 0); transition: clip-path 0.45s ease-out calc(var(--i, 0) * 70ms); }
.motion .chart:not(.run) .bar { clip-path: inset(0 100% 0 0); }
/* dots scale in instead, so their hover labels are never clipped */
.motion .chart .bar.point { clip-path: none; transition: transform 0.3s ease-out calc(var(--i, 0) * 70ms); }
.motion .chart:not(.run) .bar.point { clip-path: none; transform: scale(0); }
.motion .chart .now { transition: opacity 0.3s ease-out 1.2s, transform 0.45s ease-out 1.2s; }
.motion .chart:not(.run) .now { opacity: 0; transform: translateX(-2.5rem); }
.motion .lights i { transition: background-color 0.1s; }
.motion .matrix th, .motion .matrix td { transition: opacity 0.15s; }

@media (prefers-reduced-motion: reduce) {
  .tip { animation: none; }
}
