/* Public games page. Reuses the socials theme variables and .social-link card trim. */

/* Left on the body, the theme background is sized to the whole scrolling page, so a
   cover image gets stretched and cropped on a long list. Pinning it to the viewport
   keeps it the same size at any scroll position, including on iOS. */
body {
  background: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg);
}

.games-page {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.games-back {
  align-self: flex-start;
  width: auto;
  margin-bottom: 1.5rem;
}

/* Same text colour as the game cards, whatever state the link is in */
.games-back,
.games-back:visited {
  color: var(--text);
}

.games-tools {
  position: sticky;
  top: 0.75rem;
  z-index: 10;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}

.games-search {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.88rem;
}

.games-search::placeholder {
  color: var(--text-muted);
}

.games-search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.games-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.games-groups,
.games-group {
  width: 100%;
}

.games-group {
  margin-bottom: 1.75rem;
}

.games-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.85rem;
  margin-bottom: 0.75rem;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.games-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem;
}

.game-card {
  min-height: 52px;
}

.game-card .name {
  overflow-wrap: anywhere;
}

/* Size matches the width/height attributes, so the card never jumps when a cover loads */
.game-cover {
  flex-shrink: 0;
  width: 40px;
  height: 57px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface);
}

/* Keeps names lined up on cards that have no cover */
.game-cover-empty {
  border: 1px dashed var(--border);
}

/* The name is the card's only link; stretching it over the card gives one tab stop per game */
.game-card.has-link {
  cursor: pointer;
}

.game-link,
.game-link:visited {
  color: inherit;
  text-decoration: none;
}

.game-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.game-link:focus-visible {
  outline: none;
}

.game-link:focus-visible::before {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Every card is its own stacking layer, so the active one is lifted for its tooltip to sit on top */
.game-card:hover,
.game-card:focus-within {
  z-index: 3;
}

/* Hidden with visibility, not display: a display:none tooltip inside an animated card made
   Chrome redo style work every frame instead of leaving the trim to the GPU */
.game-tip {
  visibility: hidden;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 4;
  /* Transparent bridge so the pointer can move onto the tooltip without it closing */
  padding-top: 6px;
}

/* games.js flips it above the card when there is no room below */
.game-tip[data-side="above"] {
  top: auto;
  bottom: 100%;
  padding: 0 0 6px;
}

/* tip-dismissed is set by Escape in games.js */
@media (hover: hover) {
  .game-card:not(.tip-dismissed):hover .game-tip {
    visibility: visible;
  }
}

.game-card:not(.tip-dismissed):has(.game-link:focus-visible) .game-tip {
  visibility: visible;
}

.game-tip-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 220px;
  max-width: min(300px, calc(100vw - 16px));
  padding: 0.6rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.game-tip img {
  flex-shrink: 0;
  width: 90px;
  height: 128px;
  border-radius: 6px;
  object-fit: cover;
}

.game-tip-store {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.game-tip-date {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
}

.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;
}

.game-qty {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--text);  /* no accent tint behind it: on mid-tone themes a tint costs the contrast */
  background: transparent;
}

/* display on .social-link would otherwise beat the hidden attribute */
.game-card[hidden],
.games-group[hidden],
.games-empty[hidden] {
  display: none;
}

.games-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .game-card::after {
    animation: none !important;
  }
}

