/* =========================================================
   RatoLibre — Solitario FreeCell: estilos propios del juego
   Depende de ../../assets/css/base.css (tokens y clases) y de
   ../../assets/css/cartas.css (la baraja compartida).
   El ancho de las cartas (--carta-ancho) y el espacio entre columnas
   (--fc-hueco) los calcula juego.js según el ancho de la mesa.
   ========================================================= */

.fc-subtitulo {
  color: var(--muted);
  font-size: 1.1rem;
  margin-top: -0.2rem;
}

/* ---------- Número de partida (debajo de la mesa) ---------- */

.fc-partida {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 0 0 16px;
}

.fc-partida-numero {
  margin: 0;
  font-size: 1.1rem;
}

.fc-partida-numero strong {
  font-variant-numeric: tabular-nums;
}

.fc-partida-botones {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 12px;
}

.fc-partida-botones .btn {
  flex: 1 1 auto;
}

@media (min-width: 720px) {
  .fc-partida-botones {
    justify-content: flex-end;
  }

  .fc-partida-botones .btn {
    flex: 0 1 auto;
  }
}

/* ---------- Mesa ---------- */

.fc-area {
  --fc-tapete: #2f6f4e;
  --fc-tapete-oscuro: #24563d;
  --fc-oro: #ffd54a;

  position: relative;
  /* En el celular la mesa ocupa todo el ancho de la pantalla: así caben
     las 8 columnas con las cartas lo más grandes posible. */
  margin-left: -16px;
  margin-right: -16px;
  max-width: none;
  padding: 10px 1px 8px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  background: var(--fc-tapete);
  border-color: var(--fc-tapete-oscuro);
  /* Sin touch-action:none aquí: deslizar sobre el tapete o sobre cartas
     que no se pueden mover sigue desplazando la página. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.fc-tablero {
  --carta-ancho: 44px;
  --fc-hueco: 1px;
  --fc-alto: calc(var(--carta-ancho) * 1.5);
  --fc-radio: calc(var(--carta-ancho) * 0.08);
}

.fc-fila,
.fc-rotulos {
  display: grid;
  grid-template-columns: repeat(8, var(--carta-ancho));
  column-gap: var(--fc-hueco);
  justify-content: center;
}

.fc-rotulos {
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
}

.fc-rotulos span {
  grid-column: span 4;
  text-align: center;
  white-space: nowrap;
}

.fc-arriba {
  margin-bottom: 14px;
}

.fc-columnas {
  min-height: calc(var(--fc-alto) * 3.4);
}

/* Lugares vacíos: celdas, bases y columnas sin cartas */
.fc-hueco {
  position: relative;
  display: block;
  width: var(--carta-ancho);
  height: var(--fc-alto);
  margin: 0;
  padding: 0;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: var(--fc-radio);
  background: rgba(0, 0, 0, 0.12);
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.fc-base {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Con una carta encima, el contorno del hueco no debe asomar. */
.fc-hueco:not(.is-vacio) {
  border-color: transparent;
  background: none;
}

.fc-marca {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: calc(var(--carta-ancho) * 0.55);
  line-height: 1;
  pointer-events: none;
}

.fc-marca-roja {
  color: rgba(255, 205, 205, 0.85);
}

.fc-col {
  position: relative;
  min-height: var(--fc-alto);
}

.fc-vacia[hidden] {
  display: none;
}

/* ---------- Cartas (la baraja compartida dentro de un botón) ---------- */

.fc-carta {
  position: absolute;
  left: -2px;
  top: 0;
  display: block;
  width: var(--carta-ancho);
  height: var(--fc-alto);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--fc-radio);
  background: none;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Dentro de las columnas no hay borde de hueco que compensar. */
.fc-col > .fc-carta {
  left: 0;
}

.fc-hueco > .fc-carta {
  top: -2px;
}

/* Las cartas que se pueden arrastrar: ahí el navegador no debe
   interpretar el gesto como desplazamiento de la página. */
.fc-carta.fc-movible {
  touch-action: none;
}

.fc-carta .carta {
  display: block;
}

.fc-carta:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  z-index: 200 !important;
}

.fc-carta.fc-elegida .carta {
  box-shadow: 0 0 0 3px var(--fc-oro), 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* Las cartas elegidas se tiñen de dorado: así se distingue todo el grupo
   aunque las cartas estén encimadas. */
.fc-carta.fc-elegida::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--fc-radio);
  background: rgba(255, 213, 74, 0.3);
  box-shadow: inset 0 0 0 3px #d9a400;
  pointer-events: none;
}

.fc-carta.fc-arrastrada {
  opacity: 0.3;
}

.fc-carta.fc-volando {
  z-index: 300 !important;
}

/* Destino bajo la carta que se arrastra */
.fc-col.fc-sobre::after,
.fc-hueco.fc-sobre {
  box-shadow: 0 0 0 3px var(--fc-oro);
}

.fc-col.fc-sobre::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--fc-radio);
  pointer-events: none;
}

