/* ==========================================================================
   FUND PAGE - specification tables + advanced filters
   Scoped to .fund-* so nothing else on the site is affected.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Specification table inside each fund card
   -------------------------------------------------------------------------- */
.fund-specs {
    margin-top: 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-surface);
}

.fund-specs-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-secondary);
}

.fund-specs-head i {
    color: var(--cyan-accent);
    font-size: 0.8rem;
}

.fund-specs-list {
    margin: 0;
    padding: 0;
}

/* A two-column grid of label/value pairs. On a phone each pair stacks so the
   value never gets squeezed to an unreadable width. */
.fund-spec {
    display: grid;
    grid-template-columns: minmax(88px, 42%) 1fr;
    gap: 8px;
    align-items: baseline;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-color);
}

.fund-spec:last-child {
    border-bottom: none;
}

.fund-spec:nth-child(odd) {
    background: rgba(127, 127, 127, 0.035);
}

.fund-spec dt {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0;
    line-height: 1.5;
}

.fund-spec dd {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-highlight);
    line-height: 1.5;
    text-align: left;
    word-break: break-word;
}

.fund-spec dd.up { color: var(--bullish-green); }
.fund-spec dd.down { color: var(--bearish-red); }
.fund-spec dd.yes { color: var(--bullish-green); }
.fund-spec dd.no { color: var(--text-secondary); }
.fund-spec dd.risk-low { color: var(--bullish-green); }
.fund-spec dd.risk-medium { color: var(--gold-accent); }
.fund-spec dd.risk-high { color: var(--bearish-red); }

/* Distribution rows get their own tint so they stand out from the price rows */
.fund-spec dd.freq { color: var(--cyan-accent); }

/* Reinvest  -> stays inside the fund (compounding)
   Cash      -> paid out to the bank account
   Accumulated-> added to the unit value, not paid out */
.fund-spec dd.dist-reinvest { color: var(--cyan-accent); }
.fund-spec dd.dist-cash { color: var(--bullish-green); }
.fund-spec dd.dist-accumulated { color: var(--gold-accent); }

/* Fixed-income funds get a bronze hairline so the tab is scannable */
.fund-card-item[data-category="FixedIncome"] {
    background: linear-gradient(180deg, rgba(184, 134, 11, 0.045), transparent 140px);
}

@media (max-width: 420px) {
    .fund-spec {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .fund-spec dd {
        text-align: right;
    }
}

/* --------------------------------------------------------------------------
   2. Advanced filter panel
   -------------------------------------------------------------------------- */
.fund-filters {
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
}

.ff-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    flex-wrap: wrap;
}

.ff-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 220px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-highlight);
    cursor: pointer;
    text-align: right;
    padding: 0;
}

.ff-toggle > span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ff-toggle > span:first-child i {
    color: var(--cyan-accent);
}

/* What is currently filtering, so the collapsed header is still informative */
.ff-summary {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--cyan-accent);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.ff-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.22s ease;
    flex-shrink: 0;
}

.ff-toggle.open .ff-arrow {
    transform: rotate(180deg);
}

.ff-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--bearish-border);
    background: var(--bearish-bg);
    color: var(--bearish-red);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 800;
    cursor: pointer;
}

.ff-reset:hover {
    background: var(--bearish-red);
    color: #fff;
}

.ff-body {
    display: none;
    padding: 16px 14px;
    gap: 18px;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
}

.ff-body.open {
    display: flex;
}

.ff-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ff-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-secondary);
}

.ff-label i {
    color: var(--text-muted);
    font-size: 0.76rem;
}

/* Chips wrap, never scroll, so nothing is hidden off-screen on a phone */
.ff-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.ff-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
    white-space: nowrap;
}

.ff-chip:hover {
    border-color: var(--cyan-accent);
    color: var(--text-highlight);
}

.ff-chip.active {
    background: var(--cyan-bg);
    border-color: var(--cyan-accent);
    color: var(--cyan-accent);
}

.ff-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ff-chip .dot.risk-low { background: var(--bullish-green); }
.ff-chip .dot.risk-medium { background: var(--gold-accent); }
.ff-chip .dot.risk-high { background: var(--bearish-red); }

.ff-count {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    background: rgba(127, 127, 127, 0.18);
    color: var(--text-muted);
}

.ff-chip.active .ff-count {
    background: rgba(127, 127, 127, 0.28);
    color: inherit;
}

.ff-select {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.ff-select:focus {
    border-color: var(--cyan-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.12);
}

.ff-results {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--cyan-bg);
    border: 1px solid var(--cyan-border);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-highlight);
}

.ff-results i {
    color: var(--cyan-accent);
}

.ff-results strong {
    color: var(--cyan-accent);
    font-size: 0.95rem;
}

/* Two filter groups side by side on a tablet, stacked on a phone */
@media (min-width: 700px) {
    .ff-body.open {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ff-wide,
    .ff-results {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .ff-toggle {
        flex-wrap: wrap;
    }

    .ff-summary {
        flex-basis: 100%;
        text-align: right;
        order: 3;
    }
}