/* ShoeCare: the stitch component and the paper pieces (docs/BRAND.md "Stitch component spec").
   ONE shared file, owned by the shell. Nobody forks it: a label is a modifier, never a copy.
   Technique: four repeating-linear-gradient backgrounds on ::before, inset from the edge.
   No images, no SVG, no data: URIs. */

/* base: any block becomes a stitched piece. OBSERVED is the base (running stitch, ink, one row). */
.stitch {
  --st-c: var(--ink);
  --st-dash: 9px; --st-gap: 3px; --st-t: 2px;
  --st-in: 6px;
  --st-bg: var(--surface);
  position: relative; border-radius: var(--r, 4px); background: var(--st-bg); color: var(--ink);
  padding: calc(var(--st-in) + 12px);
}
.stitch::before, .stitch::after { content: ""; position: absolute; pointer-events: none; border-radius: 2px; }
.stitch::before {
  inset: var(--st-in);
  --run: var(--st-c) 0 var(--st-dash), transparent var(--st-dash) calc(var(--st-dash) + var(--st-gap));
  background:
    repeating-linear-gradient(90deg, var(--run)) left top / 100% var(--st-t) no-repeat,
    repeating-linear-gradient(90deg, var(--run)) left bottom / 100% var(--st-t) no-repeat,
    repeating-linear-gradient(0deg, var(--run)) left top / var(--st-t) 100% no-repeat,
    repeating-linear-gradient(0deg, var(--run)) right top / var(--st-t) 100% no-repeat;
}
.stitch--observed {}

/* POSSIBLE: dashed stitch, short dashes, wide gaps, amber */
.stitch--possible { --st-c: var(--warn); --st-dash: 3px; --st-gap: 6px; }

/* CONFIRMED: double stitch (second row offset by half a stitch) and a knot with a tick */
.stitch--confirmed { --st-c: var(--brand); --st-in: 5px; }
.stitch--confirmed::after {
  inset: calc(var(--st-in) + 4px);
  --run: var(--st-c) 0 var(--st-dash), transparent var(--st-dash) calc(var(--st-dash) + var(--st-gap));
  --half: calc((var(--st-dash) + var(--st-gap)) / -2);
  background:
    repeating-linear-gradient(90deg, var(--run)) var(--half) top / calc(100% + 12px) var(--st-t) no-repeat,
    repeating-linear-gradient(90deg, var(--run)) var(--half) bottom / calc(100% + 12px) var(--st-t) no-repeat,
    repeating-linear-gradient(0deg, var(--run)) left var(--half) / var(--st-t) calc(100% + 12px) no-repeat,
    repeating-linear-gradient(0deg, var(--run)) right var(--half) / var(--st-t) calc(100% + 12px) no-repeat;
}
.stitch__knot { position: absolute; left: calc(var(--st-in) - 5px); top: calc(var(--st-in) - 5px); width: 12px; height: 12px; border-radius: 50%;
  background: var(--st-bg); border: 2px solid var(--st-c); }
.stitch__knot::after { content: ""; position: absolute; left: 2px; top: 0; width: 3px; height: 6px; border: solid var(--st-c); border-width: 0 2px 2px 0; transform: rotate(40deg); }

/* NOT VERIFIABLE: no thread. Bare edge, hatched fill, cut-thread strike in the top-right corner */
.stitch--nv { --st-c: var(--nv); border: 1px solid var(--nv);
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--nv) 14%, transparent) 0 1px, transparent 1px 7px), var(--st-bg); }
.stitch--nv::before { inset: 0 0 auto auto; width: 26px; height: 26px; background:
  linear-gradient(to top right, transparent calc(50% - 1px), var(--nv) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); }
.stitch--nv::after { display: none; }

/* on the kraft tag the threads use the kraft inks */
.on-kraft { --st-bg: var(--kraft); color: var(--k-ink); }
.on-kraft.stitch--possible { --st-c: var(--k-warn); } .on-kraft.stitch--confirmed { --st-c: var(--k-brand); } .on-kraft.stitch--nv { --st-c: var(--k-nv); }
.on-kraft.stitch--observed { --st-c: var(--k-ink); }
.on-kraft .stitch__knot { background: var(--kraft); }

/* chip: the inline label for one fact. The printed word is mandatory (the non-colour cue). */
.stitch--chip { --st-in: 2px; --st-dash: 5px; --st-gap: 2px; --st-t: 1px; display: inline-flex; align-items: center; gap: .4em; padding: 5px 12px;
  font: 700 12px/1 var(--caps); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; vertical-align: middle; }
