/* Shared by every page: tokens, header, sentence, answer, wall drawing, fine print.
   The rules behind it are in docs/design-system.md. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 800; font-display: swap; src: url("fonts/barlow-800.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --paper: #F7F8F7;
  --wall: #DDE1DC;
  --skirting: #F3F4F1;
  --skirting-edge: #C9CEC8;
  --ink: #1E2328;
  --ink-soft: #565E66;
  --rule: #D2D6D1;
  --raised: #FFFFFF;
  --glass: #161B21;
  --glass-edge: rgb(255 255 255 / 0.16);
  --glass-text: #E9ECEA;
  --tape-1: #2F7ED0; --text-1: #1B5FA8;
  --tape-2: #3F9A3C; --text-2: #276B24;
  --tape-3: #DD6A1E; --text-3: #A3460C;
  --warn: #A8331F;
  --shadow: 0 12px 32px rgb(30 35 40 / 0.16), 0 1px 3px rgb(30 35 40 / 0.12);
  --tape-blend: multiply;

  --font: "Barlow", ui-sans-serif, system-ui, sans-serif;
  --t-sentence: 36px;
  --t-answer: 18px;
  --t-body: 16px;
  --t-fine: 15px;
  --t-small: 14px;
  --t-dim: 13px;

  --frame: 1240px;
  --gutter: 32px;
  --col-gap: 24px;
  --r-control: 4px;
  --r-pop: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #191C1F;
    --wall: #3B434A;
    --skirting: #2C3237;
    --skirting-edge: #4A535B;
    --ink: #E9ECEA;
    --ink-soft: #B0B7BD;
    --rule: #3A4045;
    --raised: #262B30;
    --glass: #0B0D10;
    --glass-edge: #6A737C;
    --tape-1: #4F9AE6; --text-1: #8BBEF2;
    --tape-2: #67B95A; --text-2: #95D48A;
    --tape-3: #F08A3E; --text-3: #F7A770;
    --warn: #F7A08C;
    --shadow: 0 12px 32px rgb(0 0 0 / 0.45), 0 0 0 1px #3A4045;
    --tape-blend: normal;
  }
}

@media (max-width: 700px) {
  :root { --gutter: 16px; --col-gap: 12px; --t-sentence: 24px; --t-answer: 17px; }
}

.c0 { --c: var(--ink); --ct: var(--ink); }
.c1 { --c: var(--tape-1); --ct: var(--text-1); }
.c2 { --c: var(--tape-2); --ct: var(--text-2); }
.c3 { --c: var(--tape-3); --ct: var(--text-3); }

* { box-sizing: border-box; }

/* A page that fills everything below its header from the script declares `pending`
   on its body: painted earlier, it grows under the reader's eyes. The not-found
   page has no script and no `pending`, so it is unaffected. docs/lighthouse.md
   explains the gate behind it. */
body.pending .tool, body.pending .about, body.pending .bottom { visibility: hidden; }
body.ready .tool, body.ready .about, body.ready .bottom { visibility: visible; }

/* Shown only where no script will fill the page; shared/no-js.css decides. */
.no-script { display: none; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.frame {
  max-width: var(--frame);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 40px;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 44px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
}
.brand img { display: block; width: 32px; height: 32px; }

.site-nav { display: flex; gap: 4px; flex: 1; }
.site-nav a {
  position: relative;
  padding: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  background: var(--ink);
}

.units { display: inline-flex; flex: none; border: 1px solid var(--rule); border-radius: var(--r-control); }
.units button {
  min-width: 44px;
  height: 44px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 500;
}
.units button:hover { color: var(--ink); }
.units button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

@media (max-width: 700px) {
  .top { flex-wrap: wrap; gap: 0; min-height: 0; padding-top: 8px; }
  .brand { flex: 1; font-size: 18px; min-height: 52px; }
  .site-nav {
    order: 3;
    flex: 0 0 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-bottom: 1px solid var(--rule);
  }
  .site-nav a { padding: 12px 0; text-align: center; font-size: 15px; }
  .site-nav a[aria-current="page"]::after { left: 8px; right: 8px; bottom: -1px; }
}

/* ---------- tool layout ---------- */

/* Question and answer on the left, the wall on the right; stacked below 1000 px. */
.tool {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding-top: 32px;
  align-items: start;
}
.ask { grid-column: 1 / span 4; position: relative; }
.stage { grid-column: 5 / -1; }
@media (max-width: 999px) {
  .ask, .stage { grid-column: 1 / -1; }
  .stage { margin-top: 24px; }
  .stage .wall { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); }
}
@media (max-width: 700px) {
  .tool { padding-top: 20px; }
  .stage { margin-top: 16px; }
}

