/* ogon.dev
   Layout: the page reads like Ogon's own workspace. Figures sit in viewport frames on the same grey the
   comparison renders use, with a mono stats overlay; orange is only ever "selected" (links, the slider,
   the active chapter), as it is in the app. Fonts are Ogon's: Young Serif for a few big lines, IBM Plex
   Sans for reading, IBM Plex Mono for every number. */

@font-face { font-family: "Young Serif"; src: url("../fonts/YoungSerif-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("../fonts/IBMPlexSans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("../fonts/IBMPlexSans-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("../fonts/IBMPlexSans-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/IBMPlexMono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("../fonts/IBMPlexMono-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }

:root {
  --page: #e7e6e2;        /* a neutral studio grey, not paper */
  --sheet: #f2f1ee;       /* the few raised surfaces */
  --viewport: #b6b6bd;    /* the renders' own background, so figures sit flush */
  --viewport-edge: #9d9da6;
  --ink: #1c1b19;
  --ink-2: #44423e;
  --quiet: #6c6963;
  --rule: #cdcbc5;
  --select: #f37b31;      /* Ogon's selection orange */
  --select-ink: #a9480f;  /* the same, dark enough for text on --page */
  --good: #2c6e47;
  --bad: #a8342a;
  --overlay: rgb(20 20 22 / 72%);
  --overlay-ink: #f1f0ec;

  --display: "Young Serif", Georgia, serif;
  --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, Consolas, monospace;

  --step--1: 0.84rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem);
  --step-3: clamp(2.3rem, 1.4rem + 3.6vw, 4.2rem);
  --measure: 64ch;
  --wide: 1240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #18181a; --sheet: #202023; --viewport: #2c2c31; --viewport-edge: #3d3d44;
    --ink: #eeece7; --ink-2: #c9c6bf; --quiet: #9a968e; --rule: #33333a;
    --select-ink: #f59a5c; --good: #6cc394; --bad: #ef7a6c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #18181a; --sheet: #202023; --viewport: #2c2c31; --viewport-edge: #3d3d44;
  --ink: #eeece7; --ink-2: #c9c6bf; --quiet: #9a968e; --rule: #33333a;
  --select-ink: #f59a5c; --good: #6cc394; --bad: #ef7a6c;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 var(--step-0)/1.62 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--page);
}
img, video { display: block; max-width: 100%; height: auto; }
a { color: var(--select-ink); text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
a:hover { color: var(--select); }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
figure { margin: 0; }
p { margin: 0; text-wrap: pretty; }
code { font: 0.92em var(--mono); }
.num, td, .mono { font-variant-numeric: tabular-nums; }

.frame {
  max-width: var(--wide);
  margin-inline: auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 99; background: var(--sheet); padding: 8px 12px; }

/* Header: the app's top bar, simplified */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--page);
  border-bottom: 1px solid var(--rule);
}
.bar .frame { display: flex; align-items: center; gap: 28px; height: 58px; }
.wordmark { display: block; line-height: 0; }
.wordmark img { height: 24px; width: auto; }
.wordmark .on-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wordmark .on-light { display: none; } :root:not([data-theme="light"]) .wordmark .on-dark { display: block; } }
:root[data-theme="dark"] .wordmark .on-light { display: none; }
:root[data-theme="dark"] .wordmark .on-dark { display: block; }
.links { display: flex; gap: 22px; font-size: 0.93rem; }
.links a { color: var(--ink-2); text-decoration: none; }
.links a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--select); }
.version { margin-left: auto; font: 400 0.78rem var(--mono); color: var(--quiet); white-space: nowrap; }
.menu { display: none; }
@media (max-width: 880px) {
  .bar .frame { gap: 14px; }
  .links { display: none; }
  .links.open {
    display: flex; flex-direction: column; gap: 0; position: absolute; top: 58px; left: 0; right: 0;
    background: var(--page); border-bottom: 1px solid var(--rule);
    padding: 6px max(20px, env(safe-area-inset-right, 0px)) 14px max(20px, env(safe-area-inset-left, 0px));
  }
  .links.open a { padding: 11px 0; border-bottom: 1px solid var(--rule); }
  .menu {
    display: block; margin-left: 4px; background: none; border: 1px solid var(--rule); color: var(--ink);
    font: 500 0.88rem var(--sans); padding: 6px 11px; border-radius: 3px; cursor: pointer;
  }
}

