/* ==========================================================================
   Basketball Arcade — Games stylesheet
   Game shell, canvas, HUD, touch controls, directory filters.
   Loaded only on pages that host or list games.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Game stage (individual game pages)
   -------------------------------------------------------------------------- */

.game-stage {
  background: var(--navy);
  padding-block: clamp(1.25rem, .9rem + 1.6vw, 2.25rem);
  border-bottom: 3px solid var(--brand);
}

.game-stage h1 {
  color: #fff;
  font-size: clamp(1.5rem, 1.15rem + 1.5vw, 2.2rem);
  margin: 0 auto .9rem;
  max-width: 980px;
}
.game-stage .eyebrow {
  max-width: 980px;
  margin: 0 auto .4rem;
  display: block;
}

.game-shell {
  max-width: 980px;
  margin-inline: auto;
  background: #0a1120;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* HUD ------------------------------------------------------------------- */

.game-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1.25rem;
  padding: .7rem 1rem;
  background: rgba(255, 255, 255, .05);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  color: #fff;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 64px;
}
.hud-stat span {
  font-size: .62rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #8fa0bd;
  font-weight: 700;
}
.hud-stat strong {
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.hud-stat--score strong { color: var(--brand); }
.hud-stat--best strong { color: var(--gold); }
.hud-stat.is-warning strong { color: #ff6b5e; }

.hud-actions { margin-left: auto; display: flex; gap: .5rem; }

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  min-height: 40px;
  padding: 0 .95rem;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .86rem;
  cursor: pointer;
}
.hud-btn:hover { background: rgba(255, 255, 255, .18); }
.hud-btn--primary { background: var(--brand); border-color: var(--brand); }
.hud-btn--primary:hover { background: var(--brand-600); }

/* Canvas ---------------------------------------------------------------- */

.canvas-wrap {
  position: relative;
  width: 100%;
  /* 16:10 keeps the court readable on phones without excessive height */
  aspect-ratio: 16 / 10;
  background: #0d1a2b;
  touch-action: none;   /* the game handles its own gestures */
  overscroll-behavior: contain;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* Crisp edges on the vector-style art at any DPR */
  image-rendering: auto;
}

/* Overlay used for start / pause / game-over states.
   Always present in the DOM so screen readers can reach the instructions. */
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(7, 12, 22, .66), rgba(7, 12, 22, .86));
  backdrop-filter: blur(2px);
  text-align: center;
  color: #fff;
  z-index: 3;
}
.game-overlay[hidden] { display: none !important; }

