:root {
  --ink: #14201a;
  --paper: #f3faf4;
  --sun: #ffe14a;
  --leaf: #1f8a5b;
  --sky: #3db8e8;
  --coral: #ff5a3c;
  --muted: #4d6358;
  --line: rgba(20, 32, 26, 0.12);
  --shadow: 0 18px 40px rgba(20, 32, 26, 0.12);
  --radius: 18px;
  --font-display: "Dela Gothic One", sans-serif;
  --font-body: "Figtree", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 225, 74, 0.35), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(61, 184, 232, 0.28), transparent 36%),
    linear-gradient(180deg, #e8f7ec 0%, var(--paper) 38%, #eef8f1 100%);
  min-height: 100vh;
}

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

a {
  color: inherit;
}

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

/* —— Hero —— */
.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: end;
  gap: 2rem;
  padding: 1.25rem clamp(1.25rem, 4vw, 3.5rem) 4rem;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(243, 250, 244, 0.92) 38%, rgba(243, 250, 244, 0.2) 68%, transparent 82%),
    url("https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/6.png")
      right center / min(62vw, 720px) no-repeat;
  opacity: 0.18;
  pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}

.nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem clamp(1.25rem, 4vw, 3.5rem);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav-link {
  text-decoration: none;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: var(--ink);
}

.hero-copy {
  position: relative;
  z-index: 1;
  padding-bottom: 1rem;
  animation: rise 0.9s ease both;
}

.brand {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-copy h1 {
  margin: 0 0 1rem;
  max-width: 14ch;
  font-size: clamp(1.45rem, 3.2vw, 2.15rem);
  font-weight: 700;
  line-height: 1.2;
}

.lede {
  margin: 0 0 1.75rem;
  max-width: 36ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.4rem;
  background: var(--ink);
  color: var(--sun);
  text-decoration: none;
  font-weight: 700;
  border-radius: 999px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.cta:hover,
.cta:focus-visible {
  transform: translateY(-2px);
  background: #0d1712;
}

.hero-visual {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: float-in 1.1s 0.15s ease both;
}

.hero-visual img {
  width: min(100%, 520px);
  height: auto;
  filter: drop-shadow(0 24px 36px rgba(20, 32, 26, 0.22));
  animation: bob 4.5s ease-in-out infinite;
}

/* —— Dex —— */
.dex {
  position: relative;
  z-index: 1;
  padding: 4rem clamp(1.25rem, 4vw, 3.5rem) 5rem;
}

.dex-head {
  max-width: 40rem;
  margin-bottom: 2rem;
}

.dex-head h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.01em;
}

.dex-head p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.controls input,
.controls select {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  min-width: min(100%, 220px);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.controls input:focus-visible,
.controls select:focus-visible {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(31, 138, 91, 0.18);
}

.status {
  color: var(--muted);
  font-weight: 500;
}

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

.poke {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 1rem 0.85rem 1.1rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  animation: rise 0.5s ease both;
}

.poke:hover,
.poke:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(31, 138, 91, 0.45);
  background: #fff;
  outline: none;
}

.poke img {
  width: 96px;
  height: 96px;
  margin: 0 auto 0.65rem;
  image-rendering: auto;
}

.poke-id {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.poke-name {
  margin: 0.15rem 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: capitalize;
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.type {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  background: #e3eee7;
  color: var(--ink);
}

.type.fire { background: #ffd4c8; }
.type.water { background: #c8e8ff; }
.type.grass { background: #c8f0d4; }
.type.electric { background: #fff1a8; }
.type.psychic { background: #ffd0e8; }
.type.ice { background: #d4f4ff; }
.type.dragon { background: #d8d8ff; }
.type.dark { background: #d9d4d0; }
.type.fairy { background: #ffd8ee; }
.type.fighting { background: #f0c8c0; }
.type.flying { background: #dce8f8; }
.type.poison { background: #e8d0f0; }
.type.ground { background: #efdfc0; }
.type.rock { background: #e0d8c8; }
.type.bug { background: #d8f0a8; }
.type.ghost { background: #d8d0e8; }
.type.steel { background: #d8e0e8; }
.type.normal { background: #e8e8e0; }

.footer {
  padding: 1.5rem clamp(1.25rem, 4vw, 3.5rem) 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--leaf);
  font-weight: 600;
}

/* —— Detail dialog —— */
.detail {
  border: none;
  border-radius: 24px;
  padding: 0;
  width: min(92vw, 380px);
  box-shadow: var(--shadow);
  background: #fff;
}

.detail::backdrop {
  background: rgba(20, 32, 26, 0.45);
  backdrop-filter: blur(2px);
}

.detail-inner {
  margin: 0;
  padding: 1.75rem 1.5rem 1.75rem;
  text-align: center;
  position: relative;
}

.detail-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.detail-inner img {
  margin: 0 auto 0.5rem;
  width: 180px;
  height: 180px;
}

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

.detail-inner h3 {
  margin: 0.2rem 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.75rem;
  text-transform: capitalize;
}

.detail-inner .type-row {
  justify-content: center;
  margin-bottom: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 1rem;
  margin: 0;
  text-align: left;
  font-size: 0.92rem;
}

.stats dt {
  color: var(--muted);
  font-weight: 500;
}

.stats dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-18px);
  }
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
    min-height: auto;
    padding-top: 5.5rem;
    padding-bottom: 2.5rem;
  }

  .hero::before {
    opacity: 0.1;
    background-size: min(90vw, 420px);
    background-position: right -40px top 80px;
  }

  .hero-visual {
    order: -1;
    justify-content: flex-start;
  }

  .hero-visual img {
    width: min(72vw, 300px);
  }

  .brand {
    font-size: clamp(2.6rem, 14vw, 4.2rem);
  }
}
