/* Live Market Lab — hours clock, sessions, ticker, chart switch fades.
   Layered on top of the shared .live / .live-board styles in components.css. */

/* —— Scrolling quote ticker ——————————————————————————————————————————————— */

.live-ticker {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.live-ticker__track {
  display: flex;
  gap: 28px;
  width: max-content;
  padding: 10px 16px;
  will-change: transform;
}

.live-ticker.is-running .live-ticker__track {
  animation: live-ticker-scroll 42s linear infinite;
}

.live-ticker:hover .live-ticker__track,
.live-ticker:focus-within .live-ticker__track {
  animation-play-state: paused;
}

.live-ticker__item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-size: 0.85rem;
}

.live-ticker__item--muted {
  color: var(--text-3);
}

.live-ticker__sym {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.live-ticker__px {
  font-weight: 600;
  color: var(--text);
}

.live-ticker__chg {
  font-weight: 600;
  min-width: 4.5ch;
}

.live-ticker__item.is-up .live-ticker__chg { color: var(--bull); }
.live-ticker__item.is-down .live-ticker__chg { color: var(--bear); }

@keyframes live-ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* —— Market hours panel ——————————————————————————————————————————————————— */

.live-hours {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-hours__head {
  --gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.live-hours__head h2 {
  margin: 0;
}

.live-hours__live {
  --gap: 8px;
  align-items: center;
  font-size: 0.85rem;
}

.live-hours__sub {
  margin: 6px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.live-hours__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.live-hours-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.live-hours-card.is-open {
  border-color: color-mix(in oklab, var(--bull) 45%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--bull) 18%, transparent);
}

.live-hours-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.live-hours-card__name {
  font-weight: 700;
  font-size: 0.95rem;
}

.live-hours-card__clock {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.live-hours-card__tz,
.live-hours-card__sess,
.live-hours-card__next {
  margin: 2px 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
}

.live-hours__note {
  margin: 4px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Session timeline bars (theme tokens; fill advances with wall clock) */

.live-hours-card--bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.live-hours-bar {
  margin-top: 8px;
}

.live-hours-bar__track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 70%, var(--line));
  border: 1px solid var(--line);
  overflow: hidden;
}

.live-hours-bar__session {
  position: absolute;
  top: 1px;
  bottom: 1px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--text-3) 28%, transparent);
  overflow: hidden;
}

.live-hours-bar__session.is-done {
  background: color-mix(in oklab, var(--bull) 22%, var(--surface-2));
}

.live-hours-bar__session.is-active {
  background: color-mix(in oklab, var(--bull) 18%, var(--surface-2));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--bull) 35%, transparent);
}

.live-hours-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--bull) 55%, transparent),
    color-mix(in oklab, var(--bull-strong, var(--bull)) 85%, var(--accent))
  );
  transition: width 0.85s linear;
}

.live-hours-card.is-closed .live-hours-bar__fill {
  background: color-mix(in oklab, var(--text-3) 45%, transparent);
}

.live-hours-bar__now {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent);
  pointer-events: none;
  z-index: 2;
}

.live-hours-bar__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

.live-feed-badge {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.72rem;
  white-space: nowrap;
}

.live-feed-badge[data-kind="delayed"] { color: var(--text-2); }
.live-feed-badge[data-kind="live"] {
  color: var(--bull-strong, var(--bull));
  border-color: color-mix(in oklab, var(--bull) 40%, var(--line));
  background: var(--bull-soft);
}
.live-feed-badge[data-kind="off"] { color: var(--text-3); }

.live-quote__err {
  margin: 4px 0 0;
  font-size: 0.7rem;
  line-height: 1.3;
}


/* Open / closed pill */

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.live-pill--open {
  color: var(--bull-strong, var(--bull));
  background: var(--bull-soft);
}

.live-pill--closed {
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--line);
}

.live-pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.live-pill--open .live-pill__dot {
  box-shadow: 0 0 0 0 color-mix(in oklab, var(--bull) 55%, transparent);
  animation: live-pill-pulse 1.8s var(--ease-out) infinite;
}

@keyframes live-pill-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--bull) 50%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* —— Unified market-hours timeline ——————————————————————————————————————— */

.live-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-timeline__head {
  --gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.live-timeline__axis-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-timeline__tz {
  font-size: 0.78rem;
}

.live-timeline__axis {
  position: relative;
  height: 18px;
  margin-left: 108px;
}

.live-timeline__tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.live-timeline__tick:first-child {
  transform: translateX(0);
}

.live-timeline__tick:last-child {
  transform: translateX(-100%);
}

.live-timeline__lanes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-timeline__lane {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 28px;
}

.live-timeline__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.live-timeline__name {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.2;
}

.live-timeline__label .live-pill {
  align-self: flex-start;
  padding: 0 6px;
  font-size: 0.6rem;
}

.live-timeline__track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 70%, var(--line));
  border: 1px solid var(--line);
  overflow: hidden;
}

