/* ── Compact (Finviz-style) Quote Layout ── */

/* Widen content area — no sidebar in compact layout */
body.quote-compact .content-wrapper {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--space-md) var(--space-lg);
}

.quote-compact {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ── Header ── */
.fv-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-md);
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.fv-header__ticker {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.fv-header__name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin: 0;
}

.fv-header__sector {
    font-size: 0.8rem;
    color: var(--color-accent);
}

.fv-header__sector a {
    color: var(--color-accent);
    text-decoration: none;
}

.fv-header__sector a:hover {
    text-decoration: underline;
}

.fv-header__price-group {
    margin-left: auto;
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.fv-header__price {
    font-size: 1.4rem;
    font-weight: 700;
}

.fv-header__change {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.fv-header__delta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--color-surface-soft);
    color: var(--color-text);
}

.fv-header__delta.positive {
    background: color-mix(in srgb, var(--color-positive) 14%, transparent);
    color: var(--color-positive);
}

.fv-header__delta.negative {
    background: color-mix(in srgb, var(--color-negative) 14%, transparent);
    color: var(--color-negative);
}

.fv-header__date {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    width: 100%;
}

/* ── Chart ── */
.fv-chart-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
}

.fv-chart-wrap .clickable-card-quote-chart {
    position: relative;
}

.fv-chart-wrap #tvchart {
    height: 280px;
}

/* Chart legend overlay — color classes used by JS-built innerHTML.
   Inline style="..." attributes are blocked by our strict CSP, so the
   legend's date/OHLC/SMA colors must come from a stylesheet. */
.chart-legend {
    font-size: 10px;
    font-family: sans-serif;
    line-height: 14px;
    position: absolute;
    top: 20px;
    left: 8px;
    text-align: left;
    background-color: rgba(255, 255, 255, 0.4);
    color: #111;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 2;
}

.chart-legend .up    { color: #1ca36b; }
.chart-legend .down  { color: #d4364c; }
.chart-legend .sma20  { color: rgba(255, 165,   0, 0.9); }
.chart-legend .sma50  { color: rgba(  0, 165, 255, 0.9); }
.chart-legend .sma200 { color: rgba(  0, 165,   0, 0.9); }

@media (prefers-color-scheme: dark) {
    .chart-legend {
        background-color: rgba(20, 24, 33, 0.45);
        color: #e6edf3;
    }
}

/* ── Key Stats Table ──
   Single bordered card, uniform throughout. Every section uses the same dense
   2-column reference list (à la stockanalysis.com) with thin row separators.
   Section captions are the only visual break — no zebra tint, no per-cell
   boxes. The whole table reads as one continuous list with chapter headings. */
.fv-stats {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface);
    font-size: 0.875rem; /* 14px — WCAG-friendly data-table floor */
    line-height: 1.4;
}

.fv-stats__section {
    padding: 14px 16px;
}

.fv-stats__caption {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 0.75rem; /* 12px */
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-accent-strong);
}

/* Accent bar before each caption — a small section marker so the chapter
   titles read as deliberate signposts. */
.fv-stats__caption::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: var(--color-accent);
}

.fv-stats__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: var(--space-md);
    row-gap: 0;
}

.fv-stat {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 7px 2px;
    border-bottom: 1px solid var(--color-border-muted);
    min-width: 0;
}

/* Hide the bottom border on the last row's cells so the table closes
   flush against the section's bottom padding instead of trailing a
   horizontal divider line. With 44 metrics in 4 columns the last row is
   exactly 4 cells; targeting the last 4 children handles it cleanly. */
.fv-stats__grid .fv-stat:nth-last-child(-n+4) {
    border-bottom: none;
}

