/* Digital Edge shared components. Framework-agnostic: plain HTML + these classes,
   painted entirely by the --de-* tokens, so every brand gets them by loading its
   own tokens.css first. Works in Next.js, WordPress and static HTML alike.
   Semantics first: real <button>/<a>/<ol>, visible words for every state, so the
   same markup serves screen readers, browser agents and search engines. */

.de-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.de-num { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Button ---------- */
.de-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--de-space-2);
  min-height: var(--de-size-control); padding: 0 var(--de-space-5);
  font: 600 15px/1 var(--de-font-text); letter-spacing: 0; text-decoration: none; white-space: nowrap;
  border-radius: var(--de-radius-md); border: 1px solid transparent; cursor: pointer;
  transition: background-color var(--de-motion-fast) var(--de-ease), border-color var(--de-motion-fast) var(--de-ease), color var(--de-motion-fast) var(--de-ease);
}
.de-btn:focus-visible { outline: 2px solid var(--de-focus); outline-offset: 2px; }
.de-btn--primary { background: var(--de-accent); color: var(--de-on-accent); }
.de-btn--primary:hover { background: var(--de-accent-hover); }
.de-btn--secondary { background: var(--de-surface-raised); color: var(--de-ink); border-color: var(--de-line-strong); }
.de-btn--secondary:hover { border-color: var(--de-accent-ink); color: var(--de-accent-ink); }
.de-btn--ghost { background: transparent; color: var(--de-accent-ink); }
.de-btn--ghost:hover { background: var(--de-accent-soft); }
.de-btn--lg { min-height: var(--de-size-control-lg); padding: 0 var(--de-space-6); font-size: 16px; }
.de-btn--block { display: flex; width: 100%; }
.de-btn[aria-disabled="true"], .de-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.de-btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Chip (filters, toggles) ---------- */
.de-chip {
  display: inline-flex; align-items: center; gap: var(--de-space-2);
  min-height: var(--de-size-control-sm); padding: 0 var(--de-space-3);
  font: 500 14px/1 var(--de-font-text); color: var(--de-ink);
  background: var(--de-surface-raised); border: 1px solid var(--de-line-strong); border-radius: var(--de-radius-pill);
  cursor: pointer; text-decoration: none;
}
.de-chip:hover { border-color: var(--de-accent-ink); }
.de-chip:focus-visible { outline: 2px solid var(--de-focus); outline-offset: 2px; }
.de-chip[aria-pressed="true"], .de-chip[aria-checked="true"], .de-chip[aria-current="true"] {
  background: var(--de-accent-soft); color: var(--de-accent-ink); border-color: var(--de-accent-ink); font-weight: 600;
}
.de-chip__count { color: var(--de-ink-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.de-chip[aria-pressed="true"] .de-chip__count { color: inherit; }

/* ---------- Badge ---------- */
.de-badge {
  display: inline-flex; align-items: center; gap: var(--de-space-1);
  padding: 3px var(--de-space-2); border-radius: var(--de-radius-sm);
  font: 600 12px/16px var(--de-font-text); background: var(--de-surface-sunken); color: var(--de-ink-muted);
}
.de-badge--accent { background: var(--de-accent-soft); color: var(--de-accent-ink); }
.de-badge--success { background: var(--de-success-soft); color: var(--de-success); }
.de-badge--warning { background: var(--de-warning-soft); color: var(--de-warning); }
.de-badge--danger { background: var(--de-danger-soft); color: var(--de-danger); }
.de-badge svg { width: 12px; height: 12px; }

/* ---------- Price block (total price first) ---------- */
.de-price { display: grid; gap: var(--de-space-1); font-family: var(--de-font-text); color: var(--de-ink); }
.de-price__label { font-size: var(--de-text-body-sm-size); line-height: var(--de-text-body-sm-line); color: var(--de-ink-muted); }
.de-price__amount {
  font-family: var(--de-font-display); font-size: var(--de-text-price-xl-size); line-height: var(--de-text-price-xl-line);
  font-weight: var(--de-text-price-xl-weight); letter-spacing: var(--de-text-price-xl-tracking); font-variant-numeric: tabular-nums lining-nums;
}
.de-price__total { font-size: var(--de-text-body-sm-size); line-height: var(--de-text-body-sm-line); color: var(--de-ink-muted); }
.de-price__total strong { color: var(--de-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.de-price__saving { font-size: var(--de-text-body-sm-size); line-height: var(--de-text-body-sm-line); color: var(--de-price-drop); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Offer row ---------- */
.de-offers { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--de-space-2); }
.de-offer {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: center; gap: var(--de-space-3) var(--de-space-5);
  padding: var(--de-space-4) var(--de-space-5); background: var(--de-surface-raised);
  border: 1px solid var(--de-line); border-radius: var(--de-radius-md); font-family: var(--de-font-text); color: var(--de-ink);
}
.de-offer[data-best="true"] { background: var(--de-accent-soft); border-color: var(--de-accent-ink); }
.de-offer__retailer { display: flex; align-items: center; gap: var(--de-space-3); min-width: 0; }
.de-offer__logo {
  width: 44px; height: 44px; flex: none; border-radius: var(--de-radius-sm); background: var(--de-surface-raised);
  border: 1px solid var(--de-line); display: grid; place-items: center; overflow: hidden;
  font: 700 13px/1 var(--de-font-text); color: var(--de-ink-muted);
}
.de-offer__logo img { width: 100%; height: 100%; object-fit: contain; }
.de-offer__name { font-weight: 600; font-size: 16px; line-height: 22px; }
.de-offer__trust { display: flex; flex-wrap: wrap; gap: 2px var(--de-space-2); font-size: 13px; line-height: 18px; color: var(--de-ink-muted); }
.de-offer__pricing { display: grid; gap: 2px; justify-items: end; text-align: right; }
.de-offer__amount { font: var(--de-text-price-weight) var(--de-text-price-size)/var(--de-text-price-line) var(--de-font-display); font-variant-numeric: tabular-nums lining-nums; }
.de-offer__meta { font-size: 13px; line-height: 18px; color: var(--de-ink-muted); font-variant-numeric: tabular-nums; }
.de-offer__meta > span { white-space: nowrap; }
.de-offer__meta .is-in-stock { color: var(--de-success); font-weight: 600; }
.de-offer__meta .is-low { color: var(--de-warning); font-weight: 600; }
@media (max-width: 640px) {
  /* fit-content caps the price column so long delivery text wraps instead of
     overlapping the retailer column on narrow phones. */
  .de-offer { grid-template-columns: minmax(0, 1fr) fit-content(55%); padding: var(--de-space-4); }
  .de-offer__pricing { min-width: 0; }
  .de-offer__cta { grid-column: 1 / -1; }
  .de-offer__cta .de-btn { width: 100%; }
}

/* ---------- Deal Verdict (signature) ---------- */
.de-verdict {
  --v-fill: var(--de-verdict-good); --v-soft: var(--de-verdict-good-soft); --v-ink: var(--de-verdict-good-ink);
  display: grid; gap: var(--de-space-3); padding: var(--de-space-5); border-radius: var(--de-radius-lg);
  background: var(--v-soft); color: var(--de-ink); font-family: var(--de-font-text);
}
.de-verdict[data-verdict="great"], .de-verdict-badge[data-verdict="great"] { --v-fill: var(--de-verdict-great); --v-soft: var(--de-verdict-great-soft); --v-ink: var(--de-verdict-great-ink); }
.de-verdict[data-verdict="good"], .de-verdict-badge[data-verdict="good"] { --v-fill: var(--de-verdict-good); --v-soft: var(--de-verdict-good-soft); --v-ink: var(--de-verdict-good-ink); }
.de-verdict[data-verdict="fair"], .de-verdict-badge[data-verdict="fair"] { --v-fill: var(--de-verdict-fair); --v-soft: var(--de-verdict-fair-soft); --v-ink: var(--de-verdict-fair-ink); }
.de-verdict[data-verdict="wait"], .de-verdict-badge[data-verdict="wait"] { --v-fill: var(--de-verdict-wait); --v-soft: var(--de-verdict-wait-soft); --v-ink: var(--de-verdict-wait-ink); }
.de-verdict__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--de-space-2) var(--de-space-3); }
.de-verdict__title {
  margin: 0; font-family: var(--de-font-display); font-size: var(--de-text-h3-size); line-height: var(--de-text-h3-line);
  font-weight: 650; letter-spacing: var(--de-text-h3-tracking); color: var(--v-ink); text-wrap: balance;
}
.de-verdict__evidence { margin: 0; font-size: var(--de-text-body-sm-size); line-height: var(--de-text-body-sm-line); color: var(--de-ink); max-width: var(--de-size-measure); }
.de-verdict__meter { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--de-space-1); }
.de-verdict__meter li { display: grid; gap: 6px; font-size: 12px; line-height: 16px; color: var(--de-ink); }
.de-verdict__meter li::before { content: ""; height: 6px; border-radius: var(--de-radius-pill); background: var(--de-ink-subtle); opacity: 0.35; }
.de-verdict__meter li[aria-current="true"] { font-weight: 700; color: var(--v-ink); }
.de-verdict__meter li[aria-current="true"]::before { background: var(--v-fill); opacity: 1; height: 8px; margin-top: -1px; }
.de-verdict__basis { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--de-space-2); font-size: 13px; line-height: 18px; color: var(--de-ink); }
.de-verdict__basis a { color: var(--v-ink); font-weight: 600; text-underline-offset: 3px; }
.de-verdict__basis a:focus-visible { outline: 2px solid var(--de-focus); outline-offset: 2px; border-radius: 2px; }

