/* ==========================================================================
   game.hibranwar.com — Hibranwar Arcade
   Tokens forked verbatim from hibranwar.com. Leather & steel, but playful.
   ========================================================================== */

:root {
  --bg: #111110;
  --bg-elevated: #191918;
  --surface: #222221;
  --surface-hover: #2a2a28;
  --border: #2e2e2c;
  --border-subtle: #252524;
  --text: #ede9e3;
  --text-secondary: #b8b2a8;
  --text-muted: #8a8478;
  --accent: #c8a882;
  --accent-hover: #d9be9e;
  --accent-glow: rgba(200, 168, 130, 0.10);
  --accent-alt: #6b8f71;
  --accent-alt-glow: rgba(107, 143, 113, 0.12);
  --error: #c47a5a;

  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --w-content: 960px;
  --w-full: 1200px;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --transition: 180ms ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: var(--font-body);
  font-size: 1.125rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--accent); color: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.02em;
}
h1 { font-size: 2.75rem; margin-bottom: var(--space-md); }
h2 { font-size: 1.75rem; margin-top: var(--space-3xl); margin-bottom: var(--space-lg); }
h3 { font-size: 1.25rem; margin-bottom: var(--space-sm); }
p  { margin-bottom: var(--space-md); color: var(--text-secondary); }
p:last-child { margin-bottom: 0; }

/* --- Skip link --- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--bg); padding: var(--space-sm) var(--space-md);
  border-radius: 0 0 var(--radius-md) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* --- Layout --- */
main { flex: 1 0 auto; }
.wrap {
  width: 100%; max-width: var(--w-content);
  margin: 0 auto; padding: var(--space-xl) var(--space-lg) var(--space-4xl);
}

/* --- Header --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(17, 17, 16, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.site-header__inner {
  max-width: var(--w-full); margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
  display: flex; align-items: center; gap: var(--space-lg);
}
.site-header__brand {
  font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem;
  color: var(--text); letter-spacing: -0.01em; white-space: nowrap;
}
.site-header__brand:hover { color: var(--text); }
.brand-sub { color: var(--accent); }

.primary-nav { margin-left: auto; }
.nav-list { list-style: none; display: flex; align-items: center; gap: var(--space-lg); }
.nav-item__link {
  font-family: var(--font-heading); font-weight: 500; font-size: 0.95rem;
  color: var(--text-secondary); padding: var(--space-xs) 0;
  border-bottom: 2px solid transparent;
}
.nav-item__link:hover { color: var(--text); }
.nav-item.is-active .nav-item__link { color: var(--text); border-bottom-color: var(--accent); }

.nav-toggle {
  display: none; margin-left: auto; background: none; border: 0; cursor: pointer;
  padding: var(--space-sm); flex-direction: column; gap: 5px;
}
.nav-toggle__bar { display: block; width: 22px; height: 2px; background: var(--text); transition: var(--transition); }
.nav-toggle.is-open .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open .nav-toggle__bar:nth-child(2) { opacity: 0; }
.nav-toggle.is-open .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .primary-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    margin: 0; max-height: 0; overflow: hidden; transition: max-height var(--transition);
  }
  .primary-nav.is-open { max-height: 320px; }
  .nav-list { flex-direction: column; align-items: flex-start; gap: 0; padding: var(--space-sm) var(--space-lg); }
  .nav-item { width: 100%; }
  .nav-item__link { display: block; padding: var(--space-md) 0; width: 100%; border-bottom: 1px solid var(--border-subtle); }
  .nav-item.is-active .nav-item__link { border-bottom-color: var(--border-subtle); color: var(--accent); }
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm);
  font-family: var(--font-heading); font-weight: 600; font-size: 1rem;
  padding: 0.7em 1.4em; border-radius: var(--radius-md); border: 1px solid var(--accent);
  background: var(--accent); color: var(--bg); cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }

/* --- Breadcrumbs --- */
.breadcrumbs { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-xs); font-size: 0.85rem; color: var(--text-muted); margin-bottom: var(--space-lg); }
.breadcrumbs li:not(:last-child)::after { content: '/'; margin-left: var(--space-xs); color: var(--text-muted); }

/* --- Hero --- */
.hero { text-align: center; padding: var(--space-3xl) 0 var(--space-2xl); }
.hero__eyebrow {
  font-family: var(--font-heading); font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin-bottom: var(--space-md);
}
.hero h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); }
.hero__lead { font-size: 1.2rem; color: var(--text-secondary); max-width: 42ch; margin: var(--space-md) auto 0; }

