/* ---------------------------------------------------------------------
   AQW Catalog
   Palette: deep indigo-slate base, warm gold accent (item-rarity gold),
   with each gear category carrying its own muted accent hue -- the
   category color is the main identity device, standing in for icons.
--------------------------------------------------------------------- */

:root {
  --bg: #14151f;
  --bg-raised: #1b1d2b;
  --bg-card: #1f2233;
  --bg-card-hover: #262a40;
  --border: #2c2f45;
  --border-bright: #3d4162;

  --text: #ecebf3;
  --text-muted: #9997ad;
  --text-faint: #6d6b82;

  --gold: #d4af6a;
  --gold-bright: #e6c688;

  --armor: #7ea3dd;
  --weapon: #dd8286;
  --cape: #b596e8;
  --headgear: #74cfa8;

  --male: #7ea3dd;
  --female: #dd86b8;

  --danger: #e0707a;

  --radius: 3px;
  --font-display: 'Cinzel', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* A class-based display rule (flex/inline-block/etc.) can otherwise defeat
   the browser's default handling of the `hidden` attribute; this keeps
   `hidden` authoritative everywhere in the page, once, rather than needing
   a `.foo[hidden]` override next to every single display rule. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

button, input {
  font-family: inherit;
  color: inherit;
}

a { color: var(--gold-bright); }

::selection { background: var(--gold); color: #14151f; }

/* -------------------- Header -------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.wordmark-icon {
  font-size: 18px;
  color: var(--gold);
  transform: translateY(-1px);
}

.wordmark h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
}

.search-wrap {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 640px;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--gold);
}

.search-input::placeholder { color: var(--text-faint); }

.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.search-chips:empty { margin-top: 0; }

.result-count {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.filters-toggle {
  display: none;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

/* -------------------- Layout -------------------- */

.layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 64px);
}

.filters-panel {
  width: 280px;
  flex-shrink: 0;
  padding: 20px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 65px;
  max-height: calc(100vh - 65px);
  overflow-y: auto;
}

.filter-section {
  margin-bottom: 26px;
}

.filter-heading {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 10px;
  letter-spacing: 0.03em;
}

.filter-note {
  font-size: 12px;
  color: var(--text-faint);
  margin: 6px 0 0;
}

.content {
  flex: 1 1 auto;
  padding: 24px;
  min-width: 0;
}

/* -------------------- Pills (category / gender / AND-OR) -------------------- */

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-row-small { gap: 4px; }

.pill {
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.pill:hover { border-color: var(--gold); color: var(--text); }

.pill.active {
  background: var(--pill-color, var(--gold));
  border-color: var(--pill-color, var(--gold));
  color: #14151f;
  font-weight: 600;
}

.pill-small {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 14px;
}

/* -------------------- Tag list -------------------- */

.tag-mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tag-search-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-bottom: 10px;
}

.tag-search-input:focus { border-color: var(--gold); }

.tag-list {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  user-select: none;
}

.tag-row:hover { background: var(--bg-card); color: var(--text); }

.tag-row .tag-count {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.tag-row.included {
  background: rgba(212, 175, 106, 0.15);
  color: var(--gold-bright);
}

.tag-row.included .tag-count { color: var(--gold); }

.tag-row.excluded {
  background: rgba(224, 112, 122, 0.12);
  color: var(--danger);
  text-decoration: line-through;
}

.tag-row.excluded .tag-count { color: var(--danger); }

.tag-row .tag-mark {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: 12px;
}

.clear-filters-btn {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.clear-filters-btn:hover { border-color: var(--danger); color: var(--danger); }

.card-size-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-bright);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.card-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  cursor: pointer;
  transition: background 0.12s ease;
}

.card-size-slider::-webkit-slider-thumb:hover { background: var(--gold-bright); }

.card-size-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  cursor: pointer;
}

.card-size-slider::-moz-range-thumb:hover { background: var(--gold-bright); }

/* Search-bar chip (a tag auto-detected from typed text) */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 175, 106, 0.15);
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 3px 6px 3px 11px;
  font-size: 12px;
}

.chip.excluded {
  background: rgba(224, 112, 122, 0.12);
  color: var(--danger);
  border-color: var(--danger);
}

.chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px;
}

/* -------------------- Card grid -------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-size, 210px), 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-accent, var(--border-bright));
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s ease, transform 0.08s ease;
}

.card:hover {
  background: var(--bg-card-hover);
}

.card:active { transform: scale(0.98); }

.card-image-wrap {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-image-wrap img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.card-name {
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.scroll-sentinel {
  height: 1px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state-sub {
  color: var(--text-faint);
  font-size: 13px;
}

/* -------------------- Modal -------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 16, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  padding: 24px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  z-index: 1;
}

.modal-close:hover { color: var(--text); }

.modal-image-wrap {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px;
  min-height: 420px;
}

.modal-image {
  max-width: 100%;
  max-height: 540px;
  object-fit: contain;
}

.modal-body {
  padding: 22px 26px 26px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 12px;
  color: var(--text);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.modal-tag {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  border: 1px solid transparent;
}

.modal-btn-primary {
  background: var(--gold);
  color: #14151f;
}

.modal-btn-primary:hover { background: var(--gold-bright); }

.modal-btn-secondary {
  background: transparent;
  border-color: var(--border-bright);
  color: var(--text);
}

.modal-btn-secondary:hover { border-color: var(--gold); color: var(--gold-bright); }

.modal-nav-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.modal-nav-btn:hover { border-color: var(--gold); color: var(--gold-bright); }

.modal-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.modal-nav-btn:disabled:hover {
  border-color: var(--border-bright);
  color: var(--text);
}

@media (max-width: 860px) {
  .modal-backdrop {
    gap: 6px;
    padding: 12px;
  }
  .modal-nav-btn {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
}

.gender-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  background: var(--bg-card);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
}

.gender-toggle-btn:hover {
  transform: scale(1.06);
}

.gender-toggle-btn.show-male {
  border-color: var(--male);
  color: var(--male);
}

.gender-toggle-btn.show-female {
  border-color: var(--female);
  color: var(--female);
}

/* -------------------- Responsive -------------------- */

@media (max-width: 860px) {
  .site-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .result-count { order: 3; }

  .filters-toggle {
    display: block;
  }

  .layout { display: block; }

  .filters-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    max-height: none;
    width: 84vw;
    max-width: 320px;
    background: var(--bg-raised);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .filters-panel.open {
    transform: translateX(0);
  }

  .content { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* -------------------- Focus visibility -------------------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
.card:focus-visible,
.tag-row:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
