/* ==========================================================
   Sam Wainwright — style.css
   Layout: two columns. Left = sticky name + index.
   Right = project sheets that scroll.
   ========================================================== */

/* ---------- 1. COLOURS AND FONTS ----------
   Change a value here and it updates everywhere. */
:root {
  --paper: #fbfbf9;   /* page background */
  --ink:   #1a1a1a;   /* text and rules */
  --dim:   #6b6b66;   /* secondary text */
  --mark:  #e8e6df;   /* index highlight */
  --screen:#0d0d0d;   /* behind videos */

  --display: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono:    "IBM Plex Mono", "Courier New", Courier, monospace;
}

/* Fonts, all self-hosted in /fonts so the site makes no requests to anyone else */
@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/HankenGrotesk-Black.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* Sam's own variable typeface, used in the MK project specimen */
@font-face {
  font-family: "MK";
  src: url("fonts/MKVF.woff2") format("woff2");
  font-weight: 50 500;
  font-display: swap;
}

/* ---------- 2. BASICS ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;                    /* same top and bottom, so the sticky column never gets nudged up */
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.4;
}

a { color: inherit; }

/* ---------- 3. PAGE GRID ---------- */
.page {
  display: grid;
  grid-template-columns: 1fr 2fr;   /* left column is a third of the width */
  gap: 32px;
  align-items: start;
}

/* ---------- 4. LEFT COLUMN ---------- */
aside {
  position: sticky;                 /* stays put while the right side scrolls */
  top: 16px;
  height: calc(100vh - 32px);       /* full screen height, so the footer sits at the bottom */
  overflow-y: auto;
  overflow-x: hidden;
  container-type: inline-size;      /* lets the name size itself to this column */
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-transform: uppercase;
}

h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: 13.5cqi;               /* 13.5% of the column width, so WAINWRIGHT always fits */
  line-height: 0.85;
  letter-spacing: -0.03em;
  margin: 0;
}

.letterhead p { margin: 0; font-size: 1.05em; }

/* Double rule above the index: a bolder top line over a thin one */
.double { border-top: 2px solid var(--ink); padding-top: 3px; }
.double::before { content: ""; display: block; border-top: 1px solid var(--ink); margin-bottom: 8px; }

/* Index: each row is a single link, so the whole row is clickable */
.idx { font-size: 0.95em; }
.idx-head,
.idx .row {
  display: grid;
  grid-template-columns: 2.2em 1fr 0.6fr 3.6em;   /* number / title / type / year */
  font-variant-numeric: tabular-nums;              /* digits line up down the column */
}
.idx-head span { padding: 0 8px 14px 4px; }
.idx .row { text-decoration: none; }
.idx .row span {
  padding: 5px 8px 2px 4px;
  border-bottom: 1px solid var(--ink);
}
.idx .row .n,
.idx-head .n {                      /* the small superscript numbers */
  border-bottom: 0;
  font-size: 0.7em;
  text-align: right;
  padding: 0 6px 0 0;
}
.idx .row:hover span:not(.n),
.idx .row.on span:not(.n) { background: var(--mark); }   /* .on is set by main.js */
.idx .row:focus-visible { outline: 1px dashed var(--ink); outline-offset: 2px; }

/* Footer, pushed to the bottom of the column */
.foot {
  margin-top: auto;
  border-top: 1px solid var(--ink);
  padding-top: 20px;
  font-size: 0.8em;
  text-transform: none;
}
.foot p { margin: 0; }

/* ---------- 5. RIGHT COLUMN ---------- */
main { display: flex; flex-direction: column; gap: 64px; min-width: 0; }

.sheet { scroll-margin-top: 16px; }   /* stops the jump landing tight to the top edge */

/* Project header row: number / title / type */
.head {
  display: grid;
  grid-template-columns: 2.5em 1fr 0.6fr;
  gap: 0 12px;
  text-transform: uppercase;
  font-size: 0.85em;
}
.head span { border-top: 2px solid var(--ink); padding-top: 3px; overflow-wrap: anywhere; }   /* double rule: bolder top line... */
.head span::before { content: ""; display: block; border-top: 1px solid var(--ink); margin-bottom: 8px; }   /* ...plus this one */

figure { margin: 28px 0 0; }

figure video,
figure img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--screen);
}

figcaption { font-size: 0.8em; margin-top: 8px; }   /* asset numbers: 2.1, 2.2 ... */

/* Play button over the poster still. It covers the whole video,
   so clicking anywhere plays it; the label sits bottom-left. */
.screen { position: relative; }
.play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;            /* label to the bottom...  */
  justify-content: flex-start;      /* ...and left             */
  padding: 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.play span {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 8px 14px;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.play:hover span,
.play:focus-visible span { background: var(--ink); color: var(--paper); }
.play[hidden] { display: none; }    /* hidden once the video starts */

.sheet p { font-size: 0.85em; max-width: 72ch; margin: 24px 0 0; }

.credits {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 16px;
  margin: 16px 0 0;
  font-size: 0.8em;
  text-transform: uppercase;
}
.credits dt { color: var(--dim); }

/* Two images side by side (wraps into a 2 x 2 grid with four) */
.pair {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 28px;
}
.pair figure { margin: 0; }

/* Three images in a row */
.trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}
.trio figure { margin: 0; }
/* Mixed shapes (9:16, 1:1, 1:1): column widths match each shape, so all share one height */
.trio.mixed { grid-template-columns: 9fr 16fr 16fr; }

