﻿.stock-ticker {
  display: flex;
  align-items: center;
  flex: 1 1 18rem;
  gap: 0.75rem;
  min-width: 0;
  max-width: 48rem;
  margin: 0 1rem;
  color: var(--text-normal, var(--text-primary, #f2f2f5));
  font-size: 0.78rem;
  line-height: 1.4;
}

.stock-ticker__snapshot {
  flex: 0 0 auto;
  color: var(--text-muted, var(--text-normal, var(--text-primary, #f2f2f5)));
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.stock-ticker__viewport {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.stock-ticker__track,
.stock-ticker__group {
  display: flex;
  width: max-content;
}

.stock-ticker__track {
  animation: stock-ticker-scroll 48s linear infinite;
  /* Theme stylesheet forces animation-duration: 0ms !important on all elements; restore the scroll speed. */
  animation-duration: 48s !important;
}

.stock-ticker__group {
  flex: 0 0 auto;
  align-items: center;
  gap: 1.5rem;
  padding-right: 1.5rem;
}

.stock-ticker__item,
.stock-ticker__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.stock-ticker__link {
  color: var(--text-normal, var(--text-primary, #f2f2f5));
  text-decoration: none;
}

.stock-ticker__link:hover,
.stock-ticker__link:focus-visible {
  color: var(--text-accent, var(--text-normal, var(--text-primary, #f2f2f5)));
  text-decoration: underline;
}

.stock-ticker__change--positive {
  color: var(--text-success, #218739);
}

.stock-ticker__change--negative {
  color: var(--text-error, #c73535);
}

.stock-ticker__change--neutral {
  color: var(--text-muted, var(--text-normal, var(--text-primary, #f2f2f5)));
}

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


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

@media (max-width: 800px) {
  .stock-ticker {
    margin: 0 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stock-ticker__viewport {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .stock-ticker__track {
    animation: none;
  }

  .stock-ticker__group--duplicate {
    display: none;
  }
}

.stock-ticker--standalone {
  position: sticky;
  top: 0;
  z-index: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.75rem 1rem;
  box-sizing: border-box;
  background: var(--background-secondary, var(--surface, #0d0e14));
}

/* One slot per layout. The 1000px breakpoint matches isDesktop in filetree.njk. */
.stock-ticker--content {
  display: none;
}

@media (min-width: 1000px) {
  .stock-ticker--filetree {
    display: none;
  }

  .stock-ticker--content {
    display: flex;
  }
}

/* === Combined ticker module: dated stocks + same-month news + resource buttons === */
.ticker-module {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
  background: var(--background-secondary, var(--surface, #0d0e14));
  color: var(--text-normal, var(--text-primary, #f2f2f5));
  font-size: 0.78rem;
  line-height: 1.4;
}

.ticker-module__rows {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.ticker-module__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.ticker-module__news-label {
  flex: 0 0 auto;
  color: #fee801;
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.ticker-module__news-label:hover,
.ticker-module__news-label:focus-visible {
  text-decoration: underline;
}

.ticker-module__news-title {
  white-space: nowrap;
}

.ticker-module__news-empty {
  color: var(--text-muted, var(--text-normal, var(--text-primary, #f2f2f5)));
  font-size: 0.72rem;
  white-space: nowrap;
}

.stock-ticker__track--news {
  animation-duration: 36s !important;
}

/* Resource buttons live inside the module; reuse the site-resource styles
   but stack them vertically on the right on wide screens. */
.ticker-module__actions.site-resource-nav {
  flex: 0 0 auto;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.ticker-module__actions .site-resource-button {
  white-space: nowrap;
  justify-content: center;
}

@media (max-width: 1000px) {
  /* The module now carries the stocks on small screens; drop the duplicate
     mobile-bar ticker only where the module rendered (filetree layouts). */
  body:has(.ticker-module) .stock-ticker--filetree {
    display: none;
  }

  .ticker-module {
    position: static;
    flex-direction: column;
    gap: 0.5rem;
  }

  .ticker-module__actions.site-resource-nav {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
