/* Discovery pages: people, themes, charts, binge, premieres, ranked lists,
   episode finder, and the series-page cast + audience sections. */

/* ---- Shared panels ---- */
.insights-panel {
    margin: 14px 0;
    padding: 12px 14px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
}

.insights-panel-title {
    margin: 0 0 4px;
    font-family: Calibri, sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: var(--theme-text);
}

.insights-panel-note,
.insights-explainer {
    margin: 0 0 10px;
    font-family: Calibri, sans-serif;
    font-size: 12px;
    color: var(--theme-muted);
}

.insights-explainer {
    margin: 8px 2px 12px;
}

.insights-count {
    display: inline-block;
    min-width: 20px;
    padding: 0 7px;
    margin-left: 4px;
    border-radius: 10px;
    background: var(--theme-accent-soft);
    color: var(--theme-accent);
    font-size: 12px;
    text-align: center;
    vertical-align: middle;
}

.insights-footer-link {
    margin: 14px 2px;
    font-family: Calibri, sans-serif;
    font-size: 13px;
    color: var(--theme-muted);
}

.insights-footer-link a {
    color: var(--theme-accent);
    font-weight: 700;
    text-decoration: none;
}

.insights-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0 12px;
}

/* ---- Tabs ---- */
.insights-tabs {
    display: flex;
    gap: 4px;
    margin: 10px 0 12px;
    padding: 4px;
    overflow-x: auto;
    background: var(--theme-surface-deep);
    border-radius: 10px;
    scrollbar-width: none;
}

.insights-tab {
    flex: 1 0 auto;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: Calibri, sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--theme-text-soft);
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.insights-tab:hover {
    color: var(--theme-accent);
}

.insights-tab.is-active {
    background: var(--theme-surface);
    color: var(--theme-accent);
    box-shadow: 0 1px 4px var(--theme-shadow);
}

/* ---- Search forms ---- */
.insights-search {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 14px;
}

.insights-search input {
    flex: 1 1 200px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--theme-border-strong);
    border-radius: 8px;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 15px;
}

.finder-form input[name='series'] {
    flex: 0 1 180px;
}

.insights-search input:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 3px var(--theme-focus);
}

.insights-search button {
    padding: 10px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--theme-accent);
    color: var(--theme-on-accent);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.insights-search button:hover {
    background: var(--theme-accent-hover);
}

/* ---- Rank / metric line inside series cards ---- */
.insight-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    margin: 2px 0;
}

.insight-rank {
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--theme-text);
    color: var(--theme-surface);
    font-size: 11px;
    font-weight: 800;
}

.insight-value {
    color: var(--theme-accent);
    font-size: 13px;
    font-weight: 800;
}

.insight-detail {
    color: var(--theme-muted);
    font-size: 12px;
    font-weight: 600;
}

.insight-meter {
    display: block;
    width: 100%;
    max-width: 220px;
    height: 5px;
    margin: 4px 0 2px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--theme-surface-deep);
}

.insight-meter span {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--theme-accent);
}

/* ---- People ---- */
.person-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.person-chip {
    display: inline-flex;
    flex-direction: column;
    padding: 5px 11px;
    background: var(--theme-surface-soft);
    border: 1px solid var(--theme-border);
    border-radius: 16px;
    font-family: Calibri, sans-serif;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.person-chip:hover {
    border-color: var(--theme-accent);
    transform: translateY(-1px);
}

.person-chip-name {
    color: var(--theme-text);
    font-size: 13px;
    font-weight: 700;
}

.person-chip-count {
    color: var(--theme-muted);
    font-size: 11px;
}

.person-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--theme-border-strong);
    text-underline-offset: 2px;
}

.person-link:hover {
    color: var(--theme-accent);
    text-decoration-color: var(--theme-accent);
}

.series-cast {
    margin: 10px 0;
    padding: 10px 12px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
}

.series-cast-row + .series-cast-row {
    margin-top: 8px;
}

.series-cast-label {
    margin-bottom: 5px;
    font-family: Calibri, sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--theme-muted);
}

.insights-rank-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.insights-rank-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--theme-border);
    font-family: Calibri, sans-serif;
    font-size: 13px;
}

.insights-rank-row:last-child {
    border-bottom: 0;
}

.insights-rank-num {
    flex: 0 0 22px;
    color: var(--theme-muted);
    font-weight: 700;
    text-align: right;
}

.insights-rank-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--theme-text);
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.insights-rank-name:hover {
    color: var(--theme-accent);
}

.insights-rank-meta {
    flex: 0 0 auto;
    color: var(--theme-muted);
    font-size: 12px;
}

/* ---- Themes ---- */
.theme-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--theme-surface-soft);
    border: 1px solid var(--theme-border);
    border-radius: 14px;
    font-family: Calibri, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--theme-text-soft);
    text-decoration: none;
}

.theme-pill:hover {
    border-color: var(--theme-accent);
    color: var(--theme-accent);
}

.theme-pill-count {
    color: var(--theme-muted);
    font-size: 10px;
    font-weight: 700;
}

.theme-pills-large .theme-pill {
    padding: 6px 12px;
    font-size: 14px;
}

.series-hero-themes {
    margin-top: 8px;
}

.series-hero-themes .theme-pill-count {
    display: none;
}

.theme-filter {
    width: 100%;
    box-sizing: border-box;
    margin: 4px 0 10px;
    padding: 9px 12px;
    border: 1px solid var(--theme-border-strong);
    border-radius: 8px;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 14px;
}

.theme-letter-group {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--theme-border);
}

