/* ================================================
   FIGMA STOCK TIMELINE — Brand-Themed Styles
   Colors: Figma brand palette
   - #F24E1E (Figma Orange-Red)
   - #FF7262 (Figma Coral)
   - #A259FF (Figma Purple)
   - #1ABCFE (Figma Blue)
   - #0ACF83 (Figma Green)
   ================================================ */

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

:root {
  --fig-red: #F24E1E;
  --fig-coral: #FF7262;
  --fig-purple: #A259FF;
  --fig-blue: #1ABCFE;
  --fig-green: #0ACF83;
  
  --bg: #0D0D0D;
  --surface: #161616;
  --surface-2: #1E1E1E;
  --surface-3: #2C2C2C;
  --border: #333;
  --text: #E8E8E8;
  --text-muted: #888;
  --text-faint: #555;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* --- HEADER --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.figma-logo {
  flex-shrink: 0;
}

.header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.ticker {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.company-name {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
}

.price-display {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.current-price {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}

.price-change {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums lining-nums;
}

.price-change.negative {
  color: var(--fig-coral);
}

.price-change.positive {
  color: var(--fig-green);
}

/* --- CHART CONTAINER --- */
.chart-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 10;
  transition: opacity 0.4s ease;
}

.chart-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

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

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

/* --- SVG CHART --- */
.chart-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 0.5;
  stroke-dasharray: 3 4;
}

.price-line {
  fill: none;
  stroke: url(#lineGradient);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.price-area {
  fill: url(#areaGradient);
}

.axis-text {
  fill: var(--text-faint);
  font-family: var(--font-body);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.ipo-line {
  stroke: var(--fig-green);
  stroke-width: 1;
  stroke-dasharray: 6 4;
  opacity: 0.6;
}

.ipo-label {
  fill: var(--fig-green);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  opacity: 0.7;
}

/* --- CROSSHAIR & HOVER --- */
.crosshair-line {
  stroke: var(--text-faint);
  stroke-width: 0.5;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.crosshair-dot {
  fill: var(--fig-purple);
  stroke: var(--bg);
  stroke-width: 2.5;
  pointer-events: none;
}

/* --- PRICE TOOLTIP --- */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}

.tooltip.visible {
  opacity: 1;
}

.tooltip-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.tooltip-price {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums lining-nums;
}

.tooltip-volume {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.tooltip-change {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.tooltip-change.up { color: var(--fig-green); }
.tooltip-change.down { color: var(--fig-coral); }

/* --- EVENT MARKERS --- */
.event-marker {
  cursor: pointer;
}

.event-marker-bg {
  opacity: 0.9;
}

.event-marker-icon {
  fill: var(--bg);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.event-stem {
  stroke-width: 1;
  stroke-dasharray: 2 2;
  opacity: 0.5;
}

/* --- EVENT TOOLTIP --- */
.event-tooltip {
  position: fixed;
  pointer-events: none;
  background: #1e1e1e;
  border: 1px solid #555;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: 340px;
  min-width: 240px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.85);
}

.event-tooltip.visible {
  opacity: 1;
}

.event-tooltip-category {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.event-tooltip-category.earnings {
  background: rgba(26, 188, 254, 0.15);
  color: var(--fig-blue);
}

.event-tooltip-category.analyst {
  background: rgba(162, 89, 255, 0.15);
  color: var(--fig-purple);
}

.event-tooltip-category.insider {
  background: rgba(255, 114, 98, 0.15);
  color: var(--fig-coral);
}

.event-tooltip-category.product {
  background: rgba(10, 207, 131, 0.15);
  color: var(--fig-green);
}

.event-tooltip-category.news {
  background: rgba(242, 78, 30, 0.15);
  color: var(--fig-red);
}

.event-tooltip-category.lockup {
  background: rgba(255, 200, 60, 0.15);
  color: #FFC83C;
}

.event-tooltip-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
  margin-bottom: 6px;
}

.event-tooltip-date {
  font-size: 11px;
  color: #999;
  margin-bottom: 8px;
}

.event-tooltip-body {
  font-size: 12.5px;
  color: #bbb;
  line-height: 1.55;
}

.event-tooltip-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* --- VOLUME BARS --- */
.volume-bar {
  opacity: 0.25;
  transition: opacity 0.1s ease;
}

.volume-bar.highlight {
  opacity: 0.5;
}

/* --- FOOTER --- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-text {
  font-size: 11px;
  color: var(--text-faint);
}

.footer-link {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.18s ease;
}

.footer-link:hover {
  color: var(--text-muted);
}

/* --- LEGEND --- */
.legend {
  position: absolute;
  top: 16px;
  right: 24px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  z-index: 5;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
  }

  .header-right {
    width: 100%;
  }

  .price-display {
    gap: 8px;
  }

  .current-price {
    font-size: 20px;
  }

  .company-name {
    display: none;
  }

  .legend {
    top: 8px;
    right: 12px;
    gap: 8px;
  }

  .legend-item {
    font-size: 9px;
  }

  .footer {
    padding: 8px 16px;
  }
}
