/*
 * Kartiq - Custom styles
 * Built on top of oat.ink (vendor/assets/stylesheets/oat.css)
 */

/* ===== CSS Variables ===== */
:root {
  --primary: #E53E3E;
  --primary-light: #FC8181;
  --primary-dark: #C53030;
  --link: #E53E3E;
  --link-hover: #C53030;
  --bg: #FAFAFA;
  --bg-card: #FFFFFF;
  --text: #1A202C;
  --text-muted: #718096;
  --border: #E2E8F0;
  --nav-height: 60px;
  --bottom-nav-height: 64px;
  --text-hero: 3.5rem;
  --font-extrabold: 800;
}

/* ===== Base ===== */
a {
  color: var(--link);
}
a:hover {
  color: var(--link-hover);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--bottom-nav-height) + 1rem);
  min-height: 100dvh;
}

/* ===== Responsive grid (oat.ink has no breakpoints) ===== */
.grid-responsive {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .grid-responsive {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-responsive {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 6-col variant for type grid */
.grid-responsive--types {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .grid-responsive--types {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-responsive--types {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4) 0;
}

/* ===== Top header ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding-top: 0;
  padding-bottom: 0;
}

.site-header__logo {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  text-decoration: none;
  min-height: 0;
  flex-shrink: 0;
}

.site-header__logo-icon {
  height: 28px;
  width: auto;
}

.site-header__logo-text {
  font-size: var(--text-4);
  font-weight: var(--font-extrabold);
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-header__nav {
  display: none;
  align-items: center;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .site-header__nav {
    display: flex;
  }
}

.site-header__nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: var(--font-medium);
  font-size: var(--text-6);
  transition: color var(--transition-fast);
  min-height: 0;
}

.site-header__nav a:hover,
.site-header__nav a[aria-current="page"] {
  color: var(--primary);
}

.site-header__lang {
  font-size: var(--text-7);
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

.site-header__lang strong {
  color: var(--primary);
}

.site-header__lang a {
  min-height: auto;
}

/* ===== Mobile bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: var(--text-8);
  font-weight: var(--font-medium);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item svg {
  width: 24px;
  height: 24px;
}

.bottom-nav__item--active {
  color: var(--primary);
}

/* ===== Big tap targets for kids ===== */
a, button, [role="button"], input[type="submit"] {
  min-height: 44px;
}
a.badge { min-height: 0; }

input[type="search"],
input[type="text"],
select {
  min-height: 48px;
  font-size: var(--text-6);
}

/* ===== Card grid item ===== */
.card-grid-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: transform var(--transition-fast);
}

.card-grid-item:hover {
  transform: translateY(-3px);
}

.card-grid-item img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-large);
  aspect-ratio: 63/88;
  object-fit: cover;
  background: var(--border);
}

.card-grid-item__placeholder {
  aspect-ratio: 63/88;
  background: var(--border);
  border-radius: var(--radius-large);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--text-7);
}

.card-grid-item__name {
  text-align: center;
  font-size: var(--text-7);
  font-weight: var(--font-medium);
  margin-top: 0.4rem;
  line-height: 1.2;
}

.card-grid-item__set {
  text-align: center;
  font-size: var(--text-8);
  color: var(--muted-foreground);
  line-height: 1.2;
}

/* ===== Pokemon sprite ===== */
.pokemon-sprite {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

.pokemon-sprite--lg {
  width: 160px;
  height: 160px;
}

.pokemon-artwork {
  max-width: 160px;
  height: auto;
  aspect-ratio: 1 / 1;
}

@media (min-width: 768px) {
  .pokemon-artwork {
    max-width: 280px;
  }
}

/* ===== Evolution chain ===== */
.evo-chain {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  max-width: 100%;
}

.evo-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  padding: var(--space-2);
  border-radius: var(--radius-large);
  transition: background var(--transition-fast);
  min-width: 0;
}

.evo-node:hover {
  background: var(--border);
}

.evo-node--current {
  background: var(--border);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.evo-node__name {
  font-size: var(--text-7);
  font-weight: var(--font-medium);
  text-align: center;
  margin-top: 0.3rem;
  max-width: 80px;
  overflow-wrap: break-word;
}

.evo-stage-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  padding: var(--space-3);
}

