/* Grid Explorer: the landing page.

   VOICE   work, with an occasion's poster in the first screen
   IDEA    an engineering drawing sheet pinned beside a photograph of the
           real thing: black ink, grey paper, one hazard-sign red
   PICTURE the photograph (a slot: swap the file, one object-position);
           below, the architecture drawn by hand in SVG
   COLOUR  white ground, black ink, the photograph's greys, signal red
           #C8102E for the rule, the section numbers and the primary link
   TYPE    IBM Plex Sans (400, 500, 600) and IBM Plex Mono (400, 500),
           self-hosted, SIL OFL 1.1
   LAYOUT  laptop: photograph a sticky left column, 40 % wide, full height;
           the page scrolls on the right on a 7 px baseline. Phone: the
           photograph is a band at the top, the headline follows. */

@font-face { font-family: "Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-Medium-Latin1.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/IBMPlexSans-SemiBold-Latin1.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/IBMPlexMono-Medium-Latin1.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #111111;
  --grey-1: #f1f1ef;   /* zones, the code block */
  --grey-2: #d6d6d3;   /* hairlines */
  --grey-3: #5c5c5c;   /* secondary text: 6.7:1 on white */
  --signal: #c8102e;   /* the one accent: 5.9:1 on white */
  --b: 7px;            /* the baseline unit */
  --sans: "Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "Plex Mono", ui-monospace, Menlo, monospace;
  /* The photograph slot. Change these two with the file. */
  --photo-x: 30%;
  --photo-y: 50%;
}

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/calc(var(--b) * 4) var(--sans); font-kerning: normal; overflow-x: clip; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
p { margin: 0 0 calc(var(--b) * 3); max-width: 38em; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }

/* ---------- The two columns ---------- */

.sheet { display: grid; grid-template-columns: minmax(0, 1fr); }
.photo { position: relative; margin: 0; height: min(68vw, 62svh); min-height: 260px; background: #9a9a98; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; object-position: var(--photo-x) var(--photo-y); }
.photo figcaption { position: absolute; left: 0; bottom: 0; padding: 4px 10px; background: var(--paper); font: 400 13px/21px var(--mono); color: var(--grey-3); }
.photo figcaption a { color: var(--grey-3); }

.page { padding: calc(var(--b) * 4) max(5vw, 16px) calc(var(--b) * 8); }

@media (min-width: 900px) {
  .sheet { grid-template-columns: minmax(0, 40fr) minmax(0, 60fr); }
  .photo { position: sticky; top: 0; height: 100vh; height: 100svh; min-height: 0; }
  .page { padding: calc(var(--b) * 5) clamp(32px, 5.5vw, 104px) calc(var(--b) * 12); }
}
@media (min-width: 900px) and (max-width: 1180px) {
  .sheet { grid-template-columns: minmax(0, 36fr) minmax(0, 64fr); }
}

/* ---------- Masthead ---------- */

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 24px; padding-bottom: calc(var(--b) * 2); border-bottom: 1px solid var(--ink); font: 500 14px/21px var(--mono); }
.top nav { display: flex; gap: 24px; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; }

.head { padding-top: calc(var(--b) * 10); }
.head h1 { margin: 0; font-weight: 600; font-size: clamp(64px, 19vw, 96px); line-height: 0.9; letter-spacing: -0.045em; margin-left: -0.05em; }
@media (min-width: 900px) { .head h1 { font-size: min(11vw, 168px); } }
.rule { width: calc(var(--b) * 14); height: var(--b); background: var(--signal); margin: calc(var(--b) * 5) 0 calc(var(--b) * 4); border: 0; }
.claim { font-size: clamp(22px, 2.1vw, 30px); line-height: 1.33; font-weight: 500; letter-spacing: -0.012em; max-width: 24em; margin: 0 0 calc(var(--b) * 4); }
.held { font-size: clamp(17px, 1.35vw, 19px); line-height: 1.45; color: var(--grey-3); max-width: 34em; margin: calc(var(--b) * -2) 0 calc(var(--b) * 4); }
.lead-links { display: flex; flex-wrap: wrap; gap: calc(var(--b) * 2) calc(var(--b) * 4); align-items: baseline; margin: 0; font-size: 17px; }
.primary { color: var(--signal); font-weight: 600; text-decoration: none; border-bottom: 2px solid var(--signal); padding-bottom: 2px; }
.primary:hover { border-bottom-width: 4px; }
.secondary { font-weight: 500; }
.quiet { font-weight: 400; color: var(--grey-3); }

