/* Hablon: an interactive study of a shaft loom.
   One family (Newsreader), five sizes, flat colour, no rules or shadows. */

:root {
  --paper: #e9ebe8;
  --paper-2: #d9dcd7;
  --ink: #191817;
  --muted: #4a4843;
  --accent: #245263;
  --accent-ink: #ffffff;

  --plate: #1b1a19;
  --plate-2: #2c2b29;
  --plate-3: #3a3936;
  --plate-ink: #efede7;
  --plate-muted: #bdb9ae;
  --focus: #8fc3d6;

  --step-small: 0.875rem;
  --step-body: 1.125rem;
  --step-lead: clamp(1.375rem, 1.1rem + 0.9vw, 1.75rem);
  --step-head: clamp(1.75rem, 1.3rem + 1.4vw, 2.5rem);
  --step-display: clamp(4.5rem, 2.8rem + 5vw, 6rem);

  --gutter: clamp(20px, 3vw, 40px);
  --font: "Newsreader", "Iowan Old Style", Georgia, serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-body);
  line-height: 1.55;
  font-optical-sizing: auto;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

::selection { background: var(--accent); color: var(--accent-ink); }
.plate ::selection, .colophon ::selection { background: var(--focus); color: var(--ink); }

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

.skip {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 10px 16px; text-decoration: none;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ------------------------------------------------------------ the split */

.folio {
  display: grid;
  grid-template-columns: minmax(0, 11fr) minmax(0, 13fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "plate head" "plate main";
  align-items: start;
}
.masthead { grid-area: head; padding: clamp(40px, 6vw, 96px) var(--gutter) 0; max-width: 54rem; }
.page { grid-area: main; }
.plate { grid-area: plate; }

.plate {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  padding: var(--gutter);
  background: var(--plate);
  color: var(--plate-ink);
}

.plate :focus-visible { outline-color: var(--focus); }

.plate-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: var(--step-body);
}
.plate-name { font-weight: 500; }
.plate-name i { font-weight: 400; color: var(--plate-muted); }
.plate-count { color: var(--plate-muted); font-variant-numeric: tabular-nums lining-nums; }

.loom {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  touch-action: manipulation;
  cursor: crosshair;
}
.loom:focus-visible { outline-offset: -3px; }

.beam { fill: var(--plate-3); }
.fell { fill: var(--plate-muted); }
.shuttle { fill: var(--plate-ink); opacity: 0; }
.probe { fill: none; stroke: #fff; stroke-width: 1.8; pointer-events: none; }

.sweep { animation: sweep 170ms ease-out both; }
.fly .shuttle { animation: fly 170ms linear backwards; }

@keyframes sweep {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes fly {
  from { transform: translateX(-90px); opacity: 1; }
  to { transform: translateX(520px); opacity: 1; }
}

.readout {
  min-height: 3.2em;
  font-size: var(--step-small);
  line-height: 1.45;
  color: var(--plate-ink);
}

.toolbar {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  gap: 8px;
}
.btn-wide { grid-column: 1 / -1; }

.btn {
  font: inherit;
  font-size: var(--step-small);
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: var(--plate-2);
  color: var(--plate-ink);
  cursor: pointer;
  transition: background-color 140ms ease, transform 90ms ease;
}
.btn:hover:not(:disabled) { background: var(--plate-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--paper); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn[aria-pressed="true"] { background: var(--plate-ink); color: var(--ink); }

/* ---------------------------------------------------------------- page */

.page {
  padding: 0 var(--gutter) clamp(72px, 9vw, 140px);
  max-width: 54rem;
}

.masthead h1 {
  font-size: var(--step-display);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.035em;
  margin-left: -0.04em;
}
.lead {
  margin-top: 32px;
  font-size: var(--step-lead);
  line-height: 1.3;
  letter-spacing: -0.01em;
  max-width: 30ch;
}
.note {
  margin-top: 24px;
  max-width: 44ch;
  color: var(--muted);
}

.block { margin-top: clamp(88px, 11vw, 160px); }
.block > h2 {
  font-size: var(--step-head);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 20ch;
  margin-bottom: 32px;
}
.block p { max-width: 46ch; }
.block p + p { margin-top: 1em; }

/* chooser */

.chooser {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.pick {
  display: grid;
  gap: 2px;
  align-content: start;
  text-align: left;
  font: inherit;
  padding: 12px 12px 14px;
  border: 0;
  border-radius: 0;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 90ms ease;
}
.pick:hover { background: #cdd0ca; }
.pick:active { transform: translateY(1px); }
.pick[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.thumb { width: 100%; aspect-ratio: 5 / 3; display: block; margin-bottom: 12px; }
.pick-name { font-size: var(--step-lead); line-height: 1.2; letter-spacing: -0.01em; }
.pick-where { font-size: var(--step-small); }
.pick[aria-pressed="false"] .pick-where { color: var(--muted); }

.entry { margin-top: 56px; }
.entry h3 {
  font-size: var(--step-lead);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}
.entry-study { color: var(--ink); }
.entry-study::before { content: "In this study. "; font-style: italic; }

.facts { margin-top: 32px; display: grid; gap: 14px; max-width: 46ch; }
.facts div { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 16px; }
.facts dt { color: var(--muted); font-style: italic; }
.facts dd { margin: 0; }

/* tie-up */

.tieup {
  --cell: clamp(28px, 6.4vw, 44px);
  margin-top: 40px;
  display: grid;
  grid-template-columns: 6.25rem repeat(8, var(--cell));
  gap: 4px;
  width: max-content;
  max-width: 100%;
}
.tu-corner { display: block; }
.tu-head {
  text-align: center;
  font-size: var(--step-small);
  color: var(--muted);
  font-variant-numeric: tabular-nums lining-nums;
}
.tu-head.idle { opacity: 0.8; }

.treadle {
  font: inherit;
  font-size: var(--step-small);
  text-align: left;
  min-height: var(--cell);
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, transform 90ms ease;
}
.treadle:hover { background: #1b4151; }
.treadle:active { transform: translateY(1px); }
.treadle.last { background: var(--ink); }

.tu-cell {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper-2);
  cursor: pointer;
  transition: background-color 120ms ease;
}
.tu-cell:hover { background: #cdd0ca; }
.tu-cell[aria-pressed="true"] { background: var(--ink); }
.tu-cell[aria-pressed="true"]:hover { background: #3a3936; }
.tu-cell.idle { opacity: 0.55; }

.nojs { padding: var(--gutter); color: var(--plate-ink); }
.follows { margin-top: 24px; font-size: var(--step-small); color: var(--muted); max-width: 52ch; }

.row-actions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }
.btn-paper {
  font: inherit;
  font-size: var(--step-small);
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 140ms ease, transform 90ms ease;
}
.btn-paper:hover:not(:disabled) { background: #cdd0ca; }
.btn-paper:active:not(:disabled) { transform: translateY(1px); }
.btn-paper:disabled { opacity: 0.45; cursor: default; }
.btn-paper[hidden] { display: none; }

.plain { padding: 0; list-style: none; display: grid; gap: 18px; max-width: 46ch; }
.plain li { padding-left: 1.2em; position: relative; }
.plain li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 0.45em; height: 0.45em; background: var(--accent); }

/* ------------------------------------------------------------- colophon */

.colophon {
  background: var(--plate);
  color: var(--plate-ink);
  padding: clamp(56px, 7vw, 96px) var(--gutter) 0;
  overflow: hidden;
}
.colophon-text { font-size: var(--step-lead); line-height: 1.3; max-width: 28ch; }
.colophon a { color: inherit; text-underline-offset: 0.2em; }
.colophon a:hover { color: #fff; text-decoration-thickness: 2px; }
.colophon :focus-visible { outline-color: var(--focus); }
.wordmark {
  margin-top: clamp(40px, 6vw, 88px);
  font-size: 27vw;
  line-height: 0.74;
  letter-spacing: -0.04em;
  margin-left: -0.03em;
  color: var(--plate-3);
  white-space: nowrap;
  user-select: none;
}

/* -------------------------------------------------------------- motion */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1), transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  .sweep, .fly .shuttle { animation: none; }
  .btn, .pick, .treadle, .tu-cell, .btn-paper { transition: none; }
  .btn:active, .pick:active, .treadle:active, .btn-paper:active { transform: none; }
}

/* ---------------------------------------------------------------- phone */

@media (max-width: 899px) {
  .folio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "head" "plate" "main";
  }
  .masthead { padding-top: 40px; padding-bottom: 40px; max-width: none; }

  .plate {
    z-index: 5;
    height: 62vh;
    height: 62svh;
    gap: 8px;
    padding: 12px var(--gutter) 12px;
  }
  .plate-head { font-size: var(--step-small); }
  .readout { min-height: 2.9em; }
  .toolbar { gap: 6px; }
  .btn { padding: 0 6px; }

  .page { max-width: none; }
  .masthead h1 { font-size: clamp(4.5rem, 24vw, 7rem); }
  .facts div { grid-template-columns: 1fr; gap: 2px; }
  .chooser { gap: 8px; }
  .pick { padding: 8px 8px 12px; }
  .tieup { grid-template-columns: 5.75rem repeat(8, var(--cell)); --cell: calc((100vw - 2 * var(--gutter) - 5.75rem - 36px) / 8); }
}

@media (max-width: 899px) and (max-height: 640px) {
  .plate { height: 74vh; height: 74svh; }
}