/* Claiming: notices, the login prompt, and the bar a winner picks games with */
.games-notice,
.games-login {
  width: 100%;
  max-width: 480px;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.games-notice.is-error {
  border-color: #f05252;
}

.games-notice a,
.games-login a {
  color: inherit;
  font-weight: 700;
}

/* Fixed to the bottom so the count and the button stay in reach while scrolling */
.games-claim {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  translate: -50% 0;
  width: min(480px, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Room under the last cards so the fixed bar never hides them */
.games-page:has(.games-claim) {
  padding-bottom: 9rem;
}

.games-claim-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.games-claim-button {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-glow, transparent);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.games-claim-button.is-secondary {
  border-color: var(--border);
  background: transparent;
  font-weight: 400;
}

.games-claim-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.games-claim-button:focus-visible,
.game-pick input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Above the card's stretched store link, so ticking never opens the store */
.game-pick {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.game-pick input {
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.game-card:has(.game-pick input:checked) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Viewer profile (layout/profile.php reuses this page's styles) */
.profile-card {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.profile-avatar {
  flex-shrink: 0;
  border-radius: 50%;
}

.profile-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  overflow-wrap: anywhere;
}

.profile-meta,
.profile-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.profile-section {
  width: 100%;
  max-width: 480px;
  margin-bottom: 1.75rem;
}

.profile-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.profile-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}

.profile-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.profile-action,
.profile-action:visited {
  position: relative;
  z-index: 2;
  color: var(--text);
  font-weight: 700;
}

.profile-login {
  width: auto;
  margin-top: 1rem;
}

/* /privacy and /terms */
.policy-text {
  width: 100%;
  max-width: 720px;
  padding: 1.25rem 1.4rem;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.policy-text h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.policy-text h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1.2rem 0 0.4rem;
}

.policy-text p,
.policy-text ul {
  margin-bottom: 0.7rem;
}

.policy-text ul {
  padding-left: 1.2rem;
  list-style: disc;
}

.policy-text a {
  color: inherit;
  text-decoration: underline;
}

.giveaway-disclaimer {
  max-width: 40rem;
  margin: 2rem auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.giveaway-links {
  margin: 1.5rem auto 0;
  text-align: center;
  font-size: 0.85rem;
}

.giveaway-links a {
  color: var(--text);
  text-decoration: underline;
}

/* On a picture background the whole content column sits on one panel, drawn behind it so the
   layout doesn't move (Socials::textColorsCss); its title and subtext don't need their own */
.games-page { position: relative; isolation: isolate; }
.games-page::before {
  content: "";
  position: absolute;
  inset: calc(var(--panel-page-pad, 0px) * -1);
  z-index: -1;
  pointer-events: none;
  background: var(--panel, transparent);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(var(--panel-blur, 0px));
  backdrop-filter: blur(var(--panel-blur, 0px));
}
.games-page .page-title, .games-page .page-sub { background: none; padding: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }

/* The outline version: the whole column's text gets the halo (it inherits); cards don't need it */
.games-page { text-shadow: var(--halo, none); }
.games-page .social-link, .games-page .os-card, .games-page .os-btn, .games-page input { text-shadow: none; }

/* ── Giveaway helpers page (staff) ──
   "html" outranks the giveaway panel's own styles, which it prints later in the page */
/* The giveaway screens use the admin's class names; here they take the site's own colours */
.staff-page { --os-text: var(--text); --os-text-muted: var(--text-muted); --os-border: var(--border);
              --os-accent: var(--accent); --os-accent-glow: var(--accent-glow); --os-surface: var(--surface);
              --os-danger: var(--danger, #f05252); --os-success: #3ecf8e; --os-accent-strong: var(--accent-fill, #6c5ae8);
              --os-warning: #f5a623; }
.staff-note { max-width: 40rem; margin: 0 auto 1.25rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.staff-panel { width: min(760px, 100%); margin: 0 auto; text-align: left; }
html .staff-panel .os-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.25rem; }
html .staff-panel .os-card-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; margin-bottom: 0.75rem; color: var(--text); }
html .staff-page .os-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 8px; font: inherit;
                      font-size: 0.8rem; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none; border: 1px solid var(--border); }
html .staff-page .os-btn-primary { background: var(--accent-fill, #6c5ae8); border-color: var(--accent-fill, #6c5ae8); color: var(--accent-fill-text, #fff); }
html .staff-page .os-btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
html .staff-page .os-btn-ghost { background: transparent; color: var(--text); }
html .staff-page .os-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html .staff-page .os-btn:disabled { opacity: 0.6; cursor: default; }
html .staff-page .os-input { width: 100%; padding: 0.5rem 0.65rem; border-radius: 8px; border: 1px solid var(--border);
                        background: rgba(0, 0, 0, 0.25); color: var(--text); font: inherit; font-size: 0.85rem; }
html .staff-page .os-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
html .staff-page .os-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; }
html .staff-page .os-alert { padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid transparent; font-size: 0.85rem; line-height: 1.5; margin-bottom: 1rem; }
html .staff-page .os-alert-success { background: rgba(62,207,142,0.08); color: var(--success, #3ecf8e); border-color: rgba(62,207,142,0.25); }
html .staff-page .os-alert-error { background: rgba(240,82,82,0.08); color: var(--danger, #f05252); border-color: rgba(240,82,82,0.25); }
html .staff-page code { font-family: 'DM Mono', monospace; font-size: 0.95em; }

/* ── Winners page ── */
.winners-list { list-style: none; padding: 0; margin: 0 auto; width: min(640px, 100%); display: flex; flex-direction: column; gap: 0.75rem; }
.winners-item { text-align: left; }
.winners-prize { font-size: 1rem; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.winners-date { font-size: 0.75rem; color: var(--text-muted); margin: 0.15rem 0 0.5rem; }
.winners-names { margin: 0; overflow-wrap: anywhere; }
.winners-empty { text-align: center; color: var(--text-muted); }
