/* /css/screener.css — Conservative Screener custom styles
   Load order: site.css → screener/styles.css → screener/theme-bridge.css → this file */

/* ═══════════════════════════════════════════════════════════════════════════
   SCREENER PAGE TOKENS & BASE
   Inherits from site.css :root / html[data-theme="dark"].
   Adds the DRM-ecosystem accent palette the screener shares.
   ═══════════════════════════════════════════════════════════════════════════ */
.screener-page {
  /* Brand accent — matches --sh-accent in site.css and DRM palette */
  --acc:          #00ff99;
  --acc-dim:      rgba(0, 255, 153, 0.10);
  --acc-border:   rgba(0, 255, 153, 0.28);
  --acc-glow:     0 0 24px rgba(0, 255, 153, 0.22), 0 0 80px rgba(0, 255, 153, 0.07);

  /* Risk red — DRM ecosystem */
  --fire:         #ff3355;
  --fire-dim:     rgba(255, 51, 85, 0.10);
  --fire-border:  rgba(255, 51, 85, 0.28);

  /* Deep card surface — sits between --bg (#0b0b0f) and Tailwind brand-800 */
  --bg2:          #111120;

  /* Layout: screener fills the viewport as a flex column (nav → content → footer) */
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Light-mode: remap the dark surface token so --bg2 references don't disappear */
html[data-theme="light"] .screener-page {
  --bg2: var(--soft);
}

/* ── Pillar 4 · Legal: sticky "NOT FINANCIAL ADVICE" micro-banner ────────── */
.screener-nfa-bar {
  background: rgba(255, 51, 85, 0.06);
  border-bottom: 1px solid rgba(255, 51, 85, 0.18);
  text-align: center;
  font-family: var(--f-mono, 'Space Mono', monospace);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 51, 85, 0.75);
  padding: 5px 16px;
  user-select: none;
}

/* ── Disclaimer modal ───────────────────────────────────────────────────── */
#disclaimer-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#disclaimer-body::-webkit-scrollbar { width: 4px; }
#disclaimer-body::-webkit-scrollbar-track { background: #1e293b; }
#disclaimer-body::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }
#ack-checkbox:checked { accent-color: #475569; }

/* ── Global floating tooltip (position:fixed breaks out of overflow containers) */
#cs-tooltip {
  position: fixed;
  z-index: 9999;
  display: none;
  width: 272px;
  pointer-events: none;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  font-family: 'Space Mono', 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.55;
}
#cs-tooltip .tp-section { padding: 10px 12px; }
#cs-tooltip .tp-divider { border-top: 1px solid #1e293b; margin: 0 12px; }
#cs-tooltip .tp-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 5px;
}
#cs-tooltip .tp-def  { color: #94a3b8; }
#cs-tooltip .tp-defb { color: #cbd5e1; font-size: 12px; }
#cs-tooltip .tp-bm   { color: #94a3b8; }
#cs-tooltip .tp-bmb  { color: #94a3b8; font-size: 12px; }

/* ── TickerInsights terminal panel ─────────────────────────────────────── */
@keyframes cs-blink {
  0%, 49%  { opacity: 0.8; }
  50%, 100%{ opacity: 0;   }
}
.cs-cursor {
  display: inline-block;
  width: 6px; height: 0.85em;
  background: currentColor;
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cs-blink 1.1s step-start infinite;
}
#insights-arrow { transition: transform .2s ease; }
#insights-toggle-btn[aria-expanded="true"] #insights-arrow { transform: rotate(90deg); }

.insights-val {
  font-family: 'Space Mono', 'JetBrains Mono', monospace;
  color: #cbd5e1;
  font-size: 0.92em;
}
.insights-val.pass { color: var(--acc, #00ff99); }
.insights-val.fail { color: #94a3b8; }

/* Tooltip info-dot trigger */
[data-tooltip-key] { cursor: help; }
[data-tooltip-key] .tip-dot {
  display: inline-block;
  margin-left: 3px;
  font-size: 9px;
  opacity: 0.5;
  vertical-align: middle;
  transition: opacity .15s;
}
[data-tooltip-key]:hover .tip-dot { opacity: 0.85; }

/* ── Disclaimer CTA button animations ──────────────────────────────────── */
@keyframes unlock-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(100,116,139,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(100,116,139,0); }
  100% { box-shadow: 0 0 0 0 rgba(100,116,139,0); }
}
#cta-btn.unlocked { animation: unlock-pulse 0.5s ease-out; }

/* ── Dashboard fade-in ──────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.35s ease-out forwards; }

/* ── Stock header (premium quote strip) ─────────────────────────────────── */
#stock-header { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.stock-header-inner {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: 0.875rem;
  border: 1px solid rgba(51, 65, 85, 0.65);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.55) 0%, rgba(15, 23, 42, 0.35) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
@media (min-width: 640px) {
  .stock-header-inner {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.5rem 1.75rem;
  }
}
.stock-identity-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.625rem;
  min-width: 0;
}
.stock-quote-block {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}
@media (min-width: 640px) { .stock-quote-block { gap: 1rem; } }

