/**
 * Leapable Discover — shared styles for the marketplace browse experience.
 *
 * Single source of truth for every style the Discover engine
 * (discover-app.js) renders against. Loaded by BOTH mount surfaces:
 *   - /marketplace/ storefront page (page chrome styles stay inline there)
 *   - /workbench/library.html dialog (discover-embed.js)
 *
 * Anything here must be safe on both surfaces; page-only chrome
 * (topbar, hero, journey panel, footer) lives in marketplace/index.html.
 */

:root {
  --mp-bg: #0b0b0d;
  --mp-bg-2: #101014;
  --mp-surface: #17171d;
  --mp-surface-2: #202027;
  --mp-border: rgba(255, 255, 255, 0.1);
  --mp-border-strong: rgba(255, 255, 255, 0.18);
  --mp-text: #f7f7fb;
  --mp-muted: #a6a6b3;
  --mp-soft: #d9d9e3;
  --mp-purple: #8b5cf6;
  --mp-cyan: #32d6c1;
  --mp-amber: #f6b44b;
  --mp-green: #58d68d;
  --mp-rose: #ff6b7a;
}

.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
  white-space: nowrap;
}
.mp-btn.primary {
  background: var(--mp-cyan);
  color: #06110f;
  border-color: rgba(50, 214, 193, 0.2);
}
.mp-btn.primary:hover {
  transform: translateY(-1px);
  background: #53e7d4;
}
.mp-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--mp-border);
  color: var(--mp-text);
}
.mp-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--mp-border-strong);
}
.mp-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--mp-soft);
}
.mp-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.mp-btn.link {
  min-height: 36px;
  padding: 4px 0;
  background: transparent;
  color: var(--mp-cyan);
  border: 0;
}
.mp-btn.link:hover {
  color: #fff;
}
/* #1886 — confirmed Library-membership state of the Subscribe CTA. */
.mp-btn.subscribed {
  background: rgba(88, 214, 141, 0.12);
  border-color: rgba(88, 214, 141, 0.38);
  color: #c8f7dc;
}
.mp-btn.subscribed:hover {
  background: rgba(88, 214, 141, 0.2);
  color: #e7fff1;
}

.hero-search-form {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.search-box {
  position: relative;
  min-width: 0;
}
.hero-search-input {
  width: 100%;
  min-height: 54px;
  background: #111116;
  border: 1px solid var(--mp-border-strong);
  border-radius: 8px;
  padding: 14px 48px 14px 44px;
  color: #fff;
  font-size: 1rem;
}
.hero-search-input:focus {
  outline: none;
  border-color: var(--mp-cyan);
  box-shadow: 0 0 0 3px rgba(50, 214, 193, 0.18);
}
.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mp-muted);
  pointer-events: none;
}
.q-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--mp-muted);
  cursor: pointer;
}
.q-clear-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.q-clear-btn.hidden {
  display: none;
}
.prompt-pills,
.category-pills,
.applied-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.prompt-pills {
  margin-top: 12px;
}
.category-pills {
  margin-top: 14px;
}
.applied-filters {
  margin-top: 14px;
  min-height: 0;
}
.prompt-pill,
.category-pill,
.filter-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--mp-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--mp-soft);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.prompt-pill:hover,
.category-pill:hover,
.filter-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: var(--mp-border-strong);
}
.category-pill.active,
.filter-chip.active {
  color: #07110f;
  background: var(--mp-amber);
  border-color: rgba(246, 180, 75, 0.3);
}
.filter-chip .x {
  color: inherit;
  opacity: 0.8;
}

.marketplace-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.facet-panel {
  position: sticky;
  top: 86px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: rgba(17, 17, 22, 0.92);
  padding: 14px;
}
.facet-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.facet-panel-title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
}
.facet-group {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 0;
}
.facet-group:first-child {
  border-top: 0;
  padding-top: 4px;
}
.facet-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--mp-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.facet-option {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 6px;
  margin: 2px -6px;
  border-radius: 7px;
  color: var(--mp-soft);
  font-size: 0.88rem;
  cursor: pointer;
}
.facet-option:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.facet-option input {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  accent-color: var(--mp-cyan);
  cursor: pointer;
}
.facet-option .count {
  color: var(--mp-muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}
.facet-option.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.result-copy {
  color: var(--mp-muted);
  font-size: 0.92rem;
}
.result-counter {
  color: var(--mp-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.result-counter.hidden {
  display: none;
}
.sort-select {
  min-height: 44px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: #111116;
  color: #fff;
  padding: 0 12px;
  font-size: 0.9rem;
}
.view-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}
.view-toggle button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--mp-muted);
  cursor: pointer;
}
.view-toggle button[aria-pressed='true'] {
  color: #06110f;
  background: var(--mp-cyan);
}