/* Pista: las cartas y el destino laten en dorado */
@keyframes fc-brillo {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 213, 74, 0); }
  50%      { box-shadow: 0 0 0 6px var(--fc-oro); }
}

@keyframes fc-latido {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

.fc-carta.fc-pista::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--fc-radio);
  background: rgba(255, 213, 74, 0.35);
  box-shadow: inset 0 0 0 3px #d9a400;
  pointer-events: none;
  animation: fc-latido 0.9s ease-in-out 3;
}

.fc-hueco.fc-pista {
  animation: fc-brillo 0.9s ease-in-out 3;
}

/* Capa que sigue al dedo o al ratón mientras se arrastra */
.fc-capa {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1050;
  width: var(--carta-ancho);
  pointer-events: none;
  will-change: transform;
}

.fc-capa .fc-carta {
  left: 0;
}

.fc-capa .carta {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.fc-capacidad {
  margin: 10px 12px 0;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* ---------- Botón para soltar la carta elegida ---------- */

.fc-cancelar {
  display: flex;
  width: 100%;
  max-width: 360px;
  margin: -4px auto 12px;
}

.fc-cancelar[hidden] {
  display: none;
}

/* ---------- Mensajes y marcador ---------- */

.fc-mensaje {
  min-height: 2.6em;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-2-soft);
  border-left: 5px solid var(--accent-2);
  font-weight: 600;
}

.fc-mensaje.is-error {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.fc-marcador {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 1.5rem;
}

.fc-dato {
  flex: 1 1 calc(25% - 6px);
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
}

.fc-dato-nombre {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.fc-dato-valor {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

@media (max-width: 759px) {
  .fc-dato {
    flex-basis: calc(50% - 4px);
  }
}

/* ---------- Paneles (confirmar, elegir número, victoria) ---------- */

.fc-panel {
  position: fixed;
  inset: 0;
  z-index: 1100; /* por encima del banner de cookies (1000) */
  display: flex;
  padding: 16px;
  background: rgba(31, 42, 55, 0.62);
  overflow-y: auto;
}

.fc-panel[hidden] {
  display: none;
}

@keyframes fc-aparecer {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.fc-panel .card {
  width: 100%;
  max-width: 460px;
  margin: auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fc-aparecer 0.25s ease-out;
}

.fc-panel h2 {
  margin-top: 0;
}

#victoria h2 {
  color: var(--accent-2);
  font-size: 1.8rem;
}

.fc-record {
  color: var(--accent);
  font-weight: 700;
}

.fc-panel-acciones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.fc-panel-acciones .btn {
  width: 100%;
  max-width: 320px;
}

.fc-etiqueta {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.fc-campo {
  display: block;
  width: 100%;
  max-width: 260px;
  min-height: 52px;
  margin: 0 auto;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.fc-campo:focus-visible {
  border-color: var(--accent-2);
}

.fc-error {
  min-height: 1.5em;
  margin: 8px 0 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.fc-aviso {
  margin: 4px 0 0;
  color: var(--muted);
}

/* ---------- Escritorio ---------- */

@media (min-width: 720px) {
  .fc-area {
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
    padding: 20px 16px 16px;
    border-radius: var(--radius);
    border-left: 1px solid var(--fc-tapete-oscuro);
    border-right: 1px solid var(--fc-tapete-oscuro);
  }

  .fc-arriba {
    margin-bottom: 22px;
  }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  .fc-carta.fc-pista::after,
  .fc-hueco.fc-pista,
  .fc-panel .card {
    animation: none !important;
  }

  .fc-hueco.fc-pista {
    box-shadow: 0 0 0 6px var(--fc-oro);
  }
}
