/* PokeAmice Search v2 — Global Ctrl+K Modal, Entity Direct-Hits, Highlighted Passages */

/* Masthead shortcut hint */
.greedy-nav .search__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search__kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.68;
  letter-spacing: 0.02em;
}

@media (max-width: 900px) {
  .search__kbd {
    display: none;
  }
}

/* Native <dialog> modal — top-layer animation + pure-CSS scroll containment */
dialog.pa-search-dialog {
  --pa-s-bg: #ffffff;
  --pa-s-surface: #f7f9fc;
  --pa-s-surface-hover: #eef4fb;
  --pa-s-border: rgba(15, 23, 42, 0.12);
  --pa-s-ink: #0f172a;
  --pa-s-muted: #475569;
  --pa-s-accent: #0077b6;
  --pa-s-accent-soft: rgba(0, 119, 182, 0.1);
  --pa-s-mark-bg: #fef08a;
  --pa-s-mark-ink: #713f12;

  width: min(760px, calc(100vw - 24px));
  max-width: 760px;
  max-height: min(82vh, 720px);
  margin: min(9vh, 72px) auto auto;
  padding: 0;
  border: 1px solid var(--pa-s-border);
  border-radius: 16px;
  background: var(--pa-s-bg);
  color: var(--pa-s-ink);
  box-shadow: 0 28px 72px rgba(15, 23, 42, 0.24), 0 4px 18px rgba(15, 23, 42, 0.08);
  overflow: hidden;

  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  dialog.pa-search-dialog {
    transform: translateY(-8px) scale(0.97);
  }
}

dialog.pa-search-dialog:modal {
  overscroll-behavior: contain;
}

dialog.pa-search-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(15, 23, 42, 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog.pa-search-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog.pa-search-dialog[open]:where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);

    @starting-style {
      transform: translateY(-8px) scale(0.97);
    }
  }
}

dialog.pa-search-dialog[open]:where(:not([data-closing]))::backdrop {
  background-color: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);

  @starting-style {
    background-color: rgba(15, 23, 42, 0);
    backdrop-filter: blur(0px);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.pa-search-dialog,
  dialog.pa-search-dialog::backdrop {
    transition-duration: 0.1s;
  }
}

.pa-search-dialog__shell {
  display: flex;
  flex-direction: column;
  max-height: min(82vh, 720px);
  min-height: 0;
}

.pa-search-dialog__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--pa-s-border);
  background: var(--pa-s-bg);
}

.pa-search-dialog__icon {
  color: var(--pa-s-accent);
  font-size: 1rem;
  flex-shrink: 0;
}

.pa-search-dialog__input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 !important;
  padding: 4px 0 !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--pa-s-ink) !important;
  font-size: 1.02rem !important;
  line-height: 1.4;
}

.pa-search-dialog__input::placeholder {
  color: var(--pa-s-muted);
  opacity: 0.78;
}

.pa-search-dialog__clear {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: var(--pa-s-surface);
  color: var(--pa-s-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.pa-search-dialog__clear:hover {
  background: var(--pa-s-surface-hover);
  color: var(--pa-s-ink);
}

.pa-search-dialog__submit {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--pa-s-accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.pa-search-dialog__submit:hover {
  filter: brightness(0.92);
}

.pa-search-dialog__close {
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid var(--pa-s-border);
  border-radius: 6px;
  background: var(--pa-s-surface);
  color: var(--pa-s-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.pa-search-dialog__close:hover {
  color: var(--pa-s-ink);
  border-color: var(--pa-s-accent);
}

.pa-search-dialog__scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pa-s-border);
  background: var(--pa-s-surface);
}

.pa-search-scope {
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--pa-s-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pa-search-scope:hover {
  background: var(--pa-s-surface-hover);
  color: var(--pa-s-ink);
}

.pa-search-scope.is-active {
  background: var(--pa-s-accent);
  color: #fff;
}

.pa-search-dialog__status {
  padding: 7px 16px;
  border-bottom: 1px solid var(--pa-s-border);
  background: var(--pa-s-bg);
  color: var(--pa-s-muted);
  font-size: 0.78rem;
}

.pa-search-dialog__body {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 18px;
}

.pa-search-section + .pa-search-section {
  margin-top: 16px;
}

.pa-search-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--pa-s-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.pa-search-section__action {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--pa-s-accent);
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.pa-search-section__action:hover {
  text-decoration: underline;
}

.pa-search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pa-search-chip {
  padding: 5px 11px;
  border: 1px solid rgba(15, 23, 42, 0.13);
  border-radius: 999px;
  background: #f8fafc;
  color: #1e293b;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.pa-search-chip:hover {
  border-color: #0077b6;
  background: rgba(0, 119, 182, 0.08);
  color: #0077b6;
}

.pa-search-chip.is-recent {
  border-style: dashed;
}

.pa-search-doors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pa-search-doors a {
  display: block;
  padding: 9px 12px;
  border: 1px solid var(--pa-s-border);
  border-radius: 10px;
  background: var(--pa-s-surface);
  color: var(--pa-s-ink);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

.pa-search-doors a:hover {
  border-color: var(--pa-s-accent);
  color: var(--pa-s-accent);
}

/* Entity direct-hit cards (shared by modal, /search/, and homepage) */
.search-lab__hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}

.search-lab__hints-label {
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
}

.search-lab__entities {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 119, 182, 0.18);
  border-radius: 12px;
  background: rgba(0, 119, 182, 0.04);
}

.search-lab__entities-head {
  margin-bottom: 8px;
  color: #0077b6;
  font-size: 0.78rem;
  font-weight: 700;
}

.pa-entity-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}

.pa-entity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  background: #ffffff;
}

.pa-entity-card__main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.pa-entity-card__main:hover strong {
  color: #0077b6;
}

.pa-entity-card__avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.pa-entity-card__icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.pa-entity-card__dot {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
}

.pa-entity-card__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pa-entity-card__text strong {
  font-size: 0.86rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pa-entity-card__text small {
  color: #64748b;
  font-size: 0.74rem;
  line-height: 1.3;
}

.pa-entity-card__filter {
  flex-shrink: 0;
  padding: 4px 9px;
  border: 1px solid rgba(0, 119, 182, 0.28);
  border-radius: 999px;
  background: rgba(0, 119, 182, 0.08);
  color: #0077b6;
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.pa-entity-card__filter:hover {
  background: #0077b6;
  color: #fff;
}

/* Modal results list */
.pa-search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pa-search-item__link {
  display: block;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--pa-s-surface);
  color: var(--pa-s-ink);
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.pa-search-item.is-active .pa-search-item__link,
.pa-search-item__link:hover,
.pa-search-item__link:focus-visible {
  background: var(--pa-s-surface-hover);
  border-color: var(--pa-s-accent);
  outline: none;
}

.pa-search-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--pa-s-muted);
}

.pa-search-item__meta .is-type {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--pa-s-accent-soft);
  color: var(--pa-s-accent);
  font-weight: 700;
}