/* ---------- Sections ---------- */

section { display: grid; grid-template-columns: minmax(0, 1fr); padding-top: calc(var(--b) * 12); }
.num { font: 500 14px/calc(var(--b) * 3) var(--mono); color: var(--signal); padding-top: calc(var(--b) * 2); border-top: 1px solid var(--ink); }
section h2 { margin: 0 0 calc(var(--b) * 3); font-size: clamp(26px, 2.4vw, 34px); line-height: calc(var(--b) * 5); font-weight: 600; letter-spacing: -0.02em; padding-top: calc(var(--b) * 2); border-top: 1px solid var(--ink); }
section h3 { margin: calc(var(--b) * 4) 0 var(--b); font-size: 17px; line-height: calc(var(--b) * 4); font-weight: 600; }
@media (min-width: 640px) {
  section { grid-template-columns: calc(var(--b) * 9) minmax(0, 1fr); }
  .num { grid-row: 1 / span 30; }
  section > :not(.num) { grid-column: 2; }
}
@media (max-width: 639px) {
  .num { border-top: 0; padding-top: 0; margin-bottom: calc(var(--b) * -1); }
  section h2 { border-top: 0; padding-top: 0; }
  section { border-top: 1px solid var(--ink); margin-top: calc(var(--b) * 8); padding-top: calc(var(--b) * 2); }
}

/* the opening run, as a timeline */
.run { margin: calc(var(--b) * 3) 0 calc(var(--b) * 3); padding: 0; list-style: none; border-top: 1px solid var(--grey-2); max-width: 38em; }
.run li { display: grid; grid-template-columns: 5.2em minmax(0, 1fr); gap: 0 calc(var(--b) * 2); padding: var(--b) 0; border-bottom: 1px solid var(--grey-2); }
.run time { font: 500 15px/calc(var(--b) * 4) var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.run-title { font: 500 14px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); margin: calc(var(--b) * 4) 0 0; }
.aside { color: var(--grey-3); }

