/* hem.is
   One page of real DOM text. The canvas (added by app.js) is decoration that
   sits behind it; without JS the stage shows a pre-rendered ASCII ring and the
   "hem is" line lists every completion. */

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-hemis-1.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-hemis-1.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #edf1ec;
  --ink: #1a2b20;
  --ink-2: #2b4433;
  --muted: #46644f;
  --soft: #54715d;          /* small text: 4.7:1 on --bg */
  --field: #54795f;         /* "hem is": large text only (4.3:1) */
  --rule: rgba(43, 68, 51, .17);
  --hover: rgba(84, 121, 95, .08);
  --focus: #2b4433;
  --sel: rgba(84, 121, 95, .24);
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --padx: clamp(20px, 5.2vw, 84px);
  --pady: clamp(22px, 4.2vw, 56px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1611;
    --ink: #e4ece4;
    --ink-2: #dae3da;
    --muted: #a2b7a9;
    --soft: #8aa494;
    --field: #8fb89b;
    --rule: rgba(218, 227, 218, .15);
    --hover: rgba(143, 184, 155, .08);
    --focus: #dae3da;
    --sel: rgba(143, 184, 155, .28);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--sel); }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ frame */
.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--pady) var(--padx) calc(var(--pady) + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto auto;
  overflow: clip;
}
/* the canvas (app.js) sits in flow, under the text */
.field {
  position: absolute;
  left: 0; top: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
}
.top, .stage, main, .foot { position: relative; z-index: 1; }

/* ------------------------------------------------------------------ wordmark */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.mark {
  margin: 0;
  font-family: var(--mono);
  font-weight: 620;
  font-size: clamp(24px, 1.05vw + 15px, 31px);
  line-height: 1;
  letter-spacing: -.055em;
  color: var(--ink);
}
.mark .dot { color: var(--field); letter-spacing: -.02em; }

/* ------------------------------------------------------------------ stage */
.stage {
  margin: 0 calc(-1 * var(--padx));
  display: grid;
  place-items: center;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.js .stage { height: clamp(250px, 84vw, 470px); }
.ascii {
  margin: 18px 0 6px;
  font-family: var(--mono);
  font-size: min(11px, calc((100vw - 24px) / 38.4));
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--soft);
  white-space: pre;
  font-variant-ligatures: none;
}
.ascii b { font-weight: 400; color: var(--ink-2); }
.ascii i { font-style: normal; color: var(--field); }
.ascii u { text-decoration: none; font-weight: 560; color: var(--ink-2); }
.js .ascii { display: none; }

.hint {
  position: absolute;
  left: 0; right: 0; bottom: 4px;
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .12em;
  color: var(--soft);
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}
.hint.on { opacity: 1; }
.hint .t { display: none; }
@media (hover: none) and (pointer: coarse) { .hint .m { display: none; } .hint .t { display: inline; } }

main { min-width: 0; }

/* ------------------------------------------------------------------ "hem is …" */
.hemis {
  position: relative;
  display: grid;
  margin: 6px 0 0;
  font-family: var(--mono);
  font-weight: 400;
  font-size: clamp(21px, 6.3vw, 32px);
  line-height: 1.2;
  letter-spacing: -.03em;
  color: var(--ink);
  font-variant-ligatures: none;
  font-kerning: none;
}
.hemis .lead {
  grid-area: 1 / 1;
  margin: 0;
  color: var(--field);
  white-space: pre;
}
.facts { grid-area: 1 / 1; list-style: none; margin: 0; padding: 0; }
.facts li { margin: 0; }
.facts li:first-child { text-indent: calc(7 * (1ch - .03em)); }
/* Without JS: every completion, fanned out under "hem is". */
.facts li + li {
  --fan: .56;
  font-size: calc(var(--fan) * 1em);
  line-height: 1.38;
  letter-spacing: -.01em;
  margin-left: calc(7 * (1ch - .03em) / var(--fan));
  margin-top: .45em;
  color: var(--muted);
}
.facts li:nth-child(2) { margin-top: .9em; }
/* With JS: the list is an invisible sizing stack (still read by assistive tech):
   the cell takes the height of the longest completion at the current width, and
   the animated line is drawn over it, so the layout never moves. */
.js .facts { display: grid; }
.js .facts li, .js .facts li + li {
  grid-area: 1 / 1;
  opacity: 0;
  text-indent: calc(7 * (1ch - .03em));
  font-size: 1em;
  line-height: inherit;
  letter-spacing: inherit;
  margin: 0;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
}
.line { display: none; }
.js .line {
  display: block;
  position: absolute;
  inset: 0;
  margin: 0;
  text-indent: calc(7 * (1ch - .03em));
  contain: strict;
  pointer-events: none;
}
.line .a { color: var(--field); }
.line .b { color: var(--field); opacity: .7; }
.line .c { color: var(--field); opacity: .45; }
.line .h { visibility: hidden; }

