/* ============================================
   OBSILA INTELLIGENCE — Global Styles
   Obsidian-inspired dark premium crypto analytics
   ============================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Manrope:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Obsidian palette */
  --bg-deep:        #060609;
  --bg-base:        #0a0a10;
  --bg-surface:     #101018;
  --bg-elevated:    #16161f;
  --bg-card:        #1a1a24;
  --bg-hover:       #22222e;

  /* Borders & dividers */
  --border-subtle:  #1e1e2a;
  --border-default: #2a2a3a;
  --border-strong:  #3a3a4e;

  /* Text */
  --text-primary:   #e8e8f0;
  --text-secondary: #9494a8;
  --text-muted:     #5e5e72;
  --text-inverse:   #0a0a10;

  /* Accent — volcanic gold */
  --accent-gold:    #c9a84c;
  --accent-gold-dim:#8a7435;
  --accent-gold-glow: rgba(201,168,76,0.15);

  /* Functional colors */
  --positive:       #22c55e;
  --positive-dim:   #166534;
  --negative:       #ef4444;
  --negative-dim:   #7f1d1d;
  --info:           #3b82f6;
  --warning:        #f59e0b;

  /* Chart palette */
  --chart-1:        #c9a84c;
  --chart-2:        #3b82f6;
  --chart-3:        #22c55e;
  --chart-4:        #a855f7;
  --chart-5:        #ec4899;
  --chart-6:        #14b8a6;
  --chart-7:        #f97316;
  --chart-8:        #06b6d4;

  /* Typography */
  --font-display:   'Syne', sans-serif;
  --font-body:      'Manrope', sans-serif;
  --font-mono:      'Space Mono', monospace;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --space-4xl: 96px;

  /* Radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-elevated: 0 4px 24px rgba(0,0,0,0.5), 0 8px 48px rgba(0,0,0,0.3);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-deep);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  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)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

a { color: var(--accent-gold); text-decoration: none; }
a:hover { color: var(--text-primary); }

img { max-width: 100%; display: block; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Utility Classes --- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

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

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-muted    { color: var(--text-muted); }
.text-gold     { color: var(--accent-gold); }

/* --- Header / Navigation --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(6,6,9,0.85);
  backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.logo-text span {
  color: var(--accent-gold);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  border: none;
  background: none;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent-gold);
  background: var(--accent-gold-glow);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.header-meta .price-tag {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 700;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  display: inline-block;
  margin-right: 4px;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-sm);
}

/* --- Hero Section --- */
.hero {
  padding: var(--space-4xl) 0 var(--space-3xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, var(--accent-gold-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: var(--space-md);
  opacity: 0;
  animation: fadeUp 0.6s var(--ease-out) 0.1s forwards;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: var(--space-lg);
  opacity: 0;
  animation: fadeUp 0.6s var(--ease-out) 0.2s forwards;
}

.hero-title .accent {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #e8d48b 50%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 580px;
  margin: 0 auto var(--space-2xl);
  line-height: 1.7;
  opacity: 0;
  animation: fadeUp 0.6s var(--ease-out) 0.3s forwards;
}

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

/* --- Metrics Bar --- */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-3xl);
  opacity: 0;
  animation: fadeUp 0.6s var(--ease-out) 0.4s forwards;
}

.metric-cell {
  background: var(--bg-surface);
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-change {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
}

/* --- Card --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  border-color: var(--border-default);
}

.card-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-title-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.card-body {
  padding: var(--space-xl);
}

.card-body.flush {
  padding: 0;
}

/* --- Section Navigation Tabs --- */
.section-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.section-tab {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.section-tab:hover {
  color: var(--text-secondary);
  border-color: var(--border-default);
}

.section-tab.active {
  color: var(--accent-gold);
  border-color: var(--accent-gold-dim);
  background: var(--accent-gold-glow);
}

/* --- Top 20 Crypto Table --- */
.crypto-table-wrap {
  overflow-x: auto;
}

.crypto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.crypto-table thead th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
}

.crypto-table thead th.right,
.crypto-table tbody td.right {
  text-align: right;
}

.crypto-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
}

.crypto-table tbody tr:last-child {
  border-bottom: none;
}

.crypto-table tbody tr:hover {
  background: var(--bg-hover);
}

.crypto-table tbody td {
  padding: var(--space-md) var(--space-lg);
  white-space: nowrap;
}

.crypto-table .rank {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 32px;
}

.coin-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.coin-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.coin-name {
  font-weight: 600;
  color: var(--text-primary);
}

.coin-symbol {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  margin-left: 4px;
}

.price-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.change-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
}

.mcap-cell, .vol-cell {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.sparkline-cell {
  width: 120px;
}

.sparkline-cell canvas {
  width: 100%;
  height: 36px;
}

/* --- Chart Container --- */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 380px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Fear & Greed Gauge --- */
.fng-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.fng-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}

.fng-gauge {
  position: relative;
  width: 240px;
  height: 140px;
}

.fng-value-display {
  text-align: center;
  margin-top: var(--space-lg);
}

.fng-value {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
}

.fng-label {
  font-size: 1rem;
  font-weight: 600;
  margin-top: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fng-history {
  padding: var(--space-xl);
}

.fng-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: var(--space-sm);
}

.fng-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.fng-day-date {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.fng-day-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- Monthly Returns Heatmap --- */
.returns-table-wrap {
  overflow-x: auto;
}

.returns-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 0.75rem;
}

.returns-table th {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--space-sm);
  text-align: center;
  text-transform: uppercase;
}

.returns-table th.year-col {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.returns-table td {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: center;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  min-width: 56px;
  transition: transform var(--duration-fast);
}

.returns-table td:hover {
  transform: scale(1.08);
  z-index: 2;
  position: relative;
}

.returns-table td.no-data {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.returns-table .yearly-col {
  font-weight: 700;
  border-left: 2px solid var(--border-default);
}

/* --- Loading States --- */
.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-line {
  height: 18px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
}

.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w40 { width: 40%; }

/* Loading spinner */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
}

.spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Cycle Markers on charts --- */
.halving-legend {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin-top: var(--space-md);
  padding: var(--space-md) 0;
}

.halving-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.halving-legend-item .swatch {
  width: 12px;
  height: 3px;
  border-radius: 1px;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-4xl);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-inner a {
  color: var(--text-muted);
  transition: color var(--duration-fast);
}

.footer-inner a:hover {
  color: var(--accent-gold);
}

/* --- Page Sections (toggled) --- */
.page-section {
  display: none;
}

.page-section.visible {
  display: block;
  animation: fadeUp 0.4s var(--ease-out);
}

/* --- Charts Grid --- */
.charts-grid {
  display: grid;
  gap: var(--space-xl);
}

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

/* --- Responsive --- */
@media (max-width: 1024px) {
  .charts-grid.cols-2 { grid-template-columns: 1fr; }
  .fng-section { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .container { padding: 0 var(--space-md); }
  .section-spacer { padding: var(--space-2xl) 0; }

  .main-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-md);
  }

  .main-nav.open { display: flex; }
  .nav-toggle { display: block; }
  .header-meta { display: none; }

  .hero-title { font-size: 2rem; }
  .metrics-bar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .metrics-bar { grid-template-columns: 1fr; }
}

/* --- Error state --- */
.error-msg {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-msg .retry-btn {
  display: inline-block;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--duration-fast);
}

.error-msg .retry-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* --- Tooltip --- */
.chart-tooltip {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.75rem !important;
  padding: var(--space-sm) var(--space-md) !important;
}

/* --- Info tag --- */
.info-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 99px;
  background: var(--accent-gold-glow);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold-dim);
}

/* Cycle background bands for charts */
.cycle-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