/* Grey placeholder for an image that's still to come */
.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: var(--mark);
  color: var(--dim);
  font-size: 0.8em;
  text-transform: uppercase;
}

/* Keep an image's own shape instead of cropping it to 16:9 */
figure.natural img { aspect-ratio: auto; height: auto; }

/* Row of three square loops (GIF-style, as muted MP4s) */
.loops {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}
.loops.four { grid-template-columns: repeat(4, 1fr); }  /* four in a row on desktop */
.loops.wide { grid-template-columns: repeat(2, 1fr); }   /* 16:9 loops, 2 across */
.loops.wide video { aspect-ratio: 16 / 9; }
.loops.wide.three { grid-template-columns: repeat(3, 1fr); }   /* 3 across on desktop */
.loops.wide img { aspect-ratio: 16 / 9; object-fit: cover; }
.loops figure { margin: 0; }
.loops video {
  aspect-ratio: 1 / 1;              /* square */
  background: var(--mark);          /* grey placeholder until the file exists */
}
.credits dd { margin: 0; }

/* ---------- TYPE SPECIMEN (MK project) ---------- */
.mk { font-family: "MK", sans-serif; }
.stage {
  background: var(--ink);           /* black box, white type */
  color: var(--paper);
  border: 1px solid var(--ink);
  padding: 24px 20px;
  min-height: 12em;
  display: flex;
  align-items: center;
  overflow: hidden;
}
#live {
  font-size: clamp(56px, 8vw, 140px);
  line-height: 0.95;
  outline: none;
  width: 100%;
  overflow-wrap: anywhere;
}
.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  margin-top: 12px;
  font-size: 0.8em;
  text-transform: uppercase;
}
.controls label { display: grid; grid-template-columns: 4.5em 1fr 3em; align-items: center; gap: 10px; }
.controls output { text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--ink); }
.anim-row { margin: 10px 0 0; }
#anim {
  font: inherit;
  font-size: 0.8em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 4px 10px;
  cursor: pointer;
}
#anim:hover, #anim[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#anim:focus-visible { outline: 1px dashed var(--ink); outline-offset: 2px; }


/* Character set grid */
.ghead {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-size: 0.8em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.ghead input { width: 140px; vertical-align: middle; }
.glyphs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}
.glyphs span {
  font-family: "MK", sans-serif;
  font-size: 26px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  font-variation-settings: "wght" var(--gw, 120), "wdth" 200;
}
.glyphs span:hover { background: var(--ink); color: var(--paper); }

/* ---------- CURSOR LABEL ---------- */
#tag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}
#tag.on { opacity: 1; }

/* ---------- INDEX HOVER PREVIEW ---------- */
#peek {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  width: 320px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--ink);
  background: var(--screen);
  pointer-events: none;            /* never gets in the way of clicks */
  opacity: 0;
  transition: opacity 0.12s;
}
#peek.on { opacity: 1; }
#peek img, #peek video { display: none; width: 100%; height: 100%; object-fit: cover; }
#peek img.show, #peek video.show { display: block; }

/* ---------- LIGHTBOX ---------- */
main figure img { cursor: zoom-in; }

#lightbox {
  border: 0;
  padding: 0;
  background: none;
  max-width: 95vw;
  max-height: 95vh;
  overflow: visible;
}
#lightbox::backdrop { background: rgba(10, 10, 10, 0.92); }
#lightbox img {
  display: block;
  max-width: 95vw;
  max-height: calc(95vh - 32px);   /* leave room for the caption bar */
  width: auto;
  height: auto;
  cursor: zoom-out;
}
.lb-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 0.75em;
  text-transform: uppercase;
  color: #e8e6df;
}

/* ---------- 6. PHONES: stack into one column ---------- */
@media (max-width: 820px) {
  .page { grid-template-columns: 1fr; gap: 20px; }

  /* Drop the aside's own box so its children (name, letterhead,
     index, footer) join the page grid alongside <main> */
  aside { display: contents; }

  /* Reorder: projects after the index, footer at the very bottom */
  main  { order: 1; margin-top: 24px; }
  .foot { order: 2; margin-top: 48px; }
  .loops.four, .loops.wide.three { grid-template-columns: repeat(2, 1fr); }  /* 2 across on phones */
  .trio, .trio.mixed { grid-template-columns: 1fr; }      /* stack on phones */
  .controls { grid-template-columns: 1fr; }
  .head { grid-template-columns: 2em 1fr; }
  .head span:nth-child(n+3) { grid-column: 2; border-top: 0; padding-top: 2px; }
  .head span:nth-child(n+3)::before { display: none; }
}
