/* ===================== TOKENS ===================== */
:root {
  color-scheme: dark;

  --bg: #050a18;
  --panel: #0b1226;
  --surface: #101a33;
  --surface-top: #15213f;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #8b5cf6;
  --accent-light: #b79cff;
  --accent-dark: #5b3ee0;
  --text: #f4f6ff;
  --muted: #9aa6c4;
  --warning: #ff7b7b;
  --gold: #ffb020;
  --radius: 20px;
  --spring: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pop: cubic-bezier(0.3, 1.6, 0.5, 1);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@font-face {
  font-family: "Inter";
  src: url("../typography/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ===================== RESET ===================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(
      900px circle at 0% 0%,
      rgba(139, 92, 246, 0.2),
      transparent 60%
    ),
    radial-gradient(
      800px circle at 100% 100%,
      rgba(34, 195, 166, 0.1),
      transparent 55%
    ),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.sheet-open {
  overflow: hidden;
}

button {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

input {
  border: none;
  color: inherit;
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

ul {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.warning-text {
  color: var(--warning);
}

/* Icons are drawn with a mask so they take the color of the text */
.icon {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-pokeball {
  --icon: url("../assets/icons/pokeball.svg");
}

.icon-sparkles {
  --icon: url("../assets/icons/sparkles.svg");
}

.icon-arrow-right {
  --icon: url("../assets/icons/arrow-right.svg");
}

.icon-star-outline {
  --icon: url("../assets/icons/star-outline.svg");
}

.icon-star {
  --icon: url("../assets/icons/star.svg");
}

.icon-map {
  --icon: url("../assets/icons/map.svg");
}

.icon-map-pin {
  --icon: url("../assets/icons/map-pin.svg");
}

.icon-layers {
  --icon: url("../assets/icons/layers.svg");
}

.icon-check {
  --icon: url("../assets/icons/check.svg");
}

.icon-close {
  --icon: url("../assets/icons/close.svg");
}

.icon-search {
  --icon: url("../assets/icons/search.svg");
}

.icon-chevron-down {
  --icon: url("../assets/icons/chevron-down.svg");
}

.icon-height {
  --icon: url("../assets/icons/height.svg");
}

.icon-weight {
  --icon: url("../assets/icons/weight.svg");
}

/* ===================== TYPE COLORS ===================== */
.type-normal {
  --type-color: #a8a878;
  --type-text: var(--bg);
}

.type-fire {
  --type-color: #f08030;
}

.type-water {
  --type-color: #6890f0;
}

.type-electric {
  --type-color: #f8d030;
  --type-text: var(--bg);
}

.type-grass {
  --type-color: #78c850;
}

.type-ice {
  --type-color: #98d8d8;
  --type-text: var(--bg);
}

.type-fighting {
  --type-color: #c03028;
}

.type-poison {
  --type-color: #a040a0;
}

.type-ground {
  --type-color: #e0c068;
  --type-text: var(--bg);
}

.type-flying {
  --type-color: #a890f0;
}

.type-psychic {
  --type-color: #f85888;
}

.type-bug {
  --type-color: #a8b820;
}

.type-rock {
  --type-color: #b8a038;
}

.type-ghost {
  --type-color: #705898;
}

.type-dragon {
  --type-color: #7038f8;
}

.type-dark {
  --type-color: #705848;
}

.type-steel {
  --type-color: #b8b8d0;
  --type-text: var(--bg);
}

.type-fairy {
  --type-color: #ee99ac;
  --type-text: var(--bg);
}

/* ===================== LAYOUT ===================== */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "logo"
    "search"
    "main";
  gap: 0.9rem;
  padding: 1rem 1rem 6rem;
}

.main {
  grid-area: main;
  min-width: 0;
}

/* ===================== LOGO ===================== */
.logo {
  grid-area: logo;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2.4rem;
  height: 2.4rem;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
  -webkit-mask-image: url("../assets/icons/pokeball.svg");
  mask-image: url("../assets/icons/pokeball.svg");
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.6));
  transition: transform 0.6s var(--spring);
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===================== NAV (bottom bar on mobile) ===================== */
.nav {
  grid-area: nav;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: flex;
  padding: 0.5rem 0.75rem calc(0.5rem + var(--safe-bottom));
  background: rgba(11, 18, 38, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.45rem;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  transition:
    color 0.2s,
    background-color 0.2s,
    transform 0.2s;
}

.nav-btn .icon {
  transition: transform 0.25s var(--spring);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-btn.active {
  color: var(--accent-light);
}

/* ===================== SEARCH ===================== */
.search-container {
  grid-area: search;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  height: 3rem;
  padding: 0 2.75rem 0 2.9rem;
  border-radius: 14px;
  background: rgba(16, 26, 51, 0.9);
  border: 1px solid var(--line);
  font-size: 1rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#searchInput::placeholder {
  color: var(--muted);
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18);
}

#searchInput::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.clear-btn {
  position: absolute;
  right: 4.25rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--muted);
  transition:
    color 0.2s,
    background-color 0.2s;
}

.clear-btn .icon {
  width: 1rem;
  height: 1rem;
}

.search-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #7a4df0, var(--accent-dark));
  color: #fff;
  transition:
    transform 0.2s,
    filter 0.2s;
}

.search-btn:active {
  transform: scale(0.92);
}

/* ===================== GENERATION AND REGION FILTER ===================== */
.group-filter {
  margin-bottom: 0.75rem;
}

.group-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.group-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  height: 2.6rem;
  padding: 0 1rem 0 0.4rem;
  border-radius: 999px;
  background: rgba(16, 26, 51, 0.8);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition:
    transform 0.2s,
    border-color 0.2s,
    background-color 0.2s;
}

.group-chip:active {
  transform: scale(0.95);
}

.group-chip.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.2);
}

