/*
 * Classic Byte — Readership Ticker Styles (Broadsheet ET Style)
 *
 * Implements horizontal step-slide animation, market badges,
 * pause-on-hover indicators, and contextual financial-style tooltips.
 */

.readership-ticker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.2;
  color: var(--ink);
  position: relative;
  min-height: 28px;
  max-width: 100%;
}

/* Badge on the left of ticker */
.ticker-badge-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.ticker-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #0f8544;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(15, 133, 68, 0.7);
  animation: ticker-pulse 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes ticker-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(15, 133, 68, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(15, 133, 68, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(15, 133, 68, 0);
  }
}

.ticker-label {
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-light);
  white-space: nowrap;
}

/* Slide viewport window */
.ticker-window {
  position: relative;
  overflow: hidden;
  height: 26px;
  min-width: 280px;
  display: flex;
  align-items: center;
}

/* Individual slide item */
.ticker-slide {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.2, 0, 0, 1), opacity 0.4s ease;
  white-space: nowrap;
}

.ticker-slide.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  position: relative;
}

.ticker-slide.exit-left {
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
}

.ticker-slide.enter-right {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

/* Clickable link inside the slide */
.ticker-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.ticker-link:hover {
  color: var(--terracotta);
}

.ticker-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Metric styling */
.ticker-metric {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: help;
  position: relative;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.ticker-metric:hover,
.ticker-metric:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.metric-up {
  color: #0b733b;
  background: rgba(11, 115, 59, 0.08);
  border: 1px solid rgba(11, 115, 59, 0.25);
}

.metric-down {
  color: #c93a2b;
  background: rgba(201, 58, 43, 0.08);
  border: 1px solid rgba(201, 58, 43, 0.25);
}

.ticker-arrow {
  font-size: 0.85rem;
  line-height: 1;
}

.ticker-delta {
  font-size: 0.74rem;
  font-weight: 500;
  opacity: 0.85;
}

/* Hover-pause subtle indicator */
.readership-ticker:hover .ticker-window {
  cursor: pointer;
}

/* Broadsheet Explanatory Tooltip */
.ticker-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 110px;
  z-index: 999;
  width: 320px;
  background: var(--paper);
  border: 1px solid var(--dust);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(40, 25, 15, 0.15);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ticker-tooltip::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 24px;
  width: 10px;
  height: 10px;
  background: var(--paper);
  border-left: 1px solid var(--dust);
  border-top: 1px solid var(--dust);
  transform: rotate(45deg);
}

.ticker-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--dust);
  padding-bottom: 0.35rem;
  margin-bottom: 0.4rem;
}

.tooltip-title {
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.tooltip-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-light);
}

.tooltip-desc {
  margin: 0;
  color: var(--ink-light);
}

.tooltip-stat-highlight {
  font-weight: 700;
  color: var(--ink);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .readership-ticker {
    font-size: 0.78rem;
  }
  .ticker-window {
    min-width: 200px;
  }
  .ticker-tooltip {
    left: 20px;
    width: 280px;
  }
}

/* Dark mode adjustments (Midnight Library protection) */
:root[data-theme="dark"] .metric-up {
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
}

:root[data-theme="dark"] .metric-down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}

:root[data-theme="dark"] .ticker-pulse-dot {
  background-color: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
}

:root[data-theme="dark"] .ticker-tooltip {
  background: var(--paper);
  border-color: var(--dust);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
}

:root[data-theme="dark"] .ticker-tooltip::before {
  background: var(--paper);
  border-color: var(--dust);
}