.pa-search-item__meta .is-ft,
.search-result-card__kicker .is-fulltext-hit {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  font-weight: 700;
}

.pa-search-item__title {
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--pa-s-ink);
}

.pa-search-item__snippet {
  margin: 4px 0 0;
  font-size: 0.81rem;
  line-height: 1.55;
  color: var(--pa-s-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Highlighted terms across modal, /search/, and homepage cards */
.pa-search-dialog mark,
.search-result-card mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #fef08a;
  color: #713f12;
  font-weight: 600;
}

.search-result-card--compact .search-result-card__snippet {
  margin: 6px 0 4px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #475569;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pa-search-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--pa-s-muted);
}

.pa-search-empty p {
  margin: 0 0 6px;
}

.pa-search-empty__tip {
  font-size: 0.82rem;
}

.pa-search-dialog__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--pa-s-border);
  background: var(--pa-s-surface);
  font-size: 0.76rem;
  color: var(--pa-s-muted);
}

.pa-search-dialog__keys {
  display: flex;
  gap: 12px;
}

.pa-search-dialog__keys kbd {
  padding: 1px 5px;
  border: 1px solid var(--pa-s-border);
  border-radius: 4px;
  background: var(--pa-s-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.pa-search-dialog__full {
  color: var(--pa-s-accent);
  font-weight: 700;
  text-decoration: none;
}

.pa-search-dialog__full:hover {
  text-decoration: underline;
}

/* Dark theme (body.theme-bg-black) parity */
body.theme-bg-black dialog.pa-search-dialog {
  --pa-s-bg: #141923;
  --pa-s-surface: #1b2332;
  --pa-s-surface-hover: #243047;
  --pa-s-border: rgba(148, 163, 184, 0.22);
  --pa-s-ink: #f1f5f9;
  --pa-s-muted: #94a3b8;
  --pa-s-accent: #56ccf2;
  --pa-s-accent-soft: rgba(86, 204, 242, 0.16);
}

body.theme-bg-black .pa-search-chip {
  background: #1b2332;
  border-color: rgba(148, 163, 184, 0.24);
  color: #e2e8f0;
}

body.theme-bg-black .pa-search-chip:hover {
  border-color: #56ccf2;
  background: rgba(86, 204, 242, 0.14);
  color: #56ccf2;
}

body.theme-bg-black .search-lab__entities {
  background: rgba(86, 204, 242, 0.08);
  border-color: rgba(86, 204, 242, 0.24);
}

body.theme-bg-black .search-lab__entities-head {
  color: #56ccf2;
}

body.theme-bg-black .pa-entity-card {
  background: #141923;
  border-color: rgba(148, 163, 184, 0.22);
}

body.theme-bg-black .pa-entity-card__main {
  color: #f1f5f9;
}

body.theme-bg-black .pa-entity-card__text small,
body.theme-bg-black .search-lab__hints-label,
body.theme-bg-black .search-result-card--compact .search-result-card__snippet {
  color: #94a3b8;
}

body.theme-bg-black .pa-entity-card__filter {
  border-color: rgba(86, 204, 242, 0.36);
  background: rgba(86, 204, 242, 0.14);
  color: #56ccf2;
}

body.theme-bg-black .pa-search-dialog mark,
body.theme-bg-black .search-result-card mark {
  background: rgba(250, 204, 21, 0.28);
  color: #fef08a;
}

body.theme-bg-black .pa-search-item__meta .is-ft,
body.theme-bg-black .search-result-card__kicker .is-fulltext-hit {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
}

/* Home facet bar shuffle button */
.fbar__shuffle {
  margin-left: auto;
  padding: 6px 13px;
  border: 1px solid rgba(0, 119, 182, 0.28);
  border-radius: 999px;
  background: rgba(0, 119, 182, 0.06);
  color: #0077b6;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fbar__shuffle:hover {
  background: #0077b6;
  border-color: #0077b6;
  color: #ffffff;
}

body.theme-bg-black .fbar__shuffle {
  border-color: rgba(86, 204, 242, 0.34);
  background: rgba(86, 204, 242, 0.12);
  color: #56ccf2;
}

body.theme-bg-black .fbar__shuffle:hover {
  background: #56ccf2;
  border-color: #56ccf2;
  color: #0f172a;
}

@media (max-width: 640px) {
  dialog.pa-search-dialog {
    width: calc(100vw - 16px);
    max-height: 88vh;
    margin: 8px auto auto;
    border-radius: 12px;
  }

  .pa-search-doors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pa-search-dialog__keys {
    display: none;
  }
}