/* Viewport frame: every figure */
.vp {
  position: relative; background: var(--viewport); border: 1px solid var(--viewport-edge); border-radius: 3px; overflow: hidden;
}
.vp > img, .vp > video { width: 100%; }
.hud {
  position: absolute; left: 10px; top: 10px; z-index: 2; pointer-events: none;
  font: 400 0.74rem/1.5 var(--mono); color: var(--overlay-ink); background: var(--overlay);
  padding: 5px 8px; border-radius: 2px; white-space: nowrap;
}
.hud.r { left: auto; right: 10px; }
.hud b { font-weight: 500; color: #fff; }
.hud.sel { background: var(--select); color: #fff; }
.vp .gizmo { position: absolute; left: 12px; bottom: 12px; width: 34px; height: 34px; z-index: 2; pointer-events: none; }
.cap { margin-top: 10px; font-size: var(--step--1); color: var(--quiet); line-height: 1.5; max-width: 90ch; }
.cap .mono { color: var(--ink-2); }
.pan { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  .pan > img { width: auto; max-width: none; height: 280px; }
  figure:has(.pan) .cap::before { content: "Swipe the picture sideways to see all of it. "; color: var(--ink-2); }
}

/* Opening */
.open { padding-block: 64px 0; }
.open-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 430px); gap: 64px; align-items: end; }
.open h1 { font-family: var(--display); font-size: var(--step-3); line-height: 1.02; letter-spacing: -0.015em; max-width: 11ch; }
.open h1 span { color: var(--select-ink); }
.open .lede { margin-top: 26px; font-size: var(--step-1); line-height: 1.5; color: var(--ink-2); max-width: 34ch; }
.actions { margin-top: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; }
.play {
  display: inline-flex; align-items: center; gap: 12px; padding: 12px 18px 12px 14px;
  background: var(--ink); color: var(--page); text-decoration: none; border-radius: 3px; font-weight: 500;
}
.play:hover { background: var(--select); color: #fff; }
.play svg { width: 14px; height: 14px; fill: currentColor; }
.play .t { font: 400 0.82rem var(--mono); opacity: 0.7; }
@media (max-width: 900px) {
  .open { padding-top: 36px; }
  .open-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .open h1 { max-width: 13ch; }
  .open figure { max-width: 320px; }
}

/* The slider */
.slider { cursor: ew-resize; user-select: none; touch-action: pan-y; }
.slider .after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos, 50%)); }
.slider .after img { width: 100%; height: 100%; object-fit: cover; }
.slider .cut { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; margin-left: -1px; background: var(--select); z-index: 1; }
.slider .knob {
  position: absolute; top: 50%; left: var(--pos, 50%); z-index: 3; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; background: var(--select); box-shadow: 0 0 0 3px rgb(255 255 255 / 85%); pointer-events: none;
}
.slider .knob::before, .slider .knob::after {
  content: ""; position: absolute; top: 50%; width: 0; height: 0; margin-top: -5px; border: 5px solid transparent;
}
.slider .knob::before { left: 3px; border-right-color: #fff; }
.slider .knob::after { right: 3px; border-left-color: #fff; }
.slider input { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.slider input:focus-visible ~ .knob { box-shadow: 0 0 0 3px var(--ink); }

/* Status bar: the facts, the way the app's own bottom bar shows them */
.status-bar {
  margin-top: 56px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font: 400 0.82rem var(--mono); color: var(--ink-2);
}
.status-bar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.status-bar li { padding: 11px 18px 11px 0; margin-right: 18px; border-right: 1px solid var(--rule); white-space: nowrap; }
.status-bar li:last-child { border-right: 0; }
.status-bar .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 7px; vertical-align: 1px; }
@media (max-width: 640px) { .status-bar li { border-right: 0; padding: 4px 0; margin-right: 22px; } .status-bar ul { padding-block: 8px; } }

/* Sections */
.part { padding-block: 104px 0; }
.part > .frame > h2, .part h2.title { font-family: var(--display); font-size: var(--step-2); line-height: 1.1; letter-spacing: -0.01em; max-width: 22ch; }
.intro { margin-top: 16px; max-width: var(--measure); color: var(--ink-2); font-size: 1.1rem; }
.part h3 { font: 600 1.08rem/1.35 var(--sans); }
.prose-col { max-width: var(--measure); }
.prose-col p + p { margin-top: 0.9em; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; margin-top: 48px; align-items: start; }
.split.rev { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.split.rev > :first-child { order: 2; }
.split > div > h3 + p, .split > div > h3 + ol, .split > div > h3 + ul { margin-top: 10px; }
.split p + p, .split p + .table, .split .table + p, .split ol + p { margin-top: 0.9em; }
.full { margin-top: 48px; }
@media (max-width: 900px) {
  .part { padding-top: 72px; }
  .split, .split.rev { grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 32px; }
  .split.rev > :first-child { order: 0; }
}

/* Steps: these really are an order (the method runs them in this order) */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0.1em; width: 22px; height: 22px; line-height: 22px; text-align: center;
  font: 500 0.75rem/22px var(--mono); color: var(--ink); border: 1px solid var(--rule); border-radius: 2px;
}

/* Number tables */
.table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
  text-align: left; font: 500 0.74rem var(--mono); color: var(--quiet); letter-spacing: 0.04em;
  padding: 0 14px 8px 0; border-bottom: 1px solid var(--ink); white-space: nowrap;
}
td { padding: 9px 14px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
td.n { font-family: var(--mono); font-size: 0.86rem; white-space: nowrap; }
td.best { color: var(--good); font-weight: 500; }
td.worst { color: var(--bad); }
tr.mine td:first-child { font-weight: 600; }
@media (max-width: 720px) { td.n { white-space: normal; } table { font-size: 0.86rem; } td { padding-right: 10px; } }
.note { margin-top: 14px; font-size: var(--step--1); color: var(--quiet); max-width: 60ch; }

/* Demo */
.demo-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; margin-top: 40px; align-items: start; }
.edl { margin: 0; padding: 0; list-style: none; font: 400 0.9rem var(--mono); border-top: 1px solid var(--ink); }
.edl button {
  display: grid; grid-template-columns: 52px 1fr; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--rule);
  background: none; color: var(--ink-2); font: inherit; text-align: left; cursor: pointer;
}
.edl button span:first-child { color: var(--quiet); }
.edl button:hover, .edl button.on { color: var(--ink); }
.edl button.on span:first-child { color: var(--select-ink); }
.edl-note { margin-top: 14px; font-size: var(--step--1); color: var(--quiet); }
@media (max-width: 900px) { .demo-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; } .edl { columns: 2; column-gap: 24px; border-top: 0; } .edl li { break-inside: avoid; } }
@media (max-width: 460px) { .edl { columns: 1; } }