.de-verdict-badge {
  --v-fill: var(--de-verdict-good); --v-ink: var(--de-verdict-good-ink); --v-soft: var(--de-verdict-good-soft);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: var(--de-radius-pill);
  background: var(--v-fill); color: var(--de-on-verdict); font: 700 13px/18px var(--de-font-text); white-space: nowrap;
}
.de-verdict-badge svg { width: 14px; height: 14px; flex: none; }
.de-verdict-badge--quiet { background: var(--v-soft); color: var(--v-ink); }

/* ---------- Product card ---------- */
.de-card {
  position: relative; display: grid; grid-template-rows: auto 1fr; background: var(--de-surface-raised);
  border: 1px solid var(--de-line); border-radius: var(--de-radius-lg); overflow: hidden; font-family: var(--de-font-text); color: var(--de-ink);
  transition: border-color var(--de-motion-fast) var(--de-ease), box-shadow var(--de-motion-fast) var(--de-ease);
}
.de-card:hover { border-color: var(--de-line-strong); box-shadow: var(--de-shadow-md); }
.de-card:focus-within { outline: 2px solid var(--de-focus); outline-offset: 2px; }
.de-card__media { aspect-ratio: 1 / 1; background: #ffffff; display: grid; place-items: center; padding: var(--de-space-4); border-bottom: 1px solid var(--de-line); }
.de-card__media img { max-width: 100%; max-height: 100%; object-fit: contain; }
.de-card__media--empty { background: var(--de-surface-sunken); color: var(--de-ink-subtle); font-size: 13px; }
.de-card__body { display: grid; align-content: start; gap: var(--de-space-2); padding: var(--de-space-4); }
.de-card__brand { font: 600 12px/16px var(--de-font-text); letter-spacing: 0.06em; text-transform: uppercase; color: var(--de-ink-muted); }
.de-card__title { margin: 0; font: 600 16px/22px var(--de-font-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.de-card__link { color: inherit; text-decoration: none; }
.de-card__link::after { content: ""; position: absolute; inset: 0; }
.de-card__link:focus-visible { outline: none; }
.de-card__price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--de-space-2); }
.de-card__from { font-size: 13px; color: var(--de-ink-muted); }
.de-card__amount { font: var(--de-text-price-weight) var(--de-text-price-size)/var(--de-text-price-line) var(--de-font-display); font-variant-numeric: tabular-nums lining-nums; }
.de-card__retailers { font-size: 13px; color: var(--de-ink-muted); }
.de-card__body > .de-verdict-badge { justify-self: start; }

/* ---------- Note (disclosure, info) ---------- */
.de-note {
  display: flex; gap: var(--de-space-2); align-items: flex-start; padding: var(--de-space-3) var(--de-space-4);
  background: var(--de-surface-sunken); border-radius: var(--de-radius-md);
  font: 400 13px/19px var(--de-font-text); color: var(--de-ink-muted);
}
.de-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--de-ink-subtle); }
.de-note strong { color: var(--de-ink); font-weight: 600; }