.game-overlay__inner { max-width: 440px; }
.game-overlay h2 {
  color: #fff;
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 2rem);
  margin-bottom: .4rem;
}
.game-overlay p { color: #c3cdde; font-size: .97rem; margin-bottom: 1.1rem; }
.game-overlay .btn-row { justify-content: center; }

.overlay-score {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1rem 0 1.35rem;
  padding: .9rem 0;
  border-block: 1px solid rgba(255, 255, 255, .15);
}
.overlay-score div span {
  display: block;
  font-size: .66rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #8fa0bd;
  font-weight: 700;
}
.overlay-score div strong {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.overlay-score div:last-child strong { color: var(--gold); }

.overlay-keys {
  font-size: .84rem;
  color: #9fb0cc;
  margin-top: 1rem;
}
.overlay-keys kbd {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}

.new-best {
  display: inline-block;
  background: var(--gold);
  color: #241a06;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .3em .8em;
  border-radius: var(--r-pill);
  margin-bottom: .75rem;
}

/* Touch control bar ------------------------------------------------------ */

.touch-controls {
  display: none;               /* enabled by JS on touch devices */
  gap: .5rem;
  padding: .65rem;
  background: rgba(255, 255, 255, .05);
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.touch-controls.is-visible { display: flex; }

.touch-btn {
  flex: 1;
  min-height: 56px;            /* comfortably above the 44px target minimum */
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.touch-btn:active,
.touch-btn.is-pressed { background: var(--brand); border-color: var(--brand); }
.touch-btn--wide { flex: 2; }

/* Caption under the stage ------------------------------------------------ */

.stage-caption {
  max-width: 980px;
  margin: .9rem auto 0;
  color: #93a1bb;
  font-size: .85rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  align-items: center;
  justify-content: space-between;
}
.stage-caption .tag { background: rgba(255, 255, 255, .1); color: #d3dbe8; }

/* Fallback shown if JavaScript is disabled */
.game-noscript {
  padding: 2rem 1.5rem;
  text-align: center;
  color: #c3cdde;
  background: #0a1120;
}

/* --------------------------------------------------------------------------
   2. Game directory — filters & toolbar
   -------------------------------------------------------------------------- */

.game-toolbar {
  position: sticky;
  top: 68px;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-block: .85rem;
  margin-bottom: 2rem;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}

.filter-search { flex: 1 1 240px; min-width: 200px; position: relative; }
.filter-search input { padding-left: 2.5rem; }
.filter-search svg {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  fill: none; stroke: var(--ink-mute); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  color: var(--ink-mute);
  font-weight: 600;
}
.sort-field select { width: auto; min-width: 150px; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  min-height: 38px;
  padding: 0 .95rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .84rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .14s ease, color .14s ease, border-color .14s ease;
}
.chip:hover { border-color: var(--brand); color: var(--brand-600); }
.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
:root[data-theme="dark"] .chip[aria-pressed="true"] { color: #16100c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip[aria-pressed="true"] { color: #16100c; }
}

.result-count {
  font-size: .88rem;
  color: var(--ink-mute);
  margin: 0 0 1.25rem;
}
.result-count strong { color: var(--ink); }

/* --------------------------------------------------------------------------
   3. Game card extras
   -------------------------------------------------------------------------- */

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .9rem;
  font-size: .78rem;
  color: var(--ink-mute);
  margin-bottom: .9rem;
}
.game-meta b {
  color: var(--ink-soft);
  font-weight: 700;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.difficulty i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  display: block;
}
.difficulty i.is-on { background: var(--brand); }

/* "Play" affordance overlaid on the thumbnail */
.card__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 17, 32, .35);
  opacity: 0;
  transition: opacity .16s ease;
  z-index: 1;
}
.card:hover .card__play,
.card:focus-within .card__play { opacity: 1; }
.card__play span {
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .85rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .6em 1.3em;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   4. Discovery strips (recently played, favourites, game of the day)
   -------------------------------------------------------------------------- */

.strip { margin-bottom: 2.5rem; }
.strip[hidden] { display: none !important; }

.gotd {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
  padding: 1.6rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
}
.gotd img { border-radius: var(--r-md); width: 100%; }
.gotd h3 { font-size: clamp(1.25rem, 1.05rem + .9vw, 1.7rem); margin-bottom: .5rem; }
.gotd p { color: var(--ink-soft); }

/* --------------------------------------------------------------------------
   5. Controls reference table on game pages
   -------------------------------------------------------------------------- */

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
}
.controls-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1.15rem 1.25rem;
  background: var(--paper);
}
.controls-card h3 {
  font-size: .82rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--brand-600);
  margin-bottom: .8rem;
}
.controls-card dl { margin: 0; }
.controls-card dt {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .9rem;
  margin-top: .8rem;
}
.controls-card dt:first-child { margin-top: 0; }
.controls-card dd {
  margin: .15rem 0 0;
  font-size: .9rem;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   6. Feature list on game pages
   -------------------------------------------------------------------------- */

.feature-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 2rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1.5rem;
}
.feature-list li {
  position: relative;
  padding-left: 1.7rem;
  font-size: .97rem;
  color: var(--ink-soft);
}
.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .42em;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}

/* --------------------------------------------------------------------------
   7. Search results page
   -------------------------------------------------------------------------- */

.search-hero { padding-block: 2.5rem 1.5rem; }
.search-form { display: flex; gap: .6rem; max-width: 620px; }
.search-form input { min-height: 52px; font-size: 1.05rem; }

.result-list { list-style: none; margin: 0; padding: 0; }
.result-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.result-item h3 { font-size: 1.1rem; margin-bottom: .3rem; }
.result-item h3 a { color: var(--ink); text-decoration: none; }
.result-item h3 a:hover { color: var(--brand-600); }
.result-item p { font-size: .93rem; color: var(--ink-soft); margin: .35rem 0 .5rem; }
.result-item mark {
  background: var(--brand-100);
  color: var(--ink);
  padding: 0 .12em;
  border-radius: 3px;
}
:root[data-theme="dark"] .result-item mark { background: var(--brand-100); color: var(--ink); }
.result-url { font-size: .8rem; color: var(--court); }
