/* =========================================================
   RESET & BASE
   ========================================================= */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, sans-serif;
  background-color: #0f0f14;
  color: #e8e8ed;
  line-height: 1.5;
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
}

/* =========================================================
   LAYOUT
   ========================================================= */

main {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  flex: 1;
}

.page-header {
  max-width: 900px;
  margin: 0 auto 2rem;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  color: #EF4444;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.5rem 0 0;
  color: #9a9aa5;
  font-size: 0.95rem;
}

.page-footer {
  max-width: 900px;
  margin: 3rem auto 0;
  padding-top: 1.5rem;
  text-align: center;
  color: #9a9aa5;
  font-size: 0.85rem;
}

/* =========================================================
   FORM / INPUTS
   ========================================================= */

.input-group {
  background-color: #1a1a23;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.input-group legend,
.input-group > label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.75rem;
  color: #e8e8ed;
  font-size: 0.95rem;
}

fieldset.input-group {
  /* fieldset defaults are weird — normalize them */
  border: 1px solid #2a2a35;
}

fieldset.input-group legend {
  /* position legend as a normal block heading inside the box */
  padding: 0;
}

fieldset.input-group label {
  display: block;
  font-weight: 400;
  margin: 0.4rem 0;
  cursor: pointer;
  color: #e8e8ed;
}

fieldset.input-group input[type="radio"] {
  accent-color: #EF4444;
  margin-right: 0.5rem;
}

#favorite-pokemon,
#favorite-type {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  background-color: #13131a;
  color: #e8e8ed;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  font-family: inherit;
}

#favorite-pokemon:focus,
#favorite-type:focus {
  outline: none;
  border-color: #EF4444;
}

#favorite-type:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =========================================================
   BUTTONS
   ========================================================= */

#build-team-btn {
  display: block;
  width: 100%;
  padding: 0.9rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
  background-color: #EF4444;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 1.5rem;
  font-family: inherit;
  transition: background-color 0.15s ease;
}

#build-team-btn:hover:not(:disabled) {
  background-color: #DC2626;
}

#build-team-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rebuild-btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #e8e8ed;
  background-color: transparent;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  margin-top: 1rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.rebuild-btn:hover {
  border-color: #EF4444;
  color: #EF4444;
}

/* =========================================================
   LOADING STATE (spinning Pokéball)
   ========================================================= */

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
  color: #9a9aa5;
}

.pokeball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #0f0f14;
  background:
    linear-gradient(to bottom, #EF4444 0%, #EF4444 50%, #ffffff 50%, #ffffff 100%);
  position: relative;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 0 2px #2a2a35;
}

.pokeball::before {
  /* the black center band */
  content: "";
  position: absolute;
  top: 50%;
  left: -3px;
  right: -3px;
  height: 4px;
  background: #0f0f14;
  transform: translateY(-50%);
}

.pokeball::after {
  /* the center button */
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 3px solid #0f0f14;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* =========================================================
   TEAM GRID & CARDS
   ========================================================= */

#team-output {
  min-height: 2rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pokemon-card {
  background-color: #1a1a23;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  animation: fade-in 0.4s ease forwards;
}

.pokemon-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border-color: #3a3a48;
}

.pokemon-sprite {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.pokemon-name {
  font-weight: 600;
  font-size: 1rem;
  margin: 0.5rem 0 0.5rem;
  color: #e8e8ed;
}

.pokemon-types {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.type-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  color: #0f0f14;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   EXPLANATION
   ========================================================= */

.team-explanation {
  background-color: #1a1a23;
  border: 1px solid #2a2a35;
  border-radius: 12px;
  padding: 1.25rem;
  line-height: 1.6;
  margin: 0;
  color: #9a9aa5;
  font-size: 0.95rem;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
  .team-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .team-grid {
    grid-template-columns: 1fr;
  }
  .page-header h1 {
    font-size: 1.75rem;
  }
  body {
    padding: 1rem;
  }
}
