/* gabrielwong.co — one stylesheet for the whole site.
   Layout: a single 640px column; the homepage and figures run wider.
   Spacing follows an 8px scale; type follows the scale below. */

:root {
  /* color: warm grey paper and black ink; the project images bring the colour */
  --paper: #f2f1ed;
  --ink: #141414;
  --ink-soft: #66645f;
  --rule: #dcdad4;
  --grid: #e4e2dc;
  --mark: #141414; /* accent: links, labels, caption numbers */
  --panel: #e7e5e0; /* quiet fill used instead of outlines */

  /* type */
  /* Archivo for headlines, labels and interface; Newsreader for reading */
  --sans: "Archivo", system-ui, -apple-system, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --step--1: 0.8125rem; /* 13px */
  --step-0: 1rem;       /* 16px */
  --step-1: 1.1875rem;  /* 19px */
  --step-2: 1.6875rem;  /* 27px */
  --step-3: clamp(1.75rem, 4vw, 2.25rem);

  /* space */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 40px;
  --s5: 64px;

  --column: 640px;
  --wide: 880px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
  background: var(--paper); /* scrolling past the edge shows paper, not white */
  overscroll-behavior: none; /* no rubber-band bounce at the top and bottom */
  scrollbar-gutter: stable; /* pages don't shift sideways when a scrollbar appears */
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  overscroll-behavior: none; /* some browsers read it from body, not html */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.125rem / 1.6 var(--serif);
  padding: var(--s4) max(var(--s2), env(safe-area-inset-left)) var(--s5);
}

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a,
button {
  touch-action: manipulation; /* no double-tap zoom delay */
}

/* hover colours only where there is a pointer, so taps don't leave links red */
@media (hover: hover) {
  a:hover {
    color: var(--mark);
    text-decoration-thickness: 2px;
  }
}

/* quick crossfade between pages in browsers that support it */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.18s;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
}

/* ---------- shared pieces ---------- */

.page {
  max-width: var(--column);
  margin: 0 auto;
  display: grid;
  gap: var(--s4);
}

/* small interface text: nav, labels, captions' numbers */
.ui {
  font: 500 0.8125rem / 1.4 var(--sans);
  font-stretch: 112%;
}

/* the display voice: wide Archivo capitals */
.intro h1,
.case-head h1 {
  font-family: var(--sans);
  font-weight: 800;
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0;
}

.site-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
  color: var(--ink-soft);
  -webkit-user-select: none;
  user-select: none;
}

.site-header a {
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: var(--s3);
}

.site-header [aria-current="page"] {
  color: var(--ink);
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding-top: var(--s2);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s1);
  color: var(--ink-soft);
}

.label {
  color: var(--mark);
}

/* quiet frame for experiment images */
.plate {
  background: var(--panel);
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

/* ---------- homepage ---------- */

.intro {
  display: grid;
  gap: var(--s2);
}

.intro h1 {
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  line-height: 1.05;
}

.intro p {
  color: var(--ink-soft);
  max-width: 54ch;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* the work leads: real images in a two-column grid */
.work ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s5) var(--s3);
  width: min(var(--wide), 100vw - 2 * var(--s2));
  margin-inline: calc((var(--column) - min(var(--wide), 100vw - 2 * var(--s2))) / 2);
}

.work a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px var(--s2);
  text-decoration: none;
}

.work .shot {
  grid-column: 1 / -1;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--panel);
  margin-bottom: var(--s1);
  transition: opacity 0.2s ease;
}

@media (hover: hover) {
  .work a:hover .shot {
    opacity: 0.88;
  }
  .work a:hover .title {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
  }
}

.work .title {
  display: block;
  font: 700 var(--step-0) / 1.4 var(--sans);
  font-stretch: 112%;
}

.work .summary {
  display: block;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.5;
}

.work .year {
  font: 400 var(--step--1) / 1.9 var(--sans);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 672px) {
  .work ol {
    grid-template-columns: 1fr;
    width: 100%;
    margin-inline: 0;
  }
}

/* ---------- case study (short version) ---------- */

.case-head {
  display: grid;
  gap: var(--s3);
}

.case-head h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.05;
}

.abstract {
  display: grid;
  gap: 6px;
}

.abstract p {
  font: 400 var(--step-1) / 1.5 var(--serif);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--s2);
  margin: 0;
  padding: var(--s2) 0;
  border-block: 1px solid var(--rule);
}

.facts dt {
  color: var(--ink-soft);
}

.facts dd {
  margin: 4px 0 0;
  font-size: 0.9375rem;
}

.further {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
}

.further a {
  color: var(--mark);
}

.section {
  display: grid;
  gap: var(--s2);
}

/* section headings: plain sentence case */
.section > h2.ui {
  font: 700 1.5rem / 1.2 var(--sans);
  font-stretch: 112%;
}

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

.fig {
  margin: 0;
  display: grid;
  gap: var(--s1);
}

.fig .plate {
  aspect-ratio: auto;
}

.fig img {
  width: 100%;
  max-height: 85vh;
  object-fit: contain;
}

.fig.hero img {
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.fig figcaption {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.fig figcaption b {
  color: var(--mark);
  font: 600 0.75rem var(--sans);
  margin-right: var(--s1);
}

/* lets an image run wider than the text column on large screens */
.fig.wide {
  width: min(var(--wide), 100vw - 2 * var(--s2));
  margin-inline: calc((var(--column) - min(var(--wide), 100vw - 2 * var(--s2))) / 2);
}

@media (max-width: 672px) {
  .fig.wide {
    width: 100%;
    margin-inline: 0;
  }
}

.next {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
  border-top: 1px solid var(--rule);
  padding-top: var(--s2);
}

/* numbered research questions at the end of a case study */
.questions {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: q;
  display: grid;
  border-top: 1px solid var(--rule);
}

.questions li {
  counter-increment: q;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--s2);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--rule);
  font: 400 var(--step-1) / 1.45 var(--serif);
}

.questions li::before {
  content: "Q" counter(q);
  font: 600 0.75rem / 2.4 var(--sans);
  color: var(--mark);
}

/* ---------- about ---------- */

.about {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: var(--s3);
  align-items: start;
}

.about .text {
  display: grid;
  gap: var(--s2);
}

@media (max-width: 520px) {
  .about {
    grid-template-columns: 1fr;
  }
  .about img {
    max-width: 160px;
  }
}

.cv {
  display: grid;
  gap: var(--s1);
}

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

.cv li {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--s2);
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.cv li span:first-child {
  font: 400 var(--step--1) var(--sans);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: no-preference) {
  a {
    transition: color 0.15s ease;
  }
}

/* ---------- experiments ---------- */

.experiments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4) var(--s3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.experiments a {
  display: grid;
  gap: var(--s1);
  text-decoration: none;
}

.experiments .plate {
  aspect-ratio: 1;
}

.experiments img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (hover: hover) {
  .experiments a:hover .plate {
    opacity: 0.88;
  }
}

.experiments .caption {
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.experiments .caption b {
  color: var(--mark);
  font: 600 0.75rem var(--sans);
  margin-right: var(--s1);
}

@media (max-width: 520px) {
  .experiments {
    grid-template-columns: 1fr;
  }
}
