/* Traffic sign CNN demo. Palette taken from road signage: mandatory-sign blue
   plates with white legends, asphalt text on concrete, marking amber for the
   keyboard cursor. */

:root {
  --blue: #0b4f8f;
  --blue-deep: #073a6b;
  --white: #ffffff;
  --asphalt: #23292e;
  --kerb: #5a6670;
  --concrete: #eef0ee;
  --rule: #cdd3d7;
  --amber: #f5b800;
  --amber-wash: #fff3cc;

  --font-sign: "Bahnschrift", "DIN Alternate", "DIN 1451 Std", "D-DIN", "Barlow Semi Condensed",
    "Roboto Condensed", "Arial Narrow", sans-serif;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --page: 70rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--concrete);
  color: var(--asphalt);
  font: 1rem/1.55 var(--font-text);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  font-family: var(--font-sign);
  line-height: 1.1;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--blue-deep);
  text-decoration-thickness: 2px;
}

code {
  font-family: var(--font-code);
  font-size: 0.875em;
  background: rgb(35 41 46 / 0.07);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  background: var(--asphalt);
  color: var(--white);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 1;
}

.skip:focus {
  top: 0.75rem;
}

/* ── Page frame ─────────────────────────────────────────────────────────── */

.masthead,
main,
.footer {
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-block: 1.25rem;
}

.brand {
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.125rem;
}

.source {
  font-size: 0.9375rem;
}

.intro {
  padding-block: clamp(1.5rem, 5vw, 3.5rem) clamp(1.75rem, 4vw, 2.75rem);
}

.intro h1 {
  font-size: clamp(2.1rem, 1.2rem + 3.6vw, 3.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.012em;
  max-width: 19ch;
}

.lede {
  margin-top: 1.1rem;
  font-size: 1.125rem;
  max-width: 58ch;
}

/* ── Drawing area ───────────────────────────────────────────────────────── */

.workbench {
  scroll-margin-top: 1rem;
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

@media (min-width: 52rem) {
  .workbench {
    grid-template-columns: minmax(0, 33rem) minmax(0, 1fr);
  }
}

/* A sign plate: blue face, white inset border. */
.plate {
  position: relative;
  background: var(--blue);
  isolation: isolate;
}

.plate::before {
  content: "";
  position: absolute;
  pointer-events: none;
  border: solid var(--white);
}

.plate--board {
  border-radius: 20px;
  padding: 20px;
}

.plate--board::before {
  inset: 7px;
  border-width: 3px;
  border-radius: 14px;
}

.board {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.board:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.tool {
  display: inline-flex;
  border: 2px solid var(--asphalt);
  border-radius: 12px;
  padding: 2px;
}

.tool__btn,
.btn {
  font: 600 1.0625rem/1 var(--font-sign);
  min-height: 2.75rem;
  padding: 0 1.15rem;
  border-radius: 9px;
  cursor: pointer;
}

.tool__btn {
  border: 0;
  background: transparent;
  color: var(--asphalt);
}

.tool__btn[aria-pressed="true"] {
  background: var(--asphalt);
  color: var(--white);
}

.actions {
  display: flex;
  gap: 0.75rem;
}

.btn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0 1.4rem;
}

.btn--primary {
  background: var(--blue);
  color: var(--white);
}

.btn--primary:hover:not(:disabled) {
  background: var(--blue-deep);
}

.btn--primary:disabled {
  opacity: 0.45;
  cursor: progress;
}

.btn--quiet {
  background: transparent;
  border-color: var(--rule);
  color: var(--asphalt);
}

.btn--quiet:hover {
  border-color: var(--asphalt);
}

.help {
  margin-top: 0.9rem;
  color: var(--kerb);
  font-size: 0.9375rem;
  max-width: 52ch;
}

/* ── Result ─────────────────────────────────────────────────────────────── */

.result {
  scroll-margin-top: 1rem;
  background: var(--white);
  border-radius: 16px;
  padding: clamp(1.25rem, 3vw, 1.75rem);
}

.result__title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--kerb);
}

.result__empty {
  margin-top: 0.75rem;
  font-family: var(--font-sign);
  font-size: 1.5rem;
  line-height: 1.2;
  max-width: 20ch;
}

.result__name {
  margin-top: 0.3rem;
  font-family: var(--font-sign);
  font-weight: 700;
  font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem);
  line-height: 1.05;
}

.result__detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: 1.25rem;
}

.reference {
  margin: 0;
}

.plate--ref {
  border-radius: 12px;
  padding: 11px;
}

.plate--ref::before {
  inset: 4px;
  border-width: 2px;
  border-radius: 8px;
}

/* The PNG is black ink on white; invert + screen turns it into white on blue. */
.plate--ref img {
  display: block;
  width: 95px;
  height: 95px;
  image-rendering: pixelated;
  filter: invert(1);
  mix-blend-mode: screen;
}

