/* Vegan Costco Bot
   Visual language borrowed from the building itself: concrete floor, white
   placards on steel racking, hazard-placard colors, stencilled marks.
   Light ground on purpose -- a warehouse is bright, and dark UI under those
   lights is all reflection. */

:root {
  --concrete: #DFDCD5;
  --placard: #FFFFFF;
  --ink: #101317;
  --steel: #5C6672;
  --hairline: #C6C2B9;

  --go: #0B6E4F;
  --safety: #B57A00;
  --stop: #A81E12;
  --maybe: #1F5673;

  --tap: 48px;
  --pad: 16px;
  --rail: 116px;
  --thumb: 74px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--concrete);
  color: var(--ink);
  font: 400 17px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- top rail ---------------------------------------------------------- */

.rail {
  position: sticky; top: 0; z-index: 20;
  background: var(--concrete);
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  border-bottom: 1px solid var(--hairline);
}

.rail-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: 15px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .14em;
  white-space: nowrap;
}
h1 span { color: var(--steel); font-weight: 600; }
h1 span::before { content: " / "; }

.stamp {
  margin: 0; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--steel);
  font-variant-numeric: tabular-nums;
}

.find { position: relative; display: block; }

#q {
  width: 100%; height: var(--tap);
  padding: 0 40px 0 14px;
  font-size: 17px; color: var(--ink);
  background: var(--placard);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  appearance: none;
}
#q:focus-visible { outline: 3px solid var(--maybe); outline-offset: 1px; }
#q::-webkit-search-cancel-button { display: none; }

.clear {
  position: absolute; right: 4px; top: 4px;
  width: 40px; height: 40px;
  font-size: 24px; line-height: 1;
  background: none; border: 0; color: var(--steel);
}

.chips { display: flex; gap: 8px; margin-top: 8px; }
.chips:empty { display: none; }

.chip {
  min-height: 34px; padding: 0 12px;
  background: var(--placard); color: var(--steel);
  border: 1px solid var(--hairline); border-radius: 17px;
  font: 600 12px/1 inherit; letter-spacing: .06em; text-transform: uppercase;
}
.chip[aria-pressed="true"] {
  background: var(--ink); color: var(--concrete); border-color: var(--ink);
}
.chip:focus-visible { outline: 3px solid var(--maybe); outline-offset: 2px; }

/* ---- list -------------------------------------------------------------- */