.stock-price-display {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}
.change-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.8125rem;
  border-radius: 9999px;
  font-family: 'Space Mono', 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}
.change-pill-up {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #059669;
}
.change-pill-down {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #e11d48;
}

/* ── Global search dropdown ─────────────────────────────────────────────── */
#global-search-input:focus ~ #search-slash-hint,
#global-search-input:not(:placeholder-shown) ~ #search-slash-hint {
  display: none !important;
}
#global-search-wrap { position: relative; }
#global-search-results {
  max-height: 320px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(51, 65, 85, 0.85);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#global-search-results::-webkit-scrollbar { width: 4px; }
#global-search-results::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }
.search-result-item {
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.search-result-item:hover,
.search-result-item[aria-selected="true"] { background: rgba(51, 65, 85, 0.55); }
.search-result-item[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--acc, #00ff99); }

/* ── Sector combobox dropdown ───────────────────────────────────────────── */
#sector-combobox-list { max-height: 240px; overflow-y: auto; }
#sector-combobox-list::-webkit-scrollbar { width: 4px; }
#sector-combobox-list::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }
.sector-combobox-item { cursor: pointer; transition: background-color 0.12s ease; }
.sector-combobox-item[aria-selected="true"],
.sector-combobox-item:hover { background: rgba(30, 41, 59, 0.9); }
.sector-combobox-item.hidden-by-filter { display: none; }

/* ── Sticky identity columns (Rank / Company / Ticker) ─────────────────── */
.sticky-col-rank, .sticky-col-company, .sticky-col-ticker {
  position: sticky;
  z-index: 2;
}
.sticky-col-rank    { left: 0; }
.sticky-col-company { left: 3rem; }
.sticky-col-ticker  { left: 15rem; }
thead .sticky-col-rank, thead .sticky-col-company, thead .sticky-col-ticker {
  z-index: 3;
  background-color: #0f172a;
}
tbody tr .sticky-col-rank, tbody tr .sticky-col-company, tbody tr .sticky-col-ticker {
  background-color: #1e293b;
}
tbody tr:hover .sticky-col-rank, tbody tr:hover .sticky-col-company, tbody tr:hover .sticky-col-ticker {
  background-color: rgba(30, 41, 59, 0.95);
}
.sticky-col-ticker { box-shadow: 2px 0 6px -2px rgba(0, 0, 0, 0.45); }

/* ── Mobile horizontal scroll — sector table ────────────────────────────── */
#sector-table-container .overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
#sector-table-container { position: relative; }
#sector-table-container::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 2.5rem;
  pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(15, 23, 42, 0.7));
  border-radius: 0 0.75rem 0.75rem 0;
  z-index: 1;
}
@media (min-width: 1280px) { #sector-table-container::after { display: none; } }

/* ── Touch targets — iOS/Android minimum 44×44 px ──────────────────────── */
#global-search-input, #ticker-input, #run-btn,
#scan-btn, #mos-select, #sector-combobox-input {
  min-height: 44px;
}
.search-result-item { min-height: 44px; display: flex; align-items: center; }
.sector-combobox-item { min-height: 44px; display: flex; align-items: center; }

/* ── Mobile padding ─────────────────────────────────────────────────────── */
@media (max-width: 639px) {
  #main-dashboard > main {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 1.5rem;
  }
  .stock-header-inner { padding: 0.875rem 1rem; gap: 0.875rem; }
  #filter-cards-container > div, #completion-summary { padding: 1rem; }
}

/* ── Screener secondary search bar (sits below site nav) ────────────────── */
.screener-search-bar {
  flex-shrink: 0;
  border-bottom: 1px solid #1e293b;
  background: rgba(11, 11, 15, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: var(--sh-h, 54px);
  z-index: 20;
}
.screener-search-bar-inner {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Ensure main site footer is dark on screener page ───────────────────── */
.screener-page footer {
  background: #0b0b0f;
  border-top: 1px solid #1e293b;
  color: #64748b;
}
.screener-page footer a { color: #64748b; }
.screener-page footer a:hover { color: #94a3b8; }

/* ── Reduced-motion accessibility (WCAG 2.3.3) ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
