/* Base (light) as default */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #121317;
  --muted: #5b6070;
  --brand: #7c5cff;
  --brand-2: #27e1c1;
  --ring: rgba(124, 92, 255, 0.45);
  --shadow: 0 10px 24px rgba(10, 14, 20, 0.06), 0 2px 6px rgba(10, 14, 20, 0.04);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --tile-ar: 1/1; /* perfect square for media area */
}

/* If NO manual theme is set, respect system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1115;
    --card: #151924;
    --text: #e6e6e9;
    --muted: #a3a6b3;
    --brand: #7c5cff;
    --brand-2: #27e1c1;
    --ring: rgba(124, 92, 255, 0.45);
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  }
}

/* Explicit user choice always wins */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --card: #151924;
  --text: #e6e6e9;
  --muted: #a3a6b3;
  --brand: #7c5cff;
  --brand-2: #27e1c1;
  --ring: rgba(124, 92, 255, 0.45);
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
}
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #121317;
  --muted: #5b6070;
  --brand: #7c5cff;
  --brand-2: #27e1c1;
  --ring: rgba(124, 92, 255, 0.45);
  --shadow: 0 10px 24px rgba(10, 14, 20, 0.06), 0 2px 6px rgba(10, 14, 20, 0.04);
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell,
    "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: all 0.5s;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0)),
    var(--bg);
}
.header-wrap {
  max-width: 1200px;
  margin: auto;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
}
.brand {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}
.brand img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: none;
}

/* Search */
.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.search input {
  width: min(55vw, 380px);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}
.search input::placeholder {
  color: var(--muted);
}
.search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
#themeToggle {
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 18px;
  line-height: 1;
}

/* Section nav */
.pill-nav {
  max-width: 1200px;
  margin: 8px auto 0;
  padding: 0 20px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.pill-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: all 0.15s;
}
.pill-nav a:hover {
  transform: translateY(-2px);
  background: linear-gradient(
      160deg,
      rgba(124, 92, 255, 0.12),
      rgba(39, 225, 193, 0.06)
    ),
    var(--card);
}

/* Hero / featured */
.hero {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}
.feature {
  position: relative;
  border-radius: var(--radius-xl);
  background: linear-gradient(
      160deg,
      rgba(124, 92, 255, 0.12),
      rgba(39, 225, 193, 0.06)
    ),
    var(--card);
  padding: 18px;
  box-shadow: var(--shadow);
}
.feature h2 {
  margin: 0 0 12px;
  font-size: clamp(16px, 1.8vw, 20px);
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

/* Sections */
section {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 20px;
}
section h3 {
  margin: 0 0 12px;
  font-size: clamp(14px, 1.6vw, 18px);
  color: var(--muted);
}
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.titlebar h2 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 26px);
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .hero {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 520px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Card */
.game-card {
  position: relative;
  display: block;
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* smooth hide/show for filtered cards */
.game-card {
  transition: opacity 200ms ease, transform 200ms ease;
}
.game-card.is-hidden {
  opacity: 0;
  transform: scale(0.75);
  pointer-events: none; /* keep hidden cards unfocusable/click-proof */
}

/* Media: always a perfect square, always COVER (no letterboxing) */
.thumb {
  aspect-ratio: var(--tile-ar);
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover; /* was contain */
  background: #0a0c11;
  transition: opacity 0.28s ease;
}
/* Featured tiles also cover (explicit but redundant-safe) */
.feature .thumb {
  object-fit: cover;
}

.meta {
  padding: 10px 12px 12px;
  position: relative;
}
.meta h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.info-btn {
  position: absolute;
  top: -22px;
  right: -18px;
  width: 44px;
  height: 44px;
  border: 0px solid currentColor;
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  cursor: help;
}
.info-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.game-card:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
.game-card:hover .thumb {
  filter: saturate(1.1);
}

/* CTA image full-width contain (no cropping/clipping) */
section[aria-label="Arcade CTA"] .game-card {
  width: 100%;
}
section[aria-label="Arcade CTA"] .thumb {
  aspect-ratio: auto;
  width: 100%;
  height: auto;
  object-fit: contain; /* keep banner undistorted */
  background: transparent;
}

/* Footer */
footer {
  max-width: 1200px;
  margin: 40px auto 60px;
  padding: 0 20px;
  color: var(--muted);
}

/* Back to top */
.to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: var(--shadow);
}

/* Crossfade preview — video confined to same square area, cover fit */
.preview {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: var(--tile-ar);
  width: 100%;
  height: auto; /* aspect-ratio sets height */
  object-fit: cover; /* no letterboxing */
  display: block;
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.game-card.is-previewing .preview {
  opacity: 1;
}
.game-card.is-previewing .thumb {
  opacity: 0;
}

/* Featured preview also cover (explicit but redundant-safe) */
.feature .preview {
  object-fit: cover;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .thumb,
  .preview,
  .game-card {
    transition: none !important;
  }
}

/* Contact link styling */
.contact-link {
  color: #e62727;
  font-weight: 800;
  text-underline-offset: 4px;
  padding: 1px 2px;
  border-radius: 2px;
}
.contact-link:hover,
.contact-link:focus-visible {
  color: #ffffff;
  background: #e62727;
  text-decoration: none;
  box-shadow: var(--shadow);
}

/* Header: make search wrap under brand earlier */
@media (max-width: 820px) {
  .header-wrap {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .brand {
    flex: 1 1 100%;
  }
  .search {
    order: 2;
    width: 100%;
    margin-left: 0;
  }
  .search input {
    width: 100%;
  }
}

/* Offset anchor scrolling so the sticky header doesn't cover sections */
section[id] {
  scroll-margin-top: 266px;
}
@media (max-width: 820px) {
  section[id] {
    scroll-margin-top: 220px;
  }
}

/* Featured: one column & square on mobile */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }
  .feature .thumb {
    aspect-ratio: var(--tile-ar);
  }
}

/* Mobile: centered emoji row with identical gaps */
@media (max-width: 700px) {
  .pill-nav {
    padding: 0 !important;
    margin: 8px 0 0 !important;
    gap: 0 !important;
    column-gap: 0 !important;
    row-gap: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(9, 32px);
    justify-content: center;
  }
  .pill-nav a {
    margin: 0 !important;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    color: transparent;
    text-decoration: none;
  }
  .pill-nav a::before {
    content: attr(data-emoji);
    font-size: 20px;
    line-height: 1;
    color: var(--text);
  }
  .pill-nav a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 6px;
  }
}

/* Only affect small screens (mobile/tablet) */
@media (max-width: 768px) {
  .game-card.not-mobile-friendly {
    filter: grayscale(100%) brightness(0.7);
    opacity: 0.6;
    cursor: not-allowed; /* optional, gives visual feedback */
  }

  .game-card.not-mobile-friendly .meta h4,
  .game-card.not-mobile-friendly .meta p {
    opacity: 0.8;
    padding-left: 2.2rem;
  }

  .game-card.not-mobile-friendly::after {
    content: "📵";
    position: absolute;
    bottom: 1rem;
    left: 0;
    font-size: 2rem;
    /*background: rgba(0,0,0,0.6);*/
    /*border-radius: 50%;*/
    padding: 0.2rem;
    line-height: 1;
    color: white;
  }
}

/* --- NEW: hide Featured + info panel on mobile --- */
/* @media (max-width:700px){
  #featured { display: none !important; }
} */

/* --- Also hide the pill navigation on mobile --- */
@media (max-width: 700px) {
  .pill-nav {
    display: none !important;
  }
}
