/* Theme tokens */
:root{
  --bg: #ffffff;
  --bg-soft:#f7f8fb;
  --text: #111827;
  --text-muted:#6b7280;
  --brand: #ef4444;
  --surface:#ffffff;
  --shadow-2: 0 6px 20px rgba(16,24,40,.08);
}

html, body {
  height: 100%;
}

body{
  color: var(--text);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header (AppBar) */
.dex-header{
  background: var(--brand);
  width: auto;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

/* Toolbar chips in header and drawer */
.type-chip, .chip, .type-pill{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* touch target */
  padding: 8px 12px;
  border-radius: 9999px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 1px rgba(16,24,40,.04);
  transition: box-shadow .2s ease, background-color .2s ease, color .2s ease;
}
.type-chip[aria-pressed="true"],
.chip[aria-pressed="true"]{
  outline: 2px solid #111827;
  box-shadow: inset 0 0 0 2px #fff;
}

/* Drawer rows (filters) */
.filters-row{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Optional horizontal scroll variant if needed */
.filters-scroll{
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-gutter: stable;
}
.filters-scroll::after{
  content:"";
  display:block;
  width:16px;
  flex: 0 0 16px;
}

/* Search placeholder contrast */
input::placeholder{
  color: #6b7280;
}
.search-pill input::placeholder{
  color: #6b7280;
}

/* Header toolbar layout and overflow handling */
.dex-header #toolbar-body{
  overflow-x: auto;
  scrollbar-gutter: stable;
}
.dex-header #toolbar-body > .flex{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.dex-header .search-pill{
  margin: 8px 0 12px;
}
.dex-header .type-chip{
  flex: 0 0 auto;
}

/* Favorites quick list strip */
.fav-strip{
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px;
  scroll-snap-type: x mandatory;
}
.fav-pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 9999px;
  background: #fff;
  box-shadow: var(--shadow-2);
  scroll-snap-align: start;
}
.fav-pill img{
  width: 28px; height: 28px; object-fit: contain;
}

/* Grid: responsive auto-fill */
#pokedex-grid{
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
  gap: 16px !important;
  margin-top: 16px; /* clear header shadow */
}

/* Cards */
.grid-card{
  position: relative;
  padding: 14px !important;
  border-radius: 16px !important;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.grid-card h3{
  margin: 0 0 6px;
  line-height: 1.15;
  min-height: 1.15em;
}
.grid-card .type-chip{
  gap: 6px;
}
.grid-card .thumb{
  width: 72px;
  height: 72px;
  object-fit: contain;
  pointer-events: none;
}
.pk-number{
  font-weight: 700;
  color: rgba(17,23,42,.5);
  font-size: 12px;
}

/* Details: hero area */
.details-hero{
  position: relative;
  padding-top: 24px;
  min-height: 260px;
}
.details-hero::before{
  content:"";
  position: absolute;
  inset: 0;
  /* Subtle softening overlay so text remains readable across themes */
  background: linear-gradient(180deg, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.15) 60%, rgba(255,255,255,0.25) 100%);
  z-index: 0;
}
.details-hero .hero-text,
.details-hero .hero-text *{
  position: relative;
  z-index: 1;
}
#pokemon-name{
  color: #0f172a !important; /* dark text for contrast */
  text-shadow: none !important;
}
#type-chips{
  margin-top: 8px;
  gap: 8px;
}
.hero-art{
  position: relative;
  z-index: 0;
  display: block;
  max-width: 320px;
  width: clamp(180px, 30vw, 320px);
  margin: 0 auto 16px; /* breathing room from tabs */
  height: auto;
  object-fit: contain;
}

/* Tabs: accessibility and states */
.tabs{
  display: flex;
  gap: 8px;
  align-items: center;
}
.tabs [role="tab"]{
  padding: 10px 14px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 600;
}
.tabs [role="tab"][aria-selected="true"]{
  background: #f59e0b;
  color: #111827;
}
.tabs [role="tab"]:focus-visible{
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Tabpanels show/hide */
.tabpanel{
  display: none;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
.tabpanel.active{
  display: block;
}

/* Stats layout */
#stats .stat-row{
  display: grid;
  grid-template-columns: 120px 48px 1fr;
  column-gap: 16px;
  align-items: center;
}
#stats .stat-name{
  text-transform: uppercase;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: .02em;
}
#stats .stat-value{
  font-weight: 700;
}
#stats .stat-bar{
  height: 10px;
  border-radius: 6px;
  background: #e5e7eb;
  overflow: hidden;
}
#stats .stat-bar > span{
  display: block;
  height: 100%;
  background: #22c55e;
  width: var(--pct, 50%);
}