.reference figcaption {
  margin-top: 0.4rem;
  font-size: 0.8125rem;
  color: var(--kerb);
}

.metrics {
  margin: 0;
  display: grid;
  gap: 0.9rem;
}

.metric dt {
  font-size: 0.875rem;
  color: var(--kerb);
}

.metric dd {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.result__note {
  margin-top: 1.25rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--concrete);
  font-size: 0.9375rem;
}

.result[data-state="stale"] .result__note {
  background: var(--amber-wash);
}

.result[data-state="stale"] :is(.result__name, .result__detail, .probs) {
  opacity: 0.4;
}

.probs__title {
  margin-top: 1.5rem;
  font-family: var(--font-text);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--kerb);
}

.probs {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.prob {
  display: grid;
  grid-template-columns: minmax(7.5rem, 9.5rem) 1fr 3.4rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.prob__bar {
  height: 6px;
  border-radius: 3px;
  background: #dde2e6;
  overflow: hidden;
}

.prob__bar span {
  display: block;
  height: 100%;
  background: #8ea4b9;
  transition: width 0.3s ease-out;
}

.prob.is-top .prob__name {
  font-weight: 600;
}

.prob.is-top .prob__bar span {
  background: var(--blue);
}

.prob__value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Samples ────────────────────────────────────────────────────────────── */

.samples {
  margin-top: clamp(3rem, 7vw, 4.5rem);
}

.samples h2,
.how h2 {
  font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem);
  font-weight: 700;
}

.samples__lede,
.how__lede {
  margin-top: 0.6rem;
  max-width: 62ch;
}

.samples__list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem 0.25rem;
}

@media (min-width: 52rem) {
  .samples__list {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

.sample {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.35rem 0.6rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--asphalt);
  font: inherit;
  cursor: pointer;
}

.sample:hover {
  background: var(--white);
}

.sample__img {
  display: block;
  width: 100%;
  max-width: 4.75rem;
  aspect-ratio: 1;
  height: auto;
  border-radius: 8px;
  image-rendering: pixelated;
}

.sample__label {
  font-size: 0.8125rem;
  /* Break between words, never inside one ("direction/s"); hyphenate if a
     single word still can't fit. */
  overflow-wrap: normal;
  hyphens: auto;
  line-height: 1.25;
  text-align: center;
}

@media (max-width: 30rem) {
  .sample {
    padding-inline: 0.1rem;
  }

  .sample__label {
    font-size: 0.75rem;
  }
}

/* ── How it works ───────────────────────────────────────────────────────── */

.how {
  margin-top: clamp(3rem, 7vw, 4.5rem);
  padding-top: clamp(2rem, 5vw, 3rem);
  border-top: 1px solid var(--rule);
}

@media (min-width: 60rem) {
  .how {
    display: grid;
    grid-template-columns: minmax(0, 44rem) minmax(0, 1fr);
    column-gap: 4rem;
    align-items: start;
  }

  .how > h2,
  .how__lede {
    grid-column: 1 / -1;
  }

  .how .facts {
    grid-template-columns: 1fr;
    margin-top: 2.25rem;
  }
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 2.25rem 0 0;
  padding: 0;
  max-width: 46rem;
}

.steps li {
  counter-increment: step;
  position: relative;
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  column-gap: 1.1rem;
  padding-bottom: 1.6rem;
}

/* Step numbers drawn as small route-number plates, joined by a line: the
   steps run in this order for every drawing. */
.steps li::before {
  content: counter(step);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 7px;
  background: var(--blue);
  color: var(--white);
  font: 700 1.125rem/1 var(--font-sign);
  box-shadow: inset 0 0 0 2px var(--blue), inset 0 0 0 3.5px var(--white);
}

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(1.125rem - 1px);
  top: 2.75rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--rule);
}

.steps h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  padding-top: 0.45rem;
}

.steps p {
  margin-top: 0.4rem;
  font-size: 0.9375rem;
  max-width: 62ch;
}

.facts {
  margin: 2.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.25rem 1.75rem;
}

.facts div {
  border-left: 3px solid var(--blue);
  padding-left: 0.9rem;
}

.facts dt {
  font-size: 0.875rem;
  color: var(--kerb);
}

.facts dd {
  margin: 0.2rem 0 0;
  font-family: var(--font-sign);
  font-size: 1.125rem;
  line-height: 1.3;
}

.facts dd code {
  font-size: 0.8em;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

.footer {
  margin-top: clamp(3rem, 7vw, 4.5rem);
  padding-block: 0 2.5rem;
}

.footer p {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  color: var(--kerb);
  font-size: 0.875rem;
}

.noscript {
  max-width: var(--page);
  margin: 1rem auto;
  padding: 1rem var(--gutter);
  background: var(--amber-wash);
}

@media (prefers-reduced-motion: reduce) {
  .prob__bar span {
    transition: none;
  }
}
