/* Lantern Courts Dex — Aftermyth Series 1 */

:root {
  --indigo: #1a1f3a;
  --indigo-deep: #12162b;
  --indigo-mid: #252b4a;
  --indigo-light: #343b66;
  --gold: #e6b84a;
  --gold-soft: #f0d078;
  --gold-dim: rgba(230, 184, 74, 0.18);
  --vermillion: #c41e3a;
  --vermillion-soft: #e8455c;
  --cream: #f5f0e6;
  --cream-muted: #c8c0b0;
  --text: #efe9dc;
  --text-dim: #a8a092;

  /* Courts */
  --bureau-a: #3d4a8c;
  --bureau-b: #c41e3a;
  --alleys-a: #9b1b2e;
  --alleys-b: #d4a017;
  --kin-a: #4a6b4a;
  --kin-b: #7eb8d4;

  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--indigo-deep);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(230, 184, 74, 0.12), transparent 55%),
    radial-gradient(ellipse 40% 40% at 10% 80%, rgba(196, 30, 58, 0.08), transparent 50%),
    radial-gradient(ellipse 35% 35% at 90% 60%, rgba(61, 74, 140, 0.15), transparent 50%),
    linear-gradient(180deg, var(--indigo) 0%, var(--indigo-deep) 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */

.site-header {
  position: relative;
  z-index: 1;
  padding: 1.75rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(230, 184, 74, 0.2);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lantern-mark {
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(230, 184, 74, 0.45));
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: 0.02em;
  color: var(--cream);
  line-height: 1.15;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tagline {
  margin: 0.85rem 0 0;
  max-width: 36rem;
  color: var(--text-dim);
  font-size: 0.98rem;
}

/* Main */

.main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.15rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.tab:hover {
  color: var(--cream);
}

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.tab .count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--gold-dim);
  color: var(--gold-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

/* Toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  align-items: center;
  margin-bottom: 1.35rem;
}

.search-wrap {
  position: relative;
  flex: 1 1 220px;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(230, 184, 74, 0.25);
  background: rgba(26, 31, 58, 0.85);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search::placeholder {
  color: var(--text-dim);
}

#search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(37, 43, 74, 0.7);
  color: var(--cream-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}

.chip:hover {
  transform: translateY(-1px);
  color: var(--cream);
}

.chip.active {
  color: var(--indigo-deep);
  background: var(--gold);
  border-color: var(--gold);
}

.chip-bureau.active {
  background: linear-gradient(135deg, var(--bureau-a), var(--bureau-b));
  border-color: transparent;
  color: #fff;
}

.chip-alleys.active {
  background: linear-gradient(135deg, var(--alleys-a), var(--alleys-b));
  border-color: transparent;
  color: #fff;
}

.chip-kin.active {
  background: linear-gradient(135deg, var(--kin-a), var(--kin-b));
  border-color: transparent;
  color: #fff;
}

.rarity-filters {
  flex-basis: 100%;
}

.rarity-filters.disabled,
.rarity-filters[hidden] {
  opacity: 0.45;
  pointer-events: none;
}

.chip-rarity-common.active {
  background: rgba(200, 192, 176, 0.35);
  border-color: var(--cream-muted);
  color: var(--cream);
}

.chip-rarity-uncommon.active {
  background: linear-gradient(135deg, #3d6b4a, #7eb87a);
  border-color: transparent;
  color: #fff;
}

.chip-rarity-rare.active {
  background: linear-gradient(135deg, #8a6a20, var(--gold));
  border-color: transparent;
  color: var(--indigo-deep);
}

.chip-rarity-mythic.active {
  background: linear-gradient(135deg, #6b3fa0, var(--vermillion), var(--gold));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 12px rgba(230, 184, 74, 0.35);
}

/* Card grid */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.15rem;
  }
}

.card {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, var(--indigo-mid) 0%, var(--indigo) 100%);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s;
  display: flex;
  flex-direction: column;
  color: inherit;
  font: inherit;
  width: 100%;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lift);
  border-color: rgba(230, 184, 74, 0.45);
  outline: none;
}

.card:focus-visible {
  box-shadow: var(--shadow-lift), 0 0 0 3px var(--gold-dim);
}

.card-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--indigo-deep);
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover .card-thumb img {
  transform: scale(1.04);
}

.card-number {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(18, 22, 43, 0.82);
  color: var(--gold);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(230, 184, 74, 0.3);
  backdrop-filter: blur(4px);
}

.card-body {
  padding: 0.75rem 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.card-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--cream);
}

.court-badge {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  color: #fff;
}

.court-badge.bureau {
  background: linear-gradient(135deg, var(--bureau-a), var(--bureau-b));
}

.court-badge.alleys {
  background: linear-gradient(135deg, var(--alleys-a), var(--alleys-b));
}

.court-badge.kin {
  background: linear-gradient(135deg, var(--kin-a), var(--kin-b));
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 1rem;
  font-size: 1.05rem;
}

/* Footer */

.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--text-dim);
  font-size: 0.82rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.site-footer p {
  margin: 0;
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 22, 0.78);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: linear-gradient(165deg, var(--indigo-mid), var(--indigo-deep));
  border: 1px solid rgba(230, 184, 74, 0.28);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  outline: none;
  animation: modalIn 0.22s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: var(--cream);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--vermillion);
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .modal-body {
    grid-template-columns: minmax(280px, 42%) 1fr;
  }
}

.modal-art {
  background: var(--indigo-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.modal-art img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  display: block;
}

.modal-info {
  padding: 1.35rem 1.4rem 1.6rem;
}

.modal-meta-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.modal-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
}

#modal-name {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--cream);
  line-height: 1.2;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tag.rarity-mythic {
  background: linear-gradient(135deg, #6b3fa0, #e6b84a);
  color: #fff;
  border-color: transparent;
}

.tag.rarity-rare {
  background: rgba(230, 184, 74, 0.2);
  color: var(--gold-soft);
  border-color: rgba(230, 184, 74, 0.35);
}

.stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.stat {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(230, 184, 74, 0.2);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--gold);
}

.modal-section {
  margin-bottom: 1rem;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.modal-section p {
  margin: 0;
  color: var(--cream-muted);
  font-size: 0.95rem;
}

/* Load error */

.load-error {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--indigo-deep);
  text-align: center;
}

.load-error[hidden] {
  display: none;
}

.load-error pre {
  background: var(--indigo);
  border: 1px solid rgba(230, 184, 74, 0.3);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  color: var(--gold);
  overflow-x: auto;
  max-width: 100%;
}

body.modal-open {
  overflow: hidden;
}