/* Trading cards strip */
#pokemon-tcg{
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}
#tcg-cards{
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 12px;
  scroll-snap-type: x mandatory;
}
#tcg-cards img{
  height: 140px;
  width: auto;
  border-radius: 8px;
  scroll-snap-align: start;
  box-shadow: 0 4px 14px rgba(16,24,40,.12);
}

/* Type color palettes (ensure adequate contrast) */
.type-grass{ background:#16a34a !important; color:#fff !important; }
.type-poison{ background:#7e22ce !important; color:#fff !important; }
.type-fire{ background:#ef4444 !important; color:#fff !important; }
.type-water{ background:#3b82f6 !important; color:#fff !important; }
.type-bug{ background:#65a30d !important; color:#fff !important; }
.type-normal{ background:#6b7280 !important; color:#fff !important; }
.type-electric{ background:#f59e0b !important; color:#111827 !important; }
.type-psychic{ background:#ec4899 !important; color:#fff !important; }
.type-ice{ background:#06b6d4 !important; color:#111827 !important; }
.type-dragon{ background:#7c3aed !important; color:#fff !important; }
.type-dark{ background:#111827 !important; color:#fff !important; }
.type-fairy{ background:#f472b6 !important; color:#111827 !important; }
.type-ghost{ background:#4b5563 !important; color:#fff !important; }
.type-rock{ background:#a16207 !important; color:#fff !important; }
.type-ground{ background:#b45309 !important; color:#fff !important; }
.type-steel{ background:#6b7280 !important; color:#fff !important; }
.type-flying{ background:#60a5fa !important; color:#111827 !important; }
.type-fighting{ background:#b91c1c !important; color:#fff !important; }

/* Utility adjustments */
.app-shell{
  min-height: 100%;
}

/* Ensure header action focus rings are visible on red background */
.dex-header :is(select, button):focus-visible{
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* About cards base */
.about-card{
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}

/* Map view routes focus */
.route:focus{
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

/* Fix contrast for small labels in details */
.text-gray-500{
  color: var(--text-muted) !important;
}

/* Clean horizontal overflow on small screens */
#main-container{
  overflow-x: hidden;
}

/* Provide a softly rounded modal and drawer */
.modal .modal-card,
.drawer .drawer-panel{
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
}

/* Ensure scrollbars don't overlap content where horizontal scrolling is used */
.fav-strip, .filters-scroll, #tcg-cards{
  scrollbar-gutter: stable both-edges;
}

/* ===== Details: Enhanced sections ===== */

/* Evolution chain */
.evo-list{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.evo-step{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  min-width: 110px;
}
.evo-step img{
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 2px 8px rgba(16,24,40,.12);
}
.evo-step .name{
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}
.evo-step .method{
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.evo-arrow{
  color: #cbd5e1;
  font-size: 18px;
}
.evo-arrow .label{
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: center;
}

/* Moves table */
.move-list{
  margin-top: 6px;
}
.move-row{
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}
.move-row .name{
  font-weight: 700;
  text-transform: capitalize;
}
.type-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
}

/* Breeding grid tweaks */
.breeding-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.breeding-grid .label{
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.breeding-grid .value{
  font-weight: 700;
}

/* Location list */
.loc-list{
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.loc-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.region-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #eef2ff;
  color: #111827;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
}

/* Inline mini-map visualization in Location tab */
.mini-map{
  margin: 8px 0 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #e6f0ff;
  box-shadow: var(--shadow-2);
}
.mini-map svg{ display:block; width:100%; height:auto; }

/* Moves header styling */
.move-list .move-row:first-child{
  font-weight: 700;
  border-bottom-color: #e2e8f0;
}
