/* ==========================================================================
   Selector de juego de cartas (game-switch.js): el botón de la barra con el logotipo del juego
   activo y el panel con los juegos, cada uno con su logo y su acento (--g-<juego>, base.css)
   ========================================================================== */

/* ---------- El botón de la barra ---------- */
/* Una pieza con borde junto a la marca: se ve que es un control y qué juego está activo. El filete
   del acento abajo, como la pestaña activa. --ar: la proporción del logo (la da su adaptador), para
   que todos se vean del mismo peso: los apaisados más bajos, los altos más altos */
.game-switch {
  --g: var(--accent);
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, color-mix(in srgb, var(--g) 9%, var(--surface)), var(--surface));
  box-shadow: var(--hairline-top);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
}
.game-switch::before {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--g);
}
.game-switch:hover, .game-switch[aria-expanded="true"] { border-color: var(--line-3); background: linear-gradient(180deg, color-mix(in srgb, var(--g) 15%, var(--surface-2)), var(--surface-2)); }
.game-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.game-switch .gs-logo { display: block; width: auto; height: clamp(18px, calc(88px / var(--ar, 3)), 28px); max-width: 92px; object-fit: contain; }
.game-switch .gs-word { font-family: var(--serif); font-size: 19px; font-weight: 500; letter-spacing: -.01em; line-height: 1; white-space: nowrap; }
.game-switch .gs-caret { display: inline-flex; color: var(--muted); }
.game-switch .gs-caret .i { width: 14px; height: 14px; transition: transform var(--dur-2) var(--ease); }
.game-switch:hover .gs-caret, .game-switch[aria-expanded="true"] .gs-caret { color: var(--text-2); }
.game-switch[aria-expanded="true"] .gs-caret .i { transform: rotate(180deg); }
/* Junto al selector, la marca es solo el símbolo (el nombre ocuparía el sitio del juego), y el filete
   entre la marca y la navegación va después del selector, no entre los dos */
.topbar > .logo:has(+ .game-switch) { margin-right: -4px; }
.topbar > .logo:has(+ .game-switch) .logo-text, .topbar > .logo:has(+ .game-switch)::after { display: none; }

/* ---------- El panel ---------- */
.gs-panel {
  position: fixed;
  z-index: 85;
  width: min(612px, calc(100vw - 16px));
  /* Bajo el selector, hasta el borde de la pantalla como mucho (place() en game-switch.js pone el tope) */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 12px;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: var(--e-2), var(--hairline-top);
  animation: pop-in var(--dur-2) var(--ease);
}
.gs-scrim { display: none; }
.gs-head { padding: 0 4px 14px; }
.gs-title { margin: 6px 0 3px; font-family: var(--serif); font-size: var(--fs-xl); font-weight: 500; letter-spacing: -.01em; line-height: 1.15; }
.gs-lead { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.gs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

/* Cada juego: una placa oscura con su logo y el brillo de su acento, y debajo su nombre y tus cifras */
.gs-tile {
  --g: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: 5px 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-1);
}
.gs-plate {
  position: relative;
  display: grid;
  place-items: center;
  height: 86px;
  margin-bottom: 9px;
  border-radius: 7px;
  overflow: hidden;
  background:
    radial-gradient(110% 95% at 50% 118%, color-mix(in srgb, var(--g) 30%, transparent), transparent 64%),
    var(--bg-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .035);
  transition: background var(--dur-2);
}
.gs-plate::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--g); opacity: 0; transition: opacity var(--dur-2); }
.gs-plate-logo { display: block; width: auto; height: auto; max-width: 74%; max-height: 54px; object-fit: contain; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .5)); transition: transform var(--dur-2) var(--ease); }
.gs-plate .gs-word { padding: 0 10px; font-family: var(--serif); font-size: 23px; font-weight: 500; letter-spacing: -.01em; line-height: 1.05; text-align: center; color: var(--text); }
.gs-name { display: -webkit-box; padding: 0 6px; font-size: var(--fs-sm); font-weight: 600; line-height: 1.25; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.gs-tile .gs-meta { margin-top: auto; }
.gs-meta { min-height: 17px; padding: 1px 6px 0; color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-skel { display: inline-block; width: 70%; height: 9px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--surface-2), var(--surface-4), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.gs-check { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-pill); background: var(--g); color: var(--bg); box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.gs-check .i { width: 12px; height: 12px; stroke-width: 3; }

.gs-tile:hover:not(:disabled) { border-color: var(--line-3); background: var(--surface-2); }
.gs-tile:hover:not(:disabled) .gs-plate { background: radial-gradient(110% 95% at 50% 118%, color-mix(in srgb, var(--g) 44%, transparent), transparent 66%), var(--bg-2); }
.gs-tile:hover:not(:disabled) .gs-plate-logo { transform: translateY(-2px) scale(1.03); }
.gs-tile.on { border-color: color-mix(in srgb, var(--g) 60%, transparent); background: color-mix(in srgb, var(--g) 7%, var(--surface)); }
.gs-tile.on .gs-plate::after { opacity: 1; }
.gs-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gs-tile:disabled { opacity: .45; cursor: default; }

/* El total de todos los juegos (Portfolio › Todos los juegos): una fila bajo la rejilla */
.gs-total { display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; align-items: center; gap: 12px; margin-top: 12px; padding: 9px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); color: inherit; text-decoration: none; transition: border-color var(--dur-1), background var(--dur-1); }
.gs-total:hover { border-color: var(--line-3); background: var(--surface-2); }
.gs-total:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gs-total-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); color: var(--brass-2); }
.gs-total-ic .i { width: 18px; height: 18px; }
.gs-total-t { display: grid; gap: 1px; min-width: 0; }
.gs-total-t b { font-size: var(--fs-sm); font-weight: 600; }
.gs-total-t small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-total-go .i { width: 15px; height: 15px; color: var(--faint); }
.gs-total:hover .gs-total-go .i { color: var(--text-2); }