/* --- Game grid --- */
.game-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg); margin: var(--space-2xl) 0;
}
.game-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}
a.game-card:hover { border-color: var(--accent); transform: translateY(-3px); background: var(--surface-hover); }
.game-card__art {
  aspect-ratio: 16 / 10; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1c1b19, #14140f);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
}
.game-card__art svg { width: 100%; height: 100%; display: block; }
.game-card__body { padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-sm); flex: 1; }
.game-card__title { font-family: var(--font-heading); font-weight: 600; font-size: 1.25rem; color: var(--text); }
.game-card__tagline { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.6; flex: 1; }
.game-card__meta { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-xs); }
.tag {
  font-family: var(--font-heading); font-size: 0.7rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px 7px;
}
.game-card__cta {
  font-family: var(--font-heading); font-weight: 600; font-size: 0.9rem; color: var(--accent);
  margin-top: var(--space-sm);
}
a.game-card:hover .game-card__cta { color: var(--accent-hover); }

.game-card.is-soon { opacity: 0.62; }
.game-card.is-soon .game-card__art { background: linear-gradient(135deg, #181715, #121210); }
.badge-soon {
  position: absolute; top: var(--space-sm); right: var(--space-sm);
  font-family: var(--font-heading); font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--bg-elevated); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 8px;
}

/* --- Section note --- */
.section-note {
  border-top: 1px solid var(--border-subtle); padding-top: var(--space-xl);
  margin-top: var(--space-2xl); color: var(--text-muted); font-size: 0.95rem;
}

/* --- Page header (interior pages) --- */
.page-header { padding: var(--space-xl) 0 var(--space-lg); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-xl); }
.page-header h1 { margin-bottom: var(--space-sm); }
.page-header .subtitle { color: var(--text-secondary); font-size: 1.1rem; }

/* ==========================================================================
   Game stage — shared chrome for individual games
   ========================================================================== */
.game-stage {
  max-width: var(--w-full); margin: 0 auto; padding: var(--space-lg);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-md);
}
.game-stage__bar {
  width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md);
}
.game-stage__title { font-family: var(--font-heading); font-weight: 700; font-size: 1.3rem; color: var(--text); }
.game-stage__title a { color: var(--text); }
.game-scores { display: flex; gap: var(--space-lg); }
.game-score { text-align: right; }
.game-score__label { font-family: var(--font-heading); font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); display: block; }
.game-score__value { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.game-frame {
  position: relative; width: 100%; max-width: 520px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  background: #0d0d0c; touch-action: none; box-shadow: 0 18px 50px rgba(0,0,0,0.45);
}
.game-frame canvas { display: block; width: 100%; height: auto; }

.game-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--space-md); text-align: center;
  background: rgba(13, 13, 12, 0.82); backdrop-filter: blur(3px);
  padding: var(--space-xl); transition: opacity var(--transition);
}
.game-overlay[hidden] { display: none; }
.game-overlay__title { font-family: var(--font-heading); font-weight: 700; font-size: 1.75rem; color: var(--text); }
.game-overlay__msg { color: var(--text-secondary); max-width: 30ch; }
.game-overlay__hint { color: var(--text-muted); font-size: 0.85rem; }

.game-help {
  width: 100%; max-width: 520px; color: var(--text-muted); font-size: 0.9rem;
  display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); justify-content: center;
}
.game-help kbd {
  font-family: var(--font-mono); font-size: 0.8rem; background: var(--surface);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-sm);
  padding: 1px 6px; color: var(--text-secondary);
}

.game-about { max-width: var(--w-content); margin: var(--space-2xl) auto 0; padding: 0 var(--space-lg); }
.game-about h2 { margin-top: var(--space-xl); font-size: 1.4rem; }

/* --- Footer --- */
.site-footer {
  flex-shrink: 0; border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated); padding: var(--space-xl) 0;
}
.site-footer .wrap { padding-top: 0; padding-bottom: 0; }
.footer-top { display: flex; flex-wrap: wrap; gap: var(--space-md) var(--space-lg); align-items: center; justify-content: space-between; }
.footer-copy { color: var(--text-secondary); font-size: 0.9rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-md); font-size: 0.9rem; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }
.footer-note { margin-top: var(--space-md); color: var(--text-muted); font-size: 0.8rem; }

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 480px) {
  .wrap { padding: var(--space-lg) var(--space-md) var(--space-3xl); }
  h1 { font-size: 2.1rem; }
  .game-stage { padding: var(--space-md) var(--space-sm); }
}
