/*
    Recurring history popup (rts-): the mobile RecurringTransactionsSummaryPopup ("See all") on the web. It reuses the
    transaction popup's header (transaction-popup.css: txp-band, txp-sheet, txp-logo, txp-titles, txp-close) and the Recurring
    tab's charge rows (recurring-stream-editor.css: rse-history-row, rse-avatar, rse-pill), so load those first. Every color
    is a --tx-* token, so light and dark follow the site's data-bs-theme. The chart's colors come from the logo: the
    component writes --rts-line-light, --rts-area-light, --rts-line-dark and --rts-area-dark on .rts-hero.
*/

/* ------------------------------------------------------------------ Header: the Active or Inactive pill */

.txp-subtitle.rts-subtitle {
    gap: 8px;
    font-size: 13px;
}

.rts-status {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 9px;
    background: var(--tx-pill-bg);
    font-weight: 600;
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--tx-pill-text);
}

.rts-status.rts-status-active {
    background: var(--tx-positive-soft);
    color: var(--tx-positive);
}

.txp-body.rts-body {
    gap: 12px;
    margin: 8px 12px 28px;
}

/* ------------------------------------------------------------------ Next payment */

.tx-section.rts-next {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    padding: 10px 12px;
}

.rse-icon-chip.rts-next-chip {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    align-self: center;
}

.rts-next-text {
    margin: 0;
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--tx-text);
}

/* ------------------------------------------------------------------ Hero chart */

.tx-section.rts-hero {
    position: relative;
    height: 268px;
    padding: 0;
    overflow: hidden;
}

/* The chart fills the card; the axes are pinned so the line sits under the total and above the edge labels. */
.rts-chart {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: rts-chart-in .45s ease both;
}

@keyframes rts-chart-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.rts-area-top {
    stop-color: var(--rts-area-light);
}

.rts-area-bottom {
    stop-color: var(--rts-area-light);
    stop-opacity: 0;
}

[data-bs-theme="dark"] .rts-area-top,
[data-bs-theme="dark"] .rts-area-bottom {
    stop-color: var(--rts-area-dark);
}

.rts-glow,
.rts-line {
    fill: none;
    stroke: var(--rts-line-light);
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

[data-bs-theme="dark"] .rts-glow,
[data-bs-theme="dark"] .rts-line {
    stroke: var(--rts-line-dark);
}

/* The home hero recipe: a 7px glow at 16%, then the 2.25px line. */
.rts-glow {
    stroke-width: 7px;
    opacity: .16;
}

.rts-line {
    stroke-width: 2.25px;
}

.rts-chart-empty {
    position: absolute;
    right: 16px;
    bottom: 34px;
    left: 16px;
    margin: 0;
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    text-align: center;
    color: var(--tx-muted);
}

/* The total over the top of the chart. */
.rts-total {
    position: absolute;
    top: 14px;
    left: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.rts-caption,
.rts-year {
    margin: 0;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .055em;
    text-transform: uppercase;
    color: var(--tx-muted);
}

.rts-total-value {
    font-weight: 700;
    font-size: 30px;
    line-height: 1.25;
    color: var(--tx-text);
}

.rts-total-sentence {
    max-width: calc(100% - 150px);
    font-family: var(--tx-font-text);
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--tx-muted);
}

/* Each charge / Monthly: the shared compact segmented menu, hugging its labels, pinned top-right over the chart.
   Doubled class so it outranks .tx-seg's position: relative. */
.tx-seg.rts-mode-seg {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 1;
}

/* Edge labels under the chart. */
.rts-edges {
    position: absolute;
    right: 16px;
    bottom: 10px;
    left: 16px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 8px;
    font-family: var(--tx-font-text);
    font-size: 11.5px;
    white-space: nowrap;
    color: var(--tx-muted);
    pointer-events: none;
}

.rts-edges > span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* ------------------------------------------------------------------ Totals */

.rts-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.tx-glance-tile.rts-tile {
    gap: 2px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--tx-surface);
}

.tx-glance-tile.rts-tile .tx-glance-value {
    font-size: 17px;
}

/* ------------------------------------------------------------------ All charges */

.rts-year-group {
    gap: 4px;
}

.rts-year-group + .rts-year-group {
    margin-top: 10px;
}

.rts-year {
    margin: 0 0 2px 4px;
}

.rts-year-rows {
    gap: 2px;
}

.rts-more {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    padding: 10px 14px;
    border: 0;
    border-radius: 14px;
    background: var(--tx-nr-tile);
    font-family: var(--tx-font);
    font-weight: 600;
    font-size: 13px;
    color: var(--tx-primary);
    cursor: pointer;
}

.rts-more-glyph {
    font-size: 11px;
}

@media (prefers-reduced-motion: reduce) {
    .rts-chart {
        animation: none;
    }
}
