/* ═══════════════════════════════════════════════════════════════════════════
   BASE - Reset, body defaults, grain texture, base typography
═══════════════════════════════════════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
}

html, body {
  height: 100%;
  background: var(--bg-deep);
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  font-kerning: auto;
  background: var(--gradient-surface);
  background-attachment: fixed;
}

/* Subtle grain texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.15;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Base link/input styling */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

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

/* Themed text selection */
::selection {
  background: rgba(59, 130, 246, 0.3);
}

/* Keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

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

/* Utilities */
.hidden { display: none !important; }
.d-none { display: none !important; }
.text-muted { color: var(--text-muted) !important; }
