/* ==========================================================================
   Jammy Deals
   Palette: Scottish thistle (color-hex.com palette 1045465)
     stem     #354732   deep green, header and ink
     mist     #faf9fa   page background
     thistle  #8858a2   actions, discounts, sponsored
     heather  #9f9ba2   lines and borders (too light for body text)
     leaf     #7ca470   highlights
   ========================================================================== */

:root {
  /* Base palette */
  --stem: #354732;
  --mist: #faf9fa;
  --thistle: #8858a2;
  --heather: #9f9ba2;
  --leaf: #7ca470;

  /* Derived shades (kept for accessible contrast) */
  --stem-deep: #26341f;
  --thistle-deep: #6f4588;
  --thistle-tint: #f1eaf5;
  --leaf-deep: #44703a;
  --leaf-tint: #eaf2e7;
  --heather-ink: #5f5a64;     /* heather darkened to pass 4.5:1 on mist */

  /* Roles */
  --bg: var(--mist);
  --surface: #ffffff;
  --ink: #1f2a1d;
  --muted: var(--heather-ink);
  --line: #e4e1e6;
  --line-strong: var(--heather);
  --accent: var(--thistle);
  --accent-hover: var(--thistle-deep);
  --accent-ink: #ffffff;
  --masthead: var(--stem);
  --masthead-ink: var(--mist);
  --price: var(--stem);
  --focus: var(--thistle);
  --chip-on-bg: var(--stem);
  --chip-on-ink: var(--mist);
  --cat-ink: var(--leaf-deep);
  --hot-ink: var(--thistle-deep);
  color-scheme: light;

  /* Logo colours (set per background: see .masthead and .site-foot) */
  --jd-ink: var(--stem);
  --jd-accent: var(--thistle);
  --jd-tuft: var(--thistle);
  --jd-leaf: var(--leaf);
  --jd-hatch: var(--stem);

  /* Type */
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --step--1: 0.8125rem;   /* 13 */
  --step-0: 1rem;         /* 16 */
  --step-1: 1.125rem;     /* 18 */
  --step-2: 1.5rem;       /* 24 */
  --step-3: clamp(1.875rem, 1.3rem + 2.4vw, 2.75rem);

  /* Space and shape */
  --wrap: 68rem;
  --gutter: 1rem;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --pill: 999px;
}

/* Dark theme: used when the visitor picks it, or when their device is set to
   dark and they haven't picked light. Both blocks must stay identical. */
:root[data-theme="dark"] {
  --bg: #161d15;
  --surface: #1e271c;
  --ink: #eceeea;
  --muted: #b3afb6;
  --line: #2f3a2d;
  --line-strong: #4c5649;
  --accent: #a77cc0;
  --accent-hover: #b993cf;
  --accent-ink: #160f1a;
  --thistle-tint: #2c2334;
  --leaf-tint: #223020;
  --masthead: #0f150e;
  --price: #c5dcbc;
  --focus: #c3a0d6;
  --chip-on-bg: var(--leaf);
  --chip-on-ink: #10170f;
  --cat-ink: var(--leaf);
  --hot-ink: #d6bce4;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161d15;
    --surface: #1e271c;
    --ink: #eceeea;
    --muted: #b3afb6;
    --line: #2f3a2d;
    --line-strong: #4c5649;
    --accent: #a77cc0;
    --accent-hover: #b993cf;
    --accent-ink: #160f1a;
    --thistle-tint: #2c2334;
    --leaf-tint: #223020;
    --masthead: #0f150e;
    --price: #c5dcbc;
    --focus: #c3a0d6;
    --chip-on-bg: var(--leaf);
    --chip-on-ink: #10170f;
    --cat-ink: var(--leaf);
    --hot-ink: #d6bce4;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }

a { color: inherit; }

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */
.masthead,
.site-foot {
  --jd-ink: var(--masthead-ink);
  --jd-accent: #c3a0d6;
  --jd-tuft: #c3a0d6;
  --jd-hatch: var(--masthead);
}

.masthead {
  background: var(--masthead);
  color: var(--masthead-ink);
}

.masthead-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.logo { display: block; height: 3.3rem; width: auto; }

.masthead-tools { display: flex; align-items: center; gap: 1rem; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  color: var(--masthead-ink);
  background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 50%;
  cursor: pointer;
}
.theme-toggle:hover { background: rgb(255 255 255 / 0.16); }
.theme-toggle svg {
  width: 1.2rem; height: 1.2rem;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
/* show the moon in light mode (switch to dark), the sun in dark mode (switch to light) */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.updated {
  margin: 0;
  font-size: var(--step--1);
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.updated:empty { display: none; }
.updated::before {
  content: "";
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--leaf);
}

/* --------------------------------------------------------------------------
   Intro and search
   -------------------------------------------------------------------------- */
.intro { padding-block: 2.5rem 1.5rem; }

.intro h1 {
  font-size: var(--step-3);
  font-weight: 750;
  letter-spacing: -0.025em;
  max-width: 18ch;
}

.lede {
  color: var(--muted);
  font-size: var(--step-1);
  max-width: 34em;
  margin: 0.75rem 0 1.5rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 36rem;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--pill);
  padding: 0 1.1rem;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--thistle-tint); }
