/**
 * BNS Data Games - thin layer over stock Bootstrap 5.
 *
 * Shares the palette and the navbar/footer treatment of the sibling tools site
 * so the two read as one family, then adds what an arcade needs and a utility
 * site does not: a dark monospaced "screen" for the text playfield, an on-screen
 * control pad for touch devices, and the game/score card grids.
 *
 * No webfont is loaded - the UI uses the system stack and the playfield uses the
 * system monospace stack, which keeps a game page fast on a phone and makes the
 * ASCII grid render in whatever fixed-width face the device already has.
 *
 * Only plain hyphens are used in this file, never an em dash, per house style.
 */

:root {
  /* BNS Data palette, applied through Bootstrap's own custom properties. */
  --bns-navy: #0b2241;
  --bns-navy-mid: #1a3a5c;
  --bns-gold: #b8944a;
  --bns-cream: #faf9f6;
  --bns-cream-mid: #f2f0eb;
  --bns-border: #ddd9cf;

  /* The playfield screen - a near-black terminal with a warm phosphor text. */
  --bns-screen-bg: #0a0f16;
  --bns-screen-fg: #e8eef5;
  --bns-screen-dim: #5b6b7d;
  --bns-screen-accent: #b8944a;
  --bns-screen-good: #5bd68a;
  --bns-screen-warn: #e86a6a;

  --bs-primary: #0b2241;
  --bs-primary-rgb: 11, 34, 65;
  --bs-link-color: #1a3a5c;
  --bs-link-color-rgb: 26, 58, 92;
  --bs-link-hover-color: #b8944a;
  --bs-link-hover-color-rgb: 184, 148, 74;
  --bs-body-bg: #ffffff;
  --bs-body-color: #1c1c1c;
  --bs-border-color: #ddd9cf;
  --bs-border-radius: 0.375rem;

  --bns-mono: ui-monospace, "SFMono-Regular", "SF Mono", "Cascadia Mono",
    "Liberation Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

body {
  background: var(--bs-body-bg);
}

/* -- buttons --------------------------------------------- */

.btn-primary {
  --bs-btn-bg: var(--bns-navy);
  --bs-btn-border-color: var(--bns-navy);
  --bs-btn-hover-bg: var(--bns-navy-mid);
  --bs-btn-hover-border-color: var(--bns-navy-mid);
  --bs-btn-active-bg: var(--bns-navy-mid);
  --bs-btn-active-border-color: var(--bns-navy-mid);
}
.btn-outline-primary {
  --bs-btn-color: var(--bns-navy);
  --bs-btn-border-color: var(--bns-navy);
  --bs-btn-hover-bg: var(--bns-navy);
  --bs-btn-hover-border-color: var(--bns-navy);
  --bs-btn-active-bg: var(--bns-navy);
}

/* -- navbar and footer ----------------------------------- */

.bns-navbar {
  background: var(--bns-navy);
  --bs-navbar-color: rgba(255, 255, 255, 0.82);
  --bs-navbar-hover-color: #fff;
  --bs-navbar-active-color: #fff;
  --bs-navbar-brand-color: #fff;
  --bs-navbar-brand-hover-color: #fff;
  --bs-navbar-toggler-border-color: rgba(255, 255, 255, 0.3);
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.bns-navbar .navbar-brand {
  font-weight: 600;
  letter-spacing: 0.01em;
}
.bns-navbar .bns-parent-link {
  color: var(--bns-gold) !important;
}

.bns-footer {
  background: var(--bns-cream-mid);
  border-top: 1px solid var(--bns-border);
  padding: 2.5rem 0 1.5rem;
  margin-top: 4rem;
  font-size: 0.9375rem;
}
.bns-footer-brand {
  font-weight: 600;
  color: var(--bns-navy);
}
.bns-footer-heading {
  font-weight: 600;
  color: var(--bns-navy);
  margin-bottom: 0.5rem;
}
.bns-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bns-footer-links a {
  color: var(--bns-navy-mid);
  text-decoration: none;
}
.bns-footer-links a:hover {
  color: var(--bns-gold);
  text-decoration: underline;
}
.bns-footer-legal {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bns-border);
  color: #6b6b6b;
  font-size: 0.8125rem;
}

/* -- layout ---------------------------------------------- */

.bns-main {
  padding: 1.5rem 0 1rem;
  min-height: 60vh;
}
.bns-breadcrumb {
  --bs-breadcrumb-divider-color: #9a9a9a;
  font-size: 0.875rem;
}
.bns-breadcrumb a {
  color: var(--bns-navy-mid);
  text-decoration: none;
}
.bns-page-head {
  margin-bottom: 1.5rem;
}
.bns-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.bns-eyebrow a {
  color: var(--bns-gold);
  text-decoration: none;
}
.bns-page-head h1 {
  color: var(--bns-navy);
  font-weight: 700;
}
.bns-lead {
  color: #44474b;
  font-size: 1.0625rem;
  max-width: 62ch;
}

/* -- hero (home) ----------------------------------------- */

.bns-hero {
  padding: 1rem 0 2rem;
  text-align: center;
}
.bns-hero h1 {
  color: var(--bns-navy);
  font-weight: 700;
}
.bns-hero .bns-lead {
  margin: 0 auto;
}
.bns-search-row {
  margin: 1.25rem 0 0.5rem;
}
.bns-search-hero {
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
}

/* -- play row: game on the left, switcher on the right ---- */

/* The game gets the room (roughly four fifths) and the switcher rail sits
   beside it (one fifth). On a narrow screen there is no room for two columns,
   so the row wraps and the rail drops under the game instead of squeezing it. */
.bns-play-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
  margin: 0 0 1.25rem;
}
.bns-play-main {
  flex: 1 1 20rem;
  min-width: 0; /* let the board shrink inside the column rather than overflow */
}
.bns-play-rail {
  flex: 1 1 12rem;
  max-width: 20rem;
}
@media (min-width: 768px) {
  .bns-play-main {
    flex: 4 1 0; /* 4 shares to the game... */
  }
  .bns-play-rail {
    flex: 1 1 0; /* ...1 share to the rail, i.e. the 80/20 split */
    position: sticky;
    top: 1rem; /* keep the switcher in view while the page scrolls */
  }
}