/* Other tools: rows, not cards */
.rows { margin-top: 44px; border-top: 1px solid var(--ink); }
.row { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 40px; padding-block: 32px; border-bottom: 1px solid var(--rule); align-items: center; }
.row h3 { font: 400 var(--step-1)/1.2 var(--display); }
.row p { margin-top: 8px; color: var(--ink-2); max-width: 52ch; }
.row .fig-num { margin-top: 14px; font: 400 0.86rem var(--mono); color: var(--ink); }
.row .fig-num b { font-weight: 500; color: var(--select-ink); }
@media (max-width: 820px) { .row { grid-template-columns: minmax(0, 1fr); gap: 18px; } .row > .vp { order: -1; } }

/* The app: a filmstrip */
.strip {
  margin-top: 40px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, 46%); gap: 18px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 14px; -webkit-overflow-scrolling: touch;
}
.strip figure { margin: 0; scroll-snap-align: start; }
.strip figcaption { margin-top: 9px; font-size: var(--step--1); color: var(--quiet); }
.strip figcaption b { color: var(--ink); font-weight: 500; }
.strip .vp img { aspect-ratio: 16 / 9; object-fit: cover; cursor: zoom-in; }
@media (max-width: 700px) { .strip { grid-auto-columns: 84%; } }
.strip-hint { margin-top: 6px; font: 400 0.78rem var(--mono); color: var(--quiet); }

