/* ==========================================================================
   Game Player — Iframe, Toolbar, Single Game Page
   ========================================================================== */

/* ── Player Container ───────────────────────────────── */
.gx-player {
  --_gap: var(--gx-sp-3);
  display: flex;
  flex-direction: column;
  margin-top: var(--_gap);
  margin-bottom: var(--gx-sp-4);
}

/* Desktop: cap at viewport height, let 16:9 aspect ratio determine natural size */
@media (min-width: 768px) {
  .gx-player {
    max-height: calc(100vh - var(--gx-navbar-height) - var(--_gap));
  }

  .admin-bar .gx-player {
    max-height: calc(100vh - var(--gx-navbar-height) - var(--wp-admin--admin-bar--height, 32px) - var(--_gap));
  }
}

.gx-player__wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 0 0 var(--gx-radius-lg) var(--gx-radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

/* Desktop: allow shrink if viewport is too short, but don't grow past 16:9 */
@media (min-width: 768px) {
  .gx-player__wrap {
    flex: 0 1 auto;
    min-height: 0;
  }
}

/* ── Placeholder ────────────────────────────────────── */
.gx-player__placeholder {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(4px) brightness(0.6);
  transform: scale(1.05);
}

/* ── Play Button ────────────────────────────────────── */
.gx-player__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  background: transparent;
}

.gx-player__play .gx-icon {
  width: 64px;
  height: 64px;
  color: #fff;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  transition: transform var(--gx-transition);
}

.gx-player__play:hover .gx-icon {
  transform: scale(1.15);
}

/* ── Iframe ─────────────────────────────────────────── */
.gx-player__iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ── Loading Spinner Overlay ────────────────────────── */
.gx-player__loader {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

.gx-player__loader.is-hidden {
  display: none;
}

.gx-player__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--gx-accent);
  border-radius: 50%;
  animation: gx-spin 0.8s linear infinite;
}

@keyframes gx-spin {
  to { transform: rotate(360deg); }
}

/* ── Close Button (mobile fullscreen) ───────────────── */
.gx-player__close {
  position: absolute;
  top: var(--gx-sp-3);
  right: var(--gx-sp-3);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border-radius: 50%;
  backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.gx-player__close .gx-icon {
  width: 22px;
  height: 22px;
}

.gx-player__close:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* ── Fullscreen Mode ────────────────────────────────── */
.gx-player__wrap.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: var(--gx-z-lightbox);
  border-radius: 0;
  aspect-ratio: unset;
  overscroll-behavior: contain;
}

/* Break stacking context so fullscreen wrap can overlay navbar */
html.gx-player-fullscreen .gx-site__content {
  view-transition-name: none;
}

/* ── Player Toolbar (always visible) ────────────────── */
.gx-player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gx-sp-3);
  height: 48px;
  padding: 0 var(--gx-sp-4);
  background: var(--gx-bg-tertiary);
  border-radius: var(--gx-radius-lg) var(--gx-radius-lg) 0 0;
  position: relative;
  z-index: 3;
}

.gx-player-toolbar__left {
  display: flex;
  align-items: center;
  gap: var(--gx-sp-3);
  min-width: 0;
  flex: 1;
}

.gx-player-toolbar__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--gx-text-xs);
  font-weight: 600;
  border-radius: var(--gx-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.gx-player-toolbar__badge--completed {
  background: rgba(0, 184, 148, 0.15);
  color: var(--gx-success);
}

.gx-player-toolbar__badge--ongoing {
  background: rgba(0, 122, 255, 0.15);
  color: var(--gx-accent);
}

.gx-player-toolbar__badge--abandoned {
  background: rgba(225, 112, 85, 0.15);
  color: var(--gx-danger);
}

.gx-player-toolbar__badge--onhold {
  background: rgba(253, 203, 110, 0.15);
  color: var(--gx-warning);
}

.gx-player-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--gx-sp-1);
  flex-shrink: 0;
}

.gx-player-toolbar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--gx-text-secondary);
  background: transparent;
  border-radius: var(--gx-radius-md);
  cursor: pointer;
  transition: color var(--gx-transition), background var(--gx-transition);
  position: relative;
}

.gx-player-toolbar__btn:hover {
  color: var(--gx-text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.gx-player-toolbar__btn .gx-icon {
  width: 18px;
  height: 18px;
}

/* Tooltip */
.gx-player-toolbar__btn[aria-label]::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  font-size: var(--gx-text-xs);
  font-weight: 500;
  color: #fff;
  background: hsl(0, 0%, 20%);
  border-radius: var(--gx-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--gx-transition);
}

.gx-player-toolbar__btn:hover[aria-label]::after {
  opacity: 1;
}

/* ── Game Title ────────────────────────────────────── */
.gx-game__title {
  font-size: var(--gx-text-2xl);
  font-weight: 700;
  color: var(--gx-text-primary);
  margin: var(--gx-sp-4) 0 0;
  line-height: var(--gx-leading-tight);
}

/* ── Compact Info Bar ──────────────────────────────── */
.gx-info-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gx-sp-1) var(--gx-sp-3);
  padding: var(--gx-sp-3) 0;
  font-size: var(--gx-text-sm);
  color: var(--gx-text-secondary);
}

