/* =========================================================
   PROJECT WILDBOUND — Index & Database page
   Builds on wildbound.css (cozy navy + gold, monospace UI).
   ========================================================= */

.dbpage { padding: 104px 0 90px; min-height: 100vh; }
.dbhead { text-align: center; max-width: 660px; margin: 0 auto 30px; }
.dbhead h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; }
.dbhead .wlede strong { color: var(--gold); }

/* ---------- tab switcher ---------- */
.dbtabs {
  display: inline-flex; gap: 6px; margin: 0 auto 26px; padding: 6px;
  border: 1px solid var(--w-bd); border-radius: 999px; background: rgba(18, 29, 52, 0.55);
  width: max-content; max-width: 100%;
}
.dbtabs { display: flex; justify-content: center; }
.dbtab {
  font-family: var(--font); font-size: 0.86rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--dim); background: none; border: 0; cursor: pointer;
  padding: 10px 22px; border-radius: 999px; transition: 0.25s var(--ease); white-space: nowrap;
}
.dbtab:hover { color: var(--cream); }
.dbtab.is-active {
  color: #2a1f05; background: linear-gradient(180deg, #fbe39a, var(--gold) 60%, var(--gold-deep));
  box-shadow: 0 6px 16px rgba(245, 215, 110, 0.28);
}
/* center the tab row */
.dbtabs-row { display: flex; justify-content: center; }

/* ---------- controls (search + type filter + count) ---------- */
.dbcontrols {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--w-bd2);
}
.dbsearch-wrap { position: relative; flex: 0 0 auto; }
.dbsearch-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--slate); font-size: 1.05rem; pointer-events: none; }
.dbsearch {
  font-family: var(--font); font-size: 0.92rem; color: var(--cream);
  background: rgba(10, 15, 28, 0.7); border: 1px solid var(--w-bd2); border-radius: 12px;
  padding: 12px 16px 12px 38px; width: 260px; max-width: 100%;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.dbsearch::placeholder { color: var(--slate); }
.dbsearch:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 215, 110, 0.15); }

.dbtypes { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.dbtype {
  --t: var(--slate);
  font-family: var(--font); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--t); cursor: pointer;
  padding: 6px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--t) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--t) 38%, transparent);
  transition: transform 0.18s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.dbtype:hover { transform: translateY(-2px); }
.dbtype.is-active {
  color: #0a0f1c; background: var(--t);
  box-shadow: 0 0 16px color-mix(in srgb, var(--t) 45%, transparent);
}
.dbtype--all { --t: var(--gold); }
.dbcount { margin-left: auto; color: var(--slate); font-size: 0.82rem; white-space: nowrap; }

/* ---------- table ---------- */
.dbtablewrap { overflow-x: auto; border: 1px solid var(--w-bd2); border-radius: 16px; background: rgba(18, 29, 52, 0.4); }
.dbtable { width: 100%; border-collapse: collapse; font-family: var(--font); font-size: 0.86rem; }
.dbtable thead th {
  position: sticky; top: 0; z-index: 2;
  background: #101a30; color: var(--gold);
  text-align: left; font-weight: 700; letter-spacing: 0.02em;
  padding: 13px 12px; white-space: nowrap; border-bottom: 1px solid var(--w-bd);
}
.dbtable th[data-sort] { cursor: pointer; user-select: none; }
.dbtable th[data-sort]:hover { color: #fff; }
.dbtable th.num { text-align: right; }
.dbtable th[data-sort]::after { content: "⇅"; opacity: 0.35; margin-left: 6px; font-size: 0.8em; }
.dbtable th.is-sorted.asc::after { content: "▲"; opacity: 1; }
.dbtable th.is-sorted.desc::after { content: "▼"; opacity: 1; }
.dbtable tbody td { padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
.dbtable tbody td.num { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.dbtable tbody tr { cursor: pointer; transition: background 0.15s var(--ease); }
.dbtable tbody tr:hover { background: rgba(245, 215, 110, 0.07); }
.db-num { color: var(--slate); font-variant-numeric: tabular-nums; }
.db-name { color: var(--cream); font-weight: 700; }
.db-bst { color: var(--gold); font-weight: 700; }
.db-sprite { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; display: block; }

/* small inline type pill (table + gallery + modal) */
.tpill {
  --t: #888; display: inline-block;
  font-size: 0.68rem; font-weight: 700; color: var(--t);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--t) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--t) 42%, transparent);
}
.tpill + .tpill { margin-left: 4px; }