.search svg {
  width: 1.2rem; height: 1.2rem; flex: none;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--step-1);
  padding: 0.8rem 0;
}
.search input:focus { outline: none; }

/* --------------------------------------------------------------------------
   Sponsored strip: the one element allowed to move
   -------------------------------------------------------------------------- */
#sponsored:empty { display: none; }
#sponsored { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }

.sponsor {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    repeating-linear-gradient(135deg, rgb(255 255 255 / 0.05) 0 2px, transparent 2px 14px),
    linear-gradient(100deg, var(--thistle-deep), var(--thistle) 55%, #9a6bb4);
}

/* Slow sheen sweep: attention without strobing (WCAG 2.3.1 safe) */
.sponsor::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgb(255 255 255 / 0.22), transparent);
  transform: translateX(-120%) skewX(-18deg);
  animation: sheen 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 55% { transform: translateX(-120%) skewX(-18deg); }
  100% { transform: translateX(320%) skewX(-18deg); }
}

.sponsor-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgb(255 255 255 / 0.16);
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: var(--pill);
  padding: 0.2rem 0.7rem;
  font-size: var(--step--1);
  font-weight: 700;
}
.sponsor-tag i {
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.75); } }

.sponsor-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 700;
}
.sponsor-text { margin: 0.15rem 0 0; font-size: 0.9375rem; opacity: 0.9; }

.sponsor-price { text-align: right; font-family: var(--font-display); white-space: nowrap; }
.sponsor-price strong { display: block; font-size: var(--step-2); font-weight: 750; line-height: 1; }
.sponsor-price s { font-size: 0.9375rem; opacity: 0.8; }

.sponsor .btn { position: relative; z-index: 1; background: #fff; color: var(--thistle-deep); }
.sponsor .btn:hover { background: var(--thistle-tint); }

@media (prefers-reduced-motion: reduce) {
  .sponsor::after, .sponsor-tag i { animation: none; }
  .sponsor::after { display: none; }
}

/* --------------------------------------------------------------------------
   Toolbar: categories and sorting
   -------------------------------------------------------------------------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-block: 1px solid var(--line);
}

.toolbar-in {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-block: 0.65rem;
}

/* Wider screens: categories wrap onto as many lines as they need */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--pill);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] {
  background: var(--chip-on-bg);
  border-color: var(--chip-on-bg);
  color: var(--chip-on-ink);
}
.chip small { margin-left: 0.3rem; opacity: 0.7; font-size: 0.8em; }

.selects { display: flex; gap: 0.5rem; flex: none; }

select {
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background-color: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
}

/* --------------------------------------------------------------------------
   Deal list
   -------------------------------------------------------------------------- */
main { padding-block: 1rem 3rem; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
  scroll-margin-top: 4.5rem;   /* clear the sticky toolbar when jumping back up */
}
.result-count { margin: 0; font-size: 0.875rem; color: var(--muted); }
.per-page { display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--muted); }
.per-page select { padding: 0.25rem 0.4rem; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: 0.9375rem;
  color: var(--muted);
}
.pager:empty { display: none; }
.pager button {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--pill);
  padding: 0.45rem 1.1rem;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: 0.4; cursor: default; }

.deals {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.deal {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.25rem 1.25rem;
  padding: 1rem 1.25rem;
}
.deal + .deal { border-top: 1px solid var(--line); }

/* Discount tag: cut corner echoes a price tag */
.off {
  display: inline-grid;
  place-items: center;
  min-width: 3.5rem;
  padding: 0.35rem 0.4rem;
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 0.9375rem;
  color: var(--accent-ink);
  background: var(--accent);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
  padding-right: 0.7rem;
}
.off-hot {
  color: var(--hot-ink);
  background: var(--thistle-tint);
}
.off-none {
  color: var(--muted);
  background: transparent;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--step--1);
  white-space: nowrap;
  padding: 0;
  clip-path: none;
}

.deal-title {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.35;
}
.deal-title a { text-decoration: none; }
.deal-title a:hover { text-decoration: underline; text-underline-offset: 3px; }

.deal-meta {
  margin: 0.3rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.9rem;
  font-size: var(--step--1);
  color: var(--muted);
}
.deal-meta .shop { color: var(--ink); font-weight: 700; }
.deal-meta .cat {
  color: var(--cat-ink);
  background: var(--leaf-tint);
  border-radius: var(--radius-sm);
  padding: 0 0.4rem;
}
.deal-meta a { color: var(--muted); }

/* Price-checked deals: our own price history backs the claim */
.deal-meta .checked {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--cat-ink);
  font-weight: 700;
}
.deal-meta .checked svg {
  width: 0.85rem; height: 0.85rem;
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}

.deal-price { text-align: right; font-family: var(--font-display); white-space: nowrap; }
.deal-price strong {
  display: block;
  font-size: var(--step-2);
  font-weight: 750;
  color: var(--price);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.deal-price s { color: var(--muted); font-size: 0.9375rem; }
.price-elsewhere {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
}

.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9375rem;
  white-space: nowrap;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--pill);
  padding: 0.6rem 1.15rem;
}
.btn:hover { background: var(--accent-hover); }

.empty { padding: 3rem 1.25rem; text-align: center; color: var(--muted); }
.empty button {
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-foot {
  background: var(--masthead);
  color: color-mix(in srgb, var(--masthead-ink) 85%, transparent);
  font-size: 0.9375rem;
  padding-block: 2.5rem;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 2rem;
}
.site-foot h2 {
  font-size: var(--step-0);
  font-weight: 700;
  color: var(--masthead-ink);
  margin-bottom: 0.4rem;
}
.site-foot p { margin: 0 0 0.6rem; max-width: 34em; }
.foot-logo { height: 2.9rem; margin-bottom: 0.6rem; }
.site-foot a { color: inherit; }
.foot-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgb(255 255 255 / 0.15);
}
.foot-nav a { color: var(--masthead-ink); font-weight: 700; text-decoration: none; }
.foot-nav a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------------------
   Text pages (About, Contact, Privacy)
   -------------------------------------------------------------------------- */
.page { padding-block: 2.5rem 3.5rem; }
.page > * { max-width: 46rem; }
.page h1 { font-size: var(--step-3); font-weight: 750; letter-spacing: -0.025em; margin-bottom: 0.75rem; }
.page h2 { font-size: var(--step-2); font-weight: 700; margin: 2.25rem 0 0.6rem; }
.page p, .page li { font-size: 1.0625rem; line-height: 1.65; max-width: 68ch; }
.page p { margin: 0 0 1rem; }
.page ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.page li + li { margin-top: 0.6rem; }
.page a { color: var(--accent); text-underline-offset: 3px; }
.page a:hover { color: var(--accent-hover); }
.page .lede { color: var(--muted); font-size: var(--step-1); margin-bottom: 1.5rem; }
.updated-note { color: var(--muted); font-size: var(--step--1) !important; }
.contact-email a {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 700;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--pill);
  padding: 0.6rem 1.4rem;
}
.contact-email a:hover { background: var(--accent-hover); color: var(--accent-ink); }

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .toolbar-in { flex-direction: column; align-items: stretch; }
  .list-head { scroll-margin-top: 7.5rem; }   /* taller toolbar on phones */
  /* Phones: one swipeable row, faded at the edge so it's clear there's more */
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 1.5rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
  }
  .selects select { flex: 1; }
  .selects label { flex: 1; display: flex; }

  .deal {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "off   off"
      "body  body"
      "price btn";
    gap: 0.6rem 1rem;
  }
  .deal-off { grid-area: off; }
  .deal-body { grid-area: body; }
  .deal-price { grid-area: price; text-align: left; }
  .deal .btn { grid-area: btn; }
  .deal-off:has(.off-none) { display: none; }

  .sponsor {
    grid-template-columns: 1fr auto;
    grid-template-areas: "tag tag" "body body" "price btn";
  }
  .sponsor-tag { grid-area: tag; justify-self: start; }
  .sponsor-body { grid-area: body; }
  .sponsor-price { grid-area: price; text-align: left; }
  .sponsor .btn { grid-area: btn; }

  .foot-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 420px) {
  .updated { display: none; }
}