.theme-letter {
    flex: 0 0 22px;
    padding-top: 4px;
    font-family: Calibri, sans-serif;
    font-size: 15px;
    font-weight: 800;
    color: var(--theme-accent);
}

/* ---- Audience panel (series page) ---- */
.audience-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin: 6px 0 12px;
}

.audience-stat {
    padding: 8px 10px;
    background: var(--theme-surface-soft);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
}

.audience-stat-value {
    font-family: Calibri, sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--theme-text);
    line-height: 1.1;
}

.audience-stat-label {
    font-family: Calibri, sans-serif;
    font-size: 11px;
    color: var(--theme-muted);
}

.audience-chart {
    display: block;
    width: 100%;
    height: 110px;
}

.audience-chart-area {
    fill: color-mix(in srgb, var(--theme-accent) 18%, transparent);
}

.audience-chart-line {
    fill: none;
    stroke: var(--theme-accent);
    stroke-width: 2;
    stroke-linejoin: round;
}

.audience-chart-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-family: Calibri, sans-serif;
    font-size: 11px;
    color: var(--theme-muted);
}

.audience-subtitle {
    margin-top: 14px;
    font-family: Calibri, sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: var(--theme-text);
}

.retention-bars {
    display: grid;
    gap: 5px;
}

.retention-row {
    display: grid;
    grid-template-columns: 34px 1fr 40px;
    align-items: center;
    gap: 8px;
    font-family: Calibri, sans-serif;
    font-size: 12px;
}

.retention-label {
    color: var(--theme-muted);
    font-weight: 700;
}

.retention-track {
    height: 10px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--theme-surface-deep);
}

.retention-fill {
    display: block;
    height: 100%;
    border-radius: 5px;
    background: var(--theme-accent);
}

.retention-value {
    color: var(--theme-text-soft);
    font-weight: 700;
    text-align: right;
}

/* ---- Premieres & finales ---- */
.premiere-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.premiere-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--theme-border);
}

.premiere-row:last-child {
    border-bottom: 0;
}

.premiere-thumb {
    flex: 0 0 42px;
    width: 42px;
    height: 60px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--theme-surface-deep);
}

.premiere-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.premiere-body {
    flex: 1 1 auto;
    min-width: 0;
    font-family: Calibri, sans-serif;
}

.premiere-name {
    display: block;
    overflow: hidden;
    color: var(--theme-text);
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.premiere-name:hover {
    color: var(--theme-accent);
}

.premiere-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--theme-muted);
}

.premiere-event {
    font-weight: 700;
    color: var(--theme-text-soft);
}

.premiere-new .premiere-event {
    color: var(--status-ok-text, #1f7a3d);
}

.premiere-series-finale .premiere-event {
    color: var(--status-bad-text, #c0392b);
}

.premiere-latest .premiere-event {
    color: var(--theme-muted);
    font-weight: 600;
}

.premiere-badge {
    padding: 0 5px;
    border-radius: 4px;
    background: var(--theme-surface-deep);
    font-size: 11px;
    font-weight: 700;
}

.premiere-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.premiere-date {
    flex: 0 0 auto;
    font-family: Calibri, sans-serif;
    text-align: right;
}

.premiere-date-day {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--theme-text);
}

.premiere-date-rel {
    display: block;
    font-size: 11px;
    color: var(--theme-accent);
    font-weight: 700;
}

/* ---- Ranked lists matrix ---- */
.toplist-matrix {
    width: 100%;
    border-collapse: collapse;
    font-family: Calibri, sans-serif;
    font-size: 13px;
}

.toplist-matrix th,
.toplist-matrix td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--theme-border);
    text-align: center;
    white-space: nowrap;
}

.toplist-matrix th[scope='row'] {
    text-align: left;
    color: var(--theme-text);
}

.toplist-matrix tr:first-child th {
    font-size: 11px;
    color: var(--theme-muted);
    text-transform: uppercase;
}

.toplist-matrix td a {
    display: inline-block;
    min-width: 30px;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--theme-accent-soft);
    color: var(--theme-accent);
    font-weight: 800;
    text-decoration: none;
}

.toplist-matrix td a:hover {
    background: var(--theme-accent);
    color: var(--theme-on-accent);
}

.toplist-matrix td.is-empty {
    color: var(--theme-muted);
}

/* ---- Episode finder ---- */
.finder-hit {
    display: flex;
    gap: 10px;
    margin: 8px 0;
    padding: 10px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
}

.finder-thumb {
    position: relative;
    flex: 0 0 120px;
    width: 120px;
    height: 68px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--theme-surface-deep);
}

.finder-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.finder-badge {
    position: absolute;
    left: 4px;
    bottom: 4px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.finder-body {
    flex: 1 1 auto;
    min-width: 0;
    font-family: Calibri, sans-serif;
}

.finder-title {
    color: var(--theme-text);
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
}

.finder-title:hover {
    color: var(--theme-accent);
}

.finder-series {
    margin-top: 1px;
    font-size: 12px;
    color: var(--theme-muted);
}

.finder-series a {
    color: var(--theme-accent);
    font-weight: 700;
    text-decoration: none;
}

.finder-plot {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--theme-text-soft);
}

.finder-hit mark {
    padding: 0 1px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--theme-accent) 22%, transparent);
    color: inherit;
}

@media (max-width: 480px) {
    .finder-thumb {
        flex-basis: 88px;
        width: 88px;
        height: 50px;
    }

    .premiere-title {
        display: none;
    }

    .audience-stat-value {
        font-size: 17px;
    }
}
