/* FCN Radar live explainer (/fcn locked preview): one Monte Carlo run drawn in WebGL by
   js/usmarket_fcn_radar_live.js. Without WebGL or JavaScript the poster and the settled tally show.
   The pyramid film (資產配置金字塔) for the same page is at the end. */

.fcn-radar-live {
    --radar-paper: var(--fcn-media-panel, var(--ds-surface));
    display: grid;
    grid-template-columns: minmax(232px, 288px) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
        "head stage"
        "tally stage"
        "line stage"
        "caption caption";
    gap: 0 28px;
    margin: 0 0 12px;
    padding: 22px 22px 16px;
    border: 1px solid var(--fcn-media-border, var(--ds-border));
    border-radius: var(--ds-radius-md);
    background: var(--radar-paper);
    color: var(--ds-on-surface);
    font-variant-numeric: tabular-nums;
}

.fcn-radar-live__head {
    grid-area: head;
    min-width: 0;
}

.fcn-radar-live__head h2 {
    margin: 0;
    color: var(--ds-on-surface);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
}

.fcn-radar-live__head p {
    margin: 6px 0 0;
    color: var(--ds-muted);
    font-size: 13px;
    line-height: 1.5;
}

.fcn-radar-live__tally {
    grid-area: tally;
    min-width: 0;
    margin-top: 22px;
}

.fcn-radar-live__count {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ds-border);
    color: var(--ds-muted);
    font-size: 13px;
}

.fcn-radar-live__count strong {
    color: var(--ds-primary);
    font-size: 18px;
    font-weight: 600;
}

.fcn-radar-live__rows {
    display: grid;
    gap: 16px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.fcn-radar-live__rows li {
    --radar-row: var(--ds-primary);
    min-width: 0;
}

.fcn-radar-live__rows li.is-exit {
    --radar-row: var(--ds-risk-low);
}

.fcn-radar-live__rows li.is-conv {
    --radar-row: var(--ds-risk-high);
}

.fcn-radar-live__row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
}

.fcn-radar-live__row-head strong {
    color: var(--radar-row);
    font-size: 18px;
    font-weight: 600;
}

.fcn-radar-live__bar {
    height: 4px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--ds-surface-2);
}

.fcn-radar-live__bar i {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--radar-row);
    transform-origin: left center;
}

.fcn-radar-live__rows small {
    display: block;
    margin-top: 6px;
    color: var(--ds-muted);
    font-size: 12px;
}

.fcn-radar-live__line {
    grid-area: line;
    align-self: end;
    margin: 24px 0 4px;
    color: var(--ds-primary);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.fcn-radar-live__line span {
    display: inline-block;
    will-change: transform, opacity;
}

.fcn-radar-live__stage {
    grid-area: stage;
    position: relative;
    min-width: 0;
    aspect-ratio: 1340 / 860;
    overflow: hidden;
}

.fcn-radar-live__canvas,
.fcn-radar-live__poster,
.fcn-radar-live__labels {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.fcn-radar-live__poster {
    background: center / contain no-repeat url("../images/usmarket/fcn/fcn-radar-live-light.webp?v=20261028");
    transition: opacity 0.4s ease;
}

html[data-theme="dark"] .fcn-radar-live__poster {
    background-image: url("../images/usmarket/fcn/fcn-radar-live-dark.webp?v=20261028");
}

.fcn-radar-live[data-radar-state="live"] .fcn-radar-live__poster,
.fcn-radar-live[data-radar-state="still"] .fcn-radar-live__poster {
    opacity: 0;
    visibility: hidden;
}

.fcn-radar-live__labels {
    pointer-events: none;
}

.fcn-radar-live__label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--radar-paper);
    color: var(--ds-primary);
    font-size: clamp(11px, 1.05vw, 13px);
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    will-change: transform;
}

.fcn-radar-live__label.is-ko {
    color: var(--ds-risk-low);
}

.fcn-radar-live__label.is-ki {
    color: var(--ds-risk-high);
}

.fcn-radar-live__label.is-time {
    color: var(--ds-muted);
    font-weight: 500;
}

.fcn-radar-live__caption {
    grid-area: caption;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--ds-border);
    color: var(--ds-muted);
    font-size: 12px;
    line-height: 1.6;
}

.fcn-radar-live__caption p {
    margin: 0;
    max-width: 76ch;
}

.fcn-radar-live__toggle {
    display: none;
    flex: none;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: transparent;
    color: var(--ds-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.fcn-radar-live__toggle:hover {
    background: var(--ds-surface-2);
    color: var(--ds-on-surface);
}

.fcn-radar-live[data-radar-state="live"] .fcn-radar-live__toggle {
    display: inline-flex;
}

.fcn-radar-live__toggle:focus-visible {
    outline: none;
    box-shadow: var(--usm-focus-ring);
}

@media (max-width: 760px) {
    .fcn-radar-live {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-template-areas:
            "head"
            "stage"
            "tally"
            "line"
            "caption";
        padding: 16px 14px 12px;
    }

    .fcn-radar-live__stage {
        margin: 12px -14px 0; /* the chart bleeds to the panel edges on phones */
    }

    .fcn-radar-live__tally {
        margin-top: 14px;
    }

    .fcn-radar-live__rows {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .fcn-radar-live__row-head {
        display: grid;
        gap: 2px;
        font-size: 12px;
    }

    .fcn-radar-live__row-head strong {
        font-size: 17px;
    }

    .fcn-radar-live__line {
        margin-top: 16px;
        font-size: 24px;
    }

    .fcn-radar-live__caption {
        flex-direction: column;
        gap: 10px;
    }

    .fcn-radar-live__toggle {
        align-self: flex-start;
    }
}

/* Pyramid film: a 16:9 cut, and a 4:5 cut with larger copy for phones (explainers/fcn-pyramid). */
.fcn-pyramid-film {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: var(--ds-radius-md);
    background: #cfe2f6;
}

.fcn-pyramid-film--4x5 {
    display: none;
    aspect-ratio: 4 / 5;
}

@media (max-width: 720px) {
    .fcn-pyramid-film--16x9 {
        display: none;
    }

    .fcn-pyramid-film--4x5 {
        display: block;
        width: min(100%, 88svh * 4 / 5);
        margin-inline: auto;
    }
}