.live-timeline__bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--text-3) 28%, transparent);
  transition: background 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}

.live-timeline__bar.is-done {
  background: color-mix(in oklab, var(--bull) 22%, var(--surface-2));
}

.live-timeline__bar.is-active {
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--bull) 55%, transparent),
    color-mix(in oklab, var(--bull-strong, var(--bull)) 85%, var(--accent))
  );
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--bull) 40%, transparent);
}

.live-timeline__lane.is-forex .live-timeline__bar.is-active {
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--accent) 45%, transparent),
    color-mix(in oklab, var(--accent-strong, var(--accent)) 80%, var(--bull))
  );
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent);
}

.live-timeline__body {
  position: relative;
  margin-left: 0;
  --timeline-label-w: 108px; /* label col 100px + gap 8px */
}

.live-timeline__now {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--timeline-label-w) + (100% - var(--timeline-label-w)) * var(--now, 0));
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 35%, transparent),
    0 0 12px color-mix(in oklab, var(--accent) 40%, transparent);
  pointer-events: none;
  z-index: 3;
  transition: left 0.85s linear;
}

.live-timeline__overlaps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.live-overlap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--text-2);
  transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.live-overlap__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.live-overlap.is-active {
  color: var(--text);
  border-color: color-mix(in oklab, var(--accent) 50%, var(--line));
  background: var(--accent-soft);
}

.live-overlap.is-active .live-overlap__dot {
  background: var(--accent);
  animation: live-pill-pulse 1.8s var(--ease-out) infinite;
}

.live-overlap__tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-strong, var(--accent));
}

.live-timeline__context {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-2);
}

.live-timeline__note {
  margin: 0;
}

/* —— Quote board rotation / open-only ————————————————————————————————————— */

.live-board__note {
  margin: 0 0 6px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.live-quote.is-muted {
  opacity: 0.72;
}

.live-quote.is-enter {
  animation: live-quote-enter 0.4s var(--ease-out);
}

@keyframes live-quote-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Quote board / chart polish ——————————————————————————————————————————— */

.live-quote {
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.live-quote:hover {
  transform: translateY(-1px);
}

.live-quote .live-quote__px {
  transition: color 0.35s var(--ease-out);
}

.live__chart {
  transition: opacity 0.28s var(--ease-out);
}

.live__chart.is-switching {
  opacity: 0.35;
}

/* —— Reduced motion ——————————————————————————————————————————————————————— */

@media (prefers-reduced-motion: reduce) {
  .live-ticker.is-running .live-ticker__track {
    animation: none;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
  }

  .live-pill--open .live-pill__dot,
  .live-overlap.is-active .live-overlap__dot {
    animation: none;
  }

  .live-hours-bar__fill {
    transition: none;
  }

  .live-timeline__now {
    transition: none;
  }

  .live-quote.is-enter {
    animation: none;
  }

  .live-quote:hover {
    transform: none;
  }

  .live__chart {
    transition: none;
  }
}

html[data-motion="reduce"] .live-ticker.is-running .live-ticker__track {
  animation: none;
  flex-wrap: wrap;
  width: auto;
  max-width: 100%;
}

html[data-motion="reduce"] .live-pill--open .live-pill__dot,
html[data-motion="reduce"] .live-overlap.is-active .live-overlap__dot {
  animation: none;
}

html[data-motion="reduce"] .live-hours-bar__fill {
  transition: none;
}

html[data-motion="reduce"] .live-timeline__now {
  transition: none;
}

html[data-motion="reduce"] .live-quote.is-enter {
  animation: none;
}

/* —— Dashboard Live markets widget ————————————————————————————————————————— */

.dash-live {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: var(--space-6, 1.5rem);
}

.dash-live__head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dash-live__head-actions {
  flex-shrink: 0;
}

.dash-live__lead {
  margin: 0;
  max-width: 72ch;
  line-height: 1.45;
}

.dash-live__hours-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-live__bar {
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dash-live__board {
  margin-top: 2px;
}

.dash-live__detail {
  padding: 12px 14px 14px;
}

.dash-live__chart-title {
  margin: 0 0 8px;
}

.dash-live__chart {
  min-height: 240px;
}

.dash-live__footnote {
  margin: 0;
  max-width: 72ch;
  line-height: 1.4;
}

.live-quote__session {
  display: inline-flex;
  margin: 0 0 6px;
  font-size: 0.68rem;
  padding: 1px 7px;
}

.live-quote.is-market-closed {
  opacity: 0.92;
}


@media (max-width: 640px) {
  .live-timeline__axis {
    margin-left: 0;
  }

  .live-timeline__lane {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .live-timeline__label {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .live-timeline__body {
    --timeline-label-w: 0px;
  }
}
