:root {
  --ink: #16181d;
  --muted: #5a6170;
  --line: #e2e5eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --brand: #c2410c; /* overridden per site from config.js */
  --brand-dark: color-mix(in srgb, var(--brand) 78%, black);
  --brand-tint: color-mix(in srgb, var(--brand) 10%, white);
  --sale: #b91c1c;
  --ok: #166534;
  --warn-bg: #fff7e6;
  --warn-ink: #7a4b00;
  --focus: #2563eb;
  --radius: 12px;
}

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

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

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

.skip-link {
  position: absolute; left: 12px; top: -48px;
  background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 10;
}
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  background: var(--card); border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--brand); padding: 18px 0 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; border-radius: 8px;
}
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 800; letter-spacing: -0.03em;
}
.brand-name { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.brand-name span { color: var(--brand); }
.tagline { margin: 6px 0 0; color: var(--muted); }

main.container { flex: 1; width: 100%; padding-top: 20px; padding-bottom: 40px; }

.sample-banner {
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid #f3d9a4; border-radius: var(--radius);
  padding: 10px 14px; margin: 0 0 16px;
}
.sample-banner code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 140px; }
.field[hidden] { display: none; }
.field-search { flex: 2 1 200px; }
.field-price { flex: 0 1 96px; }
.field-sort { flex: 1 1 170px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  font: inherit; color: var(--ink);
  height: 40px; padding: 0 10px; width: 100%;
  border: 1px solid #c9ced8; border-radius: 8px; background: #fff;
}
.field input:hover, .field select:hover { border-color: #9aa1ae; }
.field-toggle { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 8px; height: 40px; }
.field-toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.field-toggle label { font-size: 14px; color: var(--ink); white-space: nowrap; }
.btn-reset {
  flex: 0 0 auto; font: inherit; font-weight: 600; height: 40px; padding: 0 14px;
  border: 1px solid #c9ced8; border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
}
.btn-reset:hover { background: var(--bg); }

.status { color: var(--muted); margin: 16px 2px 12px; font-size: 14px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.grid:focus { outline: none; }

.card {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 20px rgba(16,24,40,.08); transform: translateY(-2px); }
.card.is-expired { opacity: .6; }

.card-media { position: relative; aspect-ratio: 4 / 3; background: #eef0f4; }
.card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; color: transparent; font-size: 0; } /* never show alt text if a photo fails */
.badge-off {
  position: absolute; top: 10px; left: 10px;
  background: var(--sale); color: #fff; font-weight: 700; font-size: 13px;
  padding: 3px 8px; border-radius: 6px;
}

.card-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.card-meta { margin: 0; font-size: 13px; color: var(--muted); }
.card-meta strong { color: var(--ink); font-weight: 600; }
.card-title { margin: 0; font-size: 17px; line-height: 1.3; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 0; }
.price { font-size: 22px; font-weight: 800; }
.was { color: var(--muted); }
.ends { margin: 0; font-size: 14px; font-weight: 600; color: var(--ok); }
.ends.soon { color: var(--sale); }
.ends.expired { color: var(--muted); }

.btn-deal {
  margin-top: auto; display: block; text-align: center;
  background: var(--brand); color: #fff; text-decoration: none; font-weight: 700;
  padding: 10px 12px; border-radius: 8px;
}
.btn-deal:hover { background: var(--brand-dark); }
.card-body .ends { margin-bottom: 8px; }

.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  background: var(--card); border: 1px dashed #c9ced8; border-radius: var(--radius); padding: 40px 20px;
}

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 18px 0 28px; }
.site-footer p { margin: 0 0 4px; }

/* Responsive */
@media (max-width: 640px) {
  .field, .field-price { flex: 1 1 calc(50% - 6px); }
  .field-search, .field-sort { flex-basis: 100%; }
  .btn-reset { flex: 1 1 calc(50% - 6px); }
  /* Keep rows even when a site hides the category or expired controls. */
  .filters:has(#category-field[hidden]) #store-field,
  .filters:has(#expired-field[hidden]) .btn-reset { flex-basis: 100%; }
  .grid { grid-template-columns: 1fr; }
  .card-media { aspect-ratio: 16 / 9; }
  .brand-name { font-size: 22px; }
  .brand-mark { width: 34px; height: 34px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

/* Footer page links */
.site-footer .footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.footer-links a { color: var(--ink); font-weight: 600; text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }

/* About and privacy pages */
.prose {
  max-width: 760px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 36px 24px;
}
.prose h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 10px; }
.prose h2 { font-size: 20px; margin: 28px 0 6px; }
.prose p, .prose li { color: #2b2f38; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--brand-dark); }
.prose .updated { color: var(--muted); font-size: 14px; }
.prose .back-link { margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.prose .back-link a { font-weight: 600; text-decoration: none; }

@media (max-width: 640px) {
  .prose { padding: 20px 18px 16px; }
  .prose h1 { font-size: 26px; }
}
