/* ── DividendIQ — Ticker Details Page (Phase B) ──
   Consumes existing theme tokens (--bg, --surface, --surface2, --accent,
   --text, --text2) and the sector palette from sectors.css. No new
   theme tokens. WCAG AA contrast preserved across all 6 theme combos
   (Slate/Midnight × Obsidian/Spectral-Copper/Spectral-Prism × light/dark).

   Reference: design § 7.2 (11 modules), § 7.7 (TTI budgets), § 9.1
   (visual language), § 9.4 (newbie-friendly UX).
   ──────────────────────────────────────────── */

.ticker-page {
  display: block;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
  color: var(--text);
}

.tk-module {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 12px;
  padding: 20px 24px;
  margin: 0 0 16px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tk-module h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text);
}

.tk-module p {
  margin: 4px 0;
  color: var(--text2);
  line-height: 1.5;
}

/* How-it-works panel uses the canonical `.diq-how-it-works` styling
   defined in `frontend/css/app.css` (lines ~1470–1525). No ticker-page
   override is needed — kept consistent across tabs intentionally. */

/* ── Hero (module 1) ── */
.tk-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tk-hero-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tk-symbol {
  /* engagement fix-ticker-a11y-color-contrast-h1: this element is now an
     <h1> (was <div>) for axe page-has-heading-one. Reset the browser
     default `h1 { margin: 0.67em 0 }` so the hero layout is unchanged. */
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.tk-company {
  font-size: 18px;
  color: var(--text2);
}

.tk-sector {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: color-mix(in srgb, var(--sector-unknown) 18%, transparent);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--sector-unknown) 36%, transparent);
}

.tk-sector[data-sector-class="sector-energy"] {
  background: color-mix(in srgb, var(--sector-energy) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-energy) 36%, transparent);
}
.tk-sector[data-sector-class="sector-tech"] {
  background: color-mix(in srgb, var(--sector-tech) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-tech) 36%, transparent);
}
.tk-sector[data-sector-class="sector-healthcare"] {
  background: color-mix(in srgb, var(--sector-healthcare) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-healthcare) 36%, transparent);
}
.tk-sector[data-sector-class="sector-financials"] {
  background: color-mix(in srgb, var(--sector-financials) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-financials) 36%, transparent);
}
.tk-sector[data-sector-class="sector-consumer-staples"] {
  background: color-mix(in srgb, var(--sector-consumer-staples) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-consumer-staples) 36%, transparent);
}
.tk-sector[data-sector-class="sector-consumer-disc"] {
  background: color-mix(in srgb, var(--sector-consumer-disc) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-consumer-disc) 36%, transparent);
}
.tk-sector[data-sector-class="sector-industrials"] {
  background: color-mix(in srgb, var(--sector-industrials) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-industrials) 36%, transparent);
}
.tk-sector[data-sector-class="sector-utilities"] {
  background: color-mix(in srgb, var(--sector-utilities) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-utilities) 36%, transparent);
}
.tk-sector[data-sector-class="sector-reit"] {
  background: color-mix(in srgb, var(--sector-reit) 18%, transparent);
  border-color: color-mix(in srgb, var(--sector-reit) 36%, transparent);
}

.tk-hero-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tk-price {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.tk-change {
  font-size: 14px;
  color: var(--text2);
}

/* ── Stat tiles (used by Dividend, Fundamentals modules) ── */
.tk-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.tk-stat {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tk-stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text2);
}

.tk-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ── DivIQ score tile ── */
.tk-diviq-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
}

.tk-diviq-summary {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

/* Empty-state UX (diviq-aapl-null-score): when the upstream data pipeline
   cannot produce a score for a ticker (AAPL/MSFT class — missing
   yrs-increasing / 5y+10y CAGR / market cap), render an explicit
   "Score unavailable" message at normal text size instead of the 48px
   bold orange em-dash that `_tkFmtNumber(null,1)` would produce inside
   `.tk-diviq-score`. Reuses the muted body text token for visual
   consistency with other "no data" states (e.g. `.tk-stat-label`). */
.tk-diviq-summary--unavailable {
  align-items: flex-start;
}
.tk-diviq-unavailable {
  margin: 0;
  font-size: 15px;
  font-style: italic;
  color: var(--text2);
}

/* ── Forward income module (DividendIQ-unique) ── */
.tk-forward-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tk-forward-form label {
  font-size: 14px;
  color: var(--text2);
}

.tk-forward-form input[type="number"] {
  width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.tk-forward-projection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.tk-forward-cell {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
}

.tk-forward-cell-label {
  font-size: 12px;
  color: var(--text2);
}

.tk-forward-cell-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

/* ── Peers list ── */
.tk-peers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tk-peer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface2);
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  transition: border-color 120ms ease;
}

