/* ============================================================
   base.css — Reset, CSS vars, keyframes, global body styles
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
}

/* --- Dark theme (default) --- */
[data-theme="dark"],
:root {
  --bg: #07080d;
  --surface: #0d0e18;
  --surface-2: #131422;
  --surface-3: #1a1c2c;
  --border: #1e2038;
  --border-light: #2a2c4a;
  --text: #e8e6de;
  --text-dim: #9e9db0;
  --text-muted: #8585a0;
  --accent: #bfb060;
  --accent-dim: #a89850;
  --accent-hover: #d0c070;
  --accent-glow: rgba(191, 176, 96, 0.06);
  --green: #57a872;
  --red-vivid: #dd4444;
  --blue: #578cba;
  --highlight-bg: rgba(191, 176, 96, 0.1);
  --highlight-text: #d0c070;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --shadow-card: rgba(0, 0, 0, 0.3);
  --pinned-bg: rgba(7, 8, 13, 0.96);
  --noise-opacity: 0.02;
}

/* --- Light theme --- */
[data-theme="light"] {
  --bg: #f5f2ed;
  --surface: #ffffff;
  --surface-2: #f0ece4;
  --surface-3: #e6e2d8;
  --border: #dcd8ce;
  --border-light: #c9c4b8;
  --text: #1a1a18;
  --text-dim: #6b6558;
  --text-muted: #9b9484;
  --accent: #7a6f3a;
  --accent-dim: #635a2e;
  --accent-hover: #635a2e;
  --accent-glow: rgba(122, 111, 58, 0.08);
  --green: #3d8a56;
  --red-vivid: #c04040;
  --blue: #3d6f94;
  --highlight-bg: rgba(122, 111, 58, 0.12);
  --highlight-text: #7a6f3a;
  --shadow-color: rgba(0, 0, 0, 0.08);
  --shadow-card: rgba(0, 0, 0, 0.06);
  --pinned-bg: rgba(245, 242, 237, 0.96);
  --noise-opacity: 0.015;
}

/* --- Theme transition --- */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  background-color: var(--bg);
  transition:
    background-color 0.4s ease,
    color 0.3s ease,
    border-color 0.4s ease,
    box-shadow 0.4s ease !important;
}

/* --- Keyframes --- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* --- Reduced motion --- */
@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;
  }
}

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

/* --- Base elements --- */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

/* --- Noise texture overlay --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  opacity: var(--noise-opacity);
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  background: var(--accent);
  color: var(--bg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: var(--space-4);
}

/* --- Screen-reader only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- Links --- */
a {
  color: inherit;
  text-decoration: none;
}

/* --- Lists --- */
ul, ol {
  list-style: none;
}

/* --- Buttons --- */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  line-height: 1;
}

/* --- Inputs and selects --- */
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

/* --- Focus visible (accessibility) --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Images --- */
img, svg {
  display: block;
  max-width: 100%;
}
