/* Discover page: unified Explore + Search */

.discover{
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.discover-hero{
  border-radius: 22px;
  padding: 22px;
}


/* Theme-aware control + cell surfaces (keeps dark as-is, fixes light mode washout) */
.discover-hero{
  --control-bg: rgba(255,255,255,.06);
  --control-border: rgba(255,255,255,.12);
  --control-bg-hover: rgba(255,255,255,.09);
  --cell-bg: rgba(255,255,255,.05);
  --cell-border: rgba(255,255,255,.10);
}

/* Support common light-theme toggles (adjust selectors if your app uses a different hook) */
[data-theme="light"] .discover-hero,
.theme-light .discover-hero,
body.light .discover-hero{
  --control-bg: rgba(0,0,0,.035);
  --control-border: rgba(0,0,0,.14);
  --control-bg-hover: rgba(0,0,0,.055);
  --cell-bg: rgba(0,0,0,.03);
  --cell-border: rgba(0,0,0,.10);
}

.discover-title{
  margin: 0 0 6px;
  font-size: 34px;
  letter-spacing: .2px;
}
.discover-subtitle{
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 700;
}

.discover-form{ display: grid; gap: 12px; padding-bottom: 12px;}

.discover-form-top{
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
}

.discover-search{
  display:flex;
  gap: 10px;
  align-items:center;
  border-radius: 16px;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  padding: 12px 14px;
}

.discover-search input{
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.discover-search-icon{ opacity: .8; }

.discover-form-filters{
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: center;
}

.discover-form-filters select{
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
}

.discover-reset{ /* legacy */
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 900;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  color: var(--ink);
}

.discover-mode{
  margin-top: 14px;
  display:flex;
  gap: 10px;
  align-items:center;
  color: var(--muted);
  font-weight: 800;
}
.discover-mode-pill{
  display:inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--ink);
}

.discover-save{
  margin: 14px 0 0;
  display:flex;
  justify-content:flex-start;
}

.discover-results{ margin-top: 18px; }

.discover-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.discover-card{
  border-radius: 18px;
  padding: 16px;
  display:flex;
  flex-direction: column;
  gap: 12px;
}

.discover-name{
  margin: 0;
  font-size: 14px;
  letter-spacing: .2px;
  text-transform: uppercase;
}

.discover-meta{
  display:grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.discover-stats{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat{
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
  border-radius: 14px;
  padding: 10px 12px;
}
.stat .k{
  display:block;
  color: var(--muted);
  font-weight: 900;
  font-size: 11px;
  margin-bottom: 3px;
}
.stat .v{
  display:block;
  font-weight: 900;
}

.discover-purposes{
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.discover-card-btn{
  margin-top: auto;
  width: 100%;
}

.discover-empty{
  border-radius: 18px;
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
}

.discover-pagination{
  margin-top: 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 14px;
  color: var(--muted);
  font-weight: 900;
}

.discover-page-link{
  text-decoration:none;
  color: var(--link);
  font-weight: 900;
}
.discover-page-link:hover{ color: var(--focus); }

/* Responsive */
@media (max-width: 980px){
  .discover-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px){
  .discover-form-top{ grid-template-columns: 1fr; }
  .discover-form-filters{ grid-template-columns: 1fr 1fr; }
  .discover-grid{ grid-template-columns: 1fr; }
}


/* UX: Search + Clear controls */
.discover-search-btn{
  white-space: nowrap;
  min-width: 120px;
  height: 44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.discover-clear-btn{
  white-space: nowrap;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  font-weight: 900;
}

/* Save-search sits inside hero now */
.discover-save--inhero{
  margin: 14px 0 0;
  display:flex;
  justify-content:flex-end;
}

@media (max-width: 680px){
  .discover-form-top{ grid-template-columns: 1fr; }
  .discover-search-btn, .discover-clear-btn{ width: 100%; }
  .discover-save--inhero{ justify-content: stretch; }
  .discover-save--inhero .cta{ width: 100%; }
}


.discover-form-filters select:hover{
  background: var(--control-bg-hover);
}
.discover-form-filters select:focus-visible{
  outline: 3px solid rgba(99, 179, 237, .75);
  outline-offset: 2px;
}


/* Save-search: moved up into the top row (right aligned) */
.discover-save-inline{
  justify-self: end;
  display:flex;
  align-items:center;
  margin-right: 10px;
}
.discover-save-inline .cta{
  height: 44px;
  white-space: nowrap;
  padding: 0 16px;
}

@media (max-width: 680px){
  .discover-form-top{ grid-template-columns: 1fr; }
  .discover-save-inline{ justify-self: stretch; }
  .discover-save-inline .cta{ width: 100%; }
}

/* Saved state for "Save this search" button
   - uses icon + border + subtle bg (not color-only)
   - theme-aware, good contrast on light/dark
*/
:root{
  --saved-bg-dark: rgba(34, 197, 94, .16);   /* subtle green tint */
  --saved-brd-dark: rgba(34, 197, 94, .45);
  --saved-txt-dark: #eafff2;                 /* very light text */

  --saved-bg-light: rgba(21, 128, 61, .10);  /* slightly darker green tint */
  --saved-brd-light: rgba(21, 128, 61, .38);
  --saved-txt-light: #0b3d1a;                /* deep green text (high contrast on light bg) */
}

/* Base saved style */
.btn-saved{
  position: relative;
  border: 1px solid var(--saved-brd-dark) !important;
  background: var(--saved-bg-dark) !important;
  color: var(--saved-txt-dark) !important;

  /* give it a “locked in” feel */
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .18);
}

/* Add a non-color cue: a checkmark badge */
.btn-saved::before{
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  margin-right: .55em;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-.02em);
}

/* Make disabled still look intentional (not washed out) */
.btn-saved[disabled],
.btn-saved[aria-disabled="true"]{
  opacity: 1;                 /* don’t fade it out */
  cursor: default;
  filter: none;
}

/* Hover should not imply click when disabled */
.btn-saved[disabled]:hover,
.btn-saved[aria-disabled="true"]:hover{
  transform: none;
}

/* Light theme overrides */
[data-theme="light"] .btn-saved,
.theme-light .btn-saved,
body.light .btn-saved{
  background: var(--saved-bg-light) !important;
  border-color: var(--saved-brd-light) !important;
  color: var(--saved-txt-light) !important;
  box-shadow: 0 0 0 2px rgba(21, 128, 61, .12);
}

/* Strong focus ring (keyboard) */
.btn-saved:focus-visible{
  outline: 3px solid rgba(99, 179, 237, .75);
  outline-offset: 2px;
}

/* ===== Fix: dropdown menu (option list) not matching theme ===== */

/* Helps the browser choose correct native colors for form controls */
.discover-form-filters select {
  color-scheme: light dark;
}

/* Dark theme: make the opened dropdown menu dark with readable text */
[data-theme="dark"] .discover-form-filters select,
.theme-dark .discover-form-filters select,
body.dark .discover-form-filters select {
  color-scheme: dark;
}

[data-theme="dark"] .discover-form-filters select option,
[data-theme="dark"] .discover-form-filters select optgroup,
.theme-dark .discover-form-filters select option,
.theme-dark .discover-form-filters select optgroup,
body.dark .discover-form-filters select option,
body.dark .discover-form-filters select optgroup {
  background-color: #0b1220; /* deep navy */
  color: #f1f5f9;            /* near-white */
}

/* Light theme: keep it clean and readable */
[data-theme="light"] .discover-form-filters select,
.theme-light .discover-form-filters select,
body.light .discover-form-filters select {
  color-scheme: light;
}

[data-theme="light"] .discover-form-filters select option,
[data-theme="light"] .discover-form-filters select optgroup,
.theme-light .discover-form-filters select option,
.theme-light .discover-form-filters select optgroup,
body.light .discover-form-filters select option,
body.light .discover-form-filters select optgroup {
  background-color: #ffffff;
  color: #0f172a;
}

/* =========================================================
   DISCOVER — Mobile controls layout (no desktop impact)
   Make Search/Clear 2-up instead of giant full-width bars
   ========================================================= */
@media (max-width: 720px){

  /* Use a 2-col grid for the action row */
  .discover-form-top{
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    align-items: stretch;
  }

  /* Search input spans both columns */
  .discover-search{
    grid-column: 1 / -1 !important;
  }

  /* Search + Clear each take one column */
  .discover-search-btn{
    grid-column: 1 / 2 !important;
    min-width: 0 !important; /* overrides min-width:120px */
  }
  .discover-form-top > a.cta.secondary{
    grid-column: 2 / 3 !important;
    width: 100% !important;
  }

  /* Save button spans both columns */
  .discover-save-inline{
    grid-column: 1 / -1 !important;
    justify-self: stretch !important;
    margin-right: 0 !important;
  }
  .discover-save-inline .cta{
    width: 100% !important;
  }

  /* Make all these controls feel consistent + non-skinny */
  .discover-search-btn,
  .discover-form-top > a.cta.secondary,
  .discover-save-inline .cta{
    height: 46px !important;
    border-radius: 14px !important;
    padding: 0 14px !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    letter-spacing: 0.2px;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }

  /* Input should be 16px to feel premium and avoid iOS zoom */
  .discover-search input{
    font-size: 16px !important;
  }
}

/* Super small phones: fall back to stacked buttons */
@media (max-width: 420px){
  .discover-form-top{
    grid-template-columns: 1fr !important;
  }
  .discover-search-btn,
  .discover-form-top > a.cta.secondary{
    grid-column: 1 / -1 !important;
  }
}

/* =========================================================
   DISCOVER — Responsive form layout (mobile/tablet)
   Your "mobile" viewport is ~819px, so 680px never triggers.
   ========================================================= */

@media (max-width: 980px){

  /* Keep the hero/card from letting children visually spill */
  .discover-hero{
    overflow: hidden;
  }

  /* Critical: allow grid children to shrink instead of overflowing */
  .discover-form,
  .discover-form-top,
  .discover-form-filters,
  .discover-search{
    min-width: 0;
    max-width: 100%;
  }

  /* Make top row a clean 2-up action layout */
  .discover-form-top{
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    align-items: stretch;
  }

  /* Search input spans both columns */
  .discover-search{
    grid-column: 1 / -1 !important;
  }

  /* Search / Clear share the row */
  .discover-search-btn{
    grid-column: 1 / 2 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .discover-form-top > a.cta.secondary{
    grid-column: 2 / 3 !important;
    width: 100% !important;
  }

  /* If save button appears, put it full-width below */
  .discover-save-inline{
    grid-column: 1 / -1 !important;
    justify-self: stretch !important;
    margin-right: 0 !important;
  }
  .discover-save-inline .cta{
    width: 100% !important;
  }

  /* Filters: 2 columns on tablet/mobile widths */
  .discover-form-filters{
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .discover-form-filters select{
    width: 100%;
    height: 46px;
    font-size: 15px;
  }

  /* Make the input feel premium + avoid iOS zoom */
  .discover-search input{
    font-size: 16px !important;
  }

  /* Buttons: fix the “12px Arial” skinny feel */
  .discover-search-btn,
  .discover-form-top > a.cta.secondary,
  .discover-save-inline .cta{
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    height: 46px !important;
    border-radius: 14px !important;
    padding: 0 14px !important;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }
}

/* Very small phones: filters become 1 column */
@media (max-width: 460px){
  .discover-form-filters{
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .discover-form-top > a.cta.secondary {
    display: inline-flex !important;
    grid-column: 2 / 3;
    width: 100%;
  }
}