.group-badge {
  display: grid;
  place-items: center;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.25);
  color: var(--accent-light);
  font-size: 0.72rem;
  font-weight: 700;
}

.group-badge .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.group-chip.active .group-badge {
  background: var(--accent);
  color: #fff;
}

/* ===================== TYPE FILTER ===================== */
.type-filter {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.type-list {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  max-height: 2.6rem;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.type-list.expanded {
  max-height: 12rem;
}

.type-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.6rem;
  padding: 0 0.95rem 0 0.5rem;
  border-radius: 999px;
  background: rgba(16, 26, 51, 0.8);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition:
    transform 0.2s,
    border-color 0.2s,
    background-color 0.2s;
}

.type-chip img,
.type-chip .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.type-chip .icon {
  color: var(--accent-light);
}

.type-chip:active {
  transform: scale(0.95);
}

.type-chip.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.2);
}

.type-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: rgba(16, 26, 51, 0.8);
  border: 1px solid var(--line);
  transition: background-color 0.2s;
}

.type-toggle .icon {
  transition: transform 0.3s;
}

.type-toggle[aria-expanded="true"] .icon {
  transform: rotate(180deg);
}

/* ===================== POKEMON LIST ===================== */
.pokemon-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.pokemon-item {
  min-width: 0;
}

.pokemon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 1rem;
  border-radius: var(--radius);
  background: linear-gradient(
    160deg,
    rgba(21, 33, 63, 0.95),
    rgba(16, 26, 51, 0.95)
  );
  border: 1px solid var(--line);
  transition:
    transform 0.25s var(--spring),
    border-color 0.25s,
    box-shadow 0.25s;
}

.pokemon-card:active {
  transform: translateY(-1px) scale(0.98);
}

.pokemon-card.selected {
  border-color: var(--accent);
  background: linear-gradient(
    160deg,
    rgba(37, 31, 92, 0.9),
    rgba(16, 26, 51, 0.95)
  );
  box-shadow:
    0 0 0 1px var(--accent),
    0 14px 34px -12px rgba(139, 92, 246, 0.75);
}

.pokemon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.75rem;
}

.pokemon-type-icons {
  display: flex;
  gap: 0.3rem;
}

.pokemon-type-icons .type-icon {
  width: 1.75rem;
  height: 1.75rem;
}

.pokemon-number {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.selected-check {
  position: absolute;
  right: 1rem;
  bottom: 1.1rem;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition:
    opacity 0.25s,
    transform 0.3s var(--pop);
}

.selected-check .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.pokemon-card.selected .selected-check {
  opacity: 1;
  transform: scale(1);
}

.pokemon-img {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.85;
  margin: 0.25rem 0;
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--type-color, transparent) 26%, transparent),
    transparent
  );
}

.pokemon-img img {
  width: 82%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45));
  transition: transform 0.35s var(--spring);
}

.pokemon-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.pokemon-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.type-icon {
  padding: 0.3rem;
  border-radius: 50%;
  background-color: var(--type-color, var(--muted));
}

.type-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem 0.2rem 0.25rem;
  border-radius: 8px;
  background: var(--type-color);
  color: var(--type-text, var(--text));
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Uppercase text sits a bit high in the line box, so it gets a small push down */
.type-tag > span {
  padding-top: 0.15rem;
}

