/* ============================================================================
 * pokemon-profile.css
 * Click a Pokémon card on a Field Guide page → modal opens with toggleable
 * sprite (pixel/3D/artwork × regular/shiny), cry playback, and stat info.
 * The modal markup lives at the bottom of every story page (rendered once
 * by story.html), and the JS in /js/pokemon-profile.js wires the toggles.
 * ============================================================================ */

/* Make the existing PokéScribe stats-card sprite clickable + give it a hover
   affordance so users know it opens a profile. */
.ps-tile [data-pokemon-id],
.pokemon-stat-card [data-pokemon-id],
.fg-pokemon-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  display: block;
}
.ps-tile [data-pokemon-id]:hover,
.pokemon-stat-card [data-pokemon-id]:hover,
.fg-pokemon-clickable:hover {
  transform: scale(1.04);
  filter: drop-shadow(0 8px 24px rgba(255, 106, 0, 0.35));
}
.ps-tile [data-pokemon-id]::after,
.fg-pokemon-clickable::after {
  /* No content — keep it minimal so the existing card layout isn't disrupted */
}

/* Modal backdrop */
.pp-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 14, 0.82);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.pp-modal[data-open="true"] {
  display: flex;
}

/* Card-shaped panel */
.pp-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(135deg, rgba(22,28,44,0.96) 0%, rgba(15,18,28,1) 100%);
  border: 1px solid rgba(255,106,0,0.32);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
  padding: 28px;
  position: relative;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.pp-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #f8f9fc;
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pp-close:hover {
  background: rgba(255,59,48,0.18);
  border-color: rgba(255,59,48,0.45);
}

/* Header: dex number + name + types */
.pp-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-right: 48px;
}
.pp-dex {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #ff6a00;
  text-transform: uppercase;
}
.pp-name {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 800;
  margin: 0;
  color: #f8f9fc;
  line-height: 1;
}
.pp-genus {
  color: rgba(248,249,252,0.52);
  font-size: 13px;
  font-style: italic;
  margin-top: 2px;
}
.pp-types {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

/* Sprite frame — robust centering for any sprite size (artwork ~475px,
 * pixel sprite 96×96, pokemon-home ~512px). Flex with min-* zero on the
 * image so it can shrink without overflowing, plus margin:auto for true
 * centering on both axes. */
.pp-sprite-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 280px;
  background:
    radial-gradient(circle at 50% 60%, rgba(255,106,0,0.18) 0%, rgba(255,255,255,0) 60%),
    rgba(255,255,255,0.04);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 14px;
  box-sizing: border-box;
}
.pp-sprite-frame img {
  display: block;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  image-rendering: -webkit-optimize-contrast;
}
/* Pixel sprites are tiny (typically 96×96) — scale them up so they fill
 * the frame instead of looking like a postage stamp lost in space. */
.pp-sprite-frame img[data-mode="pixel"] {
  image-rendering: pixelated;
  /* Force scale-up via width % so small sprites don't appear undersized.
   * The frame is 280px tall minus padding so 220px is comfortable. */
  height: 220px;
  width: auto;
}
/* Artwork sprites — let them fill to frame height with aspect preserved,
 * never exceed frame width. */
.pp-sprite-frame img[data-mode="artwork"] {
  max-height: 100%;
  max-width: 88%;
}

/* Toggle controls */
.pp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.pp-toggle-group {
  display: inline-flex;
  background: rgba(8,9,14,0.6);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 4px;
}
.pp-toggle-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: rgba(248,249,252,0.62);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  font-family: inherit;
}
.pp-toggle-btn:hover {
  color: #f8f9fc;
}
.pp-toggle-btn[aria-pressed="true"] {
  background: linear-gradient(135deg, #ff6a00, #ff3b30);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255,106,0,0.32);
}

.pp-cry-btn {
  appearance: none;
  background: rgba(173,255,47,0.1);
  border: 1px solid rgba(173,255,47,0.32);
  color: #adff2f;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: background 0.12s ease;
}
.pp-cry-btn:hover {
  background: rgba(173,255,47,0.22);
}
.pp-cry-btn[data-playing="true"] {
  background: rgba(173,255,47,0.32);
  animation: pp-pulse 1s ease-in-out infinite;
}
@keyframes pp-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(173,255,47,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(173,255,47,0); }
}

/* Info grid */
.pp-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.pp-info-tile {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 12px;
}
.pp-info-tile .lbl {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(248,249,252,0.42);
  margin-bottom: 4px;
}
.pp-info-tile .val {
  font-size: 14px;
  font-weight: 700;
  color: #f8f9fc;
}

/* Stat bars */
.pp-stats {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: rgba(8,9,14,0.5);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
}
.pp-stat-row {
  display: grid;
  grid-template-columns: 56px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.pp-stat-row .lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(248,249,252,0.62);
  text-transform: uppercase;
}
.pp-stat-row .bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.pp-stat-row .fill {
  height: 100%;
  background: linear-gradient(90deg, #ff3b30, #ff6a00);
  border-radius: inherit;
}
.pp-stat-row .val {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  color: #f8f9fc;
}

/* Flavor text */
.pp-flavor {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(248,249,252,0.78);
  font-style: italic;
  border-left: 3px solid rgba(255,106,0,0.4);
  padding: 4px 0 4px 14px;
  margin-bottom: 12px;
}

/* Footer attribution */
.pp-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
  text-align: right;
}
.pp-attribution {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(248,249,252,0.32);
}

/* Loading + error states */
.pp-loading,
.pp-error {
  text-align: center;
  padding: 40px 0;
  color: rgba(248,249,252,0.52);
  font-size: 14px;
}
