/* ============================================
   BitPulse — Global CSS
   Design System: Financial Intelligence Terminal
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Colors — Dark Theme (default) */
  --color-bg-primary: #0a0f1e;
  --color-bg-secondary: #111827;
  --color-bg-tertiary: #1a2035;
  --color-bg-card: rgba(17, 24, 39, 0.8);
  --color-bg-card-hover: rgba(26, 32, 53, 0.95);
  --color-bg-glass: rgba(17, 24, 39, 0.6);

  --color-accent: #00d4b4;
  --color-accent-hover: #00f0cc;
  --color-accent-dim: rgba(0, 212, 180, 0.15);
  --color-btc: #f4a623;
  --color-btc-dim: rgba(244, 166, 35, 0.15);
  --color-text-primary: #f0f4ff;
  --color-text-secondary: #8b95b0;
  --color-text-muted: #5a6479;
  --color-border: rgba(139, 149, 176, 0.15);
  --color-border-hover: rgba(0, 212, 180, 0.3);

  --color-green: #00e676;
  --color-green-dim: rgba(0, 230, 118, 0.15);
  --color-red: #ff5252;
  --color-red-dim: rgba(255, 82, 82, 0.15);

  --color-overlay: rgba(10, 15, 30, 0.85);

  /* Typography */
  --font-heading: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.5rem;
  --fs-4xl: 3.5rem;
  --fs-5xl: 4.5rem;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.6;

  /* Spacing */
  --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;
  --space-5xl: 8rem;

  /* Layout */
  --max-width: 1280px;
  --max-width-narrow: 800px;
  --header-height: 72px;
  --ticker-height: 36px;

  /* Borders & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow-accent: 0 0 20px rgba(0, 212, 180, 0.2);
  --shadow-glow-btc: 0 0 20px rgba(244, 166, 35, 0.2);

  /* Transitions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;

  /* Z-index layers */
  --z-ticker: 1000;
  --z-header: 1100;
  --z-drawer: 1200;
  --z-modal: 1300;
  --z-toast: 1400;
}

/* --- Light Theme --- */
[data-theme="light"] {
  --color-bg-primary: #f5f7fb;
  --color-bg-secondary: #ffffff;
  --color-bg-tertiary: #eaeff5;
  --color-bg-card: rgba(255, 255, 255, 0.9);
  --color-bg-card-hover: rgba(255, 255, 255, 1);
  --color-bg-glass: rgba(255, 255, 255, 0.7);

  --color-accent: #009d87;
  --color-accent-hover: #00b89a;
  --color-accent-dim: rgba(0, 157, 135, 0.1);
  --color-btc: #d48b0a;
  --color-btc-dim: rgba(212, 139, 10, 0.1);
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-border: rgba(15, 23, 42, 0.1);
  --color-border-hover: rgba(0, 157, 135, 0.3);

  --color-green: #059669;
  --color-green-dim: rgba(5, 150, 105, 0.1);
  --color-red: #dc2626;
  --color-red-dim: rgba(220, 38, 38, 0.1);

  --color-overlay: rgba(255, 255, 255, 0.85);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-glow-accent: 0 0 20px rgba(0, 157, 135, 0.15);
  --shadow-glow-btc: 0 0 20px rgba(212, 139, 10, 0.15);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Increased scroll padding for fixed header clearance */
  scroll-padding-top: calc(var(--header-height) + var(--ticker-height) + 2rem);
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Prevent layout shift from scrollbar */
html {
  scrollbar-gutter: stable;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-smooth);
}

a:hover {
  color: var(--color-accent-hover);
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

p {
  color: var(--color-text-secondary);
}

::selection {
  background-color: var(--color-accent);
  color: var(--color-bg-primary);
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
}

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

/* --- Layout Utilities --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

.container--narrow {
  max-width: var(--max-width-narrow);
}

.section {
  padding-block: var(--space-4xl);
}

.section--sm {
  padding-block: var(--space-2xl);
}

.section--lg {
  padding-block: var(--space-5xl);
}

/* --- Typography Utilities --- */
.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }
.font-mono { font-family: var(--font-mono); }

.text-accent { color: var(--color-accent); }
.text-btc { color: var(--color-btc); }
.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.gradient-text {
  background: linear-gradient(135deg, var(--color-accent), var(--color-btc));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Grid & Flex --- */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex {
  display: flex;
  gap: var(--space-md);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Visually Hidden (Accessibility) --- */
.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;
}

/* --- Focus Styles --- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Skip to Content --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--color-accent);
  color: var(--color-bg-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  z-index: var(--z-toast);
  transition: top var(--duration-fast) var(--ease-smooth);
}

.skip-link:focus {
  top: var(--space-md);
  color: var(--color-bg-primary);
}

/* --- Main Content --- */
main {
  min-height: 100vh;
  /* Ensure main content never hides under fixed header with extra buffer */
  padding-top: calc(var(--header-height) + var(--ticker-height) + 2rem);
}

/* --- Page Header --- */
.page-header {
  padding-block: var(--space-4xl) var(--space-2xl);
  text-align: center;
  position: relative;
  background: linear-gradient(to bottom, var(--color-bg-secondary), var(--color-bg-primary));
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  margin-bottom: var(--space-md);
}

.page-header .subtitle {
  font-size: var(--fs-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin-inline: auto;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  :root {
    --fs-4xl: 2.75rem;
    --fs-3xl: 2rem;
    --fs-2xl: 1.75rem;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --fs-4xl: 2.25rem;
    --fs-3xl: 1.75rem;
    --fs-2xl: 1.5rem;
    --space-4xl: 4rem;
    --space-5xl: 5rem;
  }

  .container {
    padding-inline: var(--space-md);
  }

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .section {
    padding-block: var(--space-2xl);
  }
}

@media (max-width: 480px) {
  :root {
    --fs-4xl: 1.875rem;
    --fs-3xl: 1.5rem;
    --fs-2xl: 1.25rem;
  }
}