/* How it's built: a plain spec list */
.spec { margin: 44px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 56px; }
.spec div { padding-block: 18px; border-top: 1px solid var(--rule); }
.spec dt { font: 500 0.78rem var(--mono); color: var(--quiet); letter-spacing: 0.03em; }
.spec dd { margin: 6px 0 0; color: var(--ink-2); }
@media (max-width: 760px) { .spec { grid-template-columns: minmax(0, 1fr); } }

/* What isn't done */
.todo { margin-top: 28px; padding: 0; list-style: none; max-width: var(--measure); }
.todo li { padding: 10px 0 10px 26px; border-bottom: 1px solid var(--rule); position: relative; color: var(--ink-2); }
.todo li::before { content: ""; position: absolute; left: 2px; top: 1.05em; width: 9px; height: 9px; border: 1.5px solid var(--quiet); border-radius: 1px; }

/* Footer */
.foot { margin-top: 120px; padding-block: 28px 44px; border-top: 1px solid var(--rule); font-size: 0.9rem; color: var(--quiet); }
.foot .frame { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: baseline; }
.foot .right { margin-left: auto; font-family: var(--mono); font-size: 0.78rem; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgb(12 12 13 / 94%);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-height: 100%; object-fit: contain; }

/* The write-up page */
.doc-head { padding-block: 56px 0; }
.doc-head h1 { font-family: var(--display); font-size: clamp(2.1rem, 1.4rem + 3vw, 3.4rem); line-height: 1.05; }
.doc-head p { margin-top: 18px; max-width: 56ch; color: var(--ink-2); font-size: 1.1rem; }
.doc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 64px; padding-block: 48px 0; }
.toc { position: sticky; top: 84px; align-self: start; font-size: 0.9rem; max-height: calc(100vh - 110px); overflow: auto; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 5px 0 5px 12px; color: var(--quiet); text-decoration: none; border-left: 2px solid var(--rule); }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--select); }
.prose { max-width: 72ch; min-width: 0; }
.prose > * + * { margin-top: 1em; }
.prose h2 { font-family: var(--display); font-size: var(--step-2); line-height: 1.12; margin-top: 2.4em; scroll-margin-top: 80px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font: 600 1.08rem var(--sans); margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 4px; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2.2em; }
.prose .source { font: 400 0.78rem/1.5 var(--mono); color: var(--quiet); }
.prose figure { margin: 1.4em 0 1.6em; }
.prose figure img { cursor: zoom-in; }
.prose figcaption { margin-top: 8px; font-size: var(--step--1); color: var(--quiet); }
.prose .table table { margin-block: 0.4em; }
.prose code { background: var(--sheet); padding: 1px 4px; border-radius: 2px; }
@media (max-width: 900px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 32px; }
  .toc { position: static; max-height: none; }
  .toc ol { columns: 2; column-gap: 20px; }
}
@media (max-width: 480px) { .toc ol { columns: 1; } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
