/*
 * Minty'Lab: figures measured live, in the visitor's own browser.
 *
 * The figures are written by <ml-live-metrics> (theme) after the page has
 * loaded. Each one replaces a dash set in the same face and size, on one line
 * that cannot wrap: the band is laid out at its final height from the first
 * paint, and the figures arriving shift nothing.
 */
/* The vertical rhythm of this section is the theme's default one
   (:where([data-block]:has(> .ml-section)) in lab/_layout.scss). */

.mpb-metrics__live {
    display: block;
}

/* The live mark before the eyebrow: the measure is this visit's. */
.mpb-metrics__eyebrow {
    display: inline-flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.mpb-metrics__eyebrow::before {
    content: "";
    width: var(--spacing-sm);
    height: var(--spacing-sm);
    border-radius: var(--border-radius-pill);
    background-color: var(--color-mint-3);
    box-shadow: 0 0 0 var(--spacing-2xs) var(--color-mint-ice);
}

/* While the browser measures, the mark breathes. */
@media (prefers-reduced-motion: no-preference) {
    [data-state="measuring"] .mpb-metrics__eyebrow::before {
        animation: mpb-metrics-pulse var(--transition-slow) infinite alternate;
    }
}

@keyframes mpb-metrics-pulse {
    to {
        opacity: 0.35;
    }
}

.mpb-metrics__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--spacing-sm);
    margin: 0;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-3xl);
    background-color: var(--color-surface-elevated);
}

/* Label, figure and note sit on rows shared by the whole line of cells
   (subgrid): a label that wraps on a phone does not push its figure below
   the figure next to it. */
.mpb-metrics__cell {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: var(--spacing-sm);
    align-content: start;
    min-width: 0;
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-xl);
    background-color: var(--color-surface-card);
}

.mpb-metrics__cell[hidden] {
    display: none;
}

.mpb-metrics__label {
    font-size: var(--font-size-label);
    font-weight: var(--font-weight-label);
    letter-spacing: var(--letter-spacing-label);
    text-transform: uppercase;
    color: var(--color-text-subtle);
}

.mpb-metrics__value {
    display: flex;
    gap: var(--spacing-xs);
    align-items: baseline;
    align-self: end;
    margin: var(--spacing-md) 0 0;
    font-family: var(--font-family-heading);
    font-size: var(--font-size-display-stat);
    font-weight: var(--font-weight-display);
    font-variant-numeric: tabular-nums;
    line-height: var(--line-height-display);
    letter-spacing: var(--letter-spacing-display);
    white-space: nowrap;
    color: var(--color-deep);
    transition: opacity var(--transition-base);
}

/* The display time is the figure the band is about. */
.mpb-metrics__cell[data-metric="lcp"] .mpb-metrics__value {
    color: var(--color-emerald);
}

/* The display face only has capitals: a unit set in it would read MS, MO. */
.mpb-metrics__unit {
    font-family: var(--font-family-base);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    letter-spacing: normal;
}

/* Not measured yet: the dash waits, faded. */
[data-state="measuring"] .mpb-metrics__cell:not([data-state="measured"]) .mpb-metrics__value {
    opacity: 0.35;
}

.mpb-metrics__note {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* The video sentence keeps its place while its figures are measured, and is
   not there at all without JavaScript: its slots would stay dashes. */
.mpb-metrics__caption {
    max-width: 46rem;
    margin: var(--spacing-xl) 0 0;
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    color: var(--color-text);
    text-wrap: pretty;
}

.mpb-metrics__caption:not([data-state="measured"]) {
    visibility: hidden;
}

/* A slot waiting for its figure is about as wide as one ("0,6 s", "903 ko"),
   so the sentence wraps on the same lines before and after. */
.mpb-metrics__caption:not([data-state="measured"]) b {
    display: inline-block;
    min-inline-size: 5ch;
}

@media (scripting: none) {
    .mpb-metrics__caption {
        display: none;
    }
}

.mpb-metrics__caption b {
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--color-emerald);
}

.mpb-metrics__foot {
    max-width: 46rem;
    margin: var(--spacing-md) 0 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-subtle);
}

@media (max-width: 991.98px) {
    .mpb-metrics__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .mpb-metrics__cell {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .mpb-metrics__value {
        font-size: var(--font-size-display-sm);
    }

    .mpb-metrics__unit {
        font-size: var(--font-size-base);
    }
}