.gx-info-bar__item {
  display: inline-flex;
  align-items: center;
  gap: var(--gx-sp-1);
}

.gx-info-bar__item + .gx-info-bar__item::before {
  content: "\00b7";
  margin-right: var(--gx-sp-1);
  color: var(--gx-text-muted);
  font-weight: 700;
}

.gx-info-bar__label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gx-text-muted);
}

.gx-info-bar__value {
  display: inline-flex;
  align-items: center;
  gap: var(--gx-sp-1);
  color: var(--gx-text-primary);
  font-weight: 500;
}

.gx-info-bar__value a {
  color: var(--gx-accent);
}

.gx-info-bar__value a:hover {
  text-decoration: underline;
}

/* ── Tags Row ──────────────────────────────────────── */
.gx-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gx-sp-2);
  padding-bottom: var(--gx-sp-4);
}

/* ── Sticky Anchor Nav ─────────────────────────────── */
.gx-anchor-nav {
  position: sticky;
  top: var(--gx-navbar-height);
  z-index: 90;
  display: flex;
  gap: 0;
  background: var(--gx-bg-primary);
  border-bottom: 1px solid var(--gx-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

/* Admin bar offset */
.admin-bar .gx-anchor-nav {
  top: calc(var(--gx-navbar-height) + var(--wp-admin--admin-bar--height, 32px));
}

@media (max-width: 782px) {
  .admin-bar .gx-anchor-nav {
    top: calc(var(--gx-navbar-height) + var(--wp-admin--admin-bar--height, 46px));
  }
}

.gx-anchor-nav::-webkit-scrollbar {
  display: none;
}

.gx-anchor-nav__link {
  flex-shrink: 0;
  padding: var(--gx-sp-3) var(--gx-sp-4);
  font-size: var(--gx-text-sm);
  font-weight: 500;
  color: var(--gx-text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--gx-transition), border-color var(--gx-transition);
  white-space: nowrap;
}

.gx-anchor-nav__link:hover {
  color: var(--gx-text-primary);
}

.gx-anchor-nav__link.is-active {
  color: var(--gx-accent);
  border-bottom-color: var(--gx-accent);
}

/* ── Stacked Sections ──────────────────────────────── */
.gx-game-section {
  padding-top: var(--gx-sp-6);
  padding-bottom: var(--gx-sp-6);
  /* Offset scroll target for sticky navbar + anchor nav */
  scroll-margin-top: calc(var(--gx-navbar-height) + 52px);
}

.admin-bar .gx-game-section {
  scroll-margin-top: calc(var(--gx-navbar-height) + var(--wp-admin--admin-bar--height, 32px) + 52px);
}

@media (max-width: 782px) {
  .admin-bar .gx-game-section {
    scroll-margin-top: calc(var(--gx-navbar-height) + var(--wp-admin--admin-bar--height, 46px) + 52px);
  }
}

.gx-game-section__title {
  font-size: var(--gx-text-xl);
  margin-bottom: var(--gx-sp-3);
  padding-bottom: var(--gx-sp-2);
  border-bottom: 1px solid var(--gx-border);
}

/* ── Collapsible Section ───────────────────────────── */
.gx-section-collapse {
  position: relative;
}

.gx-section-collapse__content {
  max-height: 300px;
  overflow: hidden;
  position: relative;
}

.gx-section-collapse__content.is-expanded {
  max-height: none;
}

.gx-section-collapse__fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(transparent, var(--gx-bg-primary));
  pointer-events: none;
}

.gx-section-collapse__content.is-expanded + .gx-section-collapse__fade {
  display: none;
}

.gx-section-collapse__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gx-sp-2);
  width: 100%;
  padding: var(--gx-sp-3);
  margin-top: var(--gx-sp-2);
  font-size: var(--gx-text-sm);
  font-weight: 500;
  color: var(--gx-accent);
  background: transparent;
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius-md);
  cursor: pointer;
  transition: background var(--gx-transition);
}

.gx-section-collapse__toggle:hover {
  background: rgba(var(--gx-accent-rgb), 0.08);
}

.gx-section-collapse__toggle .gx-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--gx-transition);
}

.gx-section-collapse__toggle.is-expanded .gx-icon {
  transform: rotate(180deg);
}

/* ── Share Toast ────────────────────────────────────── */
.gx-toast {
  position: fixed;
  bottom: var(--gx-sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 24px));
  padding: var(--gx-sp-3) var(--gx-sp-5);
  font-size: var(--gx-text-sm);
  font-weight: 500;
  color: #fff;
  background: hsl(0, 0%, 20%);
  border-radius: var(--gx-radius-full);
  box-shadow: var(--gx-shadow-lg);
  z-index: var(--gx-z-toast);
  opacity: 0;
  transition: transform var(--gx-transition-slow), opacity var(--gx-transition-slow);
  pointer-events: none;
}

