/* ============================================================
   Base — CSS reset, variables, typography
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&family=Press+Start+2P&display=swap');

:root {
  /* ── Pokemon Red/Blue Palette ───────────────────────── */
  --color-bg:          #F5F0E8;
  --color-surface:     #FFFDF7;
  --color-surface-2:   #FFF3E0;
  --color-primary:     #CC0000;
  --color-primary-dim: #A50000;
  --color-secondary:   #003A8C;
  --color-accent:      #FFD700;
  --color-accent-2:    #78C850;
  --color-text:        #1A1A2E;
  --color-text-muted:  #6B6B8A;
  --color-border:      #1A1A2E;
  --color-success:     #38A169;
  --color-danger:      #CC0000;
  --color-warning:     #D69E2E;

  /* ── Pixel Art Border System ───────────────────────── */
  --pixel-border:      3px solid #1A1A2E;
  --pixel-shadow:      4px 4px 0px #1A1A2E;
  --pixel-shadow-red:  4px 4px 0px #A50000;
  --pixel-shadow-blue: 4px 4px 0px #002060;
  --pixel-shadow-gold: 4px 4px 0px #B8860B;

  /* ── Layout ─────────────────────────────────────────── */
  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    4px 4px 0px #1A1A2E;
  --shadow-hover: 6px 6px 0px #1A1A2E;
  --transition: 0.15s ease;

  /* ── Pokemon Type Colors ────────────────────────────── */
  --type-normal:   #a8a878;
  --type-fire:     #f08030;
  --type-water:    #6890f0;
  --type-electric: #f8d030;
  --type-grass:    #78c850;
  --type-ice:      #98d8d8;
  --type-fighting: #c03028;
  --type-poison:   #a040a0;
  --type-ground:   #e0c068;
  --type-flying:   #a890f0;
  --type-psychic:  #f85888;
  --type-bug:      #a8b820;
  --type-rock:     #b8a038;
  --type-ghost:    #705898;
  --type-dragon:   #7038f8;
  --type-dark:     #705848;
  --type-steel:    #b8b8d0;
  --type-fairy:    #ee99ac;
}

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

html { font-size: 16px; }

body {
  font-family: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
  position: relative;
}

/* ── Scanline overlay ───────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    transparent 0px, transparent 1px,
    rgba(0, 0, 0, 0.025) 2px, rgba(0, 0, 0, 0.025) 2px
  );
  pointer-events: none;
  z-index: 9998;
}

a { color: var(--color-secondary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--color-primary); }

h1, h2, h3, h4 {
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  font-weight: 400;
  line-height: 1.2;
  color: var(--color-text);
}

/* ── Pixel Box Utilities ─────────────────────────────────── */
.pixel-box {
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow);
  background: var(--color-surface);
}

.pixel-box-red {
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow-red);
  background: var(--color-surface);
}

.pixel-box-blue {
  border: var(--pixel-border);
  box-shadow: var(--pixel-shadow-blue);
  background: var(--color-surface);
}

/* ── Dialogue Box (Pokemon style) ───────────────────────── */
.dialogue-box {
  border: 4px solid #1A1A2E;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.6),
    inset -2px -2px 0 rgba(0,0,0,0.15),
    4px 4px 0 #1A1A2E;
  background: #F5F0E8;
  font-family: 'Nunito', sans-serif;
  border-radius: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: 3px solid #1A1A2E;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 700;
  font-family: 'Fredoka One', 'Nunito', sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  background: var(--color-primary);
  color: #FFFDF7;
  box-shadow: var(--pixel-shadow-red);
  text-transform: uppercase;
  position: relative;
}
button:hover, .btn:hover {
  background: var(--color-primary-dim);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px #A50000;
}
button:active, .btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #A50000;
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-secondary);
  border: 3px solid #1A1A2E;
  box-shadow: var(--pixel-shadow);
}
.btn-secondary:hover {
  background: #FFE4B5;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px #1A1A2E;
}
.btn-secondary:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #1A1A2E;
}