.results-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.results-grid.list-view {
  grid-template-columns: 1fr;
}
.listing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: rgba(23, 23, 29, 0.9);
  overflow: hidden;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}
.listing-card:hover {
  transform: translateY(-2px);
  border-color: rgba(50, 214, 193, 0.42);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}
.listing-card.focus-highlight {
  border-color: var(--mp-cyan);
  box-shadow:
    0 0 0 3px rgba(50, 214, 193, 0.18),
    0 18px 40px rgba(0, 0, 0, 0.24);
}
.listing-card.your-listing-highlight {
  border-color: rgba(246, 180, 75, 0.55);
  box-shadow: 0 0 0 2px rgba(246, 180, 75, 0.12);
}
.listing-card__top {
  padding: 14px 14px 0;
  display: flex;
  gap: 10px;
  align-items: center;
}
.listing-avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--mp-border);
  object-fit: cover;
  flex: 0 0 auto;
}
.listing-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  color: #fff;
}
.creator-line {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 3px;
  color: var(--mp-muted);
  font-size: 0.78rem;
}
.creator-line a {
  color: var(--mp-cyan);
  text-decoration: none;
  font-weight: 800;
}
.creator-line a:hover {
  color: #fff;
  text-decoration: underline;
}
.listing-card__preview {
  display: block;
  width: calc(100% - 28px);
  margin: 14px;
  padding: 12px;
  border: 1px solid rgba(50, 214, 193, 0.25);
  border-radius: 8px;
  background: rgba(50, 214, 193, 0.08);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.listing-card__preview:hover {
  background: rgba(50, 214, 193, 0.12);
}
.db-name-label {
  display: block;
  font-size: 0.68rem;
  color: var(--mp-cyan);
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.db-name-code {
  display: block;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.94rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.listing-card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 14px;
  flex: 1;
}
.description {
  margin: 0;
  color: var(--mp-soft);
  font-size: 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sample-question {
  margin: 0;
  color: #fff;
  font-size: 0.84rem;
  line-height: 1.35;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(246, 180, 75, 0.24);
  background: rgba(246, 180, 75, 0.08);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta-row,
.badges-row,
.social-proof {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.price-line,
.badge-chip,
.social-proof span,
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--mp-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--mp-muted);
  font-size: 0.76rem;
  font-weight: 700;
}
.price-line strong {
  color: var(--mp-amber);
}
.badge-chip.access-free {
  color: var(--mp-green);
  border-color: rgba(88, 214, 141, 0.3);
}
.badge-chip.access-paid {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.38);
}
.badge-chip.access-hybrid {
  color: #e9d5ff;
  border-color: rgba(168, 85, 247, 0.42);
}
.badge-chip.your-listing {
  color: var(--mp-amber);
  border-color: rgba(246, 180, 75, 0.35);
}
.score-badge {
  color: #c9b8ff;
  border-style: dashed;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.listing-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
/* #1886 — every card footer is the same two equal-width actions
   (Subscribe + Details), so the grid scans symmetrically. */
.listing-card__actions > .mp-btn {
  flex: 1 1 0;
  min-width: 0;
}
.results-grid.list-view .listing-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}
.results-grid.list-view .listing-card__actions {
  border-top: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  align-items: flex-end;
  justify-content: center;
  flex-direction: column;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 36px 14px;
  overflow-y: auto;
}
.detail-panel {
  width: 100%;
  max-width: 740px;
  background: #15151b;
  border: 1px solid var(--mp-border-strong);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}
.detail-panel h2 {
  font-size: 1.25rem;
  line-height: 1.25;
}
.detail-panel section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.detail-panel h3 {
  font-size: 0.74rem;
  text-transform: uppercase;
  color: var(--mp-muted);
  font-weight: 800;
}
.detail-panel .stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.detail-panel .stats-grid div {
  padding: 10px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.detail-panel .stats-grid dt {
  color: var(--mp-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}
.detail-panel .stats-grid dd {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}
body.mp-modal-open {
  overflow: hidden;
}

.sample-q-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(50, 214, 193, 0.24);
  border-radius: 999px;
  background: rgba(50, 214, 193, 0.08);
  color: #c9fff7;
  font-size: 0.82rem;
  text-decoration: none;
}
.sample-q-pill:hover {
  background: rgba(50, 214, 193, 0.14);
  color: #fff;
}

.pagination,
.pagination-loading,
.load-more-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.pagination {
  margin-top: 24px;
}
.pagination button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--mp-soft);
  cursor: pointer;
}
.pagination button[aria-current='page'] {
  background: var(--mp-cyan);
  color: #06110f;
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination-loading {
  padding: 22px 0;
  color: var(--mp-muted);
}
/* Scoped to the discover surfaces ONLY. A global `.hidden { ... !important }`
   here overrode Tailwind's responsive `hidden lg:flex` pattern on host pages
   (it force-hid the Library page's sidebar, #1867 incident) — utility-class
   overrides in a shared stylesheet must never leak past .discover-scope. */
.discover-scope .pagination-loading.hidden,
.discover-scope .load-more-wrap.hidden,
.discover-scope .hidden {
  display: none !important;
}

.banner-error,
.banner-warn {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 107, 122, 0.1);
  border: 1px solid rgba(255, 107, 122, 0.32);
  color: #ffd8dc;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.banner-warn {
  color: #ffe6b8;
  background: rgba(246, 180, 75, 0.1);
  border-color: rgba(246, 180, 75, 0.32);
}
.empty-state {
  text-align: center;
  padding: 56px 16px;
  border: 1px solid var(--mp-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.empty-state i {
  color: var(--mp-amber);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.discover-scope a:focus-visible,
.discover-scope button:focus-visible,
.discover-scope input:focus-visible,
.discover-scope select:focus-visible {
  outline: 3px solid rgba(50, 214, 193, 0.72);
  outline-offset: 3px;
}

/* ——— Library dialog surface (discover-embed.js) ——— */
.discover-dialog {
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  height: calc(100vh - 48px);
  max-height: none;
  margin: 24px auto;
  padding: 0;
  border: 1px solid var(--mp-border-strong);
  border-radius: 12px;
  background: var(--mp-bg-2);
  color: var(--mp-text);
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.discover-dialog[open] {
  display: flex;
}
.discover-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}
.discover-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--mp-border);
  background: rgba(11, 11, 13, 0.92);
}
.discover-dialog__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
.discover-dialog__title i {
  color: var(--mp-cyan);
}
.discover-dialog__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}
.discover-dialog__search {
  margin-bottom: 18px;
}
.discover-dialog .facet-panel {
  /* The dialog body is the scroll container, not the window. */
  top: 0;
}
@media (max-width: 640px) {
  .discover-dialog {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    border: 0;
  }
}

@media (max-width: 960px) {
  .marketplace-shell {
    grid-template-columns: 1fr;
  }
  .facet-panel-slot {
    display: none;
  }
  .facet-panel-slot.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.72);
  }
  .facet-panel-slot.open .facet-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(360px, 92vw);
    height: 100vh;
    overflow-y: auto;
    border-radius: 0;
    border-left: 0;
    top: 0;
  }
}
@media (max-width: 640px) {
  .hero-search-form {
    grid-template-columns: 1fr;
  }
  .search-submit {
    width: 100%;
  }
  .results-grid {
    grid-template-columns: 1fr;
  }
  .results-grid.list-view .listing-card {
    display: flex;
  }
  .results-grid.list-view .listing-card__actions {
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
    flex-direction: row;
  }
  .listing-card__actions {
    flex-wrap: wrap;
  }
  .listing-card__actions .mp-btn {
    flex: 1;
  }
  .detail-backdrop {
    padding: 0;
  }
  .detail-panel {
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }
  .detail-panel .stats-grid {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
