/* =========================================================
   Strona „Promocje” (/promocje): filtry po lewej, kafelki ofert po prawej.
   Kolory, przyciski i naklejka cenowa pochodzą ze styles.css.
   ========================================================= */

/* Liczba wyników przy tytule (ten sam wygląd co na stronie promocji gazetki w gazetka.css) */
.offers-count { margin-left: 6px; padding: 2px 10px; border-radius: 999px; background: var(--mint); color: var(--green-ink); font: 700 15px/1.6 var(--font); letter-spacing: 0; vertical-align: middle; }

.deals { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 32px; align-items: start; }
.deals-overlay, .filters-close, .deals-filters-btn { display: none; }

/* ---------- Filtry ---------- */
/* Panel przykleja się pod nagłówkiem i ma własne przewijanie, gdy filtrów jest więcej niż ekranu. */
.deals-filters {
  position: sticky; top: 92px;
  max-height: calc(100vh - 108px); overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 20px 0; border-radius: 20px; background: var(--paper); border: 1px solid var(--line);
}
.filters-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; }
.filters-head h2 { margin-right: auto; font: 750 20px/1.2 var(--font-display); letter-spacing: -.02em; }
.filters-head a { color: var(--green); font-size: 14px; font-weight: 700; }
.filters-head a:hover { text-decoration: underline; text-underline-offset: 3px; }

.fgroup { padding-block: 16px; border-top: 1px solid var(--line); }
/* float: legenda w fieldsecie zachowuje się wtedy jak zwykły nagłówek (bez wcięcia w ramkę) */
.fgroup legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; font-size: 14px; font-weight: 750; }
.fgroup legend + * { clear: both; }

.fsearch { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border: 1px solid #cfd8d1; border-radius: 12px; background: var(--page); }
.fsearch .ico { width: 18px; height: 18px; color: var(--muted); }
.fsearch input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 15px; }
.fsearch:focus-within { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px var(--mint); }

.opt { display: flex; align-items: center; gap: 10px; margin-inline: -8px; padding: 6px 8px; border-radius: 10px; font-size: 14.5px; line-height: 1.3; cursor: pointer; }
.opt:hover { background: var(--page); }
.opt input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--green); }
.opt-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt:has(input:checked) .opt-name { font-weight: 700; }
.opt small { margin-left: auto; padding-left: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.opt-logo { position: relative; display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 12px; font-weight: 800; color: var(--green-ink); overflow: hidden; }
.opt-logo img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 2px 3px; object-fit: contain; }
.opt-tree { margin: 2px 0 4px 14px; padding-left: 12px; border-left: 2px solid var(--mint); }
.opt-icon { width: 20px; height: 20px; color: var(--green); }
/* Nazwy kategorii z ikoną są długie ("Spiżarnia i produkty sypkie"), więc zawijamy je zamiast ucinać. */
.opt:has(.opt-icon) .opt-name { white-space: normal; }

.fmore summary { display: inline-block; margin-top: 4px; padding-block: 4px; color: var(--green); font-size: 14px; font-weight: 700; cursor: pointer; list-style: none; }
.fmore summary::-webkit-details-marker { display: none; }
.fmore summary::before { content: "+ "; }
.fmore[open] summary { margin-bottom: 4px; }
.fmore[open] summary::before { content: "− "; }

/* Rabat: przyciski opcji jako pastylki (jak wybór sklepów w powiadomieniach) */
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchips label { position: relative; cursor: pointer; }
.fchips input { position: absolute; opacity: 0; }
.fchips span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid #cfd8d1; font-size: 14px; font-weight: 600; }
.fchips label:hover span { border-color: var(--green); }
.fchips input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.fchips input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }

/* Przycisk przyklejony do dołu panelu */
.filters-submit { position: sticky; bottom: 0; margin-inline: -20px; padding: 12px 20px 18px; background: linear-gradient(rgba(255, 255, 255, 0), #fff 24%); }
.filters-submit .btn { width: 100%; height: 48px; }

/* ---------- Pasek nad wynikami ---------- */
.deals-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Sortowanie wygląda jak przełącznik filtrów na stronie głównej */
.deals-sort { display: flex; gap: 4px; padding: 5px; border-radius: 14px; background: #e8ede9; overflow-x: auto; scrollbar-width: none; }
.deals-sort::-webkit-scrollbar { display: none; }
.deals-sort a { padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; color: #3b4942; white-space: nowrap; }
.deals-sort a:hover { color: var(--ink); }
.deals-sort a[aria-current] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(10, 30, 20, .14); }

.deals-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.deals-cats a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 600; white-space: nowrap; }
.deals-cats a:hover { border-color: var(--green); }
.deals-cats small { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.deals-cats a[aria-current] { background: var(--forest); border-color: var(--forest); color: #fff; }
.deals-cats a[aria-current] small { color: #9cc0aa; }
.deals-cats .ico { width: 18px; height: 18px; color: var(--green); }
.deals-cats a[aria-current] .ico { color: #9cc0aa; }

.deals-active { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.deals-active a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 12px; border-radius: 999px; background: var(--mint); color: var(--green-ink); font-size: 13.5px; font-weight: 700; }
.deals-active .ico { width: 15px; height: 15px; stroke-width: 2.2; }
.deals-active a:hover { background: #d3e9dc; }

/* ---------- Kafelki ofert ---------- */
.deals-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.deal-link {
  display: flex; flex-direction: column; height: 100%; padding: 12px;
  border-radius: 18px; background: var(--paper); border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.deal-link:hover { border-color: var(--green); box-shadow: 0 18px 30px -22px rgba(10, 30, 20, .45); transform: translateY(-2px); }

/* Zdjęcie produktu w ramce o stałej wysokości — wszystkie kafelki w rzędzie wyglądają tak samo */
.deal-media { position: relative; display: block; height: 168px; margin-bottom: 12px; }
.deal-media > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: transform .35s; }
.deal-link:hover .deal-media > img { transform: scale(1.04); }
.deal-icon { position: absolute; inset: 0 0 28px; display: grid; place-items: center; border-radius: 12px; background: var(--mint); color: var(--green-ink); }
.deal-icon .ico { width: 64px; height: 64px; stroke-width: 1.5; }
.deal-off { top: 4px; right: -4px; font-size: 14px; }
.deal-store { position: absolute; left: 0; bottom: 0; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 9px 3px 3px; border-radius: 8px; background: rgba(255, 255, 255, .94); border: 1px solid var(--line); font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-store img { width: 34px; height: 20px; object-fit: contain; }
.deal-store b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--mint); color: var(--green-ink); font-size: 12px; }

.deal-body { display: grid; gap: 3px; }
.deal-brand { font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.deal-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 650; font-size: 15px; line-height: 1.3; }
.deal-details { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; color: var(--muted); }

.deal-price { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; margin-top: 14px; }
.price-xs { padding: 4px 9px; transform: rotate(-2deg); }
.price-xs .zl { font-size: 30px; }
.price-xs .gr { font-size: 14px; padding-top: 2px; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.price-xs .unit { font-size: 9.5px; padding-bottom: 2px; }
.deal-was { padding-bottom: 2px; font-size: 13px; color: var(--muted); }
.deal-price-text { padding: 5px 10px; border-radius: 6px; background: var(--sun); color: var(--sun-ink); font-size: 14px; font-weight: 800; line-height: 1.25; transform: rotate(-2deg); }
.deal-note, .deal-terms { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px; font-size: 12px; line-height: 1.35; color: var(--muted); }
.deal-terms { color: var(--green-ink); font-weight: 600; }

/* Stopka kafelka zawsze na dole (margin-top: auto), także gdy nazwa ma jedną linię */
.deal-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 14px; font-size: 12.5px; }
.deal-date { font-weight: 650; }
.deal-date.is-ending { color: var(--red); }
.deal-date.is-soon { color: var(--green-ink); }
.deal-page { color: var(--muted); white-space: nowrap; }
.deal-link:hover .deal-page { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.deals-pages { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 32px; color: var(--muted); }
.deals-main .fineprint { text-align: center; }

/* =========================================================
   Responsywność
   ========================================================= */
@media (max-width: 1180px) {
  .deals { grid-template-columns: 248px minmax(0, 1fr); gap: 24px; }
  .deals-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Telefon i tablet: filtry w panelu wysuwanym z lewej (pole #deals-toggle), wyniki na całą szerokość */
@media (max-width: 900px) {
  .deals { grid-template-columns: minmax(0, 1fr); }
  .deals-filters {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
    width: min(360px, 88vw); max-height: none;
    border-radius: 0 20px 20px 0; border: 0;
    transform: translateX(-105%); transition: transform .25s ease;
    visibility: hidden;
  }
  .deals-toggle:checked ~ .deals .deals-filters { transform: none; visibility: visible; box-shadow: 20px 0 40px -20px rgba(10, 30, 20, .5); }
  .deals-toggle:checked ~ .deals .deals-overlay { display: block; position: fixed; z-index: 39; inset: 0; background: rgba(10, 30, 20, .45); }
  .deals-toggle:focus-visible ~ .deals .deals-filters-btn { outline: 3px solid var(--sun); outline-offset: 3px; }
  .filters-close { display: grid; place-items: center; width: 40px; height: 40px; margin-right: -8px; border-radius: 50%; color: var(--muted); cursor: pointer; }
  .filters-close:hover { background: var(--page); color: var(--ink); }
  .opt input { width: 20px; height: 20px; }
  .opt { padding-block: 8px; }

  .deals-filters-btn { display: inline-flex; flex-shrink: 0; height: 46px; padding: 0 16px; border-radius: 12px; cursor: pointer; }
  .deals-filters-btn span { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--green); color: #fff; font-size: 12.5px; }
  .deals-toolbar { flex-direction: row-reverse; justify-content: flex-end; }
  .deals-sort { flex: 1; min-width: 0; }
  /* Kategorie: przewijany rząd do krawędzi ekranu */
  .deals-cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
  .deals-cats::-webkit-scrollbar { display: none; }
}

@media (max-width: 640px) {
  .deals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
  .deal-link { padding: 10px; border-radius: 14px; }
  .deal-media { height: 128px; margin-bottom: 10px; }
  .deal-off { font-size: 12px; padding: 4px 8px; }
  .deal-store { font-size: 11px; padding-right: 7px; }
  .deal-store img { width: 28px; height: 18px; }
  .deal-name { font-size: 14px; }
  .price-xs .zl { font-size: 26px; }
  .price-xs .gr { font-size: 13px; }
  .deal-foot { flex-direction: column; gap: 2px; }
  .deals-pages { gap: 10px; font-size: 14px; }
  .deals-pages .btn { height: 46px; padding: 0 16px; }
}