/* engagement: holdings-group-by-empty-phase3 (FIX-2) — mixed-selector split.
   The original rule combined :hover with :focus-visible, putting keyboard
   focus visibility behind hover capability on iOS. Split per design § 6
   FIX-2 strategy: :hover into the @media wrap, :focus-visible stays at
   top level. */
@media (hover: hover) {
  .tk-peer:hover {
    border-color: var(--accent);
    outline: none;
  }
}
.tk-peer:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.tk-peer-symbol {
  font-weight: 600;
}

.tk-peer-meta {
  font-size: 13px;
  color: var(--text2);
}

/* ── News card ── */
.tk-news a {
  /* engagement fix-ticker-a11y-color-contrast-h1 (news-tab follow-up):
     --accent is the brand color (used as button fill, icon, border) and
     fails WCAG AA normal-text contrast on light --surface (e.g. obsidian
     #cc6b28 on #ffffff = 3.68:1). --accent-text is the text-safe variant
     defined per light theme; dark themes fall back to --accent via the
     cascade (passes contrast on dark --surface; confirmed by axe — 0
     news-link violations in dark themes). */
  color: var(--accent-text, var(--accent));
  text-decoration: none;
}

@media (hover: hover) {
  .tk-news a:hover {
    text-decoration: underline;
  }
}

.tk-news-time {
  font-size: 12px;
  color: var(--text2);
}

/* ── News list (Fix 5 — 5-headline list rewrite) ──
   Multi-item layout. Per-item border separator instead of the prior
   single-headline render. Tokens only; no hex. */
.tk-news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tk-news-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.tk-news-item:last-child {
  border-bottom: none;
}
.tk-news-item a {
  display: block;
  font-weight: 500;
  line-height: 1.35;
}
.tk-news-headline { /* unlinked fallback — preserved for back-compat
                      with the old single-headline text-only path even
                      though the list path drops items without a valid
                      link server-side */
  display: block;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
}

/* ── CTA bar (sticky on mobile) ──
   Layout container only. Buttons inside use the canonical .btn family
   (see frontend/css/app.css :772-836). Per-button color/border/font
   properties live on .btn / .btn-primary / .btn-ghost; do not re-declare
   them here. The sticky-on-mobile @media block below at the bottom
   of this file is preserved verbatim (see design § 5.2). */
.tk-cta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.tk-cta-bar .btn {
  flex: 1 1 auto;
  min-height: 44px;  /* WCAG AAA touch target on the sticky CTA bar */
}

/* ── Per-module error card (FR-T5) ── */
.tk-module-error {
  background: var(--surface2);
  border: 1px dashed color-mix(in srgb, var(--text2) 38%, transparent);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: var(--text2);
}

/* ── Empty / non-payer state (FR-T7) ── */
.tk-non-payer {
  background: var(--surface2);
  border-radius: 10px;
  padding: 16px;
  color: var(--text2);
  font-size: 14px;
}

/* ── Toast (reused from calendar) ── */
.tk-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface2);
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 9999;
}

/* ── Mobile (≤ 640 px) ── */
@media (max-width: 640px) {
  .ticker-page {
    padding: 12px;
  }
  .tk-cta-bar {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 8px 0 4px;
    margin: 8px 0 0 0;
    z-index: 5;
  }
  .tk-symbol {
    font-size: 28px;
  }
  .tk-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .tk-hero-right {
    text-align: left;
  }
}

/* ── Tab system (engagement: ticker-price-chart) ──
   Three-tab refactor: Overview / Research / News. Tab buttons reuse the
   canonical `.cal-scope-segment` + `.cal-scope-btn` pattern from
   calendar.css :41-70 — no new color/font tokens. Layout-only additions
   live below. */
.tk-tabs {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px 0;
}
.tk-tab-panel {
  display: block;
}
.tk-tab-panel[hidden] {
  display: none;
}

/* ── Chart widget (engagement: ticker-price-chart) ──
   Layout / structure only. All colors come from theme tokens
   (--pos / --neg / --text / --text2 / --text3 / --border).
   No new theme tokens introduced (per UI Consistency Hard Gate audit). */
.tk-chart {
  padding: 16px;
  box-sizing: border-box;
}
.tk-chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.tk-chart-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tk-chart-summary {
  font-size: 16px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}
