/*
 * Completeness component for /what-is-built/.
 *
 * Ported from runcible-public-core/styles/inventory.css, which scopes the same
 * component to body.runcible-public-inventory. The visual language is
 * deliberately identical: a reader who has seen runcible.com's build-state page
 * should recognise this one immediately, because it is making the same kind of
 * statement to a different audience.
 *
 * The band thresholds live in build-oversing-page.py, which writes the tone
 * class into the markup. They are stated in the legend so a reader can see the
 * scale rather than infer it from colour, which also keeps the meaning
 * available to anyone who cannot distinguish the colours.
 */

body.oversing-public-what-is-built {
  --pct-high: #4b7a52;
  --pct-mid: #b98a2c;
  --pct-low: #b06a34;
  --pct-none: #9a4a42;
}

body.oversing-public-what-is-built table {
  width: 100%;
  margin: clamp(20px, 3vw, 32px) 0 clamp(32px, 4vw, 48px);
  border-collapse: collapse;
  background: var(--white);
  font-size: .95rem;
}

body.oversing-public-what-is-built th,
body.oversing-public-what-is-built td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

body.oversing-public-what-is-built thead th {
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

body.oversing-public-what-is-built tbody tr:last-child td {
  border-bottom: 0;
}

/* ------------------------------------------------------------- state dots */

body.oversing-public-what-is-built .oversing-state-dot,
body.oversing-public-what-is-built .oversing-completeness-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pct-none);
}

body.oversing-public-what-is-built .oversing-state-dot--high,
body.oversing-public-what-is-built .oversing-completeness-legend .oversing-state-dot--high {
  background: var(--pct-high);
}

body.oversing-public-what-is-built .oversing-state-dot--mid,
body.oversing-public-what-is-built .oversing-completeness-legend .oversing-state-dot--mid {
  background: var(--pct-mid);
}

body.oversing-public-what-is-built .oversing-state-dot--low,
body.oversing-public-what-is-built .oversing-completeness-legend .oversing-state-dot--low {
  background: var(--pct-low);
}

body.oversing-public-what-is-built .oversing-state-dot--none,
body.oversing-public-what-is-built .oversing-completeness-legend .oversing-state-dot--none {
  background: var(--pct-none);
}

body.oversing-public-what-is-built td .oversing-state-dot {
  position: relative;
  top: -1px;
  margin-right: 8px;
}

/* ----------------------------------------------------------------- meters */

body.oversing-public-what-is-built .oversing-pct {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.oversing-public-what-is-built .oversing-pct__track {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 64px;
  height: 6px;
  background: var(--paper-2);
}

body.oversing-public-what-is-built .oversing-pct__fill {
  display: block;
  height: 100%;
  width: calc(var(--pct) * 1%);
  background: var(--pct-none);
}

body.oversing-public-what-is-built .oversing-pct--high .oversing-pct__fill { background: var(--pct-high); }
body.oversing-public-what-is-built .oversing-pct--mid  .oversing-pct__fill { background: var(--pct-mid); }
body.oversing-public-what-is-built .oversing-pct--low  .oversing-pct__fill { background: var(--pct-low); }
body.oversing-public-what-is-built .oversing-pct--none .oversing-pct__fill { background: var(--pct-none); }

/* ----------------------------------------------------------------- legend */

body.oversing-public-what-is-built .oversing-completeness-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  max-width: none;
  margin: clamp(18px, 2.4vw, 26px) 0 0;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

body.oversing-public-what-is-built .oversing-completeness-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

@media (max-width: 720px) {
  body.oversing-public-what-is-built table,
  body.oversing-public-what-is-built thead,
  body.oversing-public-what-is-built tbody,
  body.oversing-public-what-is-built tr,
  body.oversing-public-what-is-built td {
    display: block;
    width: 100%;
  }

  body.oversing-public-what-is-built thead {
    display: none;
  }

  body.oversing-public-what-is-built tr {
    margin-bottom: 14px;
    border: 1px solid var(--rule);
    background: var(--white);
  }

  body.oversing-public-what-is-built td {
    border-bottom: 1px solid var(--rule);
  }
}