.btn-success {
  background: var(--color-success);
  box-shadow: 4px 4px 0px #276749;
}
.btn-success:hover { background: #276749; box-shadow: 5px 5px 0px #276749; }
.btn-success:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #276749; }

.btn-danger {
  background: var(--color-danger);
  box-shadow: var(--pixel-shadow-red);
}

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.btn-accent {
  background: var(--color-accent);
  color: #1A1A2E;
  box-shadow: var(--pixel-shadow-gold);
  border-color: #1A1A2E;
}
.btn-accent:hover { background: #E6C200; box-shadow: 5px 5px 0px #B8860B; }
.btn-accent:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #B8860B; }

/* ── Inputs ──────────────────────────────────────────────── */
input, textarea, select {
  background: var(--color-surface);
  border: 3px solid #1A1A2E;
  border-radius: var(--radius);
  color: var(--color-text);
  padding: 9px 14px;
  font-size: 0.95rem;
  font-family: 'Nunito', inherit;
  width: 100%;
  outline: none;
  box-shadow: 2px 2px 0 #1A1A2E;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-secondary);
  box-shadow: 3px 3px 0 var(--color-secondary);
}
input::placeholder { color: var(--color-text-muted); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 3px solid #1A1A2E;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--pixel-shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card-hover:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 2px solid #1A1A2E;
  box-shadow: 2px 2px 0 #1A1A2E;
}

/* Level badge — Press Start 2P */
.badge-level, .badge-pixel, .pixel-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  line-height: 1.6;
}

.type-badge {
  color: #fff;
  border: 2px solid rgba(0,0,0,0.3);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}
.type-badge.normal   { background: var(--type-normal); color: #fff; }
.type-badge.fire     { background: var(--type-fire); }
.type-badge.water    { background: var(--type-water); }
.type-badge.electric { background: var(--type-electric); color: #333; }
.type-badge.grass    { background: var(--type-grass); }
.type-badge.ice      { background: var(--type-ice); color: #333; }
.type-badge.fighting { background: var(--type-fighting); }
.type-badge.poison   { background: var(--type-poison); }
.type-badge.ground   { background: var(--type-ground); color: #333; }
.type-badge.flying   { background: var(--type-flying); }
.type-badge.psychic  { background: var(--type-psychic); }
.type-badge.bug      { background: var(--type-bug); }
.type-badge.rock     { background: var(--type-rock); }
.type-badge.ghost    { background: var(--type-ghost); }
.type-badge.dragon   { background: var(--type-dragon); }
.type-badge.dark     { background: var(--type-dark); }
.type-badge.steel    { background: var(--type-steel); color: #333; }
.type-badge.fairy    { background: var(--type-fairy); }

/* ── HP Bars (pixel style) ───────────────────────────────── */
.hp-bar-wrap {
  background: #5A4A3A;
  border: 2px solid #1A1A2E;
  border-radius: 3px;
  height: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.hp-bar {
  height: 100%;
  border-radius: 1px;
  transition: width 0.4s ease;
  image-rendering: pixelated;
}
.hp-bar.high   { background: linear-gradient(90deg, #38A169, #48BB78); }
.hp-bar.medium { background: linear-gradient(90deg, #D69E2E, #F6AD55); }
.hp-bar.low    { background: linear-gradient(90deg, #CC0000, #FC8181); }

/* ── Utility Classes ─────────────────────────────────────── */
.text-muted    { color: var(--color-text-muted); }
.text-center   { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Animations ──────────────────────────────────────────── */
.main-content > * {
  animation: fadeInUp 0.25s ease both;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sprite float — subtle idle animation for Pokemon */
@keyframes spriteFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}
.sprite-float {
  animation: spriteFloat 2s ease-in-out infinite;
}

/* Pixel pop — interactive feedback */
@keyframes pixelPop {
  0%   { transform: scale(0.85); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.pixel-pop {
  animation: pixelPop 0.25s ease forwards;
}

/* Modal animations */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center; justify-content: center;
  animation: backdropIn 0.18s ease;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--color-surface);
  border: 4px solid #1A1A2E;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 480px;
  width: 90%;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    6px 6px 0 #1A1A2E;
  position: relative;
  animation: modalIn 0.2s ease;
  overflow: hidden;
}
.modal-header {
  background: var(--color-secondary);
  color: #fff;
  padding: 12px 18px;
  font-family: 'Fredoka One', sans-serif;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #1A1A2E;
}
.modal-body { padding: 20px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1;
  border: 2px solid #1A1A2E;
  box-shadow: 2px 2px 0 #A50000;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.modal-close:hover {
  background: var(--color-primary-dim);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #A50000;
}
.modal-close:active { transform: translate(2px, 2px); box-shadow: none; }

/* ── Toasts ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--color-surface);
  border: 3px solid #1A1A2E;
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: var(--pixel-shadow);
  animation: slideIn 0.25s ease;
  max-width: 300px;
  color: var(--color-text);
  font-weight: 700;
  font-size: 0.88rem;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { border-left: 5px solid var(--color-success); }
.toast.error   { border-left: 5px solid var(--color-danger); }
.toast.info    { border-left: 5px solid var(--color-secondary); }
.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error   .toast-icon { color: var(--color-danger); }
.toast.info    .toast-icon { color: var(--color-secondary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Spinner ─────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid #1A1A2E;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); border-left: 2px solid #1A1A2E; }
::-webkit-scrollbar-thumb {
  background: var(--color-secondary);
  border: 2px solid #1A1A2E;
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

/* ── SVG icon alignment ──────────────────────────────────── */
.page-icon, .nav-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  flex-shrink: 0;
}
.page-icon { margin-right: 6px; }
