/* Pokédex Page */

.pokedex-page {
  padding: 2.5rem 0 4rem;
  background:
    radial-gradient(
      circle at 20% 25%,
      rgba(40, 105, 223, 0.1),
      transparent 32%
    ),
    var(--app-background);
}

.pokedex-header {
  margin-bottom: 1.75rem;
}

.pokedex-header h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.05;
}

.pokedex-intro {
  max-width: 60ch;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Controls */

.pokedex-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(5, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 1.1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-panel);
}

.pokedex-controls .form-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.5rem;
}

.pokedex-controls label {
  color: #f8fafc;
  font-size: 0.85rem;
  font-weight: 700;
}

.pokedex-controls input,
.pokedex-controls select {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--app-border-strong);
  border-radius: 8px;
  background-color: var(--app-input);
  color: #f8fafc;
  font: inherit;
}

.pokedex-controls input:focus,
.pokedex-controls select:focus {
  border-color: var(--app-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 132, 245, 0.16);
}

.pokedex-clear-button {
  min-height: 44px;
  white-space: nowrap;
}

/* Toggles */

.pokedex-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.pokedex-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.pokedex-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--app-blue);
}

/* Status + count */

.pokedex-count {
  margin: 0 0 0.75rem;
  color: var(--app-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.pokedex-count:empty {
  display: none;
}

.pokedex-status {
  padding: 2.5rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-panel);
  color: var(--app-muted);
  text-align: center;
}

.pokedex-status[hidden] {
  display: none;
}

/* Grid */

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

.pokedex-grid:empty {
  display: none;
}

/* Card */

.pokedex-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.9rem 0.75rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-panel);
  text-align: center;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
  transition:
    border-color 120ms ease,
    transform 120ms ease;
}

.pokedex-card:hover {
  border-color: var(--app-blue);
  transform: translateY(-2px);
}

.pokedex-card:focus-visible {
  outline: 2px solid var(--app-blue);
  outline-offset: 2px;
}

.pokedex-card-number {
  align-self: flex-start;
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pokedex-card-sprite {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.pokedex-card-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.pokedex-card-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

/* Detail panel */

body.pokedex-detail-open {
  overflow: hidden;
}

.pokedex-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 8, 20, 0.6);
}

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

.pokedex-detail {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  height: 100%;
  padding: 1.25rem;
  overflow-y: auto;
  border-left: 1px solid var(--app-border);
  background: var(--app-panel);
  box-shadow: -12px 0 40px rgba(3, 8, 20, 0.45);
}

.pokedex-detail[hidden] {
  display: none;
}

.pokedex-detail-header {
  display: flex;
  justify-content: flex-end;
}

.pokedex-detail-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--app-border-strong);
  border-radius: 8px;
  background: var(--app-input);
  color: #f8fafc;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.pokedex-detail-close:hover {
  border-color: var(--app-blue);
}

.pokedex-detail-status {
  padding: 2rem 0;
  color: var(--app-muted);
  text-align: center;
}

.pokedex-detail-status[hidden] {
  display: none;
}

.pokedex-detail-body {
  text-align: center;
}

.pokedex-detail-body[hidden] {
  display: none;
}

.pokedex-detail-number {
  margin: 0;
  color: var(--app-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pokedex-detail-artwork {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  object-fit: contain;
}

.pokedex-detail-name {
  margin: 0.25rem 0 0.75rem;
  font-size: 1.5rem;
}

.pokedex-detail-types {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.6rem;
}

.pokedex-detail-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.pokedex-role-badge {
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(49, 88, 142, 0.75);
  border-radius: 999px;
  background: rgba(20, 132, 245, 0.14);
  color: #8dc5ff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
}

.pokedex-detail-flavor {
  margin: 0 0 1.25rem;
  color: #dce7f6;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
}

.pokedex-detail-flavor:empty {
  display: none;
}

.pokedex-detail-measurements {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-panel-dark);
  text-align: left;
}

.pokedex-detail-measurements dt {
  color: var(--app-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pokedex-detail-measurements dd {
  margin: 0;
  font-weight: 700;
}

.pokedex-detail-section {
  margin-bottom: 1.5rem;
  text-align: left;
}

.pokedex-detail-section h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.pokedex-stat-list {
  display: grid;
  gap: 0.5rem;
}

.pokedex-stat-row {
  display: grid;
  grid-template-columns: 42px 40px 1fr;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.pokedex-stat-label {
  color: var(--app-muted);
  font-weight: 700;
}

.pokedex-stat-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pokedex-stat-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--app-input);
}

.pokedex-stat-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--app-blue);
}

.pokedex-stat-bar.is-low {
  background: #e0794b;
}

.pokedex-stat-bar.is-mid {
  background: #e0b74b;
}

.pokedex-stat-bar.is-high {
  background: #52c77a;
}

.pokedex-stat-total {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--app-border);
  font-weight: 800;
}

.pokedex-stat-total .pokedex-stat-label,
.pokedex-stat-total .pokedex-stat-value {
  color: #f8fafc;
}

/* Abilities */

.pokedex-ability-list {
  display: grid;
  gap: 0.75rem;
}

.pokedex-ability {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-panel-dark);
}

.pokedex-ability-name {
  margin: 0 0 0.3rem;
  font-weight: 700;
}

.pokedex-ability-description {
  margin: 0;
  color: var(--app-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

/* Evolution */

.pokedex-evolution-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.pokedex-evolution-empty {
  margin: 0;
  color: var(--app-muted);
  font-size: 0.85rem;
}

.pokedex-evolution-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pokedex-evolution-arrow {
  color: var(--app-muted);
  font-size: 1.1rem;
}

.pokedex-evolution-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 88px;
  padding: 0.5rem 0.35rem;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  background: var(--app-panel-dark);
  color: #f8fafc;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.pokedex-evolution-node:hover {
  border-color: var(--app-blue);
}

.pokedex-evolution-node:focus-visible {
  outline: 2px solid var(--app-blue);
  outline-offset: 2px;
}

.pokedex-evolution-node img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.pokedex-evolution-node.is-current {
  border-color: var(--app-blue);
  background: rgba(20, 132, 245, 0.14);
  cursor: default;
}

@media (max-width: 980px) {
  .pokedex-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pokedex-clear-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .pokedex-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .pokedex-clear-button {
    grid-column: 1 / -1;
  }

  .pokedex-detail {
    width: 100%;
  }
}
