/* Theme screens (contract theme-screens-v1 §6.1). Rendered by wwwroot/js/theme-screens.js inside
   Screener Library (card grid + inline results) and Screener Index (compact row). Only site.css
   tokens are used, so light and dark themes both resolve; --bs-* variables are avoided because
   several are undefined here and an unresolved var() silently drops the whole declaration. */

.theme-screens {
    --theme-accent: var(--accent);
    border: 1px solid color-mix(in srgb, var(--theme-accent) 30%, var(--border));
    border-radius: 16px;
    background: var(--panel);
    color: var(--text);
    padding: 1rem;
    scroll-margin-top: 8.75rem;
}

.theme-screens-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; }
.theme-screens-title { font-size: 1.15rem; margin: 0; }
.theme-screens-intro { color: var(--muted); font-size: .8rem; margin: .3rem 0 0; max-width: 60rem; }
.theme-screens-status { margin-top: .75rem; color: var(--muted); font-size: .85rem; }
.theme-screens-status[hidden] { display: none; }
.theme-screens-alert { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); border-radius: 10px; background: color-mix(in srgb, var(--warning) 8%, var(--panel)); padding: .7rem .85rem; color: var(--text); }
.theme-screens-alert > i { color: var(--warning); }
.theme-screens-empty { border: 1px dashed var(--border); border-radius: 10px; padding: 1rem; text-align: center; }

.theme-screens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .7rem; list-style: none; margin: .85rem 0 0; padding: 0; }
.theme-screens-grid:empty { display: none; }
.theme-screens-compact .theme-screens-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.theme-card-item { display: flex; min-width: 0; }
.theme-card { display: flex; flex: 1; flex-direction: column; gap: .4rem; min-width: 0; border: 1px solid var(--border); border-radius: 11px; background: var(--panel-2); color: inherit; padding: .8rem .85rem; text-decoration: none; }
.theme-card:hover { border-color: color-mix(in srgb, var(--theme-accent) 60%, var(--border)); color: inherit; }
.theme-card:focus-visible, .theme-lens-button:focus-visible, .theme-results-title:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.theme-card.is-active { border-color: var(--theme-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent) 30%, transparent); }
.theme-card-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem; color: var(--theme-accent); font-size: .68rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.theme-card-source { border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .62rem; font-weight: 700; letter-spacing: 0; padding: .05rem .45rem; text-transform: none; }
.theme-card-title { font-size: .92rem; overflow-wrap: anywhere; }
.theme-card-description { color: var(--muted); font-size: .75rem; }
.theme-card-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; color: var(--muted); font-size: .72rem; }
.theme-tier-badge { font-size: .62rem; }

.theme-screens-results { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; scroll-margin-top: 8.75rem; }
.theme-screens-results[hidden] { display: none; }
.theme-results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.theme-results-kicker { color: var(--theme-accent); font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.theme-results-title { font-size: 1.2rem; margin: .15rem 0 0; }
.theme-results-lens { color: var(--muted); font-size: .8rem; margin: .2rem 0 0; }
.theme-lens-switch { display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0; }
.theme-lens-button { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: .76rem; font-weight: 700; padding: .38rem .75rem; text-align: left; }
.theme-lens-button:hover { color: var(--text); border-color: color-mix(in srgb, var(--theme-accent) 55%, var(--border)); }
.theme-lens-button.is-active { color: var(--text); border-color: var(--theme-accent); background: color-mix(in srgb, var(--theme-accent) 14%, var(--panel-2)); }

.theme-results-state { border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); padding: 1rem; }
.theme-results-locked { border-style: solid; border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); color: var(--text); }
.theme-results-locked i.bi-lock-fill { color: var(--warning); }
.theme-results-counts { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .78rem; margin: 0 0 .5rem; }
.theme-results-cap { color: var(--text); font-weight: 700; }
.theme-results-table-wrap { max-width: 100%; overflow-x: auto; }
.theme-results-table { margin-bottom: .5rem; color: var(--text); }
.theme-results-table th { color: var(--muted); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.theme-results-table td { vertical-align: top; font-size: .82rem; }
.theme-col-rank { width: 3.5rem; }
/* A-505: price and price date are visibly apart, so two adjacent em dashes never read as one. */
.theme-results-table .theme-col-price { padding-right: 1rem; }
.theme-results-table .theme-col-price-date { border-left: 1px solid var(--border); padding-left: 1rem; white-space: nowrap; }
.theme-listing-link { font-weight: 700; }
.theme-listing-meta { display: block; color: var(--muted); font-size: .7rem; }
.theme-basis { margin-top: .3rem; }
.theme-basis summary { color: var(--muted); cursor: pointer; font-size: .7rem; }
.theme-basis p { color: var(--text); font-size: .74rem; margin: .25rem 0 0; max-width: 42rem; }
.theme-subsection { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .5rem; }
.theme-subsection summary { cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 700; }
.theme-sublist { display: grid; gap: .3rem; list-style: none; margin: .5rem 0 0; padding: 0; font-size: .78rem; }
.theme-sublist .mono { color: var(--muted); margin-left: .35rem; }
.theme-sublist-reason { color: var(--muted); }
.theme-disclosure { display: flex; gap: .45rem; align-items: flex-start; border-left: 3px solid var(--theme-accent); color: var(--muted); font-size: .76rem; margin: .9rem 0 .35rem; padding-left: .6rem; }
.theme-footer { color: var(--muted); font-size: .7rem; margin: 0; }

/* Tablet: two cards a row for the compact strip; the results table keeps its columns. */
@media (max-width: 991.98px) {
    .theme-screens-compact .theme-screens-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phone: one card a row, and each ranked row becomes a labelled block so no column (rank, value,
   price, price date) is hidden behind a horizontal scroller. */
@media (max-width: 575.98px) {
    .theme-screens { padding: .8rem; border-radius: 12px; }
    .theme-screens-grid, .theme-screens-compact .theme-screens-grid { grid-template-columns: 1fr; }
    .theme-results-table-wrap { overflow-x: visible; }
    .theme-results-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .theme-results-table, .theme-results-table tbody, .theme-results-table tr, .theme-results-table td { display: block; width: 100%; }
    .theme-results-table tr { border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); margin-bottom: .55rem; padding: .45rem .6rem; }
    .theme-results-table td { display: flex; justify-content: space-between; gap: .75rem; border: 0; padding: .2rem 0; text-align: right; }
    .theme-results-table td::before { content: attr(data-label); color: var(--muted); font-family: var(--font-ui); font-size: .7rem; font-weight: 700; text-align: left; flex: 0 0 auto; }
    .theme-results-table td.theme-col-listing { display: block; text-align: left; }
    .theme-results-table td.theme-col-listing::before { display: block; margin-bottom: .1rem; }
    /* Each cell is its own labelled line here, so the column rule and gutter would only indent. */
    .theme-results-table td.theme-col-price, .theme-results-table td.theme-col-price-date { border-left: 0; padding-left: 0; padding-right: 0; }
    .theme-col-rank { width: auto; }
}