.evo-stage-group__item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.evo-stage-group__trigger {
  font-size: var(--text-8);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 90px;
  overflow-wrap: break-word;
}

.evo-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  font-size: var(--text-8);
  gap: 0.15rem;
}

.evo-arrow svg {
  width: 20px;
  height: 20px;
}

.evo-arrow__trigger {
  font-size: var(--text-8);
  max-width: 80px;
  text-align: center;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: break-word;
}

/* ===== Search bar ===== */
.search-bar {
  position: relative;
}

.hero .search-bar {
  max-width: 500px;
  margin: 0 auto;
}

.search-bar input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-5);
  background: var(--bg-card);
  transition: border-color var(--transition-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-bar__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* ===== Section headings ===== */
.section-title {
  font-size: var(--text-3);
  font-weight: var(--font-bold);
  margin: var(--space-8) 0 var(--space-2);
}

.section-title:first-child {
  margin-top: 0;
}

.section-intro {
  color: var(--text-muted);
  font-size: var(--text-6);
  margin-bottom: var(--space-6);
  max-width: 600px;
}

/* ===== Detail page ===== */
.detail-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  border-radius: var(--radius-large);
  padding: var(--space-6);
}

@media (min-width: 768px) {
  .detail-header {
    flex-direction: row;
    text-align: left;
  }
}

.detail-header__info {
  flex: 1;
  min-width: 0;
}

.detail-header__title {
  font-size: var(--text-2);
  font-weight: var(--font-extrabold);
  margin: 0 0 0.3rem;
  overflow-wrap: break-word;
}

.detail-header__subtitle {
  color: var(--text-muted);
  font-size: var(--text-6);
}

/* ===== Detail list (dl) ===== */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-4);
  font-size: var(--text-7);
  align-items: baseline;
}

.detail-list dt {
  color: var(--muted-foreground);
}

.detail-list dd {
  margin: 0;
}

.detail-list dd .badge {
  vertical-align: baseline;
}

