/* ==========================================================================
   BASE.CSS - Variables, Reset, Typography, Header, Footer
   ========================================================================== */

/* CSS Variables */
:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-display: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --bg: #050b18;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.1);
  --text: rgba(255, 255, 255, 0.92);
  /* Hơi sáng hơn một chút so với trước — dễ đọc khi cỡ chữ nhỏ */
  --muted: rgba(255, 255, 255, 0.72);
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

/* Reset */
* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: hidden;
  /* 17px thay vì 16px mặc định → mọi đơn vị rem trên site lớn hơn ~6.25%, dễ đọc hơn */
  font-size: 17px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: linear-gradient(135deg, #050b18 0%, #0b1020 50%, #050b18 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text);
  position: relative;
  overflow-x: hidden;
  max-width: 100vw;
  line-height: 1.55;
}

/* Allow scrolling on detail page */
body:has(.detail-page) {
  overflow-y: auto;
  height: auto;
}

/* Background Pokeball */
body::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60vw;
  max-width: 800px;
  height: 60vw;
  max-height: 800px;
  background-image: url("https://www.nicepng.com/png/full/160-1602324_pokemon-ball-2d-png.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: blur(20px) brightness(0.5);
  opacity: 0.4;
  pointer-events: none;
  z-index: -1;
}

/* Links */
a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   LAYOUT CONTAINERS
   ========================================================================== */
.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.container.split-view-container {
  width: calc(100% - 32px);
  max-width: 100%;
}

main.container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Allow scrolling on detail page container */
main.container.detail-page {
  overflow-y: auto;
  overflow-x: hidden;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */
.h1 {
  margin: 0 0 8px;
  font-size: 1.95rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
  line-height: 1.3;
}

.muted {
  margin: 0;
  color: var(--muted);
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Screen-reader-only heading (e.g. Pokédex page title without duplicate visible chrome) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

/* Full-bleed ARCESYS bar + contained nav hub */
.site-header--unified {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
}

/* Nav row below shared ARCESYS bar — flex: scrollable pills + search pinned right (app pages only; LP hides .header-shell) */
.header-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 10px 12px;
  margin-top: 10px;
  padding: 8px 0 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.header-shell-search {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 10px 0 12px;
}

.header-shell-search__btn.global-search-trigger {
  gap: 10px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.78);
  font-family: inherit;
}

.header-shell-search__btn.global-search-trigger:hover {
  color: rgba(255, 255, 255, 0.95);
}

.header-shell-search__label {
  white-space: nowrap;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-tagline {
  margin: 0;
  text-align: left;
}

.header-actions {
  display: flex;
  align-items: center;
}

.global-search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 6px 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.global-search-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.search-icon-svg {
  width: 16px;
  height: 16px;
}

.search-shortcut {
  opacity: 0.7;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.site-nav-hub {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: flex-start;
  gap: 10px 12px;
  margin-top: 0;
  padding: 10px 0 12px;
  min-height: 54px;
  box-sizing: border-box;
}

/* Pill glass — cùng nhịp bo tròn / blur với landing .nav-pillar (20px radius) */
.site-nav-link {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  min-height: 44px;
  box-sizing: border-box;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition:
    color 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

/* Never use `font: inherit` here: shorthand resets font-size and pulls from <body>,
   beating .site-nav-link typography — Main Series looked visibly larger than sibling <a> pills. */
button.site-nav-link {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  text-align: center;
  border-style: solid;
  outline: none;
  box-shadow: none;
}

.site-nav-link:focus-visible {
  outline: 2px solid rgba(120, 180, 255, 0.55);
  outline-offset: 3px;
}

.site-nav-label {
  line-height: 1.2;
  white-space: nowrap;
}

/* Same asset treatment as landing .nav-pillar-icon-img */
.site-nav-icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.72;
  transition: opacity 0.2s ease;
}

.site-nav-icon-svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.72;
  color: rgba(255, 255, 255, 0.85);
  transition: opacity 0.2s ease, color 0.2s ease;
}

a.site-nav-link:hover,
button.site-nav-link:hover {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(100, 160, 255, 0.12);
  border-color: rgba(100, 160, 255, 0.35);
}

a.site-nav-link:hover .site-nav-icon-img,
a.site-nav-link:hover .site-nav-icon-svg,
button.site-nav-link:hover .site-nav-icon-img,
button.site-nav-link:hover .site-nav-icon-svg {
  opacity: 0.95;
}

.site-nav-link.is-active {
  color: #fff;
  background: rgba(100, 160, 255, 0.18);
  border-color: rgba(120, 180, 255, 0.45);
  box-shadow:
    0 0 14px rgba(80, 140, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.site-nav-link.is-active .site-nav-icon-img,
.site-nav-link.is-active .site-nav-icon-svg {
  opacity: 1;
}

/* Giống landing: tắt blur trên thiết bị cảm ứng — giữ pill, nhẹ GPU */
@media (hover: none), (pointer: coarse) {
  .site-nav-link {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 750;
  letter-spacing: 0.2px;
}

.header-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 50, 50, 0.5));
}

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

@media (max-width: 640px) {
  .header-tagline {
    width: 100%;
    text-align: left;
    font-size: 0.82rem;
  }
  .site-nav-hub {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px 10px;
    padding-top: 8px;
    padding-bottom: 10px;
    min-height: 50px;
    scrollbar-width: thin;
  }
  .site-nav-link {
    flex-shrink: 0;
    border-radius: 18px;
    padding: 9px 12px;
    min-height: 42px;
    gap: 7px;
    font-size: 0.64rem;
    letter-spacing: 0.09em;
  }
  .header-shell-search {
    padding: 10px 0;
  }
  .header-shell-search__btn.global-search-trigger {
    padding: 7px 10px;
    font-size: 0.72rem;
    gap: 8px;
  }
}

@media (max-width: 400px) {
  .header-shell {
    gap: 6px;
  }

  .site-nav-link {
    border-radius: 16px;
    padding: 8px 10px;
    min-height: 40px;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
  }

  .site-nav-icon-img,
  .site-nav-icon-svg {
    width: 20px;
    height: 20px;
  }
}

/*
 * App pages (nav + global search): mobile / narrow landscape — centered 3-column hub.
 * Col 1: National Pokédex, Poké Ball | Col 2: Main Series, Search | Col 3: Type Balance, Nature
 */
@media (orientation: landscape) and (max-width: 1024px) {
  .header-shell:has(.header-shell-search) {
    display: grid;
    grid-template-columns: max-content max-content max-content;
    justify-content: center;
    column-gap: 10px;
    row-gap: 10px;
    align-items: center;
    justify-items: center;
    flex-wrap: unset;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub {
    display: contents;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub > .site-nav-link:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub > .site-nav-link:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub > .site-nav-link:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub > .site-nav-link:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
  }

  .header-shell:has(.header-shell-search) .site-nav-hub > .site-nav-link:nth-child(5) {
    grid-column: 3;
    grid-row: 1;
  }

  .header-shell:has(.header-shell-search) .header-shell-search {
    grid-column: 2;
    grid-row: 2;
    padding-top: 0;
    padding-bottom: 0;
    align-self: center;
    justify-self: center;
  }
}

/* ==========================================================================
   POKÉMON SPRITE — Local-first with cloud fallback
   ========================================================================== */
.pkmn-sprite {
  object-fit: contain;
  transition: opacity 0.25s ease;
}
.pkmn-sprite:not([src=""]) {
  opacity: 1;
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty {
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
}