/* the architecture */
.arch { container-type: inline-size; margin: calc(var(--b) * 2) 0 calc(var(--b) * 3); }
.arch svg { display: block; width: 100%; height: auto; }
.arch .narrow { max-width: 420px; }
.arch .wide { display: none; }
@container (min-width: 580px) {
  .arch .wide { display: block; }
  .arch .narrow { display: none; }
}
.arch text { font-family: var(--sans); fill: var(--ink); }
.arch .t { font-size: 15px; font-weight: 600; }
.arch .s { font-family: var(--mono); font-size: 12.5px; fill: var(--grey-3); }
.arch .l { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.arch .zone { fill: var(--grey-1); }
.arch .box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.arch .box.key { stroke-width: 2.5; }
.arch .line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.arch .check { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.arch .head-fill { fill: var(--ink); }

.notes { margin: 0 0 calc(var(--b) * 3); padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(15em, 1fr)); gap: 0 calc(var(--b) * 4); }
.notes li { padding: calc(var(--b) * 2) 0 calc(var(--b) * 1); border-top: 1px solid var(--grey-2); }
.notes b { display: block; font-weight: 600; }
.notes p { margin: 0; font-size: 15px; line-height: calc(var(--b) * 3); }

/* the video slot */
.video { position: relative; margin: calc(var(--b) * 1) 0 0; }
.video .frame { position: relative; aspect-ratio: 16 / 9; background: var(--grey-1); overflow: hidden; border: 1px solid var(--ink); }
.video .frame img { width: 100%; height: 100%; object-fit: cover; object-position: top left; filter: grayscale(1) contrast(0.9); opacity: 0.55; }
.video .tag { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; padding: 12px 20px; background: var(--ink); color: var(--paper); font: 500 15px/21px var(--mono); }
.video figcaption { margin-top: calc(var(--b) * 2); font-size: 15px; line-height: calc(var(--b) * 3); color: var(--grey-3); max-width: 38em; }

/* commands */
pre { margin: calc(var(--b) * 1) 0 calc(var(--b) * 3); padding: calc(var(--b) * 2) calc(var(--b) * 3); background: var(--grey-1); font: 400 14px/calc(var(--b) * 3) var(--mono); overflow-x: auto; max-width: 100%; }
@media (max-width: 639px) { pre { font-size: 13px; padding: var(--b) calc(var(--b) * 2); margin-inline: calc(-1 * max(5vw, 16px)); max-width: none; } }
.needs, .ops { margin: 0 0 calc(var(--b) * 3); padding: 0 0 0 1.1em; max-width: 38em; }
.needs li, .ops li { margin: 0; }

/* the limits */
.limits { margin: calc(var(--b) * 1) 0 calc(var(--b) * 3); padding: 0; list-style: none; max-width: 40em; }
.limits li { padding: var(--b) 0 var(--b) calc(var(--b) * 3); border-top: 1px solid var(--grey-2); position: relative; }
.limits li::before { content: ""; position: absolute; left: 0; top: calc(var(--b) * 3); width: 8px; height: 1.5px; background: var(--ink); }

/* credits */
.credits { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; max-width: 44em; }
.credits div { display: grid; grid-template-columns: minmax(0, 1fr); padding: var(--b) 0; border-top: 1px solid var(--grey-2); }
.credits dt { font-weight: 600; }
.credits dd { margin: 0; color: var(--ink); }
@media (min-width: 640px) {
  .credits div { grid-template-columns: 9em minmax(0, 1fr); gap: 0 calc(var(--b) * 3); }
}
.foot { margin-top: calc(var(--b) * 10); padding-top: calc(var(--b) * 2); border-top: 1px solid var(--ink); font: 400 13px/21px var(--mono); color: var(--grey-3); }

/* ---------- Variant: a very tall photograph (own.html) ----------
   The picture is about 1:4, far taller than the column. The column is
   narrower, and where the browser can tie an animation to scrolling the
   picture moves against the page: it opens on its bottom (the pylons) and,
   as the text scrolls up, slides down until its top (sky and conductors)
   is in view. Elsewhere it rests on the pylons. */
.own .photo img { object-position: 50% 100%; }
@media (min-width: 900px) {
  .own .sheet { grid-template-columns: minmax(0, 30fr) minmax(0, 70fr); }
  @supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) {
      .own .photo img { animation: follow-the-line linear both; animation-timeline: scroll(root block); }
    }
  }
}
@keyframes follow-the-line { from { object-position: 50% 100%; } to { object-position: 50% 0%; } }

/* Grain. The photograph is a hard crop and is enlarged on dense screens.
   Fine noise drawn at the screen's own resolution keeps it crisp, so the
   enlargement reads as film grain and not as softness. */
.photo::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: overlay; opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 240px 240px; }
.photo figcaption { z-index: 1; }

/* a still of a demo page, in the text column */
.still { margin: calc(var(--b) * 1) 0 calc(var(--b) * 3); }
.still img { width: 100%; height: auto; border: 1px solid var(--grey-2); }
.still video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--paper); border: 1px solid var(--grey-2); }
.still figcaption { margin-top: calc(var(--b) * 2); font-size: 15px; line-height: calc(var(--b) * 3); color: var(--grey-3); max-width: 38em; }

/* ---------- Source code, quoted from the files ----------
   Each block is verbatim from the file its data-source names, with whole
   lines left out marked by an ellipsis (check/landing.mjs holds this). The
   accent is kept for the few lines that matter: the foreign imports and the
   calls into pandapower. Long lines scroll inside the block, never the page. */
figure.code { margin: calc(var(--b) * 1) 0 calc(var(--b) * 3); }
figure.code figcaption { font: 400 13px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); padding: 0 0 var(--b); border-bottom: 1.5px solid var(--ink); }
pre.src { margin: 0; padding: calc(var(--b) * 2) calc(var(--b) * 3) calc(var(--b) * 2); font: 400 13px/calc(var(--b) * 3) var(--mono); tab-size: 4; color: var(--ink); background: var(--grey-1); }
pre.src code { font-size: inherit; }
pre.src b { font-weight: 500; color: var(--signal); }
@media (max-width: 639px) {
  pre.src { font-size: 12px; line-height: 19px; padding: var(--b) 16px; margin-inline: calc(-1 * max(5vw, 16px)); max-width: none; }
  figure.code figcaption { font-size: 12px; }
}