/* The switcher itself: a heading, two tabs (one per group), and a list of
   games under the active tab. The current game is shown but not linked. */
.bns-rail-head {
  margin: 0 0 0.5rem;
  font-family: var(--bns-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bns-screen-dim);
}
.bns-rail-tabs {
  --bs-nav-tabs-link-active-color: var(--bns-navy);
  font-size: 0.875rem;
}
.bns-rail-tabs .nav-link {
  color: var(--bns-navy);
  padding: 0.35rem 0.7rem;
}
.bns-rail-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}
.bns-rail-list li {
  margin: 0;
}
.bns-rail-link {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  color: var(--bns-navy);
  text-decoration: none;
}
.bns-rail-link:hover,
.bns-rail-link:focus {
  background: rgba(11, 34, 65, 0.06);
}
.bns-rail-current {
  font-weight: 600;
  color: var(--bns-gold);
  background: rgba(184, 148, 74, 0.1);
}

/* -- tool controls (randomizers) -------------------------- */

/* Tools reuse the game action row, but their hint sits just below it. */
.bns-tool-hint {
  width: 100%;
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--bns-screen-dim);
}

/* -- the playfield screen -------------------------------- */

.bns-game-shell {
  margin: 0 0 1.25rem;
}
.bns-game {
  background: var(--bns-screen-bg);
  color: var(--bns-screen-fg);
  border: 1px solid #000;
  border-radius: 0.5rem;
  padding: clamp(0.5rem, 2vw, 1rem);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 6px 20px rgba(11, 34, 65, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* The status line above the board - score, best, state. */
.bns-game-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  width: 100%;
  font-family: var(--bns-mono);
  font-size: 0.8125rem;
  color: var(--bns-screen-dim);
}
.bns-game-status strong {
  color: var(--bns-screen-fg);
  font-weight: 600;
}
.bns-game-status .bns-stat-accent {
  color: var(--bns-screen-accent);
}

/* The board itself - real monospaced text, sized to fill the width without
   ever overflowing it. ch units keep the aspect ratio honest to the grid. */
.bns-screen {
  font-family: var(--bns-mono);
  line-height: 1.0;
  white-space: pre;
  margin: 0;
  letter-spacing: 0;
  color: var(--bns-screen-fg);
  /* The grid is drawn to fit cols x rows exactly, so the screen never needs to
     scroll. Override Bootstrap Reboot's `pre { overflow: auto }`, which would
     otherwise raise a scrollbar over a sub-pixel rounding of the line height. */
  overflow: hidden;
  /* Scale the glyph to the container: full grid width is roughly cols ch. */
  font-size: clamp(0.5rem, calc(92vw / var(--bns-cols, 24)), 1.5rem);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
@media (min-width: 576px) {
  .bns-screen {
    font-size: clamp(0.6rem, calc(540px / var(--bns-cols, 24)), 1.5rem);
  }
}
.bns-screen .cell-accent { color: var(--bns-screen-accent); }
.bns-screen .cell-good { color: var(--bns-screen-good); }
.bns-screen .cell-warn { color: var(--bns-screen-warn); }
.bns-screen .cell-dim { color: var(--bns-screen-dim); }

/* An overlay banner (paused, game over, start) drawn over the board. */
.bns-game-overlay {
  width: 100%;
  text-align: center;
  font-family: var(--bns-mono);
  color: var(--bns-screen-fg);
  min-height: 1.25rem;
  font-size: 0.9375rem;
}
.bns-game-overlay .bns-over-title {
  color: var(--bns-screen-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Primary action row under the board (New game, Pause). */
.bns-game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.bns-game-actions .btn {
  --bs-btn-color: var(--bns-screen-fg);
  --bs-btn-border-color: rgba(255, 255, 255, 0.25);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: rgba(255, 255, 255, 0.1);
  --bs-btn-hover-border-color: rgba(255, 255, 255, 0.4);
  font-size: 0.875rem;
}

/* -- on-screen touch controls ---------------------------- */

/* Shown only where a coarse pointer (a finger) is the primary input, so a
   desktop player never sees a redundant D-pad. */
.bns-touch {
  display: none;
  width: 100%;
  max-width: 16rem;
  margin-top: 0.25rem;
  -webkit-user-select: none;
  user-select: none;
}
@media (hover: none) and (pointer: coarse) {
  .bns-touch { display: block; }
}
.bns-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.bns-dpad button,
.bns-touch-row button {
  font-family: var(--bns-mono);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.7rem 0;
  color: var(--bns-screen-fg);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.4rem;
  touch-action: manipulation;
}
.bns-dpad button:active,
.bns-touch-row button:active {
  background: rgba(184, 148, 74, 0.35);
}
.bns-dpad .bns-dpad-spacer {
  visibility: hidden;
}
.bns-touch-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.bns-touch-row button {
  font-size: 0.8125rem;
  padding: 0.6rem 0.25rem;
}

/* -- content sections ------------------------------------ */

.bns-section {
  margin: 2.25rem 0;
  max-width: 68ch;
}
.bns-section h2 {
  color: var(--bns-navy);
  font-weight: 700;
  font-size: 1.375rem;
  margin-bottom: 0.9rem;
}
.bns-section p {
  color: #333;
}
#related,
#tools {
  max-width: none;
}

.bns-legend {
  --bs-table-bg: transparent;
  max-width: 34rem;
}
.bns-legend th {
  width: 14rem;
  font-weight: 500;
  white-space: nowrap;
}
.bns-legend kbd {
  background: var(--bns-navy);
  color: #fff;
  font-size: 0.8125rem;
}
.bns-steps li,
.bns-prose li {
  margin-bottom: 0.5rem;
}

.bns-privacy {
  background: var(--bns-cream);
  border: 1px solid var(--bns-border);
  border-left: 3px solid var(--bns-gold);
  border-radius: 0.375rem;
  padding: 0.85rem 1rem;
  font-size: 0.9375rem;
  color: #44474b;
  margin: 1.25rem 0;
}
.bns-privacy a {
  color: var(--bns-navy-mid);
}

/* -- FAQ ------------------------------------------------- */

.bns-faq {
  --bs-accordion-btn-focus-box-shadow: 0 0 0 0.2rem rgba(184, 148, 74, 0.25);
  --bs-accordion-active-bg: var(--bns-cream);
  --bs-accordion-active-color: var(--bns-navy);
  --bs-accordion-border-color: var(--bns-border);
}
.bns-faq .accordion-button {
  font-weight: 500;
}

/* -- card grids ------------------------------------------ */

.bns-cat-group {
  margin: 2rem 0;
}
.bns-cat-head h2 {
  margin-bottom: 0.15rem;
}
.bns-cat-head h2 a {
  color: var(--bns-navy);
  text-decoration: none;
}
.bns-cat-head h2 a:hover {
  color: var(--bns-gold);
}
.bns-cat-head p {
  color: #5a5d61;
  margin-bottom: 1rem;
}

.bns-game-card,
.bns-related-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1rem 1.1rem;
  background: #fff;
  border: 1px solid var(--bns-border);
  border-radius: 0.5rem;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.bns-game-card:hover,
.bns-related-card:hover {
  border-color: var(--bns-gold);
  box-shadow: 0 4px 14px rgba(11, 34, 65, 0.1);
  transform: translateY(-2px);
}
.bns-game-name,
.bns-related-name {
  font-weight: 600;
  color: var(--bns-navy);
  margin-bottom: 0.25rem;
}
.bns-game-summary,
.bns-related-summary {
  color: #5a5d61;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* -- product cross-link ---------------------------------- */

.bns-product-card {
  background: var(--bns-cream);
  border: 1px solid var(--bns-border);
  border-radius: 0.5rem;
  padding: 1.25rem 1.4rem;
}
.bns-product-name {
  font-weight: 700;
  color: var(--bns-navy);
  margin-bottom: 0.35rem;
}
.bns-product-copy {
  color: #44474b;
  margin-bottom: 0.9rem;
  max-width: 60ch;
}

.bns-clear-row {
  margin-top: 2rem;
  text-align: center;
}

/* -- static prose pages ---------------------------------- */

.bns-prose {
  max-width: 68ch;
}
.bns-prose h1 {
  color: var(--bns-navy);
  font-weight: 700;
}
.bns-prose h2 {
  color: var(--bns-navy);
  font-weight: 700;
  font-size: 1.375rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.bns-prose p,
.bns-prose li {
  color: #333;
}

/* -- reserved ad space ----------------------------------- */

.bns-ad {
  display: block;
  width: 100%;
  min-height: var(--ad-h, 90px);
  margin: 1rem 0;
  background: repeating-linear-gradient(
    45deg,
    var(--bns-cream),
    var(--bns-cream) 10px,
    var(--bns-cream-mid) 10px,
    var(--bns-cream-mid) 20px
  );
  border: 1px dashed var(--bns-border);
  border-radius: 0.375rem;
}
@media (max-width: 575.98px) {
  .bns-ad {
    min-height: var(--ad-h-sm, 100px);
  }
}
.bns-ad .adsbygoogle {
  background: none;
  border: 0;
}