.gs-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 10px 4px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-xs); }
.gs-legal { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 4px 6px; margin-right: -6px; border-radius: var(--r-sm); color: var(--muted); font-size: var(--fs-xs); text-decoration: none; }
.gs-legal:hover { color: var(--text-2); background: var(--surface-2); }
.gs-legal:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.gs-legal .i { width: 13px; height: 13px; }

/* ---------- Barra llena y móvil ---------- */
/* Por debajo de 1440 px (y en el móvil) la barra va llena: el selector ocupa el sitio de la marca,
   porque el juego activo es lo que hay que ver ahí */
@media (max-width: 1440px) {
  .topbar > .logo:has(+ .game-switch) { display: none; }
  .game-switch { padding: 0 6px 0 9px; gap: 5px; }
  .game-switch .gs-logo { height: clamp(16px, calc(80px / var(--ar, 3)), 27px); max-width: 82px; }
}
@media (max-width: 900px) {
  .game-switch { height: 36px; }
  .game-switch .gs-logo { height: clamp(15px, calc(68px / var(--ar, 3)), 24px); max-width: 70px; }
  .game-switch .gs-word { font-size: 17px; }
  .game-switch .gs-caret .i { width: 12px; height: 12px; }
}
/* El panel, una hoja desde abajo, con velo detrás */
@media (max-width: 640px) {
  .gs-scrim { display: block; position: fixed; inset: 0; z-index: 84; background: var(--scrim); animation: gs-fade var(--dur-2) var(--ease); }
  .gs-panel {
    inset: auto 0 0;
    width: auto;
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
    border-bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: gs-up var(--dur-3) var(--ease);
  }
  .gs-panel::before { content: ""; display: block; width: 38px; height: 4px; margin: 0 auto 12px; border-radius: var(--r-pill); background: var(--line-3); }
  .gs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .gs-plate { height: 74px; }
  .gs-plate-logo { max-height: 46px; }
  .gs-foot { flex-wrap: wrap; }
  html.gs-open, html.gs-open body { overflow: hidden; }
}
@keyframes gs-up { from { opacity: 0; transform: translateY(32px); } }
@keyframes gs-fade { from { opacity: 0; } }