.type-tag img {
  width: 1rem;
  height: 1rem;
  padding: 0;
  background: none;
}

.skeleton .pokemon-card {
  min-height: 15rem;
  background:
    linear-gradient(
        100deg,
        transparent 20%,
        rgba(255, 255, 255, 0.07) 40%,
        transparent 60%
      )
      100% 0 / 200% 100%,
    var(--surface);
  animation: shimmer 1.4s linear infinite;
  pointer-events: none;
}

.empty-message {
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}

/* ===================== PAGINATION ===================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

.page-btn {
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  background: rgba(16, 26, 51, 0.9);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
  transition:
    transform 0.2s,
    border-color 0.2s,
    background-color 0.2s;
}

.page-btn:disabled {
  opacity: 0.4;
}

.page-info {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===================== DETAIL (sheet on mobile, side panel on desktop) ===================== */
.detail {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: 92dvh;
  padding: 0 1rem calc(1rem + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px 28px 0 0;
  transform: translateY(105%);
  transition: transform 0.4s var(--spring);
}

.detail.open {
  transform: translateY(0);
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(2, 5, 14, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.detail-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 0.7rem 0 0.4rem;
  background: var(--panel);
}

.detail-handle {
  width: 2.75rem;
  height: 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition:
    background-color 0.2s,
    transform 0.2s;
}

.detail-close .icon {
  width: 1rem;
  height: 1rem;
}

.detail-placeholder {
  display: grid;
  place-items: center;
  min-height: 14rem;
  padding: 2rem;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: opacity 0.2s;
}

.detail-body.loading {
  opacity: 0.4;
  pointer-events: none;
}

.detail-body.enter > * {
  animation: fadeUp 0.5s var(--spring) both;
}

.detail-body.enter > :nth-child(2) {
  animation-delay: 70ms;
}

.detail-body.enter > :nth-child(3) {
  animation-delay: 140ms;
}

.detail-body.enter > :nth-child(4) {
  animation-delay: 210ms;
}

.detail-body.enter > :nth-child(5) {
  animation-delay: 280ms;
}

/* ===================== DETAIL: SECTIONS ===================== */
.section {
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: rgba(16, 26, 51, 0.85);
  border: 1px solid var(--line);
}

.section-title {
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.section-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.9rem;
}

/* ===================== DETAIL: HERO ===================== */
.detail-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "types"
    "image"
    "description"
    "measures";
  gap: 0.7rem;
  align-content: start;
  overflow: hidden;
  background:
    radial-gradient(
      120% 90% at 80% 25%,
      color-mix(in srgb, var(--type-color, var(--accent)) 40%, transparent),
      transparent 65%
    ),
    linear-gradient(160deg, #111b38, #0b1329);
}

.detail-title {
  grid-area: title;
  padding-right: 5.6rem;
}

.detail-id {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.detail-name {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.detail-genus {
  color: var(--muted);
  font-size: 0.8rem;
}

.detail-hero .pokemon-types {
  grid-area: types;
  align-self: start;
}

.detail-img {
  grid-area: image;
  justify-self: center;
  width: 100%;
  max-width: 12rem;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.5));
}

.detail-img.loaded {
  opacity: 1;
  animation:
    popIn 0.6s cubic-bezier(0.3, 1.4, 0.5, 1),
    float 4s ease-in-out 0.6s infinite;
}

/* The GIF already moves by itself */
.detail-img.is-animated.loaded {
  animation: popIn 0.6s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.detail-description {
  grid-area: description;
  color: rgba(244, 246, 255, 0.88);
  font-size: 0.88rem;
  line-height: 1.55;
}

.measures {
  grid-area: measures;
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin-top: 0.4rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.measure {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
}

.measure .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.measure span {
  display: block;
}

.measure .icon {
  display: inline-block;
}

.measure-label {
  font-size: 0.75rem;
}

.measure-value {
  color: var(--text);
  font-weight: 700;
}

.hero-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: flex;
  gap: 0.4rem;
}

.icon-action {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  transition:
    background-color 0.2s,
    transform 0.2s,
    color 0.2s;
}

.icon-action:disabled {
  opacity: 0.35;
}

.icon-action.active {
  color: var(--gold);
}

.icon-action.pop .icon {
  animation: pop 0.4s var(--pop);
}

.favorite-btn .icon {
  --icon: url("../assets/icons/star-outline.svg");
}

.favorite-btn.active .icon {
  --icon: url("../assets/icons/star.svg");
}

/* ===================== DETAIL: BASE STATS ===================== */
.stat {
  display: grid;
  grid-template-columns: 1.4rem 5.2rem minmax(0, 1fr) 2rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.32rem 0;
  font-size: 0.85rem;
}

.stat-icon {
  width: 1.2rem;
  height: 1.2rem;
}

.stat-hp .stat-icon {
  --icon: url("../assets/icons/stat-hp.svg");
  color: #ff5d7a;
}

.stat-attack .stat-icon {
  --icon: url("../assets/icons/stat-attack.svg");
  color: #f6a54a;
}

.stat-defense .stat-icon {
  --icon: url("../assets/icons/stat-defense.svg");
  color: #5db7f6;
}

.stat-special-attack .stat-icon {
  --icon: url("../assets/icons/stat-special-attack.svg");
  color: #b794ff;
}

.stat-special-defense .stat-icon {
  --icon: url("../assets/icons/stat-special-defense.svg");
  color: #4fd6b4;
}

.stat-speed .stat-icon {
  --icon: url("../assets/icons/stat-speed.svg");
  color: #f6d84a;
}

.custom-meter {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-value {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dark), #b565ff);
  transition: width 0.9s var(--spring);
  transition-delay: calc(var(--index) * 80ms);
}

.stats.filled .meter-value {
  width: calc(var(--value) * 1%);
}

.stat-value {
  color: var(--accent-light);
  font-weight: 700;
  text-align: right;
}

/* ===================== DETAIL: MATCHUPS AND ABILITIES ===================== */
.matchup-label {
  display: block;
  margin: 0.2rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.matchup-list,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.matchup-list {
  margin-bottom: 0.7rem;
}

.matchup {
  position: relative;
  display: block;
  width: 2rem;
  height: 2rem;
  transition: transform 0.2s;
}

.matchup img {
  width: 100%;
  height: 100%;
  padding: 0.4rem;
}

.matchup-multiplier {
  position: absolute;
  right: -0.35rem;
  bottom: -0.3rem;
  padding: 0 0.25rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.3;
}

.ability-chip,
.chip {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.8rem;
}

.ability-chip {
  padding: 0.35rem 0.8rem;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.ability-chip.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.2);
}

.ability-info {
  margin-top: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(244, 246, 255, 0.88);
  font-size: 0.78rem;
  line-height: 1.5;
  animation: fadeUp 0.3s var(--spring);
}

.ability-chip.hidden-ability {
  border-style: dashed;
}

.chip {
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  border-color: transparent;
  font-size: 0.75rem;
}

.badges {
  margin-bottom: 0.9rem;
}

.facts {
  display: grid;
  gap: 0.7rem;
}

.fact {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.fact dt {
  color: var(--muted);
}

.fact dd {
  font-weight: 600;
}

.gender-bar {
  display: flex;
  height: 0.5rem;
  margin-bottom: 0.35rem;
  border-radius: 999px;
  overflow: hidden;
}

.gender-male {
  background: #5db7f6;
}

.gender-female {
  background: #f685b8;
}

.gender-text {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: pre;
}

.evolution {
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.evo-branch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: max-content;
}

.evo-next {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.evo-condition {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  width: 4.2rem;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.2;
  text-align: center;
}

.evo-condition .icon {
  width: 1rem;
  height: 1rem;
}

.evo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  width: 4.6rem;
  padding: 0.35rem 0.2rem;
  border-radius: 14px;
  border: 1px solid transparent;
  transition:
    transform 0.2s,
    background-color 0.2s,
    border-color 0.2s;
}

.evo-node img {
  width: 3.6rem;
  height: 3.6rem;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4));
}

.evo-name {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.evo-number {
  color: var(--muted);
  font-size: 0.6rem;
}

.evo-node.current {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.18);
}

.origin-list {
  margin-bottom: 0.7rem;
}

.origin-chip {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.8rem;
}

.origin-chip.accent {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent);
  color: var(--accent-light);
  font-weight: 600;
}

/* ===================== DETAIL: ACCORDION ===================== */
.accordion-item {
  border-radius: var(--radius);
  background: rgba(16, 26, 51, 0.85);
  border: 1px solid var(--line);
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  transition: background-color 0.2s;
}

.accordion-header .icon {
  transition: transform 0.3s;
}

.accordion-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.accordion-content > div {
  min-height: 0;
  padding: 0 1.25rem;
  overflow: hidden;
  transition: padding 0.35s;
}

.accordion-item.open .accordion-header .icon {
  transform: rotate(180deg);
}

.accordion-item.open .accordion-content {
  grid-template-rows: 1fr;
}

.accordion-item.open .accordion-content > div {
  max-height: 16rem;
  padding-bottom: 1.1rem;
  overflow-y: auto;
}

/* ===================== CREDITS ===================== */
.credits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

/* ===================== DESKTOP ===================== */
@media (min-width: 640px) and (max-width: 999px) {
  .pokemon-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .app {
    height: 100dvh;
    grid-template-columns: 200px minmax(0, 1fr) 400px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "logo search search"
      "nav main detail";
    gap: 1rem 1.25rem;
    padding: 1.25rem;
  }

  .main,
  .detail {
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  }

  body.sheet-open {
    overflow: visible;
  }

  /* Nav becomes the side menu */
  .nav {
    position: static;
    flex-direction: column;
    align-self: start;
    gap: 0.35rem;
    padding: 0;
    background: none;
    backdrop-filter: none;
    border: none;
  }

  .nav-btn {
    flex-direction: row;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    font-size: 0.95rem;
  }

  .nav-btn.active {
    background: linear-gradient(135deg, var(--accent-dark), #7a4df0);
    box-shadow: 0 10px 24px -10px rgba(139, 92, 246, 0.8);
    color: #fff;
  }

  .search-btn {
    display: none;
  }

  .clear-btn {
    right: 0.75rem;
  }

  /* The detail is a column of the page, not a sheet */
  .detail {
    position: static;
    z-index: auto;
    max-height: none;
    padding: 0 0.25rem 0 0;
    background: none;
    border: none;
    border-radius: 0;
    transform: none;
    transition: none;
  }

  .detail-backdrop,
  .detail-bar {
    display: none;
  }

  .detail-hero {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-areas:
      "title image"
      "types image"
      "description image"
      "measures measures";
    column-gap: 0.5rem;
  }

  .detail-title {
    padding-right: 0;
  }

  .hero-actions {
    top: 0.8rem;
    right: 0.8rem;
  }

  .detail-name {
    font-size: 1.75rem;
  }

  .detail-img {
    align-self: center;
    max-width: none;
    margin-right: -0.5rem;
  }

  .detail-description {
    font-size: 0.8rem;
  }
}

@media (min-width: 1200px) {
  .pokemon-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1400px) {
  .app {
    grid-template-columns: 220px minmax(0, 1fr) 440px;
  }
}

/* The collapsed type row scrolls sideways on mobile */
@media (max-width: 999px) {
  .type-list:not(.expanded) {
    flex-wrap: nowrap;
    overflow: auto hidden;
    scrollbar-width: none;
  }

  .type-list:not(.expanded)::-webkit-scrollbar {
    display: none;
  }
}

/* ===================== HOVER (pointer devices only) ===================== */
@media (hover: hover) {
  .logo:hover .logo-icon {
    transform: rotate(360deg);
  }

  .nav-btn:hover .icon {
    transform: scale(1.15);
  }

  .clear-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text);
  }

  .search-btn:hover {
    filter: brightness(1.15);
  }

  .group-chip:hover,
  .type-chip:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.22);
  }

  .type-toggle:hover {
    background: rgba(139, 92, 246, 0.2);
  }

  .pokemon-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.55);
    box-shadow: 0 14px 30px -14px rgba(139, 92, 246, 0.6);
  }

  .pokemon-card:hover .pokemon-img img {
    transform: scale(1.08) rotate(-2deg);
  }

  .page-btn:not(:disabled):hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: rgba(139, 92, 246, 0.16);
  }

  .detail-close:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: rotate(90deg);
  }

  .icon-action:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.08);
  }

  .evo-node:not(.current):hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.06);
  }

  .ability-chip:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .matchup:hover {
    transform: translateY(-3px) scale(1.1);
  }

  .accordion-header:hover {
    background-color: rgba(255, 255, 255, 0.04);
  }

  .credits a:hover {
    color: var(--accent-light);
  }
}

@media (hover: hover) and (min-width: 1000px) {
  .nav-btn:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text);
  }
}

/* ===================== ANIMATIONS ===================== */
/* Appear when entering the screen (see js/reveal.js) */
.reveal {
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition:
    opacity 0.5s ease,
    transform 0.5s var(--spring);
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8) rotate(-4deg);
  }
}

@keyframes float {
  50% {
    transform: translateY(-6px);
  }
}

@keyframes pop {
  40% {
    transform: scale(1.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