/* ---------- the sentence ---------- */

.sentence {
  margin: 0;
  font-size: var(--t-sentence);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
@media (max-width: 700px) { .sentence { line-height: 1.35; } }

/* Article, number, unit, option button and trailing punctuation never break apart. */
.size { white-space: nowrap; }

/* The padding makes a 44 px tap target; the negative margin keeps it out of the line height,
   so the underline is drawn as a background at the foot of the text. */
.num {
  --tap: 6px;
  --rule-c: var(--c, var(--ink));
  font: inherit;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: inherit;
  border: 0;
  border-radius: 0;
  padding: var(--tap) 0.03em;
  margin: calc(-1 * var(--tap)) 0;
  background: linear-gradient(var(--rule-c), var(--rule-c)) left 0 bottom calc(var(--tap) - 0.1em) / 100% 0.1em no-repeat;
  text-align: center;
  letter-spacing: inherit;
}
.num:focus-visible { outline: none; background-color: color-mix(in srgb, var(--rule-c) 14%, transparent); }
.num[aria-invalid="true"] {
  background-image: repeating-linear-gradient(90deg, var(--warn) 0 0.3em, transparent 0.3em 0.5em);
}
.inch { font-weight: 800; }

.opt {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.04em;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  vertical-align: 0.02em;
}
/* The glyph is small; the hit area is at least 44 px. */
.opt::before { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; translate: -50% -50%; }
.opt svg { width: 0.5em; height: 0.5em; }
.opt:hover { color: var(--ink); }
.opt[aria-expanded="true"] { background: var(--ink); color: var(--paper); }

/* ---------- the answer ---------- */

.answer { margin-top: 20px; font-size: var(--t-answer); line-height: 1.45; }
.answer p { margin: 0 0 6px; max-width: 36em; }
.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.3em;
  margin-right: 0.45em;
  vertical-align: 0.22em;
  background: var(--c);
}
@media (max-width: 700px) { .answer { margin-top: 14px; } }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; margin-top: 16px; }
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.link-button:hover { color: var(--ink); }
.link-button > span[aria-hidden] { display: inline-block; margin-right: 0.3em; }
.link-button:disabled { color: var(--ink-soft); opacity: 0.5; cursor: default; }

/* The one framed button on a page: the action people come back for. */
.action-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: var(--r-control);
  background: none;
  font-weight: 600;
}
.action-button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.action-button svg, .start-over svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.start-over { gap: 6px; margin-left: auto; }
@media (max-width: 700px) { .actions { gap: 4px 20px; margin-top: 12px; } }

/* ---------- options panel ---------- */

.pop {
  position: absolute;
  z-index: 10;
  width: 320px;
  padding: 16px 16px 4px;
  background: var(--raised);
  border-radius: var(--r-pop);
  box-shadow: var(--shadow);
  font-size: var(--t-fine);
}
.pop::before {
  content: "";
  position: absolute;
  top: -6px;
  left: calc(var(--arrow, 40px) - 6px);
  width: 12px;
  height: 12px;
  background: var(--raised);
  transform: rotate(45deg);
}
.pop-title { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: var(--t-body); font-weight: 600; }
.pop-title .swatch { margin: 0; vertical-align: 0; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 12px; min-height: 52px; margin: 0; padding: 0; border: 0; }
.field > :first-child { color: var(--ink-soft); padding: 0; }
fieldset.field > legend { float: left; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); border-radius: var(--r-control); overflow: hidden; }
.seg label { position: relative; display: grid; place-items: center; min-height: 44px; font-weight: 500; font-variant-numeric: tabular-nums; cursor: pointer; }
.seg label:nth-child(-n+3) { border-bottom: 1px solid var(--rule); }
.seg label:not(:nth-child(3n)) { border-right: 1px solid var(--rule); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(:checked) { background: var(--ink); color: var(--paper); }
.seg label:has(:focus-visible) { outline: 2px solid var(--ink); outline-offset: -4px; }
.seg label:has(:checked:focus-visible) { outline-color: var(--paper); }

.select {
  height: 44px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: var(--raised);
  font-variant-numeric: tabular-nums;
}

.stepper { display: inline-flex; width: max-content; border: 1px solid var(--rule); border-radius: var(--r-control); }
.stepper button, .stepper output { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.stepper > * + * { border-left: 1px solid var(--rule); }
.stepper button:disabled { color: var(--rule); cursor: default; }

/* A 44 px tall target; the visible track is its 26 px content box. */
.switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 9px 0;
  /* Outer radii minus the padding give a 13 px pill at the content edge. */
  border-radius: 13px / 22px;
  background: var(--rule) content-box;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--raised);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: translate 0.12s;
}
.switch:checked { background-color: var(--ink); }
.switch:checked::after { translate: 18px 0; }

