@layer components {
  /* ============================================================
   * FX Exchange Rates Ticker — Ticker-specific styles
   *
   * Design tokens, dark / auto theme base are inherited from
   * .crtoday-widget (shared chrome in exchange-rates/style.css).
   * Only ticker-unique elements here.
   * ============================================================ */

  .crtoday-ticker {
    --crtoday-ticker-height: 48px;
    --crtoday-ticker-bg-light: rgba(255, 255, 255, 0.92);
    --crtoday-ticker-bg-dark: rgba(15, 23, 42, 0.92);
    --crtoday-ticker-border-light: rgba(148, 163, 184, 0.12);
    --crtoday-ticker-border-dark: rgba(148, 163, 184, 0.08);

    position: relative;
    overflow: hidden;
    height: var(--crtoday-ticker-height);
    background: var(--crtoday-ticker-bg-light);
    border: 0 solid var(--crtoday-ticker-border-light);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.8125rem;
    line-height: var(--crtoday-ticker-height);
    white-space: nowrap;
    user-select: none;
    contain: layout style;
    box-sizing: border-box;
  }

  /* ---------- Track + animation ---------- */

  .crtoday-ticker .crtoday-ticker-track {
    display: flex;
    width: max-content;
    will-change: transform;
  }

  .crtoday-ticker .crtoday-ticker-content {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0;
  }

  /* Default: scroll left */
  .crtoday-ticker-dir-left .crtoday-ticker-track {
    animation: crtoday-ticker-scroll-left var(--crtoday-ticker-duration, 30s) linear infinite;
  }

  /* Scroll right */
  .crtoday-ticker-dir-right .crtoday-ticker-track {
    animation: crtoday-ticker-scroll-right var(--crtoday-ticker-duration, 30s) linear infinite;
  }

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

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

  /* Pause on hover */
  .crtoday-ticker-pause-hover:hover .crtoday-ticker-track,
  .crtoday-ticker-pause-hover:focus-within .crtoday-ticker-track {
    animation-play-state: paused;
  }

  /* Accessibility: respect reduced motion */
  @media (prefers-reduced-motion: reduce) {
    .crtoday-ticker .crtoday-ticker-track {
      animation: none !important;
    }
    .crtoday-ticker {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
    }
  }

  /* ---------- Exchange Rates Ticker items ---------- */

  .crtoday-ticker .crtoday-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0 0.25rem;
    color: var(--crtoday-text-1);
  }

  .crtoday-ticker .crtoday-ticker-flags {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
  }

  .crtoday-ticker .crtoday-ticker-flags img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--crtoday-flag-border, rgba(255, 255, 255, 0.55));
    box-shadow: var(--crtoday-flag-shadow, 0 1px 3px rgba(0, 0, 0, 0.06));
  }

  .crtoday-ticker .crtoday-ticker-flags img + img {
    margin-inline-start: -6px;
  }

  .crtoday-ticker .crtoday-ticker-code {
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--crtoday-text-1);
  }

  .crtoday-ticker .crtoday-ticker-rate {
    font-variant-numeric: tabular-nums;
    color: var(--crtoday-text-2);
  }

  /* ---------- Change indicators ---------- */

  .crtoday-ticker .crtoday-ticker-change {
    display: inline-flex;
    align-items: center;
    align-self: center;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.0625rem 0.3125rem;
    border-radius: 0.1875rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    height: auto;
  }

  .crtoday-ticker .crtoday-ticker-up {
    color: var(--crtoday-up);
    background: var(--crtoday-up-bg);
  }

  .crtoday-ticker .crtoday-ticker-down {
    color: var(--crtoday-down);
    background: var(--crtoday-down-bg);
  }

  .crtoday-ticker .crtoday-ticker-neutral {
    color: var(--crtoday-neutral);
    background: var(--crtoday-neutral-bg);
  }

  /* ---------- Separator ---------- */

  /* ---------- Bid/Ask (Buy/Sell) mode ---------- */

  .crtoday-ticker .crtoday-ticker-bid,
  .crtoday-ticker .crtoday-ticker-ask {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  .crtoday-ticker .crtoday-ticker-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--crtoday-text-3);
  }

  /* ---------- Separator ---------- */

  .crtoday-ticker .crtoday-ticker-sep {
    display: inline-flex;
    align-items: center;
    padding: 0 0.25rem;
    color: var(--crtoday-text-3);
    opacity: 0.5;
    font-size: 0.75rem;
  }

  /* ---------- Border modifiers ---------- */

  .crtoday-ticker.crtoday-border-y {
    border-top-width: 1px;
    border-bottom-width: 1px;
  }

  .crtoday-ticker.crtoday-border-x {
    border-left-width: 1px;
    border-right-width: 1px;
  }

  /* ---------- Empty state ---------- */

  .crtoday-ticker .crtoday-ticker-empty {
    color: var(--crtoday-text-3);
    font-style: italic;
    padding: 0 1rem;
  }

  /* ---------- No-flags adjustment ---------- */

  .crtoday-ticker.crtoday-no-flags .crtoday-ticker-flags {
    display: none;
  }

  /* ============================================================
   * Dark theme
   * ============================================================ */

  .crtoday-theme-dark .crtoday-ticker {
    background: var(--crtoday-ticker-bg-dark);
    border-color: var(--crtoday-ticker-border-dark);
  }

  .crtoday-theme-dark .crtoday-ticker .crtoday-ticker-item {
    color: #e2e8f0;
  }

  .crtoday-theme-dark .crtoday-ticker .crtoday-ticker-code {
    color: #f1f5f9;
  }

  .crtoday-theme-dark .crtoday-ticker .crtoday-ticker-rate {
    color: #94a3b8;
  }

  .crtoday-theme-dark .crtoday-ticker .crtoday-ticker-sep {
    color: #475569;
  }

  .crtoday-theme-dark .crtoday-ticker .crtoday-ticker-label {
    color: #64748b;
  }

  /* ============================================================
   * Auto theme (follows system preference)
   * ============================================================ */

  @media (prefers-color-scheme: dark) {
    .crtoday-theme-auto .crtoday-ticker {
      background: var(--crtoday-ticker-bg-dark);
      border-color: var(--crtoday-ticker-border-dark);
    }

    .crtoday-theme-auto .crtoday-ticker .crtoday-ticker-item {
      color: #e2e8f0;
    }

    .crtoday-theme-auto .crtoday-ticker .crtoday-ticker-code {
      color: #f1f5f9;
    }

    .crtoday-theme-auto .crtoday-ticker .crtoday-ticker-rate {
      color: #94a3b8;
    }

    .crtoday-theme-auto .crtoday-ticker .crtoday-ticker-sep {
      color: #475569;
    }

    .crtoday-theme-auto .crtoday-ticker .crtoday-ticker-label {
      color: #64748b;
    }
  }

  /* Footer: remove side padding in ticker context */
  .crtoday-ticker-wrap .crtoday-footer {
    padding-inline: 0;
  }

  .crtoday-ticker-wrap.crtoday-compact .crtoday-footer {
    padding-inline: 0;
  }
}
