/*
 * GamePass.es — /juegos authenticated GameTracker composition.
 * Route-scoped and activated only after gametracker-layout.js confirms that a
 * personal tracker (or authenticated empty state) exists.
 */

/* The base Quick View used a muted token that landed just below AA on the
 * darkest surface. This stylesheet loads after the base experience and is only
 * present on /juegos, so raise the token once for every small supporting label. */
:root {
  --gtx-faint: #7a8998;
}

/* Explicit keyboard focus: do not depend on browser defaults or global resets. */
.gtx-qv__iconbtn:focus-visible,
.gtx-qv__play:focus-visible,
.gtx-qv__thumb:focus-visible,
.gtx-qv__state:focus-visible,
.gtx-qv__primary:focus-visible,
.gtx-qv__secondary:focus-visible,
.gtx-ready .juego-card:focus-visible,
.gtx-ready .juego-card-link:focus-visible {
  outline: 2px solid #7ce8ff;
  outline-offset: 3px;
}

html.gtx-personal-first .gt,
html.gtx-personal-first .gt-cta--empty {
  margin-top: 28px;
}

html.gtx-personal-first .gt .gt-head {
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

html.gtx-personal-first .gt .gt-title {
  font-size: clamp(27px, 3vw, 36px);
  letter-spacing: 1.25px;
}

html.gtx-personal-first .gt .gt-title-mark {
  width: 5px;
  height: 27px;
  border-radius: 2px;
  background: #00d7ff;
  box-shadow: 0 0 18px rgba(0,215,255,.30);
}

html.gtx-personal-first .gt .gt-hello {
  margin-left: auto;
  color: #8796a5;
  font-size: 11px;
}

/*
 * A single status deck instead of five floating dashboard pills. The cards
 * remain the visual protagonists; this strip is navigation and orientation.
 */
html.gtx-personal-first .gt .gt-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.085);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20,27,36,.88), rgba(12,17,24,.88));
  box-shadow: 0 14px 34px rgba(0,0,0,.16);
}

html.gtx-personal-first .gt .gt-stat {
  min-width: 0;
  min-height: 62px;
  justify-content: flex-start;
  padding: 11px 14px;
  border: 0;
  border-right: 1px solid rgba(255,255,255,.065);
  border-radius: 0;
  background: transparent;
  transform: none;
}

html.gtx-personal-first .gt .gt-stat:last-child {
  border-right: 0;
}

html.gtx-personal-first .gt .gt-stat:hover {
  transform: none;
  background: rgba(255,255,255,.035);
}

html.gtx-personal-first .gt .gt-stat.is-active {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--gt-col) 12%, transparent), transparent),
    rgba(255,255,255,.018);
  box-shadow: inset 0 -2px 0 var(--gt-col);
}

html.gtx-personal-first .gt .gt-stat-n {
  font-size: 23px;
  letter-spacing: -.03em;
}

html.gtx-personal-first .gt .gt-stat-l {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b8c3cf;
}

html.gtx-personal-first .gt .gt-block {
  margin-bottom: 30px;
}

html.gtx-personal-first .gt .gt-block-head {
  align-items: center;
  margin-bottom: 13px;
}

html.gtx-personal-first .gt .gt-block-title {
  font-size: 18px;
  letter-spacing: .045em;
}

html.gtx-personal-first .gt .gt-block-sub {
  color: #82909f;
}

html.gtx-personal-first .gt .gt-block--urgent {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(255,123,112,.24);
  border-radius: 15px;
  background:
    linear-gradient(90deg, rgba(255,107,114,.07), transparent 36%),
    rgba(255,255,255,.012);
}

html.gtx-personal-first .gt .gt-block--urgent::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: #ff6b72;
}

html.gtx-personal-first .gt .gt-block--urgent .gt-block-title {
  color: #ffaaa9;
}

html.gtx-personal-first .gt .gt-grid {
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 13px;
}

html.gtx-personal-first .gt .gt-tiempo {
  border-radius: 8px;
  background: rgba(255,189,102,.065);
  border-color: rgba(255,189,102,.18);
  color: #e8c78f;
}

