/* ---------------------------------------------------- */
/* 1. CSS 변수 (Custom Properties) 기반 테마 설정 */
/* ---------------------------------------------------- */

:root {
  /* 기본 (다크) 테마 변수 */
  --bg-color: linear-gradient(135deg, #1f1f2e 0%, #0a0a1a 100%);
  --container-bg: rgba(43, 43, 64, 0.95);
  --text-color: #f0f0f0;
  --secondary-text-color: #cccccc;
  --card-bg: linear-gradient(145deg, #303045 0%, #202035 100%);
  --card-border: rgba(249, 215, 28, 0.3);
  --input-bg: #303045;
  --input-border: #5a5a70;
  --input-text: #e0e0e0;
  --search-container-bg: rgba(40, 40, 60, 0.7);
  --flavor-text-bg: #e6f0ff;
  --flavor-text-color: #444;
  --flavor-text-border: #3d7dca;
  --modal-bg: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
  --modal-text-color: #333;
  --evo-stage-bg: linear-gradient(145deg, #404055 0%, #303045 100%);
}

/* 라이트 테마 설정 */
.light-mode {
  --bg-color: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
  --container-bg: rgba(255, 255, 255, 0.98);
  --text-color: #333;
  --secondary-text-color: #555;
  --card-bg: linear-gradient(145deg, #f0f0f0 0%, #ffffff 100%);
  --card-border: rgba(61, 125, 202, 0.3);
  --input-bg: #ffffff;
  --input-border: #a0a0a0;
  --input-text: #333;
  --search-container-bg: rgba(230, 230, 240, 0.9);
  --flavor-text-bg: #ffffff;
  --flavor-text-color: #333;
  --flavor-text-border: #ff6b6b;
  --modal-bg: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  --modal-text-color: #333;
  --evo-stage-bg: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
}

/* ---------------------------------------------------- */
/* 2. 일반 스타일 (변수 사용) */
/* ---------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Malgun Gothic", "Arial", sans-serif;
  padding: 20px;
  background: var(--bg-color);
  min-height: 100vh;
  color: var(--text-color);
  transition: background-color 0.5s;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background-color: var(--container-bg);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.5s, box-shadow 0.5s;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 4px solid #f9d71c;
  position: relative;
}

#themeToggleBtn {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 15px;
  font-size: 14px;
  background: linear-gradient(135deg, #3d7dca 0%, #295eaa 100%);
  color: white;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s;
  cursor: pointer;
  border: none;
  font-weight: bold;
  z-index: 100;
}

.light-mode #themeToggleBtn {
  background: linear-gradient(135deg, #ffae00 0%, #f9d71c 100%);
  color: #333;
}

h1 {
  color: #f9d71c;
  font-size: 38px;
  text-shadow: 0 0 15px rgba(249, 215, 28, 0.5);
  margin-bottom: 5px;
  font-weight: 800;
  letter-spacing: 2px;
}

.subtitle {
  color: var(--secondary-text-color);
  font-size: 22px;
  font-weight: 400;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.light-mode .subtitle {
  text-shadow: none;
}

#searchContainer {
  margin-bottom: 40px;
  text-align: center;
  background: var(--search-container-bg);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: background-color 0.5s;

  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

input {
  padding: 14px 20px;
  font-size: 17px;
  width: 350px;
  border: 2px solid var(--input-border);
  border-radius: 30px;
  outline: none;
  transition: all 0.3s;
  background-color: var(--input-bg);
  color: var(--input-text);
  flex-grow: 1;
  min-width: 250px;
}

input::placeholder {
  color: #a0a0b0;
}
.light-mode input::placeholder {
  color: #777;
}

input:focus {
  border-color: #f9d71c;
  box-shadow: 0 0 15px rgba(249, 215, 28, 0.5);
}
.light-mode input:focus {
  border-color: #3d7dca;
  box-shadow: 0 0 15px rgba(61, 125, 202, 0.5);
}

button {
  padding: 14px 28px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 30px;
  font-weight: bold;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}

#searchBtn {
  background: linear-gradient(135deg, #f9d71c 0%, #ffae00 100%);
  color: #1f1f2e;
  box-shadow: 0 4px 10px rgba(249, 215, 28, 0.4);
}

#searchBtn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(249, 215, 28, 0.6);
}

#clearBtn {
  background: linear-gradient(135deg, #3d7dca 0%, #295eaa 100%);
  color: white;
  box-shadow: 0 4px 10px rgba(61, 125, 202, 0.4);
}

#clearBtn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(61, 125, 202, 0.6);
}

#pokemonList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 25px;
  padding: 0;
  list-style: none;
  margin-bottom: 30px;
}

li {
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  min-height: 280px;
}

li::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(249, 215, 28, 0.1) 0%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.4s;
}

.light-mode li::before {
  background: radial-gradient(
    circle,
    rgba(61, 125, 202, 0.1) 0%,
    transparent 70%
  );
}

li:hover::before {
  opacity: 1;
}

li:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 15px 30px rgba(249, 215, 28, 0.2),
    0 0 15px rgba(249, 215, 28, 0.5);
  border-color: #f9d71c;
}
.light-mode li:hover {
  box-shadow: 0 15px 30px rgba(61, 125, 202, 0.2),
    0 0 15px rgba(61, 125, 202, 0.5);
  border-color: #3d7dca;
}

.pokemon-id {
  font-weight: 800;
  margin-bottom: 15px;
  color: #1f1f2e;
  font-size: 20px;
  background: linear-gradient(135deg, #f9d71c 0%, #ffae00 100%);
  padding: 6px 16px;
  border-radius: 15px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.pokemon-name {
  margin-top: 15px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.4;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 10;
}
.light-mode .pokemon-name {
  text-shadow: none;
}

.pokemon-name br {
  display: block;
  line-height: 1.3;
}

img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  image-rendering: pixelated;
}

li:hover img {
  transform: scale(1.2) rotate(5deg);
}

#loading {
  text-align: center;
  font-size: 20px;
  margin: 30px 0;
  color: #f9d71c;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(249, 215, 28, 0.5);
}
.light-mode #loading {
  color: #3d7dca;
  text-shadow: 0 0 5px rgba(61, 125, 202, 0.5);
}

#modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.9);
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(5px);
}

#modalContent {
  background: var(--modal-bg);
  color: var(--modal-text-color);
  padding: 40px;
  border-radius: 20px;
  width: 95%;
  max-width: 900px;
  max-height: 95vh;
  text-align: center;
  position: relative;
  overflow-y: auto;
  border: 5px solid #3d7dca;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#modalContent h2 {
  color: #3d7dca;
  margin-bottom: 10px;
  font-size: 36px;
  font-weight: 900;
}

#modalContent img {
  width: 180px;
  height: 180px;
  margin: 10px 20px;
  background: radial-gradient(
    circle,
    rgba(61, 125, 202, 0.1) 0%,
    transparent 70%
  );
  border-radius: 12px;
  padding: 15px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.2));
}

#closeModal {
  position: absolute;
  top: 15px;
  right: 25px;
  font-size: 40px;
  cursor: pointer;
  font-weight: 300;
  color: #ff6b6b;
  transition: transform 0.2s, color 0.2s;
  line-height: 1;
}

#closeModal:hover {
  transform: rotate(90deg) scale(1.1);
  color: #cc0000;
}

.type {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 25px;
  color: white;
  margin: 5px;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#flavorText {
  margin-top: 20px;
  line-height: 1.7;
  color: var(--flavor-text-color);
  font-size: 17px;
  padding: 20px;
  background-color: var(--flavor-text-bg);
  border-radius: 15px;
  border: 1px dashed var(--flavor-text-border);
  font-style: italic;
  text-align: left;
  white-space: pre-wrap;
  transition: background-color 0.5s;
}

/* ---------------------------------------------------- */
/* 3. 진화 단계 스타일 (Evolution Chain) */
/* ---------------------------------------------------- */

#evolutionContainer {
  margin: 30px 0;
  padding: 10px 0;
  border: none;
  background-color: transparent;
  box-shadow: none;
  overflow-x: hidden;
  white-space: nowrap;
}

#evolutionContainer h3 {
  display: none;
}

.evolution-chain {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  padding: 10px 0;
  gap: 5px;
}

.evo-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 5px;
  min-width: 80px;
  flex-shrink: 1;
  background: var(--evo-stage-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 5px 0;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}
.light-mode .evo-stage {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.evo-stage img {
  width: 70px;
  height: 70px;
  background: none;
  padding: 0;
  margin: 0;
}

.evo-name {
  font-weight: bold;
  font-size: 14px;
  margin-top: 3px;
  color: var(--text-color);
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  padding: 0 3px;
}
.light-mode .evo-name {
  color: var(--modal-text-color);
}

.evo-condition {
  display: none;
}

.evo-arrow {
  font-size: 20px;
  color: #999;
  margin: 0 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 10px;
  flex-shrink: 0;
}

/* 타입 색상 (나머지 타입 스타일은 그대로 유지) */
.type-grass {
  background: linear-gradient(135deg, #78c850 0%, #5ca935 100%);
}
.type-fire {
  background: linear-gradient(135deg, #f08030 0%, #e06020 100%);
}
.type-water {
  background: linear-gradient(135deg, #6890f0 0%, #4870d0 100%);
}
.type-bug {
  background: linear-gradient(135deg, #a8b820 0%, #8d9a1b 100%);
}
.type-normal {
  background: linear-gradient(135deg, #a8a878 0%, #8d8d5f 100%);
}
.type-electric {
  background: linear-gradient(135deg, #f8d030 0%, #ddb518 100%);
  color: #333;
}
.type-poison {
  background: linear-gradient(135deg, #a040a0 0%, #803280 100%);
}
.type-ground {
  background: linear-gradient(135deg, #e0c068 0%, #c9a84e 100%);
  color: #333;
}
.type-fairy {
  background: linear-gradient(135deg, #ee99ac 0%, #e57a91 100%);
}
.type-fighting {
  background: linear-gradient(135deg, #c03028 0%, #a01f18 100%);
}
.type-psychic {
  background: linear-gradient(135deg, #f85888 0%, #e03868 100%);
}
.type-rock {
  background: linear-gradient(135deg, #b8a038 0%, #9d8625 100%);
}
.type-ghost {
  background: linear-gradient(135deg, #705898 0%, #5a4278 100%);
}
.type-ice {
  background: linear-gradient(135deg, #98d8d8 0%, #78c0c0 100%);
  color: #333;
}
.type-dragon {
  background: linear-gradient(135deg, #7038f8 0%, #5520d8 100%);
}
.type-dark {
  background: linear-gradient(135deg, #705848 0%, #584030 100%);
}
.type-steel {
  background: linear-gradient(135deg, #b8b8d0 0%, #9898b0 100%);
  color: #333;
}
.type-flying {
  background: linear-gradient(135deg, #a890f0 0%, #8870d0 100%);
}

/* ---------------------------------------------------- */
/* 4. 미디어 쿼리 (반응형 디자인) */
/* ---------------------------------------------------- */
@media (max-width: 768px) {
  #themeToggleBtn {
    top: 10px;
    right: 10px;
    font-size: 12px;
    padding: 8px 12px;
  }

  h1 {
    font-size: 28px;
    letter-spacing: 1px;
  }
  .subtitle {
    font-size: 18px;
  }

  .container {
    padding: 20px 15px;
    margin-top: 40px;
  }

  #searchContainer {
    padding: 15px;
    flex-direction: column;
    gap: 15px;
  }

  input {
    width: 100%;
    min-width: unset;
    margin: 0;
  }

  #searchBtn,
  #clearBtn {
    width: 48%;
    padding: 12px;
    margin: 0;
  }

  #searchBtn {
    margin-right: 2%;
  }
  #clearBtn {
    margin-left: 2%;
  }

  #searchBtn,
  #clearBtn {
    width: 100%;
    margin: 0;
  }

  #pokemonList {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }
  li {
    min-height: 250px;
  }
}
