/*
 * base.css — UI Kit Global Styles
 *
 * Reset, page surface, scrollbars, scanline, glow, default vignette,
 * shared @keyframes, and reduced-motion override.
 *
 * Load after tokens.css. All colors come from token variables.
 */

/* ── Reset ────────────────────────────────────────────────────────────── */

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

/* ── Page surface ─────────────────────────────────────────────────────── */

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

html.scroll-locked,
body.scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

body.scroll-locked {
  position: fixed;
  width: 100%;
}

/* ── Scrollbars ───────────────────────────────────────────────────────── */
/* Global only. Modules must not define their own scrollbar rules.        */

::-webkit-scrollbar             { width: 6px; height: 6px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-corner      { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

html {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Scanline overlay ─────────────────────────────────────────────────── */
/* Themes override background only. Structure stays here.                 */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.07) 2px,
    rgba(0, 0, 0, 0.07) 4px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── Default vignette ─────────────────────────────────────────────────── */
/* Republic / Empire override this with stronger theme-specific versions. */

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
  z-index: 998;
}

/* ── Glow blob ────────────────────────────────────────────────────────── */

.glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--accent) 4%, transparent) 0%,
    transparent 70%
  );
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ── Animations ───────────────────────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 20%, transparent); }
  50%      { box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 35%, transparent); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes tile-appear {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
  }

  .tile-appear {
    animation: tile-appear 0.6s ease both;
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
/* Applied by Settings accessibility toggle (Phase 10).                   */

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
