/* Mapa de juegos (mapa.html). Usa los colores y la fuente de styles.css */

.map-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Cabecera ---------- */

.map-header {
  position: relative;
  padding: 32px 16px 8px;
  text-align: center;
}

.map-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.map-header p {
  margin: 8px auto 0;
  max-width: 40ch;
  opacity: .8;
  line-height: 1.5;
}

.map-back {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  color: var(--fg);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.map-back:hover {
  background: var(--fg);
  color: var(--ink);
}

.map-back:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

@media (max-width: 560px) {
  .map-header { padding-top: 64px; }
}

/* ---------- Mapa ---------- */

.map {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.map-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  /* Difuminar los bordes para que se note que hay más mapa a los lados */
  mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}

.map-viewport::-webkit-scrollbar { display: none; }

.map-viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.map-viewport.is-dragging .map-node-button,
.map-viewport.is-dragging .map-analysis { pointer-events: none; }

.map-track {
  position: relative;
  width: calc(var(--w, 1000) * 1px);
  height: calc(var(--h, 520) * 1px);
}

.map-path {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.map-path path {
  fill: none;
  stroke: var(--fg);
  stroke-width: 3;
  stroke-linecap: round;
}

.map-path-todo {
  stroke-dasharray: 2 12;
  opacity: .5;
}

.map-nodes {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Cambio de etapa ---------- */

/* El camino se corta y en el hueco queda un punto clicable. Al pulsarlo se
   explica por qué se paró la serie. */
.map-stage-dot {
  position: absolute;
  left: calc(var(--x) * 1px);
  top: calc(var(--y) * 1px);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.map-stage-dot::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 3px solid var(--fg);
  border-radius: 50%;
  background: var(--bg);
  transition: transform .15s ease, background-color .15s ease;
}

.map-stage-dot:hover::before,
.map-stage-dot:focus-visible::before {
  background: var(--fg);
  transform: scale(1.15);
}

.map-stage-dot:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* ---------- Paradas ---------- */

.map-node {
  --cover-h: 160px;
  position: absolute;
  left: calc(var(--x) * 1px - 90px);
  top: calc(var(--y) * 1px - var(--cover-h) / 2);
  width: 180px;
}

.map-node-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.map-node-button:focus-visible { outline: none; }

/* Enlace al análisis del canal principal, encima de la carátula. Es hermano
   del botón, no hijo: un enlace no puede ir dentro de un botón. */
.map-analysis {
  position: absolute;
  top: -40px;
  left: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 2px solid var(--fg);
  border-radius: 999px;
  background: var(--fg);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.2;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: transform .15s ease, background-color .15s ease;
}

.map-analysis[hidden] { display: none; }

.map-analysis:hover {
  background: #e6e6e6;
  transform: translateX(-50%) translateY(-2px);
}

.map-analysis:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 3px;
}

.map-cover {
  position: relative;
  display: block;
  width: 120px;
  height: var(--cover-h, 160px);
  overflow: hidden;
  border: 3px solid var(--fg);
  border-radius: 12px;
  background: #111;
  transition: transform .2s ease, box-shadow .2s ease;
}

.map-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.map-cover img[hidden] { display: none; }

.map-node-button:hover .map-cover,
.map-node-button:focus-visible .map-cover {
  transform: translateY(-4px) rotate(-2deg) scale(1.05);
  box-shadow: 0 10px 30px rgba(255, 255, 255, .15);
}

.map-node-button:focus-visible .map-cover {
  outline: 3px solid var(--fg);
  outline-offset: 4px;
}

/* Carátula provisional: degradado con el nombre del juego */
.map-cover-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 12px 10px 20px;
  background: linear-gradient(160deg, var(--c1, #222), var(--c2, #444));
  color: #fff;
  text-align: left;
}

.map-cover-placeholder[hidden] { display: none; }

.map-cover-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  overflow-wrap: anywhere;
}

.map-cover-note {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .75;
}

/* El próximo juego se ve más oscuro: todavía no se ha jugado. El borde y el
   nombre se atenúan lo justo para notarse sin perder legibilidad. */
.is-proximo .map-cover {
  border-color: rgba(255, 255, 255, .72);
}

.is-proximo .map-node-title {
  color: rgba(255, 255, 255, .82);
}

.is-proximo .map-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  pointer-events: none;
}

.is-proximo .map-cover-note { display: none; }

.map-node-title {
  margin-top: 4px;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
}

.map-node-date {
  font-size: 0.8125rem;
  opacity: .7;
}

/* ---------- Estados ---------- */

.map-node-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: -18px;
  padding: 2px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--fg);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  position: relative;
}

.map-node-status[data-status="jugando"] {
  background: var(--live);
  color: #fff;
}

.map-node-status[data-status="jugando"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: live-dot 1.2s ease-in-out infinite;
}

.map-node-status[data-status="proximo"] {
  background: #333;
  color: var(--fg);
}

/* Un juego dropeado se abandonó a medias: ámbar, ni hecho ni pendiente */
.map-node-status[data-status="dropeado"] {
  background: #ffc400;
  color: #2a1c00;
}

/* La carátula conserva el dibujo, pero pierde el color; al pasar por encima
   vuelve, porque sigue habiendo vídeos que ver */
.is-dropeado .map-cover img { filter: grayscale(.7); }