.pop-foot { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid var(--rule); }
.pop-foot .remove { color: var(--warn); }
.pop-foot .remove:hover { color: var(--warn); }
.pop-foot :only-child { margin-left: auto; }

@media (max-width: 700px) {
  .pop { left: 0 !important; right: 0; width: auto; }
}

/* ---------- the wall ---------- */

/* The wall stands on a white skirting board, like the room it stands for. */
.wall {
  margin: 0;
  background: var(--wall);
  border-bottom: 14px solid var(--skirting);
  box-shadow: inset 0 -1px 0 var(--skirting-edge);
  overflow: hidden;
  touch-action: pan-y;
}
.wall svg { display: block; overflow: visible; }

.below { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; margin-top: 12px; }
.view-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.chipseg { display: inline-flex; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-control); font-size: var(--t-small); font-weight: 500; }
.chipseg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.chipseg label { position: relative; display: grid; place-items: center; min-height: 44px; padding: 0 12px; color: var(--ink-soft); cursor: pointer; }
.chipseg label + label { border-left: 1px solid var(--rule); }
.chipseg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chipseg label:hover { color: var(--ink); }
.chipseg label:has(:checked) { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.chipseg label:has(:focus-visible) { outline: 2px solid var(--ink); outline-offset: -2px; }

.hint { margin: 0; font-size: var(--t-small); color: var(--ink-soft); }
.limit-note { margin: 8px 0 0; font-size: var(--t-small); color: var(--warn); }

.tape { fill: var(--c); opacity: 0.9; mix-blend-mode: var(--tape-blend); }

.tape-note text { fill: #1E2328; font: 500 15px var(--font); }

.dim line { stroke: var(--ct, var(--ink-soft)); stroke-width: 1.2; }
.dim text {
  fill: var(--ct, var(--ink-soft));
  font: 500 var(--t-dim) var(--font);
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--wall);
  stroke-width: 6px;
  stroke-linejoin: round;
}

.glass-face { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.5; }
.glass-label { fill: var(--glass-text); font: 600 15px var(--font); }

/* ---------- fine print ---------- */

.about {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px 32px;
  margin-top: 64px;
  position: relative;
  padding-top: 24px;
}
.about::before { content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter); height: 1px; background: var(--rule); }
.about h2 { margin: 0 0 4px; font-size: var(--t-body); font-weight: 600; }
.about p { margin: 0; font-size: var(--t-fine); color: var(--ink-soft); max-width: 34em; }
@media (max-width: 999px) { .about { grid-template-columns: 1fr; gap: 18px; margin-top: 48px; } }

.bottom { padding-top: 32px; padding-bottom: 40px; font-size: var(--t-small); color: var(--ink-soft); }
.bottom a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.bottom a:hover { color: var(--ink); }

/* ---------- legal pages ---------- */
/* The text comes from legal/render.mjs; the page around it is the site's own. */
.legal { margin: 0 auto; max-width: 44em; padding-top: 48px; padding-bottom: 96px; }
.legal h1 { margin: 0 0 8px; font-size: 32px; font-weight: 600; line-height: 1.2; }
.legal h2 { margin: 40px 0 6px; font-size: 19px; font-weight: 600; }
.legal p { margin: 12px 0 0; font-size: var(--t-body); line-height: 1.6; }
.legal ul { margin: 12px 0 0; padding-left: 1.2em; font-size: var(--t-body); line-height: 1.6; }
.legal li + li { margin-top: 4px; }
.legal a { color: var(--ink); text-underline-offset: 3px; }
.legal a:hover { color: var(--ink-soft); }
@media (max-width: 700px) {
  .bottom a { white-space: nowrap; }
  .legal { padding-top: 24px; padding-bottom: 64px; }
  .legal h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { transition: none !important; }
}
