/* ============================================================
   SE2202 Project 1 — Pokédex
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #070b18;
  --surface: rgba(19, 26, 48, 0.82);
  --line: rgba(148, 163, 210, 0.18);
  --text: #eef1fb;
  --muted: #98a3c9;
  --accent: #7c6cff;
  --accent-ink: #0a0e1c;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow: 0 34px 90px rgba(2, 5, 16, 0.7);
  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

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

body {
  min-height: 100vh;
  margin: 0;
  padding: clamp(26px, 6vw, 76px) clamp(16px, 4vw, 32px);
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 6% -14%, rgba(124, 108, 255, 0.3), transparent 62%),
    radial-gradient(760px 460px at 100% 2%, rgba(34, 211, 238, 0.14), transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, #0a1024 58%, #050811 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: -26% -12% auto -12%;
  height: 62vh;
  background: radial-gradient(closest-side, var(--accent-soft), transparent 76%);
  pointer-events: none;
  transition: background 0.45s ease;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Shell ---------- */

.app {
  position: relative;
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 26px;
}

.app__header {
  display: grid;
  gap: 10px;
  padding-inline: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(#f43f5e 0 47%, #0b1020 47% 53%, #f8fafc 53% 100%);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.1),
    0 12px 28px -10px rgba(244, 63, 94, 0.8);
}

.brand__mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #0b1020;
  box-shadow: inset 0 0 0 3px #f8fafc;
}

.brand__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app__subtitle {
  max-width: 58ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.6;
}

.panel {
  position: relative;
  padding: clamp(20px, 3.6vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* ---------- Search ---------- */

.search {
  display: grid;
  gap: 9px;
}

.search__label,
.field__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.search__controls {
  display: flex;
  gap: 12px;
}

.input {
  width: 100%;
  padding: 13px 16px;
  font: 500 0.95rem/1.3 var(--font-body);
  color: var(--text);
  background: rgba(6, 10, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input::placeholder {
  color: rgba(152, 163, 201, 0.55);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.input--search {
  max-width: 320px;
  font-size: 1.02rem;
  letter-spacing: 0.02em;
}

.input--readonly {
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  cursor: default;
}

.input--readonly:focus {
  border-color: var(--line);
  box-shadow: none;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  font: 600 0.93rem/1 var(--font-body);
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.22s ease,
    border-color 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
}

.button--primary {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 14px 32px -16px var(--accent);
}

.button--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 18px 40px -14px var(--accent);
}

.button--ghost {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.button--ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.button:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

/* ---------- Status ---------- */

.status {
  min-height: 1.35em;
  margin: 16px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  transition: color 0.2s ease;
}

.status--error {
  color: #ff9aa8;
}

/* ---------- Card ---------- */

.card {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(18px, 3vw, 32px);
  margin: 20px 0 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012));
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.card--filled {
  border-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft), 0 30px 70px -50px var(--accent);
}

.card__media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 236px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 46%, var(--accent-soft), transparent 68%),
    rgba(4, 7, 16, 0.5);
  transition: background 0.45s ease;
}

.card__media::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 17px 17px;
  opacity: 0.45;
  pointer-events: none;
}

.card__sprite {
  position: relative;
  width: min(210px, 74%);
  height: auto;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  filter: drop-shadow(0 20px 26px rgba(2, 5, 14, 0.6));
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.card__sprite[src] {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.card__sprite[src].card__sprite--missing {
  width: 120px;
  opacity: 0.7;
  filter: none;
}

.card__details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-width: 0;
}

.card__types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.chip {
  padding: 6px 13px;
  font: 700 0.72rem/1 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chip-ink, #0b1020);
  background: var(--chip, #98a3c9);
  border-radius: 999px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

/* ---------- Pager ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.pager .button:first-child {
  justify-self: start;
}

.pager .button:last-child {
  justify-self: end;
}

.pager__arrow {
  font-size: 1.15rem;
  line-height: 0.8;
  opacity: 0.8;
}

.pager__count {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .card {
    grid-template-columns: 1fr;
  }

  .card__media {
    min-height: 200px;
  }

  .fields {
    grid-template-columns: 1fr;
  }

  .field--wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .search__controls {
    flex-direction: column;
  }

  .input--search {
    max-width: none;
  }

  .pager {
    grid-template-columns: 1fr 1fr;
  }

  .pager__count {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
  }

  .pager .button {
    width: 100%;
    padding-inline: 10px;
    font-size: 0.85rem;
  }
}

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