/* ==========================================================================
   Upstream — components

   1. Verdict mark .............. shared shape vocabulary
   2. Verdict banner ............ from 1b, restyled
   3. Why-chain ................. 1c's rail, 1d's document restraint
   4. Scan home ................. 1f

   Every component inherits its colour from the verdict channel. Put
   data-v="avoid|caution|clear|unknown" on the component (or anything above
   it) and it repaints. Nothing here is colour-only: shape and label always
   agree with the colour.
   ========================================================================== */

/* ==========================================================================
   1. Verdict mark

   Redundant with the label by design — shape carries the state for anyone
   who cannot separate the four hues. One vocabulary, two sizes, used
   wherever a verdict is stated.
   ========================================================================== */

.mark {
  flex: none;
  width: 14px;
  height: 14px;
  background: var(--v);
}

[data-v="caution"] .mark {
  width: 12px;
  height: 12px;
  margin: 1px;
  transform: rotate(45deg);
}

[data-v="clear"] .mark {
  border-radius: 50%;
}

[data-v="unknown"] .mark {
  background: none;
  border: 2.5px dashed var(--v);
  border-radius: 50%;
}

.mark--sm {
  width: 10px;
  height: 10px;
}

[data-v="caution"] .mark--sm {
  width: 9px;
  height: 9px;
  margin: 0.5px;
}

[data-v="unknown"] .mark--sm {
  border-width: 2px;
}

/* ==========================================================================
   2. Verdict banner

   No tint, no box, no rounded corners. The answer, the reason, where it
   came from, and a stripe underneath closing the block. Colour appears
   three times and nowhere else: the word, the mark, the stripe.
   ========================================================================== */

.verdict {
  border-bottom: 4px solid var(--v);
  border-radius: 0;
  padding-bottom: 13px;
}

.verdict__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.verdict__label {
  font: 700 21px/1 var(--font-sans);
  letter-spacing: -0.015em;
  color: var(--v);
}

/* The reason is the content, so it is set at body size in body colour and
   is the largest block on screen. The verdict word is the headline; the
   sentence under it is the argument. */
.verdict__reason {
  font: 400 14.5px/1.5 var(--font-sans);
  color: var(--tx);
  margin-top: 10px;
  text-wrap: pretty;
}

/* Neutral hairline, not a tinted one — provenance is not part of the verdict. */
.verdict__source {
  font: 400 12px/1.45 var(--font-sans);
  color: var(--tx3);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   3. Why-chain

   1c's rail threaded through 1d's rows. The rail turns hot at the first
   listed node and stays hot downward, so the contamination is visible
   before you read a word; everything else is a register extract — numbered
   rows, hairline rules, a status column, no tint anywhere.
   ========================================================================== */

.trace__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.trace__count {
  font: 400 12px/1 var(--font-sans);
  color: var(--tx3);
}

/* Row padding lives on the text cells, not the row, so the gutter spans the
   full row height and the rail can run edge to edge. */
.trace__step {
  display: grid;
  grid-template-columns: 16px 11px 1fr 44px;
  column-gap: 11px;
  border-bottom: 1px solid var(--line);
}

.trace__step:last-child {
  border-bottom: 0;
}

.trace__index,
.trace__body,
.trace__status {
  padding: 12px 0;
}

.trace__index {
  font: 400 10.5px/1 var(--font-sans);
  color: var(--tx3);
  padding-top: 16px;
}

/* -1px so the rail paints over the row rule and the trace stays unbroken. */
.trace__gutter {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: -1px;
}

.trace__node {
  flex: none;
  width: 11px;
  height: 11px;
  border: 2px solid var(--line2);
  background: var(--bg);
}

.trace__step[data-mark="flag"] .trace__node {
  background: var(--v);
  border-color: var(--v);
}

/* Two segments per row — the one arriving at the node and the one leaving
   it — because the trace changes state at the node, not at the row rule. */
.trace__rail {
  width: 2px;
  background: var(--line2);
}

.trace__rail[data-seg="in"] {
  flex: none;
  height: 15px;
}

.trace__rail[data-seg="out"] {
  flex: 1;
}

.trace__step[data-hot-in="1"] .trace__rail[data-seg="in"],
.trace__step[data-hot="1"] .trace__rail[data-seg="out"] {
  background: var(--v);
}

/* Nothing arrives at the first node; nothing leaves the last. The first
   segment stays in the layout as the node's offset. */
.trace__step:first-child .trace__rail[data-seg="in"] {
  background: none;
}

.trace__step:last-child .trace__rail[data-seg="out"] {
  display: none;
}

.trace__name {
  display: block;
  font: 500 13.5px/1.2 var(--font-sans);
  color: var(--tx);
}

/* "brand · sold under", "parent · 50% · IL" — the whole relationship on one
   checkable line, as 1d sets it. */
.trace__detail {
  display: block;
  font: 400 11.5px/1.35 var(--font-sans);
  color: var(--tx3);
  margin-top: 5px;
}

.trace__status {
  font: 400 11.5px/1 var(--font-sans);
  color: var(--tx3);
  padding-top: 16px;
  text-align: right;
}

.trace__status[data-listed] {
  font-weight: 600;
  color: var(--v);
}

.trace__note {
  font: 400 12px/1.5 var(--font-sans);
  color: var(--tx3);
  margin-top: 12px;
}

/* ==========================================================================
   4. Scan home (1f)
   The camera surface is always dark — it sits over a live viewfinder in
   both themes. Mark the root data-theme="dark" and the tokens follow.
   ========================================================================== */

.scan {
  --cam-black: #07090C;
  --cam-tx: #EAEEF3;
  --cam-tx2: rgba(234, 238, 243, 0.62);
  --cam-tx3: rgba(234, 238, 243, 0.48);
  --cam-chrome: rgba(10, 13, 17, 0.66);
  --cam-line: rgba(255, 255, 255, 0.14);

  position: relative;
  width: 402px;
  height: 600px;
  background: var(--cam-black);
  overflow: hidden;
}

/* Stand-in for the camera feed. Replace with the live <video>. */
.scan__feed {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, #0F1319 0 11px, #131922 11px 22px);
}

/* The scrim is the ground the chrome stands on — there are no boxes down
   there, so it has to go near-opaque before the first control. */
.scan__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(7, 9, 12, 0.82) 0%,
    rgba(7, 9, 12, 0.26) 22%,
    rgba(7, 9, 12, 0.26) 54%,
    rgba(7, 9, 12, 0.9) 72%,
    rgba(7, 9, 12, 0.97) 100%
  );
}

