/* Pokédex page. Loaded after site.css. */

.dex-page { --page-w: 1200px; }

/* ---------- Type colors ---------- */

.type--normal { --type: #9fa19f; }
.type--fire { --type: #e62829; }
.type--water { --type: #2980ef; }
.type--electric { --type: #e0ae00; }
.type--grass { --type: #3fa129; }
.type--ice { --type: #3dc7ef; }
.type--fighting { --type: #ff8000; }
.type--poison { --type: #9141cb; }
.type--ground { --type: #915121; }
.type--flying { --type: #81b9ef; }
.type--psychic { --type: #ef4179; }
.type--bug { --type: #91a119; }
.type--rock { --type: #afa981; }
.type--ghost { --type: #704170; }
.type--dragon { --type: #5060e1; }
.type--dark { --type: #624d4e; }
.type--steel { --type: #60a1b8; }
.type--fairy { --type: #ef70ef; }
.type--stellar { --type: #40b5a5; }

.type {
  display: inline-block;
  min-width: 66px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--type, #8a93a3);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}

.types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

/* ---------- Controls ---------- */

.dex-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px 16px;
}

.dex-search,
.dex-select select {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  transition: border-color .15s ease;
}

.dex-search:focus-within,
.dex-select select:focus { border-color: var(--blue); outline: none; }
.dex-search svg { width: 20px; height: 20px; flex: none; fill: var(--gray); }

.dex-search input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.dex-select select {
  min-width: 160px;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.dex-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.dex-toggle input { width: 18px; height: 18px; accent-color: var(--blue); }

.dex-count {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--gray);
  font-size: 14px;
}

/* ---------- Grid ---------- */

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.dex-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 190px;
}

.dex-card a {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 12px 10px 14px;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 0 var(--line), 0 10px 24px -18px rgba(15, 31, 58, .45);
  transition: transform .15s ease, box-shadow .15s ease;
}

.dex-card a:hover {
  transform: translateY(-3px);
  box-shadow: 0 1px 0 var(--line), 0 18px 32px -20px rgba(15, 31, 58, .55);
}

.dex-num {
  align-self: flex-start;
  color: var(--gray);
  font-size: 13px;
  font-weight: 700;
}

/* Showdown's icon sheet, shown at 2× with crisp pixels. */
.dex-icon {
  width: 80px;
  height: 60px;
  flex: none;
  background: url("./assets/showdown/pokemonicons-sheet.png") no-repeat;
  background-size: 960px auto;
  image-rendering: pixelated;
}

.dex-icon--missing {
  display: grid;
  place-items: center;
  background: none;
  color: #b7c0cf;
  font-size: 30px;
  font-weight: 800;
}

.dex-name {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.dex-forme {
  margin: 1px 0 0;
  color: var(--gray);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}

.dex-card .types { margin-top: 8px; }

/* Placeholder cards shown while the Pokédex loads. */
.dex-card--skel > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  height: 100%;
  min-height: 176px;
  padding: 12px 10px 14px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 0 var(--line), 0 10px 24px -18px rgba(15, 31, 58, .45);
}

.dex-card--skel .skel--num { align-self: flex-start; width: 44px; height: 12px; }
.dex-card--skel .skel--icon { width: 64px; height: 50px; margin-block: 4px; border-radius: 12px; }
.dex-card--skel .skel--name { width: 70%; height: 15px; }
.dex-card--skel .skel--types { width: 60%; height: 20px; border-radius: 999px; }

.dex-empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  color: var(--gray);
  text-align: center;
}

/* ---------- Detail ---------- */

.dex-detail { display: grid; gap: 20px; }

.dex-back { justify-self: start; }
.dex-back svg { width: 18px; height: 18px; }

.dex-hero {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}

.dex-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--type, var(--blue)) 70%, #fff) 0%, var(--type, var(--blue)) 100%);
  isolation: isolate;
}

.dex-art .rays { width: 1200px; }
.dex-art .banner-glow { width: 90%; }

.dex-sprite {
  position: relative;
  max-width: 88%;
  max-height: 88%;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .28));
}

.dex-sprite.is-pixel { image-rendering: pixelated; }

/* Glass circle shown on the artwork until the sprite has loaded. */
.dex-sprite-skel {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}

.dex-art-skel { aspect-ratio: 1; border-radius: 18px; }

.dex-art-note {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .85);
  color: var(--navy);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}

.dex-title { display: grid; gap: 10px; }
.dex-title .dex-num { font-size: 16px; }
.dex-title h2 { font-size: clamp(30px, 4vw, 42px); }
.dex-title .types { justify-content: flex-start; }
.dex-title .types .type { min-width: 84px; padding: 5px 12px; font-size: 13px; }

.dex-category { margin: -4px 0 0; color: var(--gray); font-weight: 700; }
.dex-flavor { margin: 4px 0 0; color: var(--ink); font-size: 16.5px; line-height: 1.7; }

.dex-forms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.dex-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 12px 2px 2px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
}

.dex-form[aria-current="page"] { border-color: var(--blue); background: #eef5fd; }
.dex-form .dex-icon { width: 40px; height: 30px; background-size: 480px auto; }

.dex-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 8px 0 0;
}

.dex-fact {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f4f7fb;
}

.dex-fact dt { color: var(--gray); font-size: 12.5px; font-weight: 700; }
.dex-fact dd { margin: 2px 0 0; color: var(--navy); font-weight: 800; }

.dex-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.dex-section h3 { margin-bottom: 14px; font-size: 21px; }
.dex-section--wide { grid-column: 1 / -1; }

.dex-muted { margin: 0; color: var(--gray); }

/* Base stats */
.dex-stats { display: grid; gap: 8px; margin: 0; }

.dex-stat {
  display: grid;
  grid-template-columns: 76px 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.dex-stat dt { color: var(--gray); font-size: 14px; font-weight: 700; }
.dex-stat dd { margin: 0; font-weight: 800; text-align: right; }
.dex-stat-bar { height: 10px; overflow: hidden; border-radius: 5px; background: #edf1f6; }
.dex-stat-bar span { display: block; height: 100%; border-radius: inherit; background: var(--bar); }
.dex-stat--total { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.dex-stat--total dt, .dex-stat--total dd { color: var(--navy); }

/* Abilities */
.dex-abilities { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.dex-ability strong { color: var(--navy); }
.dex-ability small { margin-left: 8px; padding: 2px 8px; border-radius: 6px; background: #eef2f7; color: var(--gray); font-size: 12px; font-weight: 700; }
.dex-ability p { margin: 4px 0 0; color: var(--gray); }

/* Type defenses */
.dex-defenses { display: grid; gap: 12px; }
.dex-defense-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: start; }
.dex-defense-row > span { padding-top: 3px; color: var(--gray); font-size: 14px; font-weight: 700; }
.dex-defense-row .types { justify-content: flex-start; }

/* Evolution */
.dex-evo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 4px; }

.dex-evo-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: 12px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.dex-evo-member:hover { background: #f4f7fb; }
.dex-evo-member[aria-current="page"] { background: #eef5fd; }
.dex-evo-steps { display: grid; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; color: var(--gray); font-size: 14.5px; }
.dex-evo-steps strong { color: var(--navy); }

/* Item icons (PokeRogue sheet, 32×32 boxes) */
.item-icon {
  position: relative;
  display: inline-block;
  flex: none;
  width: 32px;
  height: 32px;
  margin: -6px 4px -6px 0;
  vertical-align: middle;
}

.item-icon-sprite {
  position: absolute;
  background: url("./assets/pokerogue/items.png") no-repeat;
  image-rendering: pixelated;
}

.item-icon-sprite--sd { background-image: url("./assets/showdown/itemicons-sheet.png"); }

.dex-note .item-icon { width: 28px; height: 28px; margin: -4px 2px -4px -2px; transform: scale(.875); transform-origin: center; }

/* Other ways to get a Pokémon */
.dex-obtain {
  display: grid;
  gap: 2px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 2px solid #ffe27a;
  border-radius: 12px;
  background: #fff7d6;
}

.dex-obtain strong { color: var(--navy); }
.dex-obtain span { color: var(--gray); font-size: 14px; }
.dex-obtain span strong { font-weight: 800; }
/* Normal text flow (not flex) so punctuation hugs the words; icons sit inline. */
.dex-obtain > span { margin-top: 4px; line-height: 2; }
.dex-obtain .dex-evo-member--inline { display: inline-flex; vertical-align: middle; }

.dex-evo-path { margin: 10px 0 16px; }
.dex-evo-path li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.dex-evo-member--inline {
  flex-direction: row;
  gap: 4px;
  padding: 2px 8px 2px 2px;
}

.dex-evo-member--inline .dex-icon { width: 40px; height: 30px; background-size: 480px auto; }

.dex-subhead { margin: 18px 0 8px; color: var(--navy); font-size: 17px; }

/* Tables */
.dex-table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.dex-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.dex-table th {
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--gray);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.dex-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.dex-table tr:last-child td { border-bottom: 0; }
.dex-table td:first-child { color: var(--navy); font-weight: 800; }
.dex-table .num { text-align: right; white-space: nowrap; }
.dex-table .type { min-width: 72px; }
.dex-note { display: block; color: var(--gray); font-size: 13px; }

.dex-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }

.dex-tab {
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--gray);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.dex-tab[aria-selected="true"] { border-color: var(--blue); background: #eef5fd; color: var(--navy); }

.dex-move-level { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; font-size: 14px; }
.dex-move-level input { width: 80px; padding: 8px; border: 2px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font: inherit; }

.dex-loading { padding: 64px 0; color: var(--gray); text-align: center; }

@media (max-width: 900px) {
  .dex-hero { grid-template-columns: 1fr; }
  .dex-art { max-width: 420px; }
  .dex-sections { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .dex-controls { grid-template-columns: 1fr 1fr; }
  .dex-search { grid-column: 1 / -1; }
  .dex-select select { min-width: 0; width: 100%; }
  .dex-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .dex-defense-row { grid-template-columns: 1fr; gap: 6px; }
}