/* one function in both languages: side by side where both fit, else stacked */
.pair { container-type: inline-size; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 calc(var(--b) * 2); margin: calc(var(--b) * 1) 0 calc(var(--b) * 2); }
.pair figure.code { margin: 0 0 calc(var(--b) * 2); }
@media (min-width: 900px) {
  section > .pair { grid-column: 1 / -1; grid-template-columns: minmax(0, 60fr) minmax(0, 47fr); }
  .pair pre.src { font-size: 12px; padding-inline: calc(var(--b) * 2); min-height: calc(100% - 28px); }
}

/* tables of figures */
.table-wrap { overflow-x: auto; margin: calc(var(--b) * 1) 0 calc(var(--b) * 2); max-width: 44em; }
.figures { border-collapse: collapse; width: 100%; font-size: 15px; line-height: calc(var(--b) * 3); }
.figures th, .figures td { padding: var(--b) calc(var(--b) * 2) var(--b) 0; border-bottom: 1px solid var(--grey-2); text-align: left; vertical-align: top; }
.figures thead th { font: 500 12px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); border-bottom: 1.5px solid var(--ink); }
.figures td { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.figures thead th:not(:first-child) { text-align: right; }
.figures tbody th { font-weight: 500; }
.figures tbody th span { display: block; font: 400 12px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); }
.figures td:last-child, .figures th:last-child { padding-right: 0; }
p.aside { font-size: 15px; line-height: calc(var(--b) * 3); }

/* the other routes: a table that becomes blocks on a phone */
.ways { border-collapse: collapse; width: 100%; margin: calc(var(--b) * 1) 0 calc(var(--b) * 3); font-size: 15px; line-height: calc(var(--b) * 3); }
.ways th, .ways td { text-align: left; vertical-align: top; padding: calc(var(--b) * 1.5) calc(var(--b) * 2) calc(var(--b) * 1.5) 0; border-bottom: 1px solid var(--grey-2); }
.ways thead th { font: 500 12px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); border-bottom: 1.5px solid var(--ink); }
.ways tbody th { font-weight: 600; width: 22%; }
.ways td:last-child { color: var(--grey-3); width: 30%; padding-right: 0; }
@media (max-width: 759px) {
  .ways thead { display: none; }
  .ways, .ways tbody, .ways tr, .ways th, .ways td { display: block; width: auto !important; }
  .ways tr { padding: calc(var(--b) * 1.5) 0; border-bottom: 1px solid var(--grey-2); }
  .ways th, .ways td { border: 0; padding: 0; }
  .ways tbody th { margin-bottom: calc(var(--b) * 0.5); }
  .ways td:last-child { margin-top: var(--b); }
  .ways td:last-child::before { content: "Cost: "; font-weight: 500; color: var(--ink); }
}

.buys, .costs { margin-top: calc(var(--b) * 1); }

/* a cost's figures, folded: <details> with a quiet summary, no script. Open,
   the item takes the whole width so its table has room. */
.costs details { margin: var(--b) 0 calc(var(--b) * 1); }
.costs summary { display: inline-flex; align-items: baseline; gap: 8px; cursor: pointer; list-style: none; font: 500 13px/calc(var(--b) * 3) var(--mono); color: var(--grey-3); }
.costs summary::-webkit-details-marker { display: none; }
.costs summary::before { content: "+"; display: inline-block; width: 1ch; color: var(--signal); }
.costs details[open] > summary::before { content: "\2212"; }
.costs summary:hover { color: var(--ink); }
.costs summary:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.costs details[open] > summary { margin-bottom: var(--b); }
.costs details .table-wrap { margin-top: 0; }
.costs li:has(details[open]) { grid-column: 1 / -1; }

/* the Lab, looping: a still in its place with reduced motion, and in print */
.loop video { display: block; width: 100%; height: auto; aspect-ratio: 1280 / 630; background: var(--paper); border: 1px solid var(--grey-2); }
.loop .still-frame { display: none; }
@media (prefers-reduced-motion: reduce) {
  .loop video { display: none; }
  .loop .still-frame { display: block; }
}
@media print {
  .loop video { display: none; }
  .loop .still-frame { display: block; }
  .costs summary { display: none; }
}
.still.small { max-width: 30em; }
.still a { display: block; }

.top a { text-decoration: none; }