.stitch--chip.stitch--possible { --st-dash: 2px; --st-gap: 4px; color: var(--warn); }
.stitch--chip.stitch--confirmed { color: var(--brand-ink); padding-left: 20px; }
.stitch--chip.stitch--confirmed::after { inset: calc(var(--st-in) + 3px); }
.stitch--chip.stitch--confirmed .stitch__knot { left: 3px; top: 50%; margin-top: -6px; }
.stitch--chip.stitch--nv { color: var(--nv); }
.stitch--chip.stitch--nv::before { width: 14px; height: 14px; }
.on-kraft.stitch--chip.stitch--possible { color: var(--k-warn); } .on-kraft.stitch--chip.stitch--confirmed { color: var(--k-brand); } .on-kraft.stitch--chip.stitch--nv { color: var(--k-nv); }
/* the legend and the landing pulse one label's lines */
.stitch.is-pulse::before { animation: stitch-pulse .9s ease-out 1; }
@keyframes stitch-pulse { 0%, 60% { filter: drop-shadow(0 0 0 transparent); } 30% { filter: drop-shadow(0 0 3px var(--st-c)); } }

/* the needle: the sewing reveal when an item appears (reduced motion: nothing moves) */
@media (prefers-reduced-motion: no-preference) {
  .stitch.is-sewn::before { animation: sew .7s steps(24, end) both; }
  @keyframes sew { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
}
/* forced colours keep the grammar with real borders */
@media (forced-colors: active) {
  .stitch::before, .stitch::after { display: none; }
  .stitch { border: 1px solid CanvasText; }
  .stitch--possible { border-style: dashed; } .stitch--confirmed { border-style: double; border-width: 4px; } .stitch--nv { border-style: dotted; }
}

/* ---------- perforation ---------- */
.perf { width: 9px; align-self: stretch; background: radial-gradient(circle, var(--line-strong) 1.4px, transparent 2px) 0 0 / 9px 9px repeat-y; }
.perf--h { width: auto; height: 9px; background: radial-gradient(circle, var(--line-strong) 1.4px, transparent 2px) 0 0 / 9px 9px repeat-x; }

/* ---------- the care tag shell ---------- */
.caretag { position: relative; background: var(--kraft); color: var(--k-ink); padding: 40px 18px 18px;
  clip-path: polygon(0 14px, 14px 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.025) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 1px, transparent 1px 4px); }
.caretag .stitch { --st-in: 10px; --st-bg: var(--kraft); background: transparent; padding: 22px 20px 18px; color: var(--k-ink); }
.caretag__eyelet { position: absolute; left: 50%; top: 14px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--bg); border: 3px solid var(--kraft-2); box-sizing: border-box; z-index: 1; }
.caretag__string { position: absolute; left: 50%; bottom: calc(100% - 38px); width: 64px; margin-left: -32px; height: 60px; color: var(--kraft-2); transform-origin: 50% 100%; pointer-events: none; overflow: visible; }
.caretag__string path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* the tag hangs from its string, so a wrapper reserves the string's height */
.caretag-hang { position: relative; padding-top: 52px; }
.caretag-hang > .caretag__string { top: 0; bottom: auto; transform-origin: 50% 0; }
@media (prefers-reduced-motion: no-preference) { .caretag-hang.sway-once > .caretag { animation: tag-sway 1.6s ease-in-out 1 both; transform-origin: 50% -52px; } }
@keyframes tag-sway { 0% { transform: rotate(-2deg); } 35% { transform: rotate(1.4deg); } 65% { transform: rotate(-.6deg); } 100% { transform: rotate(0); } }
.caretag .label, .on-kraft .label { color: var(--k-muted); }

/* ---------- risk dots: three 9 px dots, filled count = level, then the printed word ---------- */
.risk { --risk-c: var(--ok); --off: color-mix(in srgb, var(--risk-c) 22%, transparent); display: inline-flex; align-items: center; gap: 8px; font: 700 12px/1 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--risk-c); white-space: nowrap; }
.risk::before { content: ""; flex: none; width: 9px; height: 9px; margin-right: 24px; border-radius: 50%; background: var(--risk-c); box-shadow: 14px 0 0 var(--risk-2, var(--off)), 28px 0 0 var(--risk-3, var(--off)); }
.risk[data-risk="low"] { --risk-c: var(--ok); }
.risk[data-risk="medium"] { --risk-c: var(--warn); --risk-2: var(--warn); }
.risk[data-risk="high"] { --risk-c: var(--bad); --risk-2: var(--bad); --risk-3: var(--bad); }
.on-kraft .risk[data-risk="low"], .caretag .risk[data-risk="low"] { --risk-c: var(--k-ok); }
.on-kraft .risk[data-risk="medium"], .caretag .risk[data-risk="medium"] { --risk-c: var(--k-warn); --risk-2: var(--k-warn); }
.on-kraft .risk[data-risk="high"], .caretag .risk[data-risk="high"] { --risk-c: var(--k-bad); --risk-2: var(--k-bad); --risk-3: var(--k-bad); }

/* ---------- the test box: the only dashed ink rectangle in the product ---------- */
.testbox { position: relative; display: grid; gap: 10px; padding: 16px 18px; border: 2px dashed var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.testbox h3, .testbox__title { font: 700 14px/1.2 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.testbox__arrow { display: inline-block; width: 44px; height: 18px; color: var(--ink); flex: none; }
.testbox__arrow path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.testbox .tick { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.testbox .tick input { width: 20px; height: 20px; accent-color: var(--brand); }
