/* ==========================================================================
   aff.css — Amazon affiliate component library
   Framework-agnostic. Drop this file in, override the tokens per site.
   Docs: AFFILIATE_LIBRARY.md
   ========================================================================== */

.aff, .aff *, .aff *::before, .aff *::after { box-sizing: border-box; }

.aff {
  /* --- brand / theme ---------------------------------------------------- */
  --aff-accent:        #0b5fff;
  --aff-accent-hover:  #0947c4;
  --aff-accent-ink:    #ffffff;
  --aff-cta:           #ff7a18;   /* buy button */
  --aff-cta-hover:     #e56605;
  --aff-cta-ink:       #1a1005;
  --aff-sale:          #d81f4a;   /* discount / urgency */
  --aff-star:          #ff9900;

  /* --- surfaces --------------------------------------------------------- */
  --aff-bg:            #ffffff;
  --aff-bg-soft:       #f6f7f9;
  --aff-bg-tint:       #f0f5ff;
  --aff-border:        #e5e7eb;
  --aff-border-strong: #d1d5db;
  --aff-ink:           #10131a;
  --aff-ink-soft:      #4b5563;
  --aff-ink-faint:     #8b93a1;

  /* --- shape & type ----------------------------------------------------- */
  --aff-radius:        16px;
  --aff-radius-sm:     10px;
  --aff-radius-pill:   999px;
  --aff-shadow:        0 1px 2px rgba(16,19,26,.04), 0 8px 24px -12px rgba(16,19,26,.14);
  --aff-shadow-lift:   0 2px 4px rgba(16,19,26,.05), 0 18px 40px -16px rgba(16,19,26,.24);
  --aff-font:          "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --aff-gap:           16px;
  --aff-pad:           20px;

  font-family: var(--aff-font);
  color: var(--aff-ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Dark override: add class .aff--dark alongside .aff */
.aff--dark {
  --aff-bg: #14171d; --aff-bg-soft: #1b1f27; --aff-bg-tint: #1a2230;
  --aff-border: #2a2f3a; --aff-border-strong: #3a4150;
  --aff-ink: #f3f5f8; --aff-ink-soft: #b3bac6; --aff-ink-faint: #7d8695;
  --aff-shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
  --aff-shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 20px 44px -18px rgba(0,0,0,.8);
}

/* ---------- primitives ---------------------------------------------------- */

.aff-card {
  background: var(--aff-bg);
  border: 1px solid var(--aff-border);
  border-radius: var(--aff-radius);
  box-shadow: var(--aff-shadow);
  position: relative;
  transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease;
}
.aff-card:hover { box-shadow: var(--aff-shadow-lift); transform: translateY(-2px); }

.aff-title {
  font-size: 17px; font-weight: 650; letter-spacing: -.01em;
  color: var(--aff-ink); text-decoration: none; text-wrap: pretty;
  display: block;
}
.aff-title:hover { color: var(--aff-accent); }
.aff-title--sm { font-size: 15px; font-weight: 600; }
.aff-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.aff-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.aff-thumb {
  display: flex; align-items: center; justify-content: center; background: var(--aff-bg);
  border-radius: var(--aff-radius-sm); overflow: hidden; flex: none;
}
.aff-thumb img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }

/* --- badges --- */
.aff-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 10px; border-radius: var(--aff-radius-pill); white-space: nowrap;
  background: var(--aff-bg-soft); color: var(--aff-ink-soft);
}
.aff-badge--sale   { background: var(--aff-sale);  color: #fff; }
.aff-badge--rank   { background: var(--aff-ink);   color: var(--aff-bg); }
.aff-badge--accent { background: var(--aff-bg-tint); color: var(--aff-accent); }
.aff-badge--new    { background: #0f8a5f; color: #fff; }
.aff-badge--float  { position: absolute; top: 12px; left: 12px; z-index: 2; box-shadow: var(--aff-shadow); }

.aff-prime {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: #0d7ea8;
}
.aff-prime::before {
  content: ""; width: 16px; height: 10px; border-radius: 2px;
  background: linear-gradient(135deg, #00a8e1, #0d7ea8);
  clip-path: polygon(0 55%, 45% 100%, 100% 0, 100% 30%, 45% 100%, 0 80%);
}

/* --- stock --- */
.aff-stock { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.aff-stock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.aff-stock--in  { color: #0f8a5f; }
.aff-stock--low { color: #b45309; }
.aff-stock--out { color: var(--aff-ink-faint); }

/* --- stars --- */
.aff-rating { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--aff-ink-soft); }
.aff-stars {
  --aff-pct: 90%;
  position: relative; font-size: 14px; letter-spacing: 1.5px; line-height: 1;
  color: var(--aff-border-strong); flex: none;
}
.aff-stars::before { content: "★★★★★"; }
.aff-stars::after {
  content: "★★★★★"; position: absolute; inset: 0; color: var(--aff-star);
  width: var(--aff-pct); overflow: hidden; white-space: nowrap;
}
.aff-reviews { color: var(--aff-ink-faint); }

/* --- self-assigned score --- */
.aff-score {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  background: var(--aff-bg-tint); color: var(--aff-accent);
  border: 2px solid currentColor; font-variant-numeric: tabular-nums;
}
.aff-score b { font-size: 19px; font-weight: 750; line-height: 1; }
.aff-score span { font-size: 8.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }

/* --- price --- */
.aff-price { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.aff-price b { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.aff-price s { font-size: 14px; color: var(--aff-ink-faint); font-weight: 500; }
.aff-price em {
  font-style: normal; font-size: 12px; font-weight: 700; color: var(--aff-sale);
  background: color-mix(in oklab, var(--aff-sale) 12%, transparent);
  padding: 3px 7px; border-radius: var(--aff-radius-sm);
}
.aff-price--sm b { font-size: 17px; }

/* --- buttons --- */
.aff-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14.5px; font-weight: 700; letter-spacing: -.005em;
  padding: 12px 20px; border-radius: var(--aff-radius-pill); border: 1px solid transparent;
  background: var(--aff-cta); color: var(--aff-cta-ink); text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 6px 16px -8px color-mix(in oklab, var(--aff-cta) 70%, transparent);
}
.aff-btn:hover  { background: var(--aff-cta-hover); }
.aff-btn:active { transform: translateY(1px); }
.aff-btn--block { width: 100%; }
.aff-btn--sm    { font-size: 13px; padding: 9px 15px; }
.aff-btn--lg    { font-size: 16px; padding: 15px 26px; }
.aff-btn--ghost {
  background: transparent; color: var(--aff-ink); border-color: var(--aff-border-strong); box-shadow: none;
}
.aff-btn--ghost:hover { background: var(--aff-bg-soft); border-color: var(--aff-ink-faint); }
.aff-btn--accent { background: var(--aff-accent); color: var(--aff-accent-ink); box-shadow: none; }
.aff-btn--accent:hover { background: var(--aff-accent-hover); }
.aff-btn::after { content: "↗"; font-size: .85em; opacity: .7; }
.aff-btn--noarrow::after { content: none; }

/* --- fine print --- */
.aff-fineprint { font-size: 11px; color: var(--aff-ink-faint); line-height: 1.4; }
.aff-fineprint a { color: inherit; text-decoration: underline; }
.aff-bullets { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--aff-ink-soft); }
.aff-bullets li { margin: 3px 0; text-wrap: pretty; }
.aff-blurb {
  font-size: 14px; color: var(--aff-ink-soft); text-wrap: pretty; margin: 0;
  border-left: 2px solid var(--aff-accent); padding-left: 12px;
}

/* ==========================================================================
   1. HORIZONTAL PRODUCT BOX  .aff-box
   variants: --spotlight  --minimal
   ========================================================================== */
.aff-box { display: flex; gap: var(--aff-gap); padding: var(--aff-pad); align-items: flex-start; }
.aff-box > .aff-thumb { width: 148px; height: 148px; }
.aff-box__body { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1; }
.aff-box__meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.aff-box__foot {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 2px;
}
.aff-box--spotlight {
  border-color: color-mix(in oklab, var(--aff-accent) 35%, var(--aff-border));
  background: linear-gradient(180deg, var(--aff-bg-tint), var(--aff-bg) 70%);
  padding-top: 30px;
}
.aff-box--spotlight .aff-badge--float { top: -1px; left: var(--aff-pad); border-radius: 0 0 var(--aff-radius-sm) var(--aff-radius-sm); }
.aff-box--minimal { box-shadow: none; border-radius: var(--aff-radius-sm); padding: 14px; gap: 14px; }
.aff-box--minimal:hover { transform: none; box-shadow: none; border-color: var(--aff-border-strong); }
.aff-box--minimal > .aff-thumb { width: 84px; height: 84px; }

@media (max-width: 560px) {
  .aff-box { flex-direction: column; align-items: stretch; }
  .aff-box > .aff-thumb { width: 100%; height: 190px; }
  .aff-box__foot .aff-btn { width: 100%; }
}

/* ==========================================================================
   2. VERTICAL BOX / SIDEBAR WIDGET  .aff-vbox
   ========================================================================== */
.aff-vbox {
  display: flex; flex-direction: column; gap: 10px; padding: var(--aff-pad);
  width: 100%; max-width: 320px; text-align: center; align-items: center;
}
.aff-vbox > .aff-thumb { width: 100%; height: 170px; }
.aff-vbox .aff-price { justify-content: center; }
.aff-vbox__head {
  font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase;
  color: var(--aff-accent);
}

/* ==========================================================================
   3. GRID  .aff-grid (data-cols 2|3|4)
   ========================================================================== */
.aff-grid { display: grid; gap: var(--aff-gap); grid-template-columns: repeat(var(--aff-cols, 3), minmax(0, 1fr)); }
.aff-grid[data-cols="2"] { --aff-cols: 2; }
.aff-grid[data-cols="3"] { --aff-cols: 3; }
.aff-grid[data-cols="4"] { --aff-cols: 4; }
.aff-grid .aff-vbox { max-width: none; padding: 16px; }
.aff-grid .aff-vbox > .aff-thumb { height: 140px; }
@media (max-width: 760px) { .aff-grid { --aff-cols: 2 !important; } }
@media (max-width: 460px) { .aff-grid { --aff-cols: 1 !important; } }

/* ==========================================================================
   4. COMPARISON TABLE  .aff-table  (wrap in .aff-table-wrap)
   variants: --compact
   ========================================================================== */
.aff-table-wrap {
  border: 1px solid var(--aff-border); border-radius: var(--aff-radius);
  box-shadow: var(--aff-shadow); overflow: hidden; background: var(--aff-bg);
}
.aff-table-wrap > .aff-table-scroll { overflow-x: auto; }
.aff-table { width: 100%; border-collapse: collapse; min-width: 660px; }
.aff-table thead th {
  background: var(--aff-bg-soft); text-align: left; padding: 13px 16px;
  font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
  color: var(--aff-ink-soft); border-bottom: 1px solid var(--aff-border); white-space: nowrap;
}
.aff-table td { padding: 16px; border-bottom: 1px solid var(--aff-border); vertical-align: middle; font-size: 14px; color: var(--aff-ink-soft); }
.aff-table tbody tr:last-child td { border-bottom: 0; }
.aff-table tbody tr { transition: background .16s ease; }
.aff-table tbody tr:hover { background: var(--aff-bg-soft); }
.aff-table tbody tr.is-pick { background: var(--aff-bg-tint); }
.aff-table tbody tr.is-pick:hover { background: var(--aff-bg-tint); }
.aff-table .aff-thumb { width: 76px; height: 76px; }
.aff-table__product { display: flex; gap: 14px; align-items: center; min-width: 240px; }
.aff-table__product > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.aff-table--compact td { padding: 11px 14px; }
.aff-table--compact .aff-thumb { width: 52px; height: 52px; }
.aff-table__foot { padding: 11px 16px; background: var(--aff-bg-soft); border-top: 1px solid var(--aff-border); }

/* ==========================================================================
   5. BESTSELLER LIST  .aff-list  (+ .aff-list--ranked)
   6. NEW RELEASES     .aff-list--new
   ========================================================================== */
.aff-listbox { border: 1px solid var(--aff-border); border-radius: var(--aff-radius); box-shadow: var(--aff-shadow); background: var(--aff-bg); overflow: hidden; }
.aff-listbox__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--aff-border); background: var(--aff-bg-soft);
}
.aff-listbox__head h3 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.aff-list { list-style: none; margin: 0; padding: 0; }
.aff-list > li {
  display: flex; gap: 14px; align-items: center; padding: 14px 18px;
  border-bottom: 1px solid var(--aff-border); transition: background .16s ease;
}
.aff-list > li:last-child { border-bottom: 0; }
.aff-list > li:hover { background: var(--aff-bg-soft); }
.aff-list .aff-thumb { width: 68px; height: 68px; }
.aff-list__body { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.aff-list__side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.aff-rank {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 750;
  background: var(--aff-bg-soft); color: var(--aff-ink-soft); font-variant-numeric: tabular-nums;
}
.aff-list--ranked > li:nth-child(1) .aff-rank { background: var(--aff-ink); color: var(--aff-bg); }
.aff-list--ranked > li:nth-child(2) .aff-rank,
.aff-list--ranked > li:nth-child(3) .aff-rank { background: var(--aff-bg-tint); color: var(--aff-accent); }
.aff-date { font-size: 11.5px; font-weight: 650; color: var(--aff-ink-faint); }
@media (max-width: 520px) {
  .aff-list > li { flex-wrap: wrap; }
  .aff-list__side { align-items: flex-start; width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ==========================================================================
   7. INLINE MINI BOX / TEXT LINK
   ========================================================================== */
.aff-inline {
  display: inline-flex; align-items: center; gap: 10px; vertical-align: middle;
  padding: 6px 14px 6px 8px; border: 1px solid var(--aff-border);
  border-radius: var(--aff-radius-pill); background: var(--aff-bg);
  text-decoration: none; color: var(--aff-ink); font-size: 14px; font-weight: 600;
  transition: border-color .18s ease, background .18s ease;
}
.aff-inline:hover { border-color: var(--aff-accent); background: var(--aff-bg-tint); }
.aff-inline .aff-thumb { width: 30px; height: 30px; }
.aff-inline b { font-weight: 750; color: var(--aff-accent); }
.aff-textlink {
  color: var(--aff-accent); font-weight: 650; text-decoration: none;
  border-bottom: 2px solid color-mix(in oklab, var(--aff-accent) 30%, transparent);
}
.aff-textlink:hover { border-bottom-color: var(--aff-accent); }
.aff-textlink sup { font-size: .7em; }

/* ==========================================================================
   8. AWARD BOXES  .aff-awards > .aff-award (data-award)
   ========================================================================== */
.aff-awards { display: grid; gap: var(--aff-gap); grid-template-columns: repeat(3, minmax(0,1fr)); align-items: start; }
.aff-award { display: flex; flex-direction: column; gap: 12px; padding: 0 0 18px; overflow: hidden; text-align: center; align-items: center; }
.aff-award__ribbon {
  width: 100%; padding: 10px 14px; font-size: 11.5px; font-weight: 750;
  letter-spacing: .07em; text-transform: uppercase; color: var(--aff-ink-soft);
  background: var(--aff-bg-soft); border-bottom: 1px solid var(--aff-border);
}
.aff-award[data-award="best"] { border-color: color-mix(in oklab, var(--aff-accent) 45%, var(--aff-border)); }
.aff-award[data-award="best"] .aff-award__ribbon { background: var(--aff-accent); color: var(--aff-accent-ink); border-color: transparent; }
.aff-award[data-award="best"] { transform: translateY(-6px); box-shadow: var(--aff-shadow-lift); }
.aff-award[data-award="best"]:hover { transform: translateY(-9px); }
.aff-award > *:not(.aff-award__ribbon) { width: calc(100% - 36px); }
.aff-award .aff-thumb { height: 150px; }
.aff-award .aff-price { justify-content: center; }
@media (max-width: 760px) { .aff-awards { grid-template-columns: 1fr; } .aff-award[data-award="best"] { transform: none; } }

/* ==========================================================================
   9. PROS & CONS  .aff-proscons
   ========================================================================== */
.aff-proscons { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--aff-border); overflow: hidden; padding: 0; }
.aff-proscons > div { background: var(--aff-bg); padding: 18px; }
.aff-proscons h4 {
  margin: 0 0 10px; font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
  display: flex; align-items: center; gap: 7px;
}
.aff-proscons ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.aff-proscons li { font-size: 14px; color: var(--aff-ink-soft); display: flex; gap: 9px; text-wrap: pretty; }
.aff-proscons li::before { flex: none; font-weight: 750; }
.aff-proscons__pros h4 { color: #0f8a5f; }
.aff-proscons__pros li::before { content: "＋"; color: #0f8a5f; }
.aff-proscons__cons h4 { color: var(--aff-sale); }
.aff-proscons__cons li::before { content: "－"; color: var(--aff-sale); }
@media (max-width: 520px) { .aff-proscons { grid-template-columns: 1fr; } }

/* ==========================================================================
   10. MULTI-STORE BUTTONS  .aff-stores
   ========================================================================== */
.aff-stores { display: flex; flex-direction: column; gap: 8px; }
.aff-stores--row { flex-direction: row; flex-wrap: wrap; }
.aff-store {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 16px; border: 1px solid var(--aff-border); border-radius: var(--aff-radius-pill);
  background: var(--aff-bg); text-decoration: none; color: var(--aff-ink);
  font-size: 14px; font-weight: 650; transition: border-color .18s ease, background .18s ease;
}
.aff-store:hover { border-color: var(--aff-ink-faint); background: var(--aff-bg-soft); }
.aff-store__name { display: flex; align-items: center; gap: 9px; }
.aff-store__price { font-weight: 750; font-variant-numeric: tabular-nums; }
.aff-store--primary { background: var(--aff-cta); border-color: transparent; color: var(--aff-cta-ink); }
.aff-store--primary:hover { background: var(--aff-cta-hover); border-color: transparent; }
.aff-store__tag { font-size: 11px; font-weight: 700; color: var(--aff-ink-faint); text-transform: uppercase; letter-spacing: .04em; }

/* ==========================================================================
   11. STICKY CTA BAR  .aff-sticky
   ========================================================================== */
.aff-sticky {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px; background: var(--aff-bg);
  border: 1px solid var(--aff-border); border-radius: var(--aff-radius);
  box-shadow: 0 -2px 4px rgba(16,19,26,.03), 0 -14px 40px -18px rgba(16,19,26,.3);
}
.aff-sticky .aff-thumb { width: 46px; height: 46px; }
.aff-sticky__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aff-sticky__body .aff-title { font-size: 14px; }
@media (max-width: 560px) {
  .aff-sticky { border-radius: var(--aff-radius) var(--aff-radius) 0 0; }
  .aff-sticky .aff-thumb, .aff-sticky .aff-rating { display: none; }
}

/* ==========================================================================
   12. DATA-FIELD SNIPPETS — use primitives standalone:
   .aff-price / .aff-rating / .aff-badge / .aff-stock / .aff-prime / .aff-score
   .aff-field wraps one inline in body copy.
   ========================================================================== */
.aff-field { display: inline-flex; align-items: center; vertical-align: baseline; }
.aff-updated { font-size: 11px; color: var(--aff-ink-faint); font-weight: 500; }
.aff-updated::before { content: "⟳ "; }
