/*
 * The coverholder book: the overview band and the charts on a coverholder's
 * overview page. The dashboard used to draw the same band and charts for the
 * whole book, which is where these styles began, but the dashboard was
 * simplified to plain quick links and the coverholder pages kept the figures.
 *
 * Every other widget on the page is a white Filament section, so the band that
 * carries the headline figures is painted in the Temple navy instead: it marks
 * the summary as the thing to read first, and ties the top of the page back to
 * the navy topbar above it.
 *
 * The charts below it are left alone. One coloured block reads as emphasis;
 * several read as decoration.
 */
.fi-portfolio-overview {
    background-color: var(--primary-600);
    border-radius: var(--radius-xl);
    color: var(--color-white);
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing) * 6);
    padding: calc(var(--spacing) * 6);
}

/*
 * In dark mode the page drops to near black, which the navy is only a few
 * shades off. The band steps up to the next shade so it still reads as a panel
 * sitting on the page rather than a hole cut into it.
 */
.dark .fi-portfolio-overview {
    background-color: var(--primary-500);
}

.fi-portfolio-headline {
    align-items: flex-end;
    display: flex;
    gap: calc(var(--spacing) * 8);
}

.fi-portfolio-headline-figures {
    flex: none;
}

/*
 * Labels sit well below white so they never compete with the figure they
 * introduce, while staying far enough above the navy to be read comfortably.
 */
.fi-portfolio-label {
    color: var(--primary-200);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    line-height: 1rem;
    text-transform: uppercase;
}

/*
 * The one number the business is measured on, set as large as the band allows
 * and scaled with the viewport so it never wraps.
 *
 * Deliberately not `tabular-nums`: equal width digits are for columns that line
 * up vertically, and at this size they leave visible gaps inside the number.
 */
.fi-portfolio-figure {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-block: calc(var(--spacing) * 1);
}

.fi-portfolio-change {
    color: var(--primary-200);
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/*
 * The sparkline takes whatever width is left over. `min-width: 0` is what lets
 * it give that width back when the band is narrow, because a flex item will
 * otherwise refuse to shrink below its own content.
 */
.fi-portfolio-sparkline {
    color: var(--primary-300);
    flex: 1;
    height: 4.5rem;
    min-width: 0;
}

.fi-portfolio-tiles {
    border-top: 1px solid color-mix(in oklab, var(--color-white) 15%, transparent);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-top: calc(var(--spacing) * 5);
}

/*
 * Hairlines between the tiles rather than around them: a rule that only appears
 * between neighbours needs no corner handling and no exception at the ends.
 */
.fi-portfolio-tile + .fi-portfolio-tile {
    border-left: 1px solid color-mix(in oklab, var(--color-white) 15%, transparent);
    padding-left: calc(var(--spacing) * 5);
}

.fi-portfolio-tile:not(:last-child) {
    padding-right: calc(var(--spacing) * 5);
}

.fi-portfolio-value {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 2rem;
    margin-block: calc(var(--spacing) * 1);
}

.fi-portfolio-note {
    color: var(--primary-200);
    font-size: 0.8125rem;
    line-height: 1.125rem;
}

/*
 * Below the large breakpoint the four tiles are too narrow to hold a figure and
 * its note on one line each, so they fall to two rows. The dividing rules come
 * off with them: `+` only knows about the previous tile in source order, not
 * about which row it landed on, so once the grid wraps it would draw a rule
 * down the left of a tile that starts a row. Spacing separates them instead.
 */
@media (max-width: 1024px) {
    .fi-portfolio-tiles {
        gap: calc(var(--spacing) * 5);
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .fi-portfolio-tile + .fi-portfolio-tile {
        border-left: 0;
        padding-left: 0;
    }

    .fi-portfolio-tile:not(:last-child) {
        padding-right: 0;
    }
}

/*
 * The headline stacks before the figure and the sparkline start fighting over
 * the same row.
 */
@media (max-width: 768px) {
    .fi-portfolio-headline {
        align-items: stretch;
        flex-direction: column;
        gap: calc(var(--spacing) * 4);
    }

    .fi-portfolio-sparkline {
        height: 3.5rem;
    }

    .fi-portfolio-tiles {
        grid-template-columns: minmax(0, 1fr);
    }
}

/*
 * The charts across the bottom, on one baseline.
 *
 * They sit in one grid row, and a card is only as tall as its own contents, so
 * a donut with its legend leaves a bar chart beside it floating short of it. The grid already stretches each cell to the row; what
 * stops the card filling that cell is the section inside it sizing to its own
 * content, so the card, the section and the section's body are each told to
 * take the height they have been given.
 *
 * Scoped to chart widgets. The overview band above is a single full width
 * widget with nothing to line up against.
 */
.fi-wi-chart,
.fi-wi-chart > .fi-section {
    height: 100%;
}

.fi-wi-chart > .fi-section {
    display: flex;
    flex-direction: column;
}

/*
 * The body takes the slack, so the canvas grows rather than the card padding.
 */
.fi-wi-chart > .fi-section > .fi-section-content-ctn {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.fi-wi-chart > .fi-section > .fi-section-content-ctn > .fi-section-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
}
