/* PF2e Glossary — term highlighting + modal + quick-reference search panel
 * Shared across all Pathfinder 2e campaign sites.
 */

/* ── Term highlighting ────────────────────────────────────────────────── */
.glossary-term {
  border-bottom: 1px dotted var(--md-accent-fg-color, #ffb300);
  cursor: help;
  text-decoration: none;
  transition: border-color 0.15s;
}
.glossary-term:hover { border-bottom-style: solid; }

/* ════════════════════════════════════════════════════════════════════════
   Glossary modal
   ════════════════════════════════════════════════════════════════════════ */

/* ── Backdrop ─────────────────────────────────────────────────────────── */
.glossary-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.glossary-modal-backdrop.open { display: flex; }

/* ── Modal card ───────────────────────────────────────────────────────── */
.glossary-modal {
  background: var(--md-default-bg-color, #1e1a2e);
  color: var(--md-default-fg-color, #e8e3f0);
  border: 1px solid var(--md-accent-fg-color, #ffb300);
  border-radius: 10px;
  max-width: 580px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  font-size: 0.93rem;
  line-height: 1.55;
  scrollbar-width: thin;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.glossary-modal__header { margin-bottom: 0.75rem; }

.glossary-modal__title {
  margin: 0 0 0.2rem;
  color: var(--md-accent-fg-color, #ffb300);
  font-size: 1.3rem;
  font-weight: 700;
}
.glossary-modal__subtitle {
  font-size: 0.78rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Traits row ───────────────────────────────────────────────────────── */
.glossary-modal__traits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0 0.75rem;
}
.glossary-modal__traits:empty { margin: 0; }
.glossary-modal__traits .trait {
  background: rgba(255, 179, 0, 0.12);
  border: 1px solid rgba(255, 179, 0, 0.4);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.glossary-modal__traits .trait.rarity-uncommon { border-color: #2196f3; background: rgba(33,150,243,0.12); }
.glossary-modal__traits .trait.rarity-rare     { border-color: #9c27b0; background: rgba(156,39,176,0.12); }
.glossary-modal__traits .trait.rarity-unique   { border-color: #e91e63; background: rgba(233,30,99,0.12); }

/* ── Stats grid ───────────────────────────────────────────────────────── */
.glossary-modal__stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.4rem 1rem;
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.glossary-modal__stats:empty,
.glossary-modal__stats[style*="none"] { display: none; }
/* Each div wrapper is one grid cell — label stacked above value */
.glossary-modal__stats > div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.glossary-modal__stats dt {
  opacity: 0.6;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.glossary-modal__stats dd { margin: 0; }

/* ── Body text ────────────────────────────────────────────────────────── */
.glossary-modal__body {
  white-space: pre-wrap;
  line-height: 1.65;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}
.glossary-modal__body:empty { display: none; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.glossary-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.82rem;
  gap: 0.75rem;
}
.glossary-modal__source {
  opacity: 0.45;
  font-size: 0.75rem;
  font-style: italic;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.glossary-modal__link {
  color: var(--md-accent-fg-color, #ffb300);
  text-decoration: none;
  white-space: nowrap;
}
.glossary-modal__link:hover { text-decoration: underline; }
.glossary-modal__close {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: inherit;
  border-radius: 4px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
.glossary-modal__close:hover { border-color: var(--md-accent-fg-color, #ffb300); }

/* ════════════════════════════════════════════════════════════════════════
   Quick Reference search panel
   ════════════════════════════════════════════════════════════════════════ */

/* ── Floating trigger button ─────────────────────────────────────────── */
.gl-search-trigger {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--md-primary-fg-color, #6a3fa0);
  color: #fff;
  border: none;
  border-radius: 2rem;
  padding: 0.6rem 1.1rem 0.6rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.gl-search-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.gl-search-trigger svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

/* ── Panel shell ─────────────────────────────────────────────────────── */
.gl-search {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--md-default-bg-color, #1a1625);
  border-left: 1px solid var(--md-accent-fg-color, #ffb300);
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 8500;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.gl-search.open { transform: translateX(0); }

/* ── Header (search input row) ───────────────────────────────────────── */
.gl-search__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.gl-search__icon {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.5;
  flex-shrink: 0;
  color: var(--md-default-fg-color, #e8e3f0);
}
.gl-search__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--md-default-fg-color, #e8e3f0);
  font-size: 1rem;
  line-height: 1.4;
}
.gl-search__input::placeholder { opacity: 0.4; }
.gl-search__close {
  background: none;
  border: none;
  color: var(--md-default-fg-color, #e8e3f0);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.5;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  line-height: 1;
}
.gl-search__close:hover { opacity: 1; }

/* ── Filter bar ──────────────────────────────────────────────────────── */
.gl-search__filters {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 40vh;
}
.gl-filter-group {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.gl-filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.5;
  padding-top: 0.25rem;
  white-space: nowrap;
  min-width: 5.5rem;
}
.gl-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.gl-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--md-default-fg-color, #e8e3f0);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  text-transform: capitalize;
}
.gl-chip:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
}
.gl-chip.active {
  background: var(--md-accent-fg-color, #ffb300);
  border-color: var(--md-accent-fg-color, #ffb300);
  color: #1a1625;
  font-weight: 700;
}

/* ── Status line ─────────────────────────────────────────────────────── */
.gl-search__status {
  font-size: 0.75rem;
  opacity: 0.5;
  padding: 0.4rem 1rem 0;
  flex-shrink: 0;
  min-height: 1.4rem;
}

/* ── Results list ────────────────────────────────────────────────────── */
.gl-search__results {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* ── Individual result card ──────────────────────────────────────────── */
.gl-result {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  text-align: left;
  cursor: pointer;
  color: var(--md-default-fg-color, #e8e3f0);
  transition: background 0.12s, border-color 0.12s;
}
.gl-result:hover {
  background: rgba(255,255,255,0.09);
  border-color: var(--md-accent-fg-color, #ffb300);
}
.gl-result__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.gl-result__name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--md-accent-fg-color, #ffb300);
}
.gl-result__level {
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gl-result__meta {
  font-size: 0.75rem;
  opacity: 0.6;
  text-transform: capitalize;
  margin-bottom: 0.2rem;
}
.gl-result__traits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
}
.gl-result__traits span {
  font-size: 0.65rem;
  background: rgba(255,179,0,0.1);
  border: 1px solid rgba(255,179,0,0.28);
  border-radius: 2px;
  padding: 0.05rem 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