.is-dropeado .map-node-button:hover .map-cover img,
.is-dropeado .map-node-button:focus-visible .map-cover img {
  filter: none;
}

/* El juego actual, con borde rojo y brillo */
.is-jugando .map-cover {
  border-color: var(--live);
  animation: live-glow 2s ease-in-out infinite;
}

/* Foto de Joce X3 encima del juego actual */
.map-pin {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  animation: pin-bounce 2.4s ease-in-out infinite;
}

.map-pin img {
  border: 3px solid var(--fg);
  border-radius: 50%;
}

.map-pin::after {
  content: "";
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: var(--fg);
  margin-top: -2px;
}

@keyframes pin-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -6px); }
}

/* ---------- Controles y leyenda ---------- */

.map-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px 12px;
}

.map-arrow {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 2px solid var(--fg);
  border-radius: 50%;
  background: none;
  color: var(--fg);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, opacity .15s ease;
}

.map-arrow:hover:not(:disabled) {
  background: var(--fg);
  color: var(--ink);
}

.map-arrow:disabled {
  opacity: .3;
  cursor: default;
}

.map-arrow:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.map-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fg);
}

.dot-jugando { background: var(--live); }
.dot-dropeado { background: #ffc400; }
.dot-proximo { background: #333; border: 1px dashed var(--fg); }

/* Con cuatro botones y la leyenda en la misma fila, en móvil la leyenda baja a
   su propia línea y los botones quedan juntos */
@media (max-width: 560px) {
  .map-controls {
    flex-wrap: wrap;
    gap: 8px;
    row-gap: 12px;
  }

  .map-legend {
    order: 1;
    flex-basis: 100%;
  }
}

/* Aclaración de la leyenda: va debajo del mapa para no romper la fila de
   flechas en pantallas estrechas */
.map-legend-note {
  max-width: 62ch;
  margin: 0 auto 24px;
  padding: 0 16px;
  font-size: 0.75rem;
  font-style: italic;
  line-height: 1.6;
  text-align: center;
  text-wrap: pretty;
  opacity: .85;
}

/* ---------- Ficha del juego ---------- */

.game-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 2px solid #000;
  border-radius: var(--radius);
  /* La ficha va en blanco sobre el fondo rojo: texto negro y detalles oscuros */
  color-scheme: light;
  background: #fff;
  color: #000;
}

.game-dialog::backdrop {
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(4px);
}

.game-dialog[open] { animation: dialog-in .25s cubic-bezier(.2, .8, .2, 1); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
}

.game-dialog-inner {
  position: relative;
  display: flex;
  gap: 20px;
  padding: 24px;
}

.game-cover {
  --cover-h: 200px;
  flex: none;
  width: 150px;
}

.game-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.game-status { margin-top: 0; }

.game-info h2 {
  margin: 10px 0 4px;
  padding-right: 32px;
  font-size: 1.5rem;
  line-height: 1.15;
}

.game-meta {
  margin: 0;
  font-size: 0.875rem;
  opacity: .75;
}

.game-summary {
  margin: 12px 0 20px;
  line-height: 1.5;
}

.game-link {
  min-height: 48px;
  margin: auto 0 0;
  padding: 8px 24px;
  align-self: stretch;
  /* Los colores del enlace se invierten respecto a la web: negro sobre blanco */
  --fg: #000;
  --ink: #fff;
}

.game-link[hidden] { display: none; }

.game-close,
.stage-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(0, 0, 0, .35);
  border-radius: 50%;
  background: none;
  color: #000;
  cursor: pointer;
}

.game-close:hover,
.stage-close:hover { background: rgba(0, 0, 0, .08); }

.game-close:focus-visible,
.stage-close:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* ---------- Aviso de cambio de etapa ---------- */

.stage-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 2px solid #000;
  border-radius: var(--radius);
  /* Igual que la ficha: blanco sobre el fondo rojo */
  color-scheme: light;
  background: #fff;
  color: #000;
}

.stage-dialog::backdrop {
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(4px);
}

.stage-dialog[open] { animation: dialog-in .25s cubic-bezier(.2, .8, .2, 1); }

.stage-dialog-inner {
  position: relative;
  padding: 28px 24px;
}

.stage-dialog h2 {
  margin: 0 0 10px;
  padding-right: 32px;
  font-size: 1.25rem;
  line-height: 1.2;
}

.stage-dialog p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .game-dialog-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .game-info { align-items: center; }

  .game-info h2 { padding-right: 0; }
}

/* Con más contraste pedido por el sistema, no se atenúa nada */
@media (prefers-contrast: more) {
  .is-proximo .map-cover { border-color: var(--fg); }
  .is-proximo .map-node-title { color: var(--fg); }
  .is-dropeado .map-cover img { filter: none; }
  .map-legend-note { opacity: 1; }
}

@media (forced-colors: active) {
  .map-cover,
  .map-arrow,
  .game-dialog,
  .stage-dialog { border-color: CanvasText; }
  .map-path path { stroke: CanvasText; }
  .map-stage-dot::before {
    border-color: ButtonText;
    background: Canvas;
  }
  .map-stage-dot:hover::before,
  .map-stage-dot:focus-visible::before {
    background: Highlight;
  }
  .map-analysis {
    border-color: ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }
}