.gx-toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Gallery ────────────────────────────────────────── */
.gx-gallery {
  position: relative;
}

.gx-gallery__carousel {
  display: flex;
  gap: var(--gx-sp-2);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--gx-sp-2);
}

.gx-gallery__carousel::-webkit-scrollbar {
  height: 6px;
}

.gx-gallery__carousel::-webkit-scrollbar-thumb {
  background: var(--gx-border-light);
  border-radius: 3px;
}

/* WordPress gallery wrapper — collapse so items are direct flex children */
.gx-gallery__carousel .gallery {
  display: contents;
}

/* WordPress gallery items inside carousel */
.gx-gallery__carousel .gallery-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  margin: 0;
}

.gx-gallery__carousel .gallery-item img {
  height: 180px;
  width: auto;
  object-fit: cover;
  border-radius: var(--gx-radius-md);
  cursor: pointer;
  transition: opacity var(--gx-transition);
}

.gx-gallery__carousel .gallery-item img:hover {
  opacity: 0.8;
}

/* Gallery carousel arrow buttons */
.gx-carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--gx-transition);
}

.gx-carousel-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.gx-carousel-btn--left {
  left: var(--gx-sp-2);
}

.gx-carousel-btn--right {
  right: var(--gx-sp-2);
}

/* ── Lightbox ───────────────────────────────────────── */
.gx-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--gx-z-lightbox);
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--gx-transition-slow);
  overscroll-behavior: contain;
}

.gx-lightbox.is-open {
  display: flex;
  opacity: 1;
}

.gx-lightbox__img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--gx-radius-md);
}

.gx-lightbox__close {
  position: absolute;
  top: var(--gx-sp-4);
  right: var(--gx-sp-4);
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: background var(--gx-transition);
}

.gx-lightbox__close:hover {
  background: rgba(255,255,255,0.2);
}

.gx-lightbox__prev,
.gx-lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--gx-transition);
}

.gx-lightbox__prev:hover,
.gx-lightbox__next:hover {
  background: rgba(255,255,255,0.2);
}

.gx-lightbox__prev { left: var(--gx-sp-4); }
.gx-lightbox__next { right: var(--gx-sp-4); }

/* ── Admin Tools ────────────────────────────────────── */
.gx-admin-tools {
  padding: var(--gx-sp-3);
  background: var(--gx-bg-tertiary);
  border-radius: var(--gx-radius-md);
  border: 1px solid var(--gx-border);
}

/* ── Keyboard shortcut badge ────────────────────────── */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--gx-font-mono);
  font-size: 0.8em;
  background: var(--gx-bg-tertiary);
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius-sm);
}

/* ── Report Popover ────────────────────────────────── */
.gx-report {
  position: relative;
}

.gx-report__popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--gx-bg-secondary);
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius-lg);
  box-shadow: var(--gx-shadow-lg);
  z-index: var(--gx-z-dropdown);
  overflow: hidden;
  padding: var(--gx-sp-1) 0;
}

.gx-report__popover[hidden] {
  display: none;
}

.gx-report__header {
  padding: var(--gx-sp-2) var(--gx-sp-3);
  font-size: var(--gx-text-xs);
  font-weight: 600;
  color: var(--gx-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gx-report__option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--gx-sp-2) var(--gx-sp-3);
  background: transparent;
  border: none;
  color: var(--gx-text-primary);
  font-size: var(--gx-text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--gx-transition);
  text-align: left;
  white-space: nowrap;
}

.gx-report__option:hover {
  background: var(--gx-bg-tertiary);
}

.gx-report__option.is-selected {
  border-left: 3px solid var(--gx-accent);
  padding-left: calc(var(--gx-sp-3) - 3px);
  color: var(--gx-accent);
  font-weight: 600;
}

.gx-report__option.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.gx-report__custom {
  display: flex;
  flex-direction: column;
  gap: var(--gx-sp-2);
  padding: var(--gx-sp-2) var(--gx-sp-3) var(--gx-sp-3);
}

.gx-report__custom[hidden] {
  display: none;
}

.gx-report__textarea {
  width: 100%;
  padding: var(--gx-sp-2);
  background: var(--gx-bg-input, var(--gx-bg-tertiary));
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius-md);
  color: var(--gx-text-primary);
  font-size: var(--gx-text-sm);
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color var(--gx-transition);
}

.gx-report__textarea:focus {
  border-color: var(--gx-accent);
}

.gx-report__feedback {
  padding: var(--gx-sp-2) var(--gx-sp-3) var(--gx-sp-3);
  font-size: var(--gx-text-sm);
  text-align: center;
}

.gx-report__feedback[hidden] {
  display: none;
}

.gx-report__feedback.is-success {
  color: var(--gx-success);
}

.gx-report__feedback.is-error {
  color: var(--gx-danger);
}