/* env() is 0 everywhere but a notched phone, so the board is unaffected. */
.scan__top {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Two controls of the same box, so the top bar reads as a pair rather than
   as a pill next to a circle. Outline only — the scrim is the fill. */
.scan__campaign,
.scan__settings {
  display: flex;
  align-items: center;
  height: 34px;
  border: 1px solid var(--cam-line);
  border-radius: var(--r-md);
  cursor: pointer;
}

.scan__campaign:hover,
.scan__settings:hover {
  border-color: rgba(255, 255, 255, 0.34);
}

/* Which campaigns are switched on. The dot is the "on" signal, so it takes
   the completed-check green rather than the accent. */
.scan__campaign {
  gap: 9px;
  padding: 0 13px;
  font: 500 12.5px/1 var(--font-sans);
  color: var(--cam-tx);
}

.scan__campaign::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clear);
}

.scan__settings {
  justify-content: center;
  width: 34px;
}

.scan__settings::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cam-tx2);
}

/* Reticle — sits high for one-handed reach. Corners in signal blue: the
   only saturation the camera surface gets, and it marks the live target. */
.reticle {
  position: absolute;
  top: 190px;
  left: 50%;
  transform: translateX(-50%);
  width: 262px;
  height: 162px;
}

.reticle__corner {
  position: absolute;
  width: 30px;
  height: 30px;
}

.reticle__corner[data-corner="tl"] {
  top: 0;
  left: 0;
  border-top: 2.5px solid var(--ink);
  border-left: 2.5px solid var(--ink);
  border-radius: var(--r-xs) 0 0 0;
}

.reticle__corner[data-corner="tr"] {
  top: 0;
  right: 0;
  border-top: 2.5px solid var(--ink);
  border-right: 2.5px solid var(--ink);
  border-radius: 0 var(--r-xs) 0 0;
}

.reticle__corner[data-corner="bl"] {
  bottom: 0;
  left: 0;
  border-bottom: 2.5px solid var(--ink);
  border-left: 2.5px solid var(--ink);
  border-radius: 0 0 0 var(--r-xs);
}

.reticle__corner[data-corner="br"] {
  bottom: 0;
  right: 0;
  border-bottom: 2.5px solid var(--ink);
  border-right: 2.5px solid var(--ink);
  border-radius: 0 0 var(--r-xs) 0;
}

.reticle__line {
  position: absolute;
  top: 74px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink), transparent);
}

/* Names the decoder and the formats, so a failed scan is diagnosable. */
.reticle__status {
  position: absolute;
  bottom: -24px;
  left: 0;
  right: 0;
  text-align: center;
  font: 400 11.5px/1 var(--font-sans);
  color: var(--cam-tx2);
}

.scan__bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --------------------------------------------------------------------------
   Recent scan — the verdict banner compressed to one row. Same stripe, same
   mark, same rule: no box.
   -------------------------------------------------------------------------- */

.recent {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 0 0 11px;
  border-bottom: 4px solid var(--v);
  text-align: left;
  cursor: pointer;
}

.recent__text {
  min-width: 0;
}