.fv-stat-label {
    font-size: 0.8125rem; /* 13px */
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fv-stat-value {
    font-size: 0.9375rem; /* 15px */
    color: var(--color-text);
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fv-stat-value.positive {
    color: var(--color-positive);
}

.fv-stat-value.negative {
    color: var(--color-negative);
}

/* ── Below-fold sections ── */
.fv-below-fold {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.fv-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.fv-section h4 {
    margin: 0 0 var(--space-sm);
    font-size: 0.9rem;
}

/* Top-level chapter heading for a below-fold section. Distinct from the
   sub-card h4 (~14px) so users can locate "which section am I in" at a glance. */
.fv-section__title {
    margin: 0 0 var(--space-md);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

/* Analytics grid */
.fv-analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

/* Grid items default to min-width:auto, which expands to fit overflowing
   children. Without this, the seasonal table's 720px min-width pushes its
   column past the viewport instead of triggering its container's overflow. */
.fv-analytics-grid > * {
    min-width: 0;
}

.fv-analytics-grid .linechart-panel {
    height: 180px;
}

.fv-analytics-grid #dataFieldSelector {
    font-size: 0.75rem;
    padding: 2px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

/* Financials grid */
.fv-financials-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.fv-financials-grid .financials-chart-card {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
}

.fv-financials-grid .financials-chart-card h4 {
    font-size: 0.8rem;
    margin: 0 0 var(--space-xs);
}

.fv-financials-grid .financials-chart-card canvas {
    max-height: 160px;
}

/* Company Overview compact */
.fv-profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.fv-profile-grid .profile-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px var(--space-sm);
    font-size: 0.875rem;
}

.fv-profile-grid .profile-list dt {
    color: var(--color-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.fv-profile-grid .profile-list dd {
    margin: 0;
}

/* Muted secondary text inside a dd — e.g. "as of 2025-09-27" next to employee count,
   or "· View SEC filings ↗" next to the CIK number. */
.fv-profile-grid .profile-list .profile-list__hint {
    color: var(--color-text-muted);
    font-size: 0.8125rem; /* 13px caption floor */
    font-weight: 400;
}

/* Subsection headings inside the Company Overview card (Filing Status, Key Executives). */
.fv-profile-grid .fv-profile-subhead {
    margin: var(--space-md) 0 var(--space-xs) 0;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

/* Executive officers table — compact 3-col grid: Name · Title · FY Pay. */
.fv-profile-grid .fv-executives-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.fv-profile-grid .fv-executives-table th,
.fv-profile-grid .fv-executives-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.fv-profile-grid .fv-executives-table thead th {
    font-size: 0.8125rem; /* 13px caption floor */
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.fv-profile-grid .fv-executives-table tbody tr:last-child td {
    border-bottom: none;
}

.fv-profile-grid .fv-executives-table__pay {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.fv-profile-grid .fv-description {
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--color-text-muted);
}

/* News compact list */
.fv-news-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.fv-news-list li {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.fv-news-list li:last-child {
    border-bottom: none;
}

.fv-news-list .news-date {
    color: var(--color-text-muted);
    white-space: nowrap;
    min-width: 70px;
    font-size: 0.8125rem; /* 13px caption floor */
}

/* Headline links: underlined by default so link affordance does not rely on
   color alone (WCAG 1.4.1 / A11Y-003). Thicker on hover; keyboard focus ring
   comes from the global :focus-visible rule. */
.fv-news-list a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.fv-news-list a:hover {
    text-decoration-thickness: 2px;
}

.fv-news-list .news-source {
    color: var(--color-text-muted);
    font-size: 0.8125rem; /* 13px caption floor */
}

/* Subhead text that sits below an fv-section__title — used to disclose
   adjustment conventions (e.g. split-adjusted dividends) so users can
   interpret the numbers below at a glance. */
.fv-section__caption {
    margin: calc(-1 * var(--space-sm)) 0 var(--space-md);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Dividend section: 6-metric grid + last-12-payouts table */
.fv-dividend-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.fv-dividend-metrics > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.fv-dividend-metrics span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.fv-dividend-metrics strong {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
}

.fv-dividend-history-heading {
    margin: var(--space-md) 0 var(--space-xs);
}

.fv-dividend-history-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fv-dividend-history {
    min-width: 0; /* override .table-compact's 720px min-width — 3 cols fit fine */
}

/* Seasonal table compact */
#monthlyWinRateContainer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}

.fv-section .table-compact {
    width: 100%;
    min-width: 720px; /* forces horizontal scroll on narrow viewports */
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem; /* 14px data floor */
    font-variant-numeric: tabular-nums;
}

.fv-section .table-compact th,
.fv-section .table-compact td {
    padding: 6px 8px;
    text-align: right;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.fv-section .table-compact th:first-child,
.fv-section .table-compact td:first-child {
    text-align: left;
    font-weight: 600;
}

.fv-section .table-compact th {
    font-size: 0.8125rem; /* 13px caption */
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-surface);
}

/* Sticky "Year" column on narrow viewports so users keep their place
   while horizontally scrolling the matrix. */
@media (max-width: 640px) {
    .fv-section .table-compact th:first-child,
    .fv-section .table-compact td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--color-surface);
        box-shadow: 1px 0 0 var(--color-border);
    }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .fv-analytics-grid,
    .fv-financials-grid,
    .fv-profile-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .fv-header__price-group {
        margin-left: 0;
        width: 100%;
    }
}

/* Step down: 4 → 2 columns on narrow desktop / tablet. With 44 metrics laid
   out as 2 columns the last row is 2 cells, so only the last 2 should lose
   their border-bottom — restore the borders on the others. */
@media (max-width: 1024px) {
    .fv-stats__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .fv-stats__grid .fv-stat:nth-last-child(-n+4) {
        border-bottom: 1px solid var(--color-border-muted);
    }
    .fv-stats__grid .fv-stat:nth-last-child(-n+2) {
        border-bottom: none;
    }
}

/* RESP-004: collapse to a single column on small phones. Only the very
   last row (1 cell) should drop its bottom border. */
@media (max-width: 600px) {
    .fv-stats__grid {
        grid-template-columns: 1fr;
    }
    .fv-stats__grid .fv-stat:nth-last-child(-n+2) {
        border-bottom: 1px solid var(--color-border-muted);
    }
    .fv-stats__grid .fv-stat:last-child {
        border-bottom: none;
    }
}

@media (max-width: 480px) {
    .fv-header {
        gap: var(--space-xs);
    }
}
