/* ---------------------------------------------------------------------
   Design tokens
   A dark, ticket-board feel: this is checked standing in a parking lot,
   often at night, in quick glances -- so it's built for legibility and
   thumb-friendly taps first, with a distinct point of view instead of a
   generic dashboard look. Numbers (price, weight, potency) always render
   in a tabular monospace, like a scale readout or a receipt -- that's the
   one consistent typographic device tying every number on the page
   together. Sale discounts get amber; genuine best-value reads get teal --
   two different signals for two different things.
------------------------------------------------------------------------ */
:root {
  --bg: #14161a;
  --surface: #1e2126;
  --surface-hover: #262a31;
  --border: #2b2f36;
  --text: #edeef0;
  --text-dim: #8b93a1;
  --text-faint: #5b6270;
  --accent-sale: #e8a33d;
  --accent-sale-ink: #241a08;
  --accent-value: #4fd1c5;
  --accent-value-ink: #0b1c1a;
  --radius: 14px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: 48px;
}

button, select, input {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-value);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ----- Header ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.last-updated {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.terpene-crawl-link {
  display: block;
  margin: 6px 0 0;
  padding: 0;
  background: none;
  border: none;
  font-size: 11.5px;
  color: var(--text-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.terpene-crawl-link:disabled {
  opacity: 0.6;
  cursor: default;
}

.terpene-crawl-link[hidden] {
  display: none;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  min-height: 40px;
  cursor: pointer;
  white-space: nowrap;
}

.refresh-btn:active { background: var(--surface-hover); }

.refresh-icon {
  width: 13px;
  height: 13px;
  border: 2px solid var(--text-dim);
  border-top-color: var(--accent-value);
  border-radius: 50%;
  display: none;
}

.refresh-btn.busy .refresh-icon {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Filter bar ----- */
.filter-bar {
  position: sticky;
  top: 64px;
  z-index: 9;
  background: var(--bg);
  padding: 10px 0 10px;
  border-bottom: 1px solid var(--border);
}

.scope-hint {
  margin: 0 0 8px;
  padding: 0 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.4;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 3px 16px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 14px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

.chip small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.chip.active {
  background: var(--accent-value);
  border-color: var(--accent-value);
  color: var(--accent-value-ink);
}

.chip.partial {
  background: var(--surface);
  border-color: var(--accent-value);
  color: var(--accent-value);
}

.chip-row.drilldown {
  padding: 4px 16px 4px 28px;
  gap: 6px;
}

.drilldown-label {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-faint);
  align-self: center;
  padding-right: 2px;
}

.chip-sm {
  padding: 5px 11px;
  font-size: 12px;
  min-height: 30px;
  border-radius: 11px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px 0;
}

.sale-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text-dim);
  min-height: 36px;
}

.sale-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-sale);
}

#sortSelect {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  min-height: 38px;
  max-width: 58%;
}

.search-row {
  padding: 10px 16px 0;
}

.name-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  min-height: 38px;
}

.name-search::placeholder {
  color: var(--text-faint);
}

/* ----- Results ----- */
.result-count {
  padding: 12px 16px 0;
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card-list {
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.card-brand {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 1px;
}

.value-chip {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 6px 18px;
  background: var(--accent-value);
  color: var(--accent-value-ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}

.value-chip::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: var(--accent-value-ink);
  transform: translateY(-50%);
  opacity: 0.55;
}

.value-chip .unit {
  font-size: 10.5px;
  font-weight: 600;
  opacity: 0.75;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
}

.badge.strain-sativa { color: #d9a441; }
.badge.strain-indica { color: #8b7ee8; }
.badge.strain-hybrid { color: #5fbf7f; }

.card-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.price-now {
  font-size: 17px;
  font-weight: 700;
}

.price-was {
  font-size: 13px;
  color: var(--text-faint);
  text-decoration: line-through;
}

.sale-tag {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-sale-ink);
  background: var(--accent-sale);
  border-radius: 5px;
  padding: 2px 7px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.card-store-link {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
}

.card-store-link:active { color: var(--accent-value); }

.card-footer-potency {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card-terpenes {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.card-vibes {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.card-cannabinoids {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ----- Toast ----- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
}