.recent__name {
  display: block;
  font: 500 14px/1.2 var(--font-sans);
  color: var(--cam-tx);
}

/* Longhand, not the `font` shorthand: a .t-mono barcode sits inside this
   element and the shorthand would reset its family back to Archivo. */
.recent__meta {
  display: block;
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  color: var(--cam-tx3);
  margin-top: 5px;
}

/* Fixed to the name's line box so the mark centres on the product name
   rather than drifting with the two-line block. */
.recent__verdict {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 17px;
  font: 600 13px/1 var(--font-sans);
  color: var(--v);
}

.recent:hover .recent__name {
  color: #fff;
}

/* --------------------------------------------------------------------------
   Search — a field rendered as a document line, not a pill. The 2px signal
   blue bar is the same 2px as the scan line and the trace rail: it means
   live, and here it means type here.
   -------------------------------------------------------------------------- */

.scan__search {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 16px 0 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  text-align: left;
  font: 500 13.5px/1 var(--font-sans);
  color: var(--cam-tx2);
  cursor: pointer;
}

.scan__search::before {
  content: "";
  flex: none;
  width: 2px;
  height: 15px;
  background: var(--ink);
}

.scan__search:hover {
  color: var(--cam-tx);
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   5. Record rows

   The trace's row grammar, generalised: content left, state right, hairline
   between. Used for settings, search results and alternatives.
   ========================================================================== */

.rows > li:not(:last-child) .row,
.sources > li:not(:last-child) .source,
.alts > li:not(:last-child) .alt {
  border-bottom: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 14px 0;
  text-align: left;
  cursor: pointer;
}

.row[disabled] {
  cursor: default;
  opacity: 0.55;
}

.row__text {
  min-width: 0;
}

.row__name {
  display: block;
  font: 500 14px/1.2 var(--font-sans);
  color: var(--tx);
}

.row__meta {
  display: block;
  font: 400 11.5px/1.35 var(--font-sans);
  color: var(--tx3);
  margin-top: 5px;
}

.row__state {
  flex: none;
  font: 600 11.5px/1 var(--font-sans);
  color: var(--tx3);
}

.row[aria-pressed="true"] .row__state {
  color: var(--ink);
}

/* A row that carries a verdict states it the same way everything else does:
   mark, word, verdict colour. */
.row__verdict {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font: 600 11.5px/1 var(--font-sans);
  color: var(--v);
}

/* Geometric chevron — the corner bracket from the reticle, at row scale. */
.row__go {
  flex: none;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid var(--tx3);
  border-right: 1.5px solid var(--tx3);
  transform: rotate(45deg);
}

.row:hover .row__name {
  color: var(--ink);
}

.row[disabled]:hover .row__name {
  color: var(--tx);
}

/* ==========================================================================
   6. Source entry

   What a register says, who says it, and when it was last read. Every line
   here is quotation and provenance — never our own characterisation.
   ========================================================================== */

.source {
  padding: 15px 0;
}

.source__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.source__name {
  font: 600 13px/1.2 var(--font-sans);
  color: var(--tx);
}

.source__kind {
  font: 400 11px/1.2 var(--font-sans);
  color: var(--tx3);
  text-align: right;
}

.source__statement {
  font: 400 13.5px/1.5 var(--font-sans);
  color: var(--tx2);
  margin-top: 8px;
  text-wrap: pretty;
}

.source__statement b {
  font-weight: 600;
  color: var(--tx);
}

.source__detail {
  font: 400 12px/1.5 var(--font-sans);
  color: var(--tx3);
  margin-top: 6px;
  text-wrap: pretty;
}

.source__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font: 400 11.5px/1.4 var(--font-sans);
  color: var(--tx3);
}

.source__foot a {
  flex: none;
  text-align: right;
}

/* ==========================================================================
   7. Alternatives
   ========================================================================== */

.alt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
}

.alt__text {
  min-width: 0;
}

.alt__name {
  display: block;
  font: 500 14px/1.2 var(--font-sans);
  color: var(--tx);
}

.alt__meta {
  display: block;
  font: 400 11.5px/1.35 var(--font-sans);
  color: var(--tx3);
  margin-top: 5px;
}

.alt__state {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  font: 600 11.5px/1 var(--font-sans);
  color: var(--v);
}

/* ==========================================================================
   8. Facts grid

   1g's readout, given the home it lost when 1f won the scan screen. The 1px
   gaps are the border colour showing through.
   ========================================================================== */

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.fact {
  background: var(--s1);
  padding: 12px 13px;
}

.fact dt {
  font: 400 11px/1 var(--font-sans);
  color: var(--tx3);
}

.fact dd {
  font: 600 14px/1.2 var(--font-sans);
  color: var(--tx);
  margin: 6px 0 0;
}

.fact dd[data-fresh] {
  color: var(--clear);
}