/* rarity badge */
.rar { font-size: 0.72rem; font-weight: 700; text-transform: capitalize; }
.rar--common { color: #9aa5b1; }
.rar--uncommon { color: #7fe87f; }
.rar--rare { color: #8ad0ff; }
.rar--epic { color: #c79bff; }
.rar--legendary { color: var(--gold); }

.is-hidden { display: none !important; }
.dbempty { text-align: center; color: var(--slate); padding: 40px 0; }

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; }
.gcard {
  position: relative; text-align: center; cursor: pointer;
  border: 1px solid var(--w-bd2); border-radius: 16px; padding: 16px 12px 14px;
  background: linear-gradient(180deg, var(--w-panel), rgba(18, 29, 52, 0.4));
  transition: transform 0.28s var(--ease), border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}
.gcard:hover { transform: translateY(-5px); border-color: var(--w-bd); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4); }
.gcard__img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; margin: 0 auto 8px; display: block; }
.gcard__num { color: var(--slate); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.gcard__name { color: var(--cream); font-weight: 700; font-size: 0.92rem; margin: 2px 0 8px; }

/* ---------- detail modal ---------- */
.dbmodal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; }
.dbmodal[hidden] { display: none; }
.dbmodal__backdrop { position: absolute; inset: 0; background: rgba(4, 7, 14, 0.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dbmodal__card {
  position: relative; z-index: 1; width: min(540px, 100%); max-height: 88vh; overflow-y: auto;
  border: 1px solid var(--w-bd); border-radius: 22px; padding: 28px;
  background: radial-gradient(120% 80% at 50% 0%, rgba(245, 215, 110, 0.1), transparent 55%), linear-gradient(180deg, var(--w-panel), var(--w-bg2));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dbmodal__close {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--w-bd2);
  color: var(--dim); font-size: 1.4rem; line-height: 1; transition: 0.2s var(--ease);
}
.dbmodal__close:hover { color: #fff; border-color: var(--gold); }

.cdet__top { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.cdet__art { width: 128px; height: 128px; object-fit: contain; image-rendering: pixelated; flex: 0 0 auto;
  background: radial-gradient(circle at 50% 45%, rgba(245,215,110,0.12), transparent 60%); border-radius: 16px; }
.cdet__num { color: var(--slate); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.cdet__name { font-family: var(--title); font-size: 1.7rem; font-weight: 700; color: #fff; line-height: 1.1; margin: 2px 0 4px; }
.cdet__title { color: var(--gold); font-size: 0.86rem; font-style: italic; margin-bottom: 8px; }
.cdet__desc { color: var(--dim); font-size: 0.9rem; margin: 4px 0 18px; }
.cdet__meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; font-size: 0.8rem; color: var(--slate); }
.cdet__meta b { color: var(--cream); font-weight: 700; }
.cdet__evo { margin-bottom: 16px; font-size: 0.85rem; color: var(--dim); }
.cdet__evo b { color: var(--gold); }

.stat { display: grid; grid-template-columns: 64px 36px 1fr; align-items: center; gap: 10px; margin-bottom: 7px; }
.stat__l { color: var(--slate); font-size: 0.74rem; letter-spacing: 0.03em; }
.stat__v { color: var(--cream); font-size: 0.82rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.stat__bar { display: block; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.stat__fill { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--mint), var(--gold)); }
.cdet__bst { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--w-bd2); display: flex; justify-content: space-between; font-size: 0.9rem; }
.cdet__bst b { color: var(--gold); font-size: 1.05rem; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .dbtable .stat-col { display: none; }
  .dbsearch { width: 100%; }
  .dbsearch-wrap { width: 100%; }
  .dbcount { margin-left: 0; }
  .cdet__top { flex-direction: column; text-align: center; }
  .stat { grid-template-columns: 58px 32px 1fr; }
}
