/* =========================================================
   Base Styles — Modern immersive game library
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  font-family: var(--font-ar);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-primary);
  direction: rtl;
}

/* faint CRT scanlines */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.018) 0px,
    rgba(255, 255, 255, 0.018) 1px,
    transparent 1px,
    transparent 3px
  );
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-xl);
  }
}

/* Visually-hidden but available to assistive tech (skip-link / section labels). */
.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;
}

/* Stat chip — reused by formatStats() in the card/modal. */
.stat {
  min-width: 78px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.main-content {
  padding-bottom: var(--space-2xl);
  min-height: 50vh;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: var(--header-height);
  flex-wrap: wrap;
}

.topbar__brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.topbar__sep { color: var(--text-muted); }

.topbar__nav a { transition: color var(--transition-fast); }
.topbar__nav a:hover { color: var(--accent-hover); }
.topbar__nav a.is-active { color: var(--text-primary); text-decoration: underline; text-underline-offset: 4px; }

/* Visible keyboard focus for all interactive elements (terminal-style box). */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.topbar__brand:focus-visible,
.topbar__nav a:focus-visible { color: var(--accent-hover); }

/* ---- masthead ---- */
.masthead {
  text-align: center;
  padding-block: var(--space-2xl) var(--space-lg);
}

.masthead__rule {
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.1;
  user-select: none;
}

.masthead__title {
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  padding-block: var(--space-md);
}

.masthead__title span { color: var(--text-muted); font-family: var(--font-mono); }

.masthead__hint {
  margin-top: var(--space-sm);
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: var(--text-sm);
}

/* ---- footer status bar ---- */
.site-footer {
  margin-top: var(--space-2xl);
  padding-block: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.statusbar strong { color: var(--text-primary); }

.games-section {
  padding-block: var(--space-xl);
}

.games-section[hidden] {
  display: none !important;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
  font-size: var(--text-lg);
  font-weight: 700;
}

.section-title::before {
  content: '››';
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.section-title__icon {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding-inline: 0.6rem;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}

@media (max-width: 768px) {
  /* Center the wrapped top bar (brand on one line, nav under it). */
  .topbar__inner { justify-content: center; }

  /* Trim the big masthead spacing so content starts sooner. */
  .masthead { padding-block: var(--space-lg) var(--space-md); }
  .masthead__title { padding-block: var(--space-sm); }
}

@media (max-width: 640px) {
  .stat {
    min-width: 0;
  }
}