/* ------------------------------------------------------------------ things he made */
.made { margin-top: clamp(30px, 5.5vh, 60px); }
/* the reserved lines under a short completion already give the list room */
.js .made { margin-top: clamp(16px, 2.5vh, 30px); }
.made h2 {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 6px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.made h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.works { list-style: none; margin: 0; padding: 0; counter-reset: w; }
.works li { counter-increment: w; border-bottom: 1px solid var(--rule); }
.works a {
  position: relative;
  display: grid;
  grid-template-columns: 3.4ch minmax(0, 1fr) auto;
  grid-template-areas: "n nm ar" "n ds ar";
  column-gap: 12px; row-gap: 2px;
  align-items: baseline;
  padding: 13px 8px 14px;
  margin: 0 -8px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color .35s ease;
}
.works a::before {
  content: counter(w, decimal-leading-zero);
  content: counter(w, decimal-leading-zero) / "";
  grid-area: n;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--soft);
  transition: color .35s ease;
}
.works .nm {
  grid-area: nm;
  font-family: var(--mono);
  font-weight: 480;
  font-size: 16px;
  letter-spacing: -.015em;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .5s cubic-bezier(.2, .7, .2, 1);
}
.works .ds { grid-area: ds; font-size: 14.5px; line-height: 1.4; color: var(--muted); }
.works .ar {
  grid-area: ar;
  align-self: center;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--soft);
  transition: transform .5s cubic-bezier(.2, .7, .2, 1), color .35s ease;
}
.works a:hover, .works a:focus-visible { background: var(--hover); }
.works a:hover .nm, .works a:focus-visible .nm { background-size: 100% 1px; }
.works a:hover .ar, .works a:focus-visible .ar { transform: translate(3px, -3px); color: var(--ink); }
.works a:hover::before, .works a:focus-visible::before { color: var(--ink-2); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ footer */
.foot {
  margin-top: clamp(32px, 6vh, 56px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 20px;
}
.foot p { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .03em; color: var(--muted); }
.foot .sep { color: var(--soft); padding: 0 .35em; }
.toggle {
  appearance: none;
  margin: -8px -10px;
  padding: 8px 10px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .03em;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background-color .3s ease, color .3s ease;
}
.toggle::before {
  content: "";
  width: 7px; height: 9px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
}
.toggle.off::before {
  width: 0; height: 0;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent currentColor;
}
.toggle:hover { background: var(--hover); color: var(--ink); }
.toggle[hidden] { display: none; }

/* ------------------------------------------------------------------ 404 */
.page.nf { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
.nf .top, .nf main, .nf .foot { grid-column: 1; grid-row: auto; }
.nf main { align-self: center; padding: 6vh 0; }
.nf .mark a { color: inherit; text-decoration: none; border-radius: 4px; }
.nf .ascii.nf-ring { margin: 0 0 30px; font-size: min(13px, calc((100vw - 40px) / 22.8)); color: var(--soft); }
.nf .hemis.nf-line { display: block; margin: 0; font-size: clamp(26px, 6vw, 40px); }
.nf .hemis.nf-line .lead { display: inline; }
.nf-home { margin: 22px 0 0; font-family: var(--mono); font-size: 15px; }
.nf-home a {
  color: var(--ink); text-decoration: none; border-radius: 4px;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
}
.nf-home a:hover { background-size: 0 1px; }
.nf-home .ar { color: var(--soft); }

/* ------------------------------------------------------------------ entrance */
@media (prefers-reduced-motion: no-preference) {
  .js .rise { animation: rise 1s cubic-bezier(.2, .7, .2, 1) both; }
  .js .rise.r2 { animation-delay: .1s; }
  .js .rise.r3 { animation-delay: .2s; }
  .js .rise.r4 { animation-delay: .32s; }
}
@keyframes rise { from { opacity: 0; } }

/* ------------------------------------------------------------------ wider */
@media (min-width: 560px) {
  .works a {
    grid-template-columns: 3.4ch minmax(0, 15.5ch) minmax(0, 1fr) auto;
    grid-template-areas: "n nm ds ar";
    column-gap: 18px;
  }
  .works .ds { font-size: 15px; }
}
@media (min-width: 960px) {
  .page {
    --L: clamp(30rem, 47vw, 46rem);
    --gap: clamp(28px, 3vw, 56px);
    grid-template-columns: minmax(0, var(--L)) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    column-gap: var(--gap);
  }
  .top { grid-column: 1; grid-row: 1; }
  .stage {
    grid-column: 2; grid-row: 1 / -1;
    margin: calc(-1 * var(--pady)) calc(-1 * var(--padx)) calc(-1 * var(--pady)) 0;
  }
  .js .stage { height: auto; }
  .ascii { font-size: min(12.5px, calc((50vw - 60px) / 38.4)); margin: 0; }
  .hint { bottom: calc(var(--pady) + 2px); }
  main { grid-column: 1; grid-row: 2; align-self: center; padding: 4vh 0; }
  .foot { grid-column: 1; grid-row: 3; margin-top: 0; }
  .hemis { font-size: clamp(25px, calc(var(--L) / 20), 38px); }
  .facts li + li { --fan: .5; }
  .made, .js .made { margin-top: clamp(32px, 6vh, 64px); }
}
@media (min-width: 960px) and (max-height: 720px) {
  main { padding: 2vh 0; }
  .made { margin-top: 28px; }
  .works a { padding-top: 10px; padding-bottom: 11px; }
}
@media (min-width: 960px) {
  .page.nf { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  .nf main { grid-column: 1; grid-row: 2; padding: 4vh 0; }
  .nf .foot { grid-column: 1; grid-row: 3; }
}
@media print {
  .field, .stage, .toggle { display: none; }
}