main {
  padding: 10px var(--pad) calc(var(--thumb) + env(safe-area-inset-bottom) + 24px);
  display: grid; gap: 8px;
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px 10px 0;
  text-align: left;
  background: var(--placard);
  border: 1px solid var(--hairline);
  border-left: 6px solid var(--mark);
  border-radius: 2px;
  font: inherit; color: inherit;
}
.card:focus-visible { outline: 3px solid var(--maybe); outline-offset: 2px; }
.card:active { background: #F5F3EF; }

/* The stencil mark. Shape carries the verdict, not just hue. */
.card .mark {
  justify-self: center;
  font-size: 22px; font-weight: 800; line-height: 1;
  color: var(--mark);
}

.card .name {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
.card .why {
  display: block; margin-top: 3px;
  font-size: 12px; letter-spacing: .04em;
  color: var(--steel);
  text-transform: lowercase;
}
.card .price {
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.v-PASS   { --mark: var(--go); }
.v-CHECK  { --mark: var(--safety); }
.v-REJECT { --mark: var(--stop); }
.v-LIKELY { --mark: var(--maybe); }
.v-UNKNOWN{ --mark: var(--steel); }

.card .tag {
  display: inline-block; margin-right: 6px;
  padding: 1px 5px; border-radius: 2px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  vertical-align: 1px;
}
.card .tag.new { background: #DCEFE6; color: var(--go); }
.card .tag.gone { background: #EFE7DA; color: #7A5B12; }

.seen {
  margin: 14px 0 0; font-size: 12px; letter-spacing: .04em;
  color: var(--steel); font-variant-numeric: tabular-nums;
}

.mine::after {
  content: "your call";
  position: absolute; top: 6px; right: 10px;
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--steel);
}

.empty {
  margin: 40px var(--pad); text-align: center;
  color: var(--steel); font-size: 15px; line-height: 1.6;
}

/* ---- thumb bar --------------------------------------------------------- */

.thumb {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--placard);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
}
.thumb button {
  display: grid; justify-items: center; gap: 1px;
  min-height: var(--thumb);
  padding: 10px 4px;
  background: none; border: 0; border-top: 3px solid transparent;
  color: var(--steel); font: inherit;
}
.thumb button i { font-style: normal; font-size: 19px; font-weight: 800; line-height: 1.1; }
.thumb button b { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.thumb button em {
  font-style: normal; font-size: 11px;
  font-variant-numeric: tabular-nums; opacity: .75;
}
.thumb button:focus-visible { outline: 3px solid var(--maybe); outline-offset: -3px; }

.thumb button[data-v=PASS]   { --mark: var(--go); }
.thumb button[data-v=CHECK]  { --mark: var(--safety); }
.thumb button[data-v=UNKNOWN] { --mark: var(--steel); }
.thumb button[data-v=REJECT] { --mark: var(--stop); }
.thumb button.on { color: var(--mark); border-top-color: var(--mark); background: #FBFAF8; }

/* ---- detail sheet ------------------------------------------------------ */

dialog {
  width: 100%; max-width: 560px;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 2px 2px 0 0;
  background: var(--placard); color: var(--ink);
  max-height: 88dvh;
}
dialog::backdrop { background: rgba(16, 19, 23, .55); }
dialog article {
  padding: 20px var(--pad) calc(env(safe-area-inset-bottom) + 24px);
  overflow-y: auto; max-height: 88dvh;
}

.close {
  float: right; width: 44px; height: 44px; margin: -8px -8px 0 0;
  font-size: 28px; line-height: 1; background: none; border: 0; color: var(--steel);
}

.eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--steel);
}
dialog h2 { margin: 0 0 14px; font-size: 21px; line-height: 1.25; font-weight: 700; }

.verdict {
  margin: 0 0 6px;
  font-size: 13px; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--mark);
}
.reason { margin: 0 0 18px; color: var(--steel); font-size: 15px; }

dialog h3 {
  margin: 22px 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--steel);
  border-top: 1px solid var(--hairline); padding-top: 14px;
}

/* The signature: the real label, with the words that decided it marked in
   place. You read it the way you would read the box. */
.label-text {
  margin: 0; font-size: 15px; line-height: 1.65;
  overflow-wrap: anywhere;
}
.label-text mark {
  padding: 1px 3px; border-radius: 2px;
  background: #FBE6A2; color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--safety);
}
.label-text mark.hit-reject {
  background: #F6CFCB; box-shadow: inset 0 -2px 0 var(--stop);
}

.allergen {
  margin: 12px 0 0; padding: 10px 12px;
  background: #FBF3E4; border-left: 4px solid var(--safety);
  font-size: 14px;
}

.fineprint { margin: 20px 0 0; font-size: 12px; color: var(--steel); line-height: 1.5; }

.decide {
  margin: 0 0 4px; padding: 14px;
  background: #FBFAF8; border: 1px solid var(--hairline);
}
.decide p { margin: 0 0 10px; font-size: 13px; color: var(--steel); }
.decide div { display: flex; flex-wrap: wrap; gap: 8px; }
.decide button {
  flex: 1 1 auto; min-height: var(--tap);
  padding: 0 14px;
  font: 600 15px/1 inherit;
  background: var(--placard); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px;
}
.decide button:focus-visible { outline: 3px solid var(--maybe); outline-offset: 2px; }
.decide button.undo { flex-basis: 100%; border-color: var(--hairline); color: var(--steel); }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: rise .22s cubic-bezier(.2, .7, .3, 1); }
  @keyframes rise { from { transform: translateY(14px); opacity: 0; } }
}

@media (min-width: 640px) {
  main { grid-template-columns: repeat(2, 1fr); }
  .thumb { max-width: 560px; margin: 0 auto; border: 1px solid var(--hairline); border-bottom: 0; }
}

/* Costco's marketing description, shown only when there is no real label.
   Visually demoted because it is context, not evidence: it carries serving
   suggestions that name animal products the item does not contain. */
.blurb {
  display: block; margin-top: 14px; padding: 10px 12px;
  background: #F5F3EF; border-left: 3px solid var(--hairline);
  font-size: 13px; line-height: 1.55; color: var(--steel);
}
.blurb b {
  display: block; margin-bottom: 4px;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}

/* Native select on purpose: iOS renders it as the wheel picker, which is the
   easiest control to hit one-handed with a cart in the other hand. */
.pick { position: relative; display: block; flex: 1 1 auto; min-width: 0; }
.pick::after {
  content: "";
  position: absolute; right: 13px; top: 50%; margin-top: -2px;
  width: 7px; height: 7px;
  border-right: 2px solid var(--steel); border-bottom: 2px solid var(--steel);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
}
.pick select {
  width: 100%; min-height: 34px; padding: 0 30px 0 12px;
  background: var(--placard); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 17px;
  font: 600 12px/1 inherit; letter-spacing: .06em; text-transform: uppercase;
  appearance: none;
}
.pick select:focus-visible { outline: 3px solid var(--maybe); outline-offset: 2px; }
