/* ==========================================================================
   Solitario Klondike - adaptacion Readingg
   Basado en "solitaire" de Justin Hatzimalis (MIT, ver LICENSE).
   Mesa, controles y textos usan los tokens de ../_shared/tokens.css.
   Las caras de las cartas conservan el rojo y el negro tradicionales.
   ========================================================================== */

[hidden] {
  display: none !important;
}

html,
body {
  overflow-x: hidden;
}

.solitaire-app {
  gap: 8px;
  padding-left: max(4px, var(--rg-safe-left));
  padding-right: max(4px, var(--rg-safe-right));
  padding-bottom: calc(var(--rg-safe-bottom) + 8px);
}

/* ---------- Barra superior ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
}

.hud-title {
  min-width: 0;
}

.hud-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-actions .rg-btn {
  padding: 0 16px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--rg-border);
  border-radius: 14px;
  background: var(--rg-surface);
  color: var(--rg-text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.96);
}

/* ---------- Marcadores ---------- */

.hud-stats {
  display: flex;
  gap: 8px;
}

.rg-stat {
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  padding: 6px 12px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
}

.rg-stat strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--rg-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.table {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  padding: 6px 0 10px;
  isolation: isolate;
}

.table::before {
  content: "";
  position: absolute;
  inset: 0 -2px -2px;
  z-index: -1;
  border-radius: 22px;
  background:
    radial-gradient(140% 60% at 50% 0%, rgba(76, 109, 240, 0.18), rgba(76, 109, 240, 0) 65%),
    linear-gradient(180deg, var(--rg-surface), var(--rg-bg-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.board {
  position: relative;
  margin: 0 auto;
  touch-action: pan-y;
}

.board.no-anim .card,
.board.no-anim .card-inner {
  transition: none !important;
}

/* ---------- Huecos de las pilas ---------- */

.pile {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px dashed rgba(128, 140, 175, 0.42);
  border-radius: max(5px, calc(var(--card-w) * 0.12));
  box-sizing: border-box;
  transition: left 0.2s ease, top 0.2s ease;
}

.pile--foundation::after {
  content: "A";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(128, 140, 175, 0.55);
  font-size: calc(var(--card-w) * 0.42);
  font-weight: 800;
}

.pile--stock .stock-refresh {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--rg-muted);
  font-size: calc(var(--card-w) * 0.46);
  line-height: 1;
}

.pile--stock.is-empty .stock-refresh {
  display: flex;
}

/* ---------- Cartas ---------- */

.card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  perspective: 600px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: left 0.22s ease, top 0.22s ease;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.card.face-up .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: max(5px, calc(var(--card-w) * 0.12));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-front {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotateY(180deg);
  border: 1px solid #cdc7b6;
  background: linear-gradient(180deg, #fffdf7, #f3efe4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  color: #16171c;
}

.card.red .card-front {
  color: #c62828;
}

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
  font-size: calc(var(--card-w) * 0.26);
  line-height: 0.95;
}

.corner b {
  font-weight: 800;
}

.corner i {
  margin-top: 1px;
  font-style: normal;
  font-size: calc(var(--card-w) * 0.2);
}

.corner--tl {
  top: 5%;
  left: 6%;
}

.corner--br {
  right: 6%;
  bottom: 5%;
  transform: rotate(180deg);
}

.card-center {
  font-size: calc(var(--card-w) * 0.52);
  line-height: 1;
  opacity: 0.92;
}

.card-back {
  border: 1px solid rgba(9, 12, 24, 0.45);
  background:
    radial-gradient(120% 100% at 50% 0%, #6b86ff 0%, var(--rg-primary) 42%, #2c3c94 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.4);
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: max(2px, calc(var(--card-w) * 0.05));
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.14) 0 2px,
    transparent 2px 6px
  );
}

.card-back::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24%;
  height: 24%;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 12%;
  background: rgba(255, 255, 255, 0.08);
}

.card.selected .card-front {
  box-shadow:
    inset 0 0 0 2px var(--rg-accent),
    0 0 0 2px rgba(253, 57, 161, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.4);
}

.card.dragging {
  z-index: 2000 !important;
  transition: none;
}

.card.dragging .card-front,
.card.dragging .card-back {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
}

/* ---------- Modales ---------- */

.rg-overlay {
  animation: rg-fade 0.18s ease-out;
}

.rg-modal {
  animation: rg-pop 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.help-modal {
  text-align: left;
}

.help-modal h2 {
  text-align: center;
}

.help-list {
  margin: 0 0 18px;
  padding-left: 18px;
  color: var(--rg-muted);
  font-size: 14px;
  line-height: 1.5;
}

.help-list li {
  margin-bottom: 8px;
}

.help-list b {
  color: var(--rg-text);
}

.help-modal .rg-actions {
  justify-content: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rg-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rg-pop {
  from {
    transform: translateY(8px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
