/* ════════════════════════════════════════════════════════════════════
   Discover screen — v1.9.7 Premium Search Surface
   ────────────────────────────────────────────────────────────────────
   Layout:
     #screen-discover
       └─ #discover-feed (mount)
            └─ .ds-shell (flex column, fills available height)
                 ├─ .ds-search-wrap   FIXED at top, safe-area aware
                 │    ├─ .ds-search       (input + clear)
                 │    ├─ .ds-chip-rail    (horizontal scrolling chip rail)
                 │    └─ .ds-context-row  (result count + applied filters)
                 └─ .ds-results-wrap (scrolls under the fixed header)
                      └─ .ds-results        (CSS-grid responsive card grid)

   Legacy block at the end keeps the old .discover-card / .dc-* rules
   alive for a few minutes after deploy while service workers update.
   ════════════════════════════════════════════════════════════════════ */

#screen-discover {
  position: relative;
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg, #faf6ee);
}
body.discover-active #screen-discover { display: flex; }

#discover-feed {
  flex: 1;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}

/* ────────── Shell ────────── */
.ds-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg, #faf6ee);
}

/* ────────── Sticky search header ────────── */
.ds-search-wrap {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  padding: 10px 14px 6px;
  background: var(--bg, #faf6ee);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
  border-bottom: 1px solid transparent;
}
.ds-search-wrap.is-stuck {
  box-shadow: 0 6px 16px -10px rgba(0,0,0,0.25);
  border-bottom-color: rgba(0,0,0,0.06);
}

.ds-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 0 12px;
  height: 46px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.ds-search:focus-within {
  border-color: var(--primary, #1A5C3A);
  box-shadow: 0 0 0 4px rgba(26,92,58,0.10);
}
.ds-search-icon {
  font-size: 1.1rem;
  color: var(--text-muted, #6b6357);
  flex-shrink: 0;
}
.ds-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text, #1a1714);
  min-width: 0;
}
.ds-input::placeholder { color: rgba(0,0,0,0.42); }
.ds-input::-webkit-search-cancel-button { display: none; }
.ds-clear {
  appearance: none;
  background: rgba(0,0,0,0.06);
  border: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted, #6b6357);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.ds-clear:active { background: rgba(0,0,0,0.1); }
.ds-clear i { font-size: 0.85rem; pointer-events: none; }

/* ────────── Filter chip rail ────────── */
.ds-chip-rail {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px 4px;
  margin-left: -4px;
  margin-right: -4px;
}
.ds-chip-rail::-webkit-scrollbar { display: none; }
.ds-chip-rail { scrollbar-width: none; }

.ds-chip {
  appearance: none;
  background: rgba(0,0,0,0.04);
  border: 1px solid transparent;
  color: var(--text, #1a1714);
  padding: 7px 13px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.ds-chip i { font-size: 0.95rem; color: var(--text-muted, #6b6357); }
.ds-chip:active { transform: scale(0.97); }
.ds-chip:hover { background: rgba(0,0,0,0.07); }
.ds-chip.is-active {
  background: var(--primary, #1A5C3A);
  color: #fff;
  border-color: var(--primary, #1A5C3A);
}
.ds-chip.is-active i { color: var(--accent, #C9A84C); }

.ds-chip-more {
  background: #fff;
  border-color: rgba(0,0,0,0.10);
}
.ds-chip-more.is-active {
  background: var(--accent, #C9A84C);
  color: var(--text, #1a1714);
  border-color: var(--accent, #C9A84C);
}
.ds-chip-more.is-active i { color: var(--primary, #1A5C3A); }

/* ────────── Context row (result count + applied filters) ────────── */
.ds-context-row {
  margin-top: 6px;
  padding: 0 2px;
  font-size: 0.74rem;
  color: var(--text-muted, #6b6357);
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 16px;
}
.ds-ctx-count {
  font-weight: 700;
  color: var(--text, #1a1714);
}
.ds-ctx-applied {
  color: var(--text-muted, #6b6357);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ────────── Results scroller + grid ────────── */
.ds-results-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}
.ds-results-wrap::-webkit-scrollbar { width: 0; height: 0; display: none; }
.ds-results-wrap { scrollbar-width: none; }

.ds-results {
  display: grid;
  gap: 14px;
  padding: 14px 14px calc(var(--nav-height, 60px) + var(--safe-bottom, 0px) + 24px);
  grid-template-columns: 1fr;
}
@media (min-width: 540px) {
  .ds-results { grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (min-width: 900px) {
  .ds-results { grid-template-columns: 1fr 1fr 1fr; gap: 20px; padding: 20px 24px; }
}
@media (min-width: 1200px) {
  .ds-results { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* ────────── Result card ────────── */
.ds-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 1px 0 rgba(0,0,0,0.02);
  cursor: pointer;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  border: 1px solid rgba(0,0,0,0.04);
}
.ds-card:hover { box-shadow: 0 6px 22px rgba(0,0,0,0.10); }
.ds-card:active { transform: scale(0.985); }

.ds-card-media {
  position: relative;
  height: 170px;
  overflow: hidden;
  background: #ece6da;
}
.ds-card-media img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform 0.5s ease;
}
.ds-card:hover .ds-card-media img { transform: scale(1.04); }
.ds-card-media-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(0,0,0,0.25);
  font-size: 2rem;
}
.ds-card-grad {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 60%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
}

/* status pill (top-left of media) */
.ds-status {
  position: absolute;
  top: 10px; left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255,255,255,0.96);
  color: var(--text, #1a1714);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ds-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ds-status-open         { color: #117a39; }
.ds-status-closing-soon { color: #b56b00; }
.ds-status-closed       { color: #b5292d; background: rgba(216,58,63,0.10); }

/* iFood pill (left of the save heart).
   v1.9.7.1 — the icon is now the official red-circle brand mark, so
   the pill itself is just a thin white capsule that hosts the icon +
   wordmark "iFood" together. On very narrow phones the wordmark
   collapses and we render just the round brand mark. */
.ds-ifood-pill {
  position: absolute;
  top: 10px;
  right: 52px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 4px;
  border-radius: 999px;
  background: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  color: #e53139;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
}
.ds-ifood-pill img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: block;
}
@media (max-width: 380px) {
  /* Narrow phones: drop the wordmark; the brand mark alone is
     unmistakable. Switch to a transparent wrapper since the icon is
     its own circle. */
  .ds-ifood-pill span { display: none; }
  .ds-ifood-pill {
    padding: 0;
    background: transparent;
    box-shadow: none;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.30));
  }
  .ds-ifood-pill img { width: 22px; height: 22px; }
}

/* save heart (top-right of media) */
.ds-save {
  position: absolute;
  top: 8px; right: 8px;
  appearance: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.94);
  color: var(--text, #1a1714);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.16s ease, color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.ds-save:active { transform: scale(0.92); }
.ds-save i { font-size: 1.1rem; }
.ds-save.is-saved { color: #d83a3f; }

/* card body */
.ds-card-body {
  padding: 12px 14px 14px;
}
.ds-card-name {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.18;
  margin: 0 0 4px;
  color: var(--text, #1a1714);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ds-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted, #6b6357);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}
.ds-meta-sep { opacity: 0.5; }
.ds-meta-cat { font-weight: 600; color: var(--text, #1a1714); }
.ds-meta-neigh {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.ds-meta-neigh i { font-size: 0.85rem; }

.ds-card-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted, #6b6357);
}
.ds-stat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.ds-stat i { font-size: 0.85rem; }
.ds-stat-rating { color: var(--text, #1a1714); font-weight: 600; }
.ds-stat-rating i { color: var(--accent, #C9A84C); }
.ds-stat-price { margin-left: auto; font-weight: 700; color: var(--primary, #1A5C3A); }

/* ────────── Empty state ────────── */
.ds-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px 60px;
  color: var(--text-muted, #6b6357);
}
.ds-empty-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.04);
  font-size: 1.6rem;
  color: var(--text-muted, #6b6357);
}
.ds-empty-title {
  font-family: var(--font-display, 'Cormorant Garamond', serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text, #1a1714);
  margin-bottom: 4px;
}
.ds-empty-sub {
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.ds-empty-cta {
  appearance: none;
  background: var(--primary, #1A5C3A);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(26,92,58,0.22);
}
.ds-empty-cta:active { transform: scale(0.97); }

/* ────────── Advanced filter sheet ────────── */
.ds-filter-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 80;
}
.ds-filter-backdrop.is-open { opacity: 1; pointer-events: auto; }

.ds-filter-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 520px;
  background: var(--bg, #faf6ee);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.25);
  z-index: 90;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  transition: transform 0.32s cubic-bezier(0.25,0.46,0.45,0.94);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ds-filter-sheet.is-open {
  transform: translateX(-50%) translateY(0);
}
.ds-filter-sheet-handle {
  width: 44px;
  height: 4px;
  background: rgba(0,0,0,0.18);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}
.ds-filter-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 4px;
  flex-shrink: 0;
}
.ds-filter-sheet-title {
  font-family: var(--font-display, serif);
  font-size: 1.3rem;
  font-weight: 700;
}
.ds-filter-sheet-close {
  appearance: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text, #1a1714);
  -webkit-tap-highlight-color: transparent;
}
.ds-filter-sheet-close:active { background: rgba(0,0,0,0.10); }

.ds-filter-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 18px 12px;
  -webkit-overflow-scrolling: touch;
}
.ds-fs-block { margin-bottom: 18px; }
.ds-fs-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #6b6357);
  margin-bottom: 8px;
}
.ds-fs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ds-fs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ds-fs-pill {
  appearance: none;
  background: rgba(0,0,0,0.05);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text, #1a1714);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.ds-fs-pill:active { transform: scale(0.97); }
.ds-fs-pill.is-active {
  background: var(--primary, #1A5C3A);
  color: #fff;
  border-color: var(--primary, #1A5C3A);
}

.ds-filter-sheet-actions {
  display: flex;
  gap: 10px;
  padding: 10px 18px 14px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
  background: var(--bg, #faf6ee);
}
.ds-filter-reset,
.ds-filter-apply {
  flex: 1;
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ds-filter-reset {
  background: rgba(0,0,0,0.06);
  color: var(--text, #1a1714);
}
.ds-filter-apply {
  background: var(--primary, #1A5C3A);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26,92,58,0.22);
}
.ds-filter-reset:active,
.ds-filter-apply:active { transform: scale(0.99); }

/* ════════════════════════════════════════════════════════════════════
   LEGACY (v1.9.6 and earlier): swipe-card Discover styles. Kept ONLY
   so service-worker-cached old HTML (briefly served during SW activation)
   still renders without throwing layout errors. Inert under v1.9.7.
   Will be removed in a future release once the SW cache cutover is
   confirmed stable in the field.
   ════════════════════════════════════════════════════════════════════ */

.df-inner {
  position: absolute;
  top: 0; left: 0; right: 0;
  will-change: transform;
}
.discover-card {
  width: 100%;
  height: calc(100vh - 56px);
  position: relative;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
  box-sizing: border-box;
}
.dc-media { position: absolute; inset: 0; z-index: 0; }
.dc-img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.dc-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0.0) 35%, rgba(0,0,0,0.55) 65%, rgba(0,0,0,0.85) 100%);
}
.dc-top { position: absolute; top: 16px; right: 16px; z-index: 4; display: flex; gap: 6px; flex-direction: column; align-items: flex-end; }
.dc-badge {
  background: rgba(255,255,255,0.92);
  color: var(--text, #1a1714);
  font-size: 0.7rem; font-weight: 700;
  padding: 5px 11px; border-radius: 20px;
  letter-spacing: 0.04em;
}
.dc-badge.open   { color: #117a39; }
.dc-badge.closed { color: #b5292d; }
.dc-info { position: absolute; bottom: 24px; left: 18px; right: 78px; z-index: 4; color: #fff; }
.dc-name { font-family: var(--font-display, serif); font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.dc-sidebar {
  position: absolute; bottom: 80px; right: 16px; z-index: 4;
  display: flex; flex-direction: column; gap: 14px;
}
