/* ============================================================
   KINGDOM · Razas — Pantalla de Creación de Personaje (Diegética)
   Estética auténtica Dark Fantasy Lineage 2
   ============================================================ */

.section-races {
  padding: 0;
  overflow: hidden;
  background: var(--bg-0);
  position: relative;
}

/* Encabezado noble compacto */
.races-head {
  padding: 48px 0 22px;
}

.races-head .section-kicker {
  color: var(--gold-dim);
  letter-spacing: 0.28em;
}

.races-head .section-title {
  background: linear-gradient(180deg, #fff7d6 0%, #d4af37 60%, #8c6d23 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.8);
}

/* Marco contenedor principal de la pantalla de razas */
.race-screen {
  position: relative;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  min-height: 640px;
  border-top: 2px solid var(--gold-shadow);
  border-bottom: 2px solid var(--gold-shadow);
  background: radial-gradient(ellipse 100% 100% at 50% 50%, #16120b 0%, #080604 100%);
  box-shadow: inset 0 20px 40px -15px #000, inset 0 -20px 40px -15px #000;
}

/* ============================================================
   VIEWPORT DEL PERSONAJE (LADO IZQUIERDO)
   ============================================================ */
.race-viewport {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 640px;
  background: #090705;
}

/* Atmósfera elemental dinámica */
.race-ambient {
  position: absolute;
  inset: 0;
  transition: background 0.6s ease;
  background: radial-gradient(85% 75% at 50% 35%, var(--ra-1, #3c2a12), var(--ra-2, #0c0804) 80%);
}

.race-ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('../assets/images/backgrounds/bg-texture-stone.webp');
  background-size: 512px;
  opacity: 0.16;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.race-ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--race-bg, none);
  background-size: cover;
  background-position: center 30%;
  opacity: 0.18;
  filter: saturate(0.7) brightness(0.65);
  mix-blend-mode: luminosity;
  transition: background-image 0.6s ease;
  pointer-events: none;
}

/* Haz de luz volumétrico superior */
.race-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 65% 55% at 50% 18%, var(--ra-glow, #e2b855) 0%, transparent 72%);
  opacity: 0.32;
  mix-blend-mode: screen;
  transition: background 0.6s ease;
}

/* Marca de agua monumental con el nombre de la raza */
.race-name-flash {
  position: absolute;
  top: 32px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  font-family: var(--f-display);
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ra-glow, #e2b855);
  opacity: 0.09;
  text-shadow: 0 0 35px var(--ra-glow, #e2b855);
  transition: color 0.6s ease, text-shadow 0.6s ease;
}

/* ============================================================
   CÍRCULO DE INVOCACIÓN RÚNICO (PEDESTAL 3D)
   ============================================================ */
.summon-circle {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 78%);
  aspect-ratio: 2.7 / 1;
  pointer-events: none;
  z-index: 2;
}

.summon-circle .pool {
  position: absolute;
  inset: 12% 8%;
  border-radius: 50%;
  transform: rotateX(65deg);
  background: radial-gradient(circle, var(--ra-glow, #e2b855) 0%, rgba(0, 0, 0, 0.8) 75%);
  opacity: 0.42;
  filter: blur(8px);
  transition: background 0.6s ease;
}

.summon-circle .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: rotateX(65deg);
  border: 2px solid var(--ra-glow, #e2b855);
  box-shadow: 0 0 32px 3px var(--ra-glow, #e2b855), inset 0 0 25px var(--ra-glow, #e2b855);
  opacity: 0.62;
  transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

.summon-circle .runes {
  position: absolute;
  inset: -8% -3%;
  border-radius: 50%;
  transform: rotateX(65deg);
  animation: circleSpin 36s linear infinite;
  filter: drop-shadow(0 0 6px var(--ra-glow, #e2b855));
  transition: filter 0.6s ease;
}

.summon-circle .runes svg {
  width: 100%;
  height: 100%;
  opacity: 0.75;
}

@keyframes circleSpin {
  to {
    transform: rotateX(65deg) rotate(360deg);
  }
}

/* ============================================================
   RENDER DE PERSONAJE DE CUERPO ENTERO
   ============================================================ */
.race-figure {
  position: relative;
  z-index: 3;
  height: 520px;
  margin-bottom: 82px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.race-figure img {
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 30px var(--ra-glow, #e2b855));
  user-select: none;
  pointer-events: none;
  transition: filter 0.6s ease;
}

/* Sombra de contacto realista en el suelo */
.race-figure::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.85) 0%, transparent 75%);
  filter: blur(5px);
  z-index: -1;
  pointer-events: none;
}

/* Animación de entrada al cambiar raza */
.race-figure.is-out {
  opacity: 0;
  transform: translateY(14px) scale(0.975);
}

/* ============================================================
   SELECTOR DE MEDALLONES HERÁLDICOS (ALTAR INFERIOR)
   ============================================================ */
.race-selector {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 0 16px;
}

.race-medal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--parch-dim);
  transition: transform 0.25s ease;
}

.race-medal .disc {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gold-shadow);
  background: radial-gradient(circle at 50% 30%, #2a2014, #080604);
  box-shadow: inset 0 0 14px #000, 0 8px 18px -4px rgba(0, 0, 0, 0.85);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.race-medal .disc img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  filter: saturate(0.9) contrast(1.05);
}

.race-medal .disc::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(244, 220, 148, 0.18);
}

.race-medal .m-name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.25s, text-shadow 0.25s;
}

.race-medal:hover:not(.is-active) .disc {
  transform: translateY(-2px);
  border-color: var(--gold);
}

.race-medal:hover:not(.is-active) .m-name {
  color: var(--gold-dim);
}

.race-medal.is-active .disc {
  border-color: var(--ra-glow, #e2b855);
  box-shadow: 0 0 20px var(--ra-glow, #e2b855), inset 0 0 10px #000;
  transform: translateY(-4px) scale(1.06);
}

.race-medal.is-active .m-name {
  color: var(--gold-bright);
  font-weight: 800;
  text-shadow: 0 0 8px var(--ra-glow, #e2b855);
}

.race-medal.is-active::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--ra-glow, #e2b855);
}

/* ============================================================
   HUD DE ATRIBUTOS DIEGÉTICO (LADO DERECHO)
   ============================================================ */
.race-hud {
  position: relative;
  z-index: 4;
  padding: 38px 40px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(180deg, rgba(20, 15, 10, 0.97), rgba(10, 7, 5, 0.99));
  border-left: 2px solid var(--gold-shadow);
  box-shadow: inset 2px 0 0 rgba(244, 220, 148, 0.08), -15px 0 35px rgba(0, 0, 0, 0.6);
}

/* Remaches decorativos en esquinas del HUD */
.race-hud::before {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a3a22;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.5), 0 1px 3px #000;
}

.race-hud::after {
  content: "";
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a3a22;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.5), 0 1px 3px #000;
}

/* Cabecera del HUD */
.race-hud-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 6px;
}

.race-crest {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--ra-glow, #e2b855);
  background: radial-gradient(circle at 50% 30%, #2a2014, #080604);
  box-shadow: 0 0 20px -3px var(--ra-glow, #e2b855), inset 0 0 12px #000;
  color: var(--ra-glow, #e2b855);
  transition: border-color 0.5s, box-shadow 0.5s, color 0.5s;
}

.race-crest .icon {
  width: 26px;
  height: 26px;
}

.race-hud h3 {
  font-family: var(--f-display);
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--gold-bright);
  line-height: 1.1;
  margin: 0 0 4px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

.race-role {
  display: inline-block;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ra-glow, #e2b855);
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(244, 220, 148, 0.2);
  border-radius: 2px;
  transition: color 0.5s, border-color 0.5s;
}

/* Descripción de lore */
.race-desc {
  position: relative;
  color: var(--parch-2);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 14px 0 20px;
  min-height: 58px;
}

/* Títulos de sección internos del HUD */
.race-hud h4 {
  position: relative;
  font-family: var(--f-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.race-hud h4::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-shadow), transparent);
}

/* ============================================================
   BARRAS DE ATRIBUTOS ESTILO STATUS WINDOW L2
   ============================================================ */
.race-stats {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.stat-row {
  display: grid;
  grid-template-columns: 46px 1fr 32px;
  align-items: center;
  gap: 12px;
}

.stat-name {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  color: var(--gold-dim);
}

.stat-bar {
  position: relative;
  height: 10px;
  background: #0a0805;
  border: 1px solid #382b19;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.9);
}

.stat-fill {
  height: 100%;
  width: 0;
  border-radius: 1px;
  background: linear-gradient(90deg, #8a6522, var(--ra-glow, #e2b855));
  box-shadow: 0 0 10px var(--ra-glow, #e2b855);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1), background 0.5s;
}

.stat-val {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gold-bright);
  text-align: right;
}

/* ============================================================
   CHIPS DE CLASES DESTACADAS
   ============================================================ */
.race-classes {
  position: relative;
}

.race-class-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.class-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--parch-2);
  background: linear-gradient(180deg, #241b10, #130f08);
  border: 1px solid var(--gold-shadow);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(244, 220, 148, 0.1), 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: border-color 0.25s, color 0.25s, transform 0.25s, box-shadow 0.25s;
  cursor: default;
}

.class-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  transform: rotate(45deg);
  background: var(--ra-glow, #e2b855);
  box-shadow: 0 0 6px var(--ra-glow, #e2b855);
  transition: background 0.5s;
}

.class-chip:hover {
  border-color: var(--gold);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 8px var(--ra-glow, #e2b855);
}

/* ============================================================
   RESPONSIVIDAD Y BREAKPOINTS
   ============================================================ */
@media (max-width: 960px) {
  .race-screen {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .race-viewport {
    min-height: 480px;
    height: 480px;
  }
  .race-figure {
    height: 380px;
    margin-bottom: 86px;
  }
  .race-hud {
    border-left: 0;
    border-top: 2px solid var(--gold-shadow);
    padding: 32px 24px;
  }
  .race-selector {
    gap: 10px;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0 16px;
    scrollbar-width: none;
  }
  .race-selector::-webkit-scrollbar {
    display: none;
  }
  .race-medal .disc {
    width: 54px;
    height: 54px;
  }
}

@media (max-width: 560px) {
  .races-head {
    padding: 36px 0 16px;
  }
  .race-viewport {
    min-height: 400px;
    height: 400px;
  }
  .race-figure {
    height: 310px;
    margin-bottom: 80px;
  }
  .race-hud {
    padding: 24px 16px;
  }
  .race-hud h3 {
    font-size: 1.6rem;
  }
  .race-desc {
    min-height: 0;
    font-size: 0.88rem;
  }
  .stat-row {
    grid-template-columns: 42px 1fr 28px;
    gap: 8px;
  }
  .class-chip {
    padding: 5px 9px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .summon-circle .runes {
    animation: none;
  }
  .race-figure {
    transition: opacity 0.2s;
  }
}