/*
 * Main catalog can contain hundreds of rich cards. Keep every SSR card/link in
 * the DOM for search, filters and crawlability, but let the browser skip
 * layout/paint for offscreen cards. This is progressive performance, not
 * virtualization or infinite-scroll-only content.
 */
.gtx-ready .juegos-grid > .juego-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 390px;
}

/*
 * Personal state belongs on the artwork, not hidden in a footer button. Use the
 * existing canonical data-estado-actual attribute: no extra PHP field, no DOM
 * duplication, and state changes in Quick View update the label immediately.
 */
.gtx-ready .juego-card-img { position: relative; }
.gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual]:not([data-estado-actual=""])) .juego-card-img::before {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 4;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(7,11,16,.86);
  box-shadow: 0 5px 18px rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
  color: #e8f2f8;
  font: 750 9.5px/1 Inter, system-ui, sans-serif;
  letter-spacing: .065em;
  text-transform: uppercase;
  pointer-events: none;
}
.gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual="pendiente"]) .juego-card-img::before {
  content: 'Pendiente';
  color: #7ce8ff;
  border-color: rgba(0,215,255,.34);
}
.gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual="jugando"]) .juego-card-img::before {
  content: 'Jugando';
  color: #8ce7b5;
  border-color: rgba(94,224,160,.34);
}
.gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual="terminado"]) .juego-card-img::before {
  content: 'Terminado';
  color: #d9baff;
  border-color: rgba(200,155,255,.34);
}
.gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual="abandonado"]) .juego-card-img::before {
  content: 'Abandonado';
  color: #ffaaaa;
  border-color: rgba(255,107,114,.30);
}

/* Native-looking state selector with an explicit affordance after the base
 * Quick View removes browser appearance for visual consistency. */
.gtx-qv__state {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ecbd5' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}
.gtx-qv__state:disabled { opacity: .56; cursor: wait; }
.gtx-qv__feedback:empty { display: none; }

/* The catalog/discovery hero stays available, but the personal workspace owns
 * the first screen for authenticated users. Keep a clear visual separation. */
html.gtx-personal-first .juegos-hero {
  margin-top: 8px;
}

@media (max-width: 900px) {
  html.gtx-personal-first .gt .gt-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  html.gtx-personal-first .gt .gt-stat:nth-child(3n) {
    border-right: 0;
  }

  html.gtx-personal-first .gt .gt-stat:nth-child(n+4) {
    border-top: 1px solid rgba(255,255,255,.065);
  }
}

@media (max-width: 560px) {
  html.gtx-personal-first .gt,
  html.gtx-personal-first .gt-cta--empty {
    margin-top: 16px;
  }

  html.gtx-personal-first .gt .gt-head {
    align-items: flex-end;
  }

  html.gtx-personal-first .gt .gt-hello {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html.gtx-personal-first .gt .gt-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 12px;
  }

  html.gtx-personal-first .gt .gt-stat {
    min-height: 56px;
    flex: none;
    border-right: 1px solid rgba(255,255,255,.065);
    border-top: 1px solid rgba(255,255,255,.065);
  }

  html.gtx-personal-first .gt .gt-stat:first-child {
    grid-column: 1 / -1;
    border-top: 0;
    border-right: 0;
  }

  html.gtx-personal-first .gt .gt-stat:nth-child(2),
  html.gtx-personal-first .gt .gt-stat:nth-child(3) {
    border-top: 1px solid rgba(255,255,255,.065);
  }

  html.gtx-personal-first .gt .gt-stat:nth-child(3),
  html.gtx-personal-first .gt .gt-stat:nth-child(5) {
    border-right: 0;
  }

  html.gtx-personal-first .gt .gt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  html.gtx-personal-first .gt .gt-block-sub {
    display: none;
  }

  .gtx-ready .juego-card:has(.juego-card-pendiente-btn[data-estado-actual]:not([data-estado-actual=""])) .juego-card-img::before {
    left: 6px;
    bottom: 6px;
    padding: 4px 6px;
    font-size: 8.5px;
  }
}

@media (max-width: 350px) {
  html.gtx-personal-first .gt .gt-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html.gtx-personal-first .gt .gt-stat,
  html.gtx-personal-first .gt .gt-stat:hover {
    transition: none;
    transform: none;
  }
}
