/* ==========================================================
   Step 4 — Which Fund Should I Choose? — two-section layout
   Namespaced with s4- to avoid collisions with shared shell CSS.
   ========================================================== */

.s4-wrap {
    display: flex;
    flex-direction: column;
    padding: var(--space-4, 4px) var(--space-4, 4px) var(--space-8, 8px);
}

.s4-section {
    position: relative;
    padding-left: var(--space-44, 44px);
    padding-bottom: var(--space-4, 4px);
    margin-bottom: var(--space-4, 4px);
    border-bottom: 1px solid var(--color-border, #e6e8ec);
}

.s4-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* .s4-section-num styling now lives in journey-layout.css, shared
   with steps 2-3, 5-6. */

.s4-loading,
.s4-error {
    padding: var(--space-24, 24px);
    text-align: center;
    color: var(--color-gray-muted, #6b7280);
    font-size: var(--font-size-14, 14px);
}

.s4-title {
    font-family: var(--ev-font-heading, "Playfair Display", serif);
    font-size: var(--font-size-12, 12px);
    color: var(--ev-color-navy, #173763);
    margin: 0 0 4px;
}

.s4-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-4, 4px);
}

.s4-sub {
    font-size: var(--font-size-10, 10px);
    color: var(--color-gray-muted, #6b7280);
    margin: 0 0 4px;
}

/* ---------- Section 1: Priority cards ---------- */

.s4-priority-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.s4-priority-card {
    padding: var(--space-4, 4px);
}

.s4-priority-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-circle, 50%);
    margin-bottom: var(--space-4, 4px);
}

.s4-priority-icon svg {
    width: 18px;
    height: 18px;
}

.s4-priority-title {
    font-size: var(--font-size-12, 12px);
    font-weight: 700;
    margin-bottom: var(--space-4, 4px);
}

.s4-priority-body {
    font-size: var(--font-size-10, 10px);
    color: var(--color-gray-slate, #4b5563);
    line-height: 1.35;
    margin: 0 0 6px;
}

.s4-priority-fit {
    font-size: var(--font-size-9, 9px);
    color: var(--color-gray-light, #9aa1ab);
    line-height: 1.1;
    margin: 0;
}

.s4-howitworks-card {
    background: var(--color-off-white, #f7f8fa);
    padding: var(--space-12, 12px);
}

.s4-howitworks-title {
    font-size: var(--font-size-12, 12px);
    font-weight: 700;
    color: var(--color-ink, #1f2733);
    margin-bottom: var(--space-4, 4px);
}

.s4-howitworks-body {
    font-size: var(--font-size-10, 10px);
    color: var(--color-gray-slate, #4b5563);
    line-height: 1.2;
    margin: 0 0 8px;
}

.s4-howitworks-link {
    font-size: var(--font-size-10, 10px);
    font-weight: 700;
    color: var(--ev-color-navy, #173763);
    text-decoration: none;
}

.s4-howitworks-link:hover {
    text-decoration: underline;
}

/* ---------- Section 2: Fund table ---------- */

.s4-table-scroll {
    overflow-x: auto;
}

.s4-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-10, 10px);
}

.s4-table thead th {
    text-align: left;
    font-size: var(--font-size-9, 9px);
    font-weight: 700;
    color: var(--color-gray-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: var(--space-6, 6px) var(--space-8, 8px);
    border-bottom: 1px solid var(--color-border, #e6e8ec);
    white-space: nowrap;
}

.s4-table tbody tr {
    border-bottom: 1px solid var(--color-bg-muted, #f0f1f3);
}

.s4-table tbody td {
    padding: var(--space-4, 4px);
    vertical-align: middle;
}

.s4-cell-rank {
    font-weight: 700;
    color: var(--color-gray-light, #9aa1ab);
    width: 24px;
}

.s4-cell-fund {
    font-weight: 700;
    color: var(--color-ink, #1f2733);
    white-space: nowrap;
}

.s4-cell-fund-sub {
    display: block;
    font-weight: 400;
    font-size: var(--font-size-9, 9px);
    color: var(--color-gray-light, #9aa1ab);
}

.s4-cell-score {
    font-weight: 700;
    font-size: var(--font-size-10, 10px);
}

.s4-cell-overall {
    color: #b8862b;
}

.s4-cell-trend svg {
    display: block;
}

.s4-cell-why {
    color: var(--color-gray-slate, #4b5563);
    line-height: 1.35;
    min-width: 160px;
}

.s4-th-arrow {
    display: inline-block;
    font-weight: 700;
}

.s4-th-arrow--up { color: #0aa97f; }
.s4-th-arrow--down { color: var(--color-red, #c0392b); }

.s4-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: var(--font-size-10, 10px);
    color: var(--color-gray-muted, #6b7280);
}

.s4-legend-note {
    font-style: italic;
    color: var(--color-gray-light, #9aa1ab);
}

@media (max-width: 900px) {
    .s4-priority-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .s4-priority-row { grid-template-columns: 1fr; }
}

/* ---------- Section 3: Rank consistency ---------- */

.s4-rank-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.s4-rank-card {
    padding: var(--space-12, 12px);
    text-align: center;
}

.s4-rank-card--missing {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gray-light, #9aa1ab);
    font-size: var(--font-size-10, 10px);
    min-height: 110px;
}

.s4-rank-name {
    font-size: var(--font-size-11, 11px);
    font-weight: 700;
    color: var(--color-ink, #1f2733);
    margin-bottom: var(--space-6, 6px);
}

.s4-rank-headline {
    font-size: var(--font-size-12, 12px);
    font-weight: 700;
    line-height: 1.1;
}

.s4-rank-track {
    position: relative;
    height: 4px;
    background: var(--color-bg-muted, #f0f1f3);
    border-radius: var(--radius-3, 3px);
    margin-bottom: var(--space-2, 2px);
    margin-top:var(--space-2, 2px);
}

.s4-rank-fill {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: var(--radius-3, 3px);
    opacity: 0.35;
}

.s4-rank-dot {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-circle, 50%);
    transform: translate(-50%, -50%);
    box-shadow: var(--shadow-marker-ring, 0 0 0 2px var(--color-white, #fff));
}

.s4-rank-range {
    font-size: var(--font-size-9, 9px);
    color: var(--color-gray-light, #9aa1ab);
}

@media (max-width: 900px) {
    .s4-rank-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .s4-rank-row { grid-template-columns: 1fr; }
}