/* ================================================
   Korea Fear & Greed Index — Design System
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Base colors */
  --bg-base:       #080c12;
  --bg-primary:    #0d1117;
  --bg-secondary:  #111827;
  --bg-card:       #161e2e;
  --bg-card-2:     #1a2235;
  --bg-hover:      #1f2a3d;
  --border:        #1e2d45;
  --border-light:  #253550;

  /* Text */
  --text-primary:   #f0f4fc;
  --text-secondary: #8899b4;
  --text-tertiary:  #4a5a70;

  /* Fear / Greed spectrum */
  --extreme-fear:  #ef233c;
  --fear:          #f97316;
  --neutral:       #64748b;
  --greed:         #22c55e;
  --extreme-greed: #10b981;

  /* Accent */
  --accent:        #38bdf8;
  --accent-glow:   rgba(56, 189, 248, 0.15);

  /* Shadows */
  --shadow-card:   0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow-fear:  0 0 30px rgba(239, 35, 60, 0.25);
  --shadow-glow-greed: 0 0 30px rgba(16, 185, 129, 0.25);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ── */
.site-header {
  background: linear-gradient(180deg, var(--bg-primary) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header-brand-icon {
  font-size: 22px;
}

.header-brand-text h1 {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #ef233c 0%, #f97316 50%, #22c55e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.header-brand-text p {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.last-updated {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

.btn-load {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.btn-load:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

/* ── MAIN LAYOUT ── */
.main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── GRID ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ── CARD ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

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

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── HERO SECTION ── */
.hero {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ── GAUGE CARD ── */
.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
}

.gauge-wrap {
  position: relative;
  width: 280px;
  height: 160px;
  margin-bottom: 8px;
}

#gauge-canvas {
  width: 100%;
  height: 100%;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  width: 280px;
  margin-top: 4px;
}

.gauge-labels span {
  font-size: 9px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.gauge-score-display {
  text-align: center;
  margin-top: 20px;
}

.score-number {
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
  font-family: 'JetBrains Mono', monospace;
  transition: color 0.5s ease;
}

.score-label {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
  transition: color 0.5s ease;
}

.score-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.score-change.negative {
  background: rgba(239, 35, 60, 0.1);
  color: var(--extreme-fear);
  border: 1px solid rgba(239, 35, 60, 0.2);
}

.score-change.positive {
  background: rgba(16, 185, 129, 0.1);
  color: var(--extreme-greed);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.score-desc {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
  max-width: 260px;
}

/* ── SPECTRUM BAR ── */
.spectrum-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ef233c, #f97316, #eab308, #22c55e, #10b981);
  position: relative;
  margin-top: 20px;
}

.spectrum-marker {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 8px rgba(255,255,255,0.5);
  transform: translateX(-50%);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── INFO PANEL ── */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── STAT GRID ── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.stat-item-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.stat-item-value {
  font-size: 24px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.stat-item-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── COMMUNITY BREAKDOWN ── */
.community-card {
  padding: 20px 24px;
}

.community-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.community-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.community-item:first-child {
  padding-top: 0;
}

.community-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.community-info {
  flex: 1;
  min-width: 0;
}

.community-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.community-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.community-score-wrap {
  text-align: right;
  flex-shrink: 0;
}

.community-score {
  font-size: 22px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.community-label {
  font-size: 10px;
  font-weight: 700;
  margin-top: 3px;
}

.community-bar-wrap {
  margin-top: 10px;
}

.community-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.community-bar-label {
  font-size: 10px;
  color: var(--text-tertiary);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.community-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}

.community-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.community-bar-fill.fear {
  background: linear-gradient(to right, var(--extreme-fear), var(--fear));
}

.community-bar-fill.greed {
  background: linear-gradient(to right, var(--greed), var(--extreme-greed));
}

.community-bar-pct {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  width: 30px;
  flex-shrink: 0;
}

/* ── CHART SECTION ── */
.chart-card {
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card-2);
  border-radius: 8px;
  padding: 3px;
}

.chart-tab {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
}

.chart-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.chart-wrap {
  position: relative;
  height: 200px;
}

/* ── KEYWORD SECTION ── */
.keyword-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.keyword-card {
  padding: 20px 24px;
}

.keyword-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keyword-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.keyword-rank {
  width: 18px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-align: center;
  flex-shrink: 0;
}

.keyword-word {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  width: 80px;
  flex-shrink: 0;
}

.keyword-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}

.keyword-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.keyword-bar-fill.is-fear {
  background: linear-gradient(to right, var(--fear), var(--extreme-fear));
}

.keyword-bar-fill.is-greed {
  background: linear-gradient(to right, var(--greed), var(--extreme-greed));
}

.keyword-count {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.keyword-change {
  font-size: 10px;
  font-weight: 600;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.keyword-change.up { color: var(--extreme-fear); }
.keyword-change.up::before { content: '▲ '; }
.keyword-change.dn { color: var(--extreme-greed); }
.keyword-change.dn::before { content: '▼ '; }

/* ── POSTS SECTION ── */
.posts-card {
  margin-bottom: 20px;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.post-card {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  transition: all 0.2s ease;
}

.post-card.is-fear::before { background: var(--extreme-fear); }
.post-card.is-greed::before { background: var(--extreme-greed); }

.post-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.post-community {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.post-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 10px;
  word-break: keep-all;
}

.post-meta {
  display: flex;
  gap: 10px;
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

.post-sentiment-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  margin-top: 8px;
}

.post-sentiment-badge.fear {
  background: rgba(239, 35, 60, 0.12);
  color: var(--extreme-fear);
  border: 1px solid rgba(239, 35, 60, 0.2);
}

.post-sentiment-badge.greed {
  background: rgba(16, 185, 129, 0.12);
  color: var(--extreme-greed);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  margin-top: 8px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drop-zone-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.drop-zone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.drop-zone-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.btn-demo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(56, 189, 248, 0.05));
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  margin-right: 8px;
}

.btn-demo:hover {
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.btn-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--bg-card-2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.btn-file:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── VELOCITY INDICATOR ── */
.velocity-card {
  padding: 20px 24px;
}

.velocity-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}

.velocity-bar-item {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: 0.7;
  transition: all 0.5s ease;
  animation: vel-appear 0.5s ease forwards;
  min-height: 4px;
}

@keyframes vel-appear {
  from { opacity: 0; transform: scaleY(0); transform-origin: bottom; }
  to { opacity: 0.7; transform: scaleY(1); }
}

.velocity-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.velocity-value {
  font-size: 28px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.velocity-unit {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── COLOR UTILITIES ── */
.color-extreme-fear { color: var(--extreme-fear); }
.color-fear         { color: var(--fear); }
.color-neutral      { color: var(--neutral); }
.color-greed        { color: var(--greed); }
.color-extreme-greed{ color: var(--extreme-greed); }

/* ── SECTION HEADER ── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── LOADER STATE ── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(4px);
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── TOOLTIP ── */
.tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 50;
  box-shadow: var(--shadow-card);
  white-space: nowrap;
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .gauge-card {
    padding: 24px;
  }
  .posts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 12px 16px;
  }
  .main {
    padding: 20px 16px 60px;
  }
  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .grid-2, .grid-3, .keyword-section, .stat-grid {
    grid-template-columns: 1fr;
  }
  .posts-grid {
    grid-template-columns: 1fr;
  }
  .gauge-wrap {
    width: 240px;
    height: 140px;
  }
  .gauge-labels {
    width: 240px;
  }
  .score-number {
    font-size: 48px;
  }
}