/* ===== Badge color modifiers ===== */
.badge--legendary { background-color: #F6E05E; color: #744210; }
.badge--mythical { background-color: #D6BCFA; color: #44337A; }
.badge--baby { background-color: #FED7E2; color: #97266D; }

.badge--hidden {
  border-style: dashed;
  opacity: 0.8;
}

/* ===== Species flavor text ===== */
.species-flavor-text {
  background: var(--bg-card);
  border-radius: var(--radius-large);
  padding: var(--space-6);
  padding-left: var(--space-8);
  border-left: 4px solid var(--primary);
  font-size: var(--text-6);
  font-style: italic;
  color: var(--text);
  margin: 0;
  position: relative;
}

.species-flavor-text::before {
  content: "\201C";
  position: absolute;
  top: var(--space-2);
  left: var(--space-3);
  font-size: 2.5rem;
  line-height: 1;
  color: var(--primary);
  opacity: 0.3;
  font-style: normal;
}

/* ===== Species color swatch ===== */
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.3rem;
  border: 1px solid var(--border);
}

/* Species body color variables */
:root {
  --species-color-black: #333333;
  --species-color-blue: #6390F0;
  --species-color-brown: #A0522D;
  --species-color-gray: #A8A8A8;
  --species-color-green: #7AC74C;
  --species-color-pink: #F4BDC9;
  --species-color-purple: #A33EA1;
  --species-color-red: #E53E3E;
  --species-color-white: #F5F5F5;
  --species-color-yellow: #F7D02C;
}



/* ===== Matchup groups ===== */
.matchup-group {
  margin-bottom: 0;
}

.matchup-group__label {
  font-weight: var(--font-bold);
  font-size: var(--text-7);
  margin-bottom: 0.4rem;
}

.matchup-group__types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.matchup-label--weak { color: var(--danger); }
.matchup-label--resist { color: var(--success); }
.matchup-label--immune { color: var(--foreground); font-weight: var(--font-black); }

/* ===== Type hero banner ===== */
.type-hero {
  padding: var(--space-8);
  border-radius: var(--radius-large);
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  margin-bottom: var(--space-6);
  background: var(--primary);
}

.type-hero__name {
  font-size: var(--text-1);
  font-weight: var(--font-extrabold);
  line-height: 1.2;
}

.type-hero__count {
  font-size: var(--text-7);
  opacity: 0.85;
  margin-top: 0.3rem;
}

/* ===== Type matchup panels ===== */
.type-matchups {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

@media (min-width: 640px) {
  .type-matchups {
    grid-template-columns: 1fr 1fr;
  }
}

.type-matchup-row__label {
  font-size: var(--text-7);
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

/* ===== Detail header logo ===== */
.detail-header__logo {
  max-width: 200px;
  height: auto;
}

.series-logo {
  max-width: 120px;
  height: auto;
}

/* ===== Set symbol icon ===== */
.set-symbol-icon {
  height: 16px;
  vertical-align: middle;
}

/* ===== Evolution explorer item ===== */
.evo-explorer__item--compact {
  padding: var(--space-3);
}

/* ===== Card detail layout ===== */
.card-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .card-detail {
    flex-direction: row;
    align-items: flex-start;
  }
}

.card-detail__image {
  flex-shrink: 0;
}

.card-detail__image img {
  width: 100%;
  max-width: 350px;
  aspect-ratio: 63 / 88;
  object-fit: contain;
  border-radius: var(--radius-large);
  margin: 0 auto;
  display: block;
  background: var(--border);
}

.card-detail__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

/* ===== Card sections ===== */
.card--sectioned {
  padding: 0;
}

.card-section {
  padding: var(--space-6);
}

.card-section + .card-section,
.card-section + .card-action {
  border-top: 1px solid var(--border);
}

.card--sectioned .card-action {
  margin: 0;
}

/* ===== Card list (divided items within a section) ===== */
.card-list > * + * {
  border-top: 1px solid var(--border);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}

/* ===== Attack list ===== */

.attack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.attack-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.attack-name {
  font-weight: var(--font-bold);
  font-size: var(--text-6);
  overflow-wrap: break-word;
}

.attack-damage {
  font-weight: var(--font-bold);
  font-size: var(--text-4);
  color: var(--primary);
}

.attack-cost {
  display: flex;
  gap: 0.2rem;
  margin-right: 0.5rem;
}

.energy-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,0.1);
  font-size: 0.6rem;
  font-weight: var(--font-bold);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  line-height: 1;
}

.energy-icon--normal { background: var(--type-normal); }
.energy-icon--fire { background: var(--type-fire); }
.energy-icon--water { background: var(--type-water); }
.energy-icon--electric { background: var(--type-electric); color: #333; text-shadow: none; }
.energy-icon--grass { background: var(--type-grass); }
.energy-icon--psychic { background: var(--type-psychic); }
.energy-icon--fighting { background: var(--type-fighting); }
.energy-icon--dark { background: var(--type-dark); }
.energy-icon--steel { background: var(--type-steel); color: #333; text-shadow: none; }
.energy-icon--dragon { background: var(--type-dragon); }
.energy-icon--fairy { background: var(--type-fairy); }

.attack-description {
  color: var(--text-muted);
  font-size: var(--text-7);
  margin-top: 0.3rem;
}

/* ===== Set list ===== */
.set-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-medium);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition-fast);
}

.set-item:hover {
  background: var(--border);
}

.set-item__logo {
  width: 100px;
  height: auto;
  flex-shrink: 0;
  object-fit: contain;
  max-width: 100%;
}

.set-item__info {
  flex: 1;
  min-width: 0;
}

.set-item__name {
  font-weight: var(--font-semibold);
  overflow-wrap: break-word;
}

.set-item__meta {
  font-size: var(--text-7);
  color: var(--text-muted);
}

/* Vertical stack when set-items are inside a responsive grid */
.grid-responsive .set-item {
  flex-direction: column;
  text-align: center;
}

.grid-responsive .set-item__logo {
  width: 80px;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: var(--space-12);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--text-7);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Pagination ===== */
.pagy {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin: var(--space-8) 0;
  flex-wrap: wrap;
}