.tk-chart-delta.tk-chart-pos {
  /* engagement fix-ticker-a11y-color-contrast-h1: prefer text-tuned
     --pos-text (defined per light theme) for WCAG AA on white --surface;
     fall back to --pos for dark themes (where the existing token passes
     contrast on dark backgrounds). */
  color: var(--pos-text, var(--pos, #1aaf5d));
}
.tk-chart-delta.tk-chart-neg {
  /* engagement fix-ticker-a11y-color-contrast-h1: see .tk-chart-pos above. */
  color: var(--neg-text, var(--neg, #d23a3a));
}
.tk-chart-date {
  margin-left: 4px;
}
/* engagement: chart-toolbar-overpaint — toolbar wrapper keeps the range
   row and scrub-stats in one grid cell. Both states remain in layout, so
   the wrapper height is the max of the two and does not shrink/grow as
   scrubbing toggles; visibility controls which state is painted. */
.tk-chart-toolbar {
  display: grid;
  grid-template-areas: "swap";
  box-sizing: border-box;
  width: 100%;
}
.tk-range-row,
.tk-chart-scrub-stats {
  grid-area: swap;
}
.tk-range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 12px 0;
  flex-wrap: nowrap;
  gap: 8px;
  box-sizing: border-box;
  max-width: 100%;
}
.tk-chart-toolbar .cal-scope-segment {
  flex: 0 0 auto;
  white-space: nowrap;
}
.tk-chart-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  box-sizing: border-box;
  padding: 0;
  color: var(--text2);
}
.tk-chart-mode-btn[aria-selected="true"] {
  background: transparent;
  color: var(--accent);
}
.tk-chart-mode-icon {
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.tk-chart-scrub-stats {
  visibility: hidden;
  margin: 8px 0 12px 0;
  text-align: center;
}
.tk-chart-scrub-stats .tk-stat-value,
.tk-chart-scrub-stats .tk-stat-label {
  max-width: 100%;
  white-space: nowrap;
}
.tk-chart-scrub-stats .tk-stat-value {
  font-variant-numeric: tabular-nums;
}
.tk-chart-scrub-placeholder {
  visibility: hidden;
}
.tk-chart[data-tk-scrub="on"] .tk-range-row {
  visibility: hidden;
}
.tk-chart[data-tk-scrub="on"] .tk-chart-scrub-stats {
  visibility: visible;
}
/* Bug 3 — on narrow viewports (iPhone 13 = 390 CSS px), the 8 range
   buttons + mode toggle row exceeds the card's width with the default
   .cal-scope-btn padding (6px 14px) + font-size 13px. Shrink both within
   the chart toolbar only (does not affect calendar usage of the canonical
   .cal-scope-btn). The 360px breakpoint is the practical floor for iOS
   devices today; the iPhone 13 (390px) gets the relaxed rule, smallest
   devices fall through to the same rule. */
@media (max-width: 480px) {
  .tk-chart-toolbar .cal-scope-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  .tk-chart-toolbar .cal-scope-segment {
    padding: 2px;
  }
  .tk-chart-scrub-stats .tk-stat-value {
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: -0.02em;
  }
  .tk-chart-scrub-stats .tk-stat-label {
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: -0.01em;
  }
}
@media (max-width: 380px) {
  .tk-chart-toolbar .cal-scope-btn {
    padding: 3px 6px;
    font-size: 11px;
  }
}
.tk-chart-toolbar .tk-chart-mode-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
}
.tk-chart-body {
  position: relative;
  min-height: 320px;
}

/* engagement: chart-orange-dots-abc — Variant A. Inline-flex legend chip
   below the chart body. The dot uses var(--accent) so it visually
   matches the dividend marker fill in _buildSvg.
   engagement: fix-ticker-axe-color-contrast-comprehensive — Label uses
   var(--text2) at 12px (was --text3). axe-core color-contrast on
   /ticker/{KO,AAPL} × {light,dark} flagged --text3 at 12px DOM text as
   serious AA violations (light: 4.06:1 vs 4.5; dark: 2.45:1 vs 4.5).
   --text2 is the medium-emphasis token already used by the price-scale
   labels in _buildSvg and by the .empty-state / .holdings-empty__copy
   family for the same reason (see tests/frontend/test-empty-state-
   contrast.js for the canonical anchor + regression-guard pattern).
   The slot is rendered only in line mode + when data.dividends has
   entries; the [hidden] attribute hides the empty default state on
   first paint. */
.tk-chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--text2, #555);
}
.tk-chart-legend[hidden] {
  display: none;
}
.tk-chart-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}
.tk-chart-legend-label {
  line-height: 1;
}
.tk-chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* engagement: chart-toolbar-overpaint — the "As-traded view" mode-note
   and its data-tk-mode hide rule were removed per operator directive
   (PR #309 visual review). The .tk-chart-floating-label rule was also
   removed: the line-mode scrub UX moved to the toolbar overpaint pattern
   above; the floating-near-cursor label is no longer rendered. */

/* News thumbnail (Phase B addition — small inline-block, layout-only). */
.tk-news-thumb {
  max-width: 56px;
  max-height: 56px;
  border-radius: 6px;
  margin-top: 6px;
}

/* ── Scrub polish (engagement: ticker-chart-scrub-polish) ──
   Layout-only additions per design §2 / §5. No new color or
   typography tokens. No :hover rules (mobile-first; the scrub UX is
   touch-driven). */
.tk-chart-ohlcv {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
