/* Design tokens, taken from the Figma file (1442px frame, 10px margin and gutter, 12 columns). */
:root {
  --unit: 10px;
  --gap: var(--unit);
  --margin: var(--unit);

  --text: 15px;
  --lh-tight: 0.92;
  --lh-body: 1.11;
  --tracking: -0.15px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --weight: 300;

  --header-h: 300px;
  --header-h-about: 331px; /* Figma: about text starts at y=351 */
  --nav-gap: 5px;
  --tile-gap: 10px;
  --tile-pad: 20px;
  --control-gap: 4px;
  --arrow-w: 50px;

  --color-bg: #ffffff;
  --color-fg: #000000;
  --color-ph: #d9d9d9;
  --hover-opacity: 0.4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--color-bg); }

body {
  font-family: var(--font);
  font-weight: var(--weight);
  font-size: var(--text);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking);
  color: var(--color-fg);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
p, h1 { font-size: inherit; font-weight: inherit; text-box: trim-both cap alphabetic; }
img, iframe { display: block; }

/* Page: 12 column grid, every direct child places itself with grid-column. */
.page {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--margin);
  align-content: start;
}

/* ---------- header ---------- */

.header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  height: var(--header-h);
  align-items: start;
}
.header--about { height: var(--header-h-about); }
.header__name { grid-column: 1 / 5; white-space: nowrap; }
.header__detail { white-space: nowrap; }
.header > .header__detail { grid-column: 5 / 9; }
.header__end { grid-column: 9 / 13; display: flex; justify-content: space-between; align-items: start; }

.nav { display: flex; flex-direction: column; gap: var(--nav-gap); align-items: start; }
.nav__link { text-box: trim-both cap alphabetic; }

/* Hover: name, nav links and Prev/Next fade. */
.header__name a:hover, .nav__link:hover, .control:hover { opacity: var(--hover-opacity); }

/* ---------- images ---------- */

.ph { background: var(--color-ph); width: 100%; height: 100%; }
img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- home ---------- */

.hero { grid-column: 1 / -1; display: block; aspect-ratio: var(--r, 1.5); }

.tiles {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: var(--gap);
}
.tile { grid-column: span 4; display: flex; flex-direction: column; gap: var(--tile-gap); padding-bottom: var(--tile-pad); }
.tile__image { aspect-ratio: 3 / 2; }
.tile__title { width: 100%; }

/* ---------- project ---------- */

.controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: start;
}
.control { display: flex; align-items: center; gap: var(--control-gap); white-space: nowrap; }
.control svg { width: var(--arrow-w); height: auto; flex: none; }
.control span { text-box: trim-both cap alphabetic; }
.control--prev { grid-column: 1 / 3; justify-self: start; }
.controls__title { grid-column: 5 / 9; white-space: nowrap; }
.control--next { grid-column: 11 / 13; justify-self: end; }

.main { grid-column: 1 / -1; aspect-ratio: var(--r, 1.5); }
.main--video iframe { width: 100%; height: 100%; border: 0; }

/* Bento rows: each row is its own 12 column grid matching the page grid. */
.row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: var(--gap);
  align-items: start;
}
.cell { aspect-ratio: var(--r, 1.5); }
.row--full .cell { grid-column: 1 / -1; }
.row--halves .cell { grid-column: span 6; }
.row--thirds .cell { grid-column: span 4; }
.row--single .cell { grid-column: span 6; }

/* Tall: the portrait fills the height of two stacked landscapes plus the gap between them. */
.row--tall { grid-template-rows: auto auto; }
.row--tall .cell--stack { grid-column: span 6; }
.row--tall .cell--tall { grid-row: 1 / 3; aspect-ratio: auto; align-self: stretch; position: relative; }
.row--tall .cell--tall > * { position: absolute; inset: 0; }
.row--tall-left .cell--tall { grid-column: 1 / 7; }
.row--tall-left .cell--stack { grid-column: 7 / 13; }
.row--tall-right .cell--tall { grid-column: 7 / 13; }
.row--tall-right .cell--stack { grid-column: 1 / 7; }
.row--tall-right .cell--stack:nth-child(2) { grid-row: 1; }
.row--tall-right .cell--stack:nth-child(3) { grid-row: 2; }

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

/* About copy is centered in the viewport; it shares the first grid row with the header. */
.page--about { min-height: 100vh; grid-template-rows: minmax(0, 1fr); }
.page--about .header { grid-row: 1; }
/* Centered on the grid, vertically centered in the window. Takes more columns as the window narrows. */
.about { grid-column: 6 / 8; grid-row: 1; align-self: center; line-height: var(--lh-body); }
/* Width stays roughly 355-540px: more columns as the window narrows. Odd spans sit half a column left of center. */
@media (max-width: 2200px) { .about { grid-column: 5 / 8; } }
@media (max-width: 1600px) { .about { grid-column: 5 / 9; } }
@media (max-width: 1200px) { .about { grid-column: 4 / 9; } }
@media (max-width: 1000px) { .about { grid-column: 4 / 10; } }
@media (max-width: 800px)  { .about { grid-column: 3 / 10; } }
@media (max-width: 700px)  { .about { grid-column: 3 / 11; } }
.about p { text-box: none; }
.about p + p { margin-top: calc(var(--text) * var(--lh-body)); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  :root { --header-h: 200px; --header-h-about: 200px; }
  /* Header collapses to two columns: name and details stacked left, nav right. */
  .header { grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; row-gap: calc(var(--text) * var(--lh-tight) + var(--nav-gap)); align-content: start; }
  .header__name { grid-column: 1; grid-row: 1; }
  .header > .header__detail { grid-column: 1; grid-row: 2; }
  .header__end { display: contents; }
  .header__end .header__detail { grid-column: 1; grid-row: 3; }
  .header__end .nav { grid-column: 2; grid-row: 1 / 4; }

  .tile { grid-column: span 6; }
  .controls__title { grid-column: 3 / 11; justify-self: center; }
}

@media (max-width: 600px) {
  :root { --header-h: 160px; --header-h-about: 160px; }
  .tile { grid-column: 1 / -1; }
  .row--halves .cell, .row--thirds .cell, .row--single .cell,
  .row--tall .cell--stack, .row--tall .cell--tall { grid-column: 1 / -1; }
  .row--tall { grid-template-rows: none; }
  .row--tall .cell--tall { grid-row: auto; aspect-ratio: var(--r, 0.75); position: static; }
  .row--tall .cell--tall > * { position: static; }
  .row--tall-right .cell--stack:nth-child(2), .row--tall-right .cell--stack:nth-child(3) { grid-row: auto; }
  .controls__title { grid-column: 4 / 10; }
  .control--prev { grid-column: 1 / 4; }
  .control--next { grid-column: 10 / 13; }
  .control svg { width: 30px; }
  /* Phone: copy flows below the header at full width. */
  .page--about { min-height: 0; grid-template-rows: none; }
  .about { grid-column: 1 / -1; grid-row: auto; align-self: start; }
}