.pagy a, .pagy em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-medium);
  text-decoration: none;
  font-weight: var(--font-medium);
  font-size: var(--text-7);
}

.pagy a {
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.pagy a:hover {
  background: var(--border);
}

.pagy a[aria-disabled] {
  opacity: 0.4;
  pointer-events: none;
}

.pagy em {
  background: var(--primary);
  color: #fff;
  font-style: normal;
  border: 1px solid var(--primary);
}

/* ===== Hero section ===== */
.hero {
  text-align: center;
  padding: 0 0;
}

.hero__title {
  font-size: var(--text-1);
  font-weight: var(--font-extrabold);
  margin-bottom: var(--space-2);
}

@media (min-width: 768px) {
  .hero__title {
    font-size: 2.5rem;
  }
}

.hero__subtitle {
  color: var(--text-muted);
  font-size: var(--text-5);
  margin-bottom: var(--space-6);
}

/* ===== Generation hero number ===== */
.gen-hero-number {
  font-size: var(--text-hero);
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF5F5;
  border-radius: var(--radius-large);
  flex-shrink: 0;
}

/* ===== Type filter chips ===== */
.chip.type-color--normal,
.chip.type-color--fire,
.chip.type-color--water,
.chip.type-color--electric,
.chip.type-color--grass,
.chip.type-color--ice,
.chip.type-color--fighting,
.chip.type-color--poison,
.chip.type-color--ground,
.chip.type-color--flying,
.chip.type-color--psychic,
.chip.type-color--bug,
.chip.type-color--rock,
.chip.type-color--ghost,
.chip.type-color--dragon,
.chip.type-color--dark,
.chip.type-color--steel,
.chip.type-color--fairy {
  border-color: transparent;
}

.chip[aria-pressed="true"][class*="type-color--"] {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

.type-distribution__count {
  font-weight: var(--font-normal);
  opacity: 0.8;
}

/* ===== Card overrides & hover lift ===== */
.card {
  border-radius: var(--radius-large);
}

a.card {
  text-decoration: none;
  color: var(--text);
}

.hover-lift {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-large);
}

/* ===== Filter select ===== */
.filter-select {
  min-width: 140px;
  max-width: 100%;
}

/* ===== Small screen fallback ===== */
@media (max-width: 374px) {
  .grid-responsive {
    grid-template-columns: 1fr;
  }
}

/* ===== Page stack ===== */
.page-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ===== Accordion content ===== */
.accordion-content {
  padding: var(--space-1) var(--space-2) var(--space-2);
}

/* ===== Form switcher ===== */
.form-switcher {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: center;
  flex-wrap: wrap;
}

.form-switcher::-webkit-scrollbar {
  display: none;
}

.form-switcher__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-large);
  text-decoration: none;
  color: var(--text-muted);
  font-size: var(--text-7);
  font-weight: var(--font-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
  border: 2px solid transparent;
}

.form-switcher__item:hover {
  background: var(--border);
  color: var(--text);
}

.form-switcher__item--active {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--primary);
}

.form-switcher__sprite {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

/* ===== Card footer link ===== */
.card-action {
  margin: var(--space-4) calc(var(--space-6) * -1) calc(var(--space-6) * -1);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-large) var(--radius-large);
  overflow: hidden;
}

.card-action > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  text-decoration: none;
  color: var(--foreground);
  font-weight: var(--font-medium);
  font-size: var(--text-6);
  transition: background var(--transition-fast), color var(--transition-fast);
  min-height: 44px;
}

.card-action > a:hover {
  background: var(--accent);
  color: var(--foreground);
}

.card-action__arrow {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--muted-foreground);
  transition: transform var(--transition-fast);
}

.card-action > a:hover .card-action__arrow {
  transform: translateX(3px);
  color: var(--foreground);
}

/* ===== Utility ===== */

/* ===== Search results section header ===== */
.search-results-section__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: var(--space-8) 0 var(--space-2);
}

.search-results-section__header:first-child {
  margin-top: 0;
}

/* ===== Utility ===== */

.text-muted { color: var(--text-muted); }
.flex-wrap { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.flex-wrap--center { justify-content: center; }
.text-italic { font-style: italic; }
