/* Statistics calculator (/statistics-calculator): what is its own. Everything else (stage, chart frame, fields, buttons,
   stat tiles, key/value rows, table, colours) comes from the app kit (css/app-kit, docs/app-kit.md). Loaded only on this
   app's page (StylePaths). */

/* Narrow screens: the site's phone rule for app stages (seo-pages.css, place-items: start center, more specific than
   the kit's align-items: stretch) would shrink the panels to their content; they keep the stage's width. */
.statistics-landing-app > .ak-stage > * {
    align-self: stretch;
}

/* --- Chart -------------------------------------------------------------------------------------------------------- */

.statistics-landing-app .sc-chart-head {
    align-items: flex-end;
}

/* Quartile method sits on the chart it changes (the box plot), at the end of the head, its label beside it. */
.statistics-landing-app .sc-method {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.5rem;
    margin-inline-start: auto;
    max-width: 100%;
}

.statistics-landing-app .sc-method .ak-field {
    flex: 1 1 12rem;
    width: auto;
    max-width: 18rem;
}

/* "Enter at least one number" over the empty chart. */
.statistics-landing-app .sc-empty {
    position: absolute;
    inset: 0;
}

/* --- Five-number summary: min, the box, the median, the mean, max -------------------------------------------------- */

.statistics-landing-app .sc-five {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.statistics-landing-app .sc-five-scale {
    position: relative;
    height: 1.7rem;
    margin: 0.15rem 0.4rem 0;
}

.statistics-landing-app .sc-five-rail,
.statistics-landing-app .sc-five-whiskers,
.statistics-landing-app .sc-five-iqr,
.statistics-landing-app .sc-five-med,
.statistics-landing-app .sc-five-mean,
.statistics-landing-app .sc-five-out {
    position: absolute;
    top: 50%;
}

.statistics-landing-app .sc-five-rail {
    right: 0;
    left: 0;
    height: 2px;
    transform: translateY(-50%);
    background: var(--ak-border);
}

.statistics-landing-app .sc-five-whiskers {
    z-index: 1;
    height: 2px;
    transform: translateY(-50%);
    background: var(--ak-text);
}

.statistics-landing-app .sc-five-whiskers::before,
.statistics-landing-app .sc-five-whiskers::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 2px;
    height: 0.7rem;
    transform: translateY(-50%);
    background: var(--ak-text);
}

.statistics-landing-app .sc-five-whiskers::before { left: 0; }
.statistics-landing-app .sc-five-whiskers::after { right: 0; }

.statistics-landing-app .sc-five-iqr {
    z-index: 2;
    height: 1.15rem;
    transform: translateY(-50%);
    border: 2px solid var(--ak-accent);
    border-radius: 0.28rem;
    background: color-mix(in srgb, var(--ak-accent) 24%, var(--ak-panel));
}

.statistics-landing-app .sc-five-med {
    z-index: 3;
    width: 2px;
    height: 1.15rem;
    transform: translate(-50%, -50%);
    background: var(--ak-text);
}

.statistics-landing-app .sc-five-mean {
    z-index: 4;
    width: 0.55rem;
    height: 0.55rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--ak-danger);
    box-shadow: 0 0 0 2px var(--ak-panel);
}

.statistics-landing-app .sc-five-outs {
    position: absolute;
    inset: 0;
    z-index: 4;
}

.statistics-landing-app .sc-five-out {
    width: 0.48rem;
    height: 0.48rem;
    transform: translate(-50%, -50%);
    border: 2px solid var(--ak-warning);
    border-radius: 50%;
    background: var(--ak-panel);
}

/* Labels sit under their marks. The script sets left (the centre of the label) and nudges overlaps apart. */
.statistics-landing-app .sc-five-read {
    position: relative;
    height: 2.7rem;
    margin: 0 0.4rem;
}

.statistics-landing-app .sc-five-label {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    max-width: 7.5rem;
    transform: translateX(-50%);
    text-align: center;
}

.statistics-landing-app .sc-five-label span {
    color: var(--ak-muted);
    font-size: 0.68rem;
    line-height: 1.2;
}

.statistics-landing-app .sc-five-label b {
    color: var(--ak-text);
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

/* --- The other results, in two panels under the chart -------------------------------------------------------------- */

.statistics-landing-app .sc-results-block,
.statistics-landing-app .sc-more {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.statistics-landing-app .sc-group {
    gap: 0.85rem;
}

/* A long value (a list of modes or outliers) wraps at its separators and leaves the label room. */
.statistics-landing-app .sc-results {
    grid-template-columns: minmax(min(8rem, 46%), 1fr) minmax(0, max-content);
}

.statistics-landing-app .sc-results > dd {
    overflow-wrap: anywhere;
}

.statistics-landing-app .sc-results + .sc-results {
    padding-top: 0.75rem;
    border-top: 1px solid var(--ak-border);
}

/* --- Data box ------------------------------------------------------------------------------------------------------ */

.statistics-landing-app .sc-input {
    min-height: 9.5rem;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
}

/* --- Sorted data and frequency table ------------------------------------------------------------------------------- */

.statistics-landing-app .sc-details {
    padding: 0 0.75rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-panel);
    color: var(--ak-text);
}

.statistics-landing-app .sc-details > summary {
    padding: 0.5rem 0;
    border-radius: 0.25rem;
    color: var(--ak-accent);
    font-weight: 600;
    cursor: pointer;
}

.statistics-landing-app .sc-details > summary:focus-visible {
    outline: 2px solid var(--ak-accent);
    outline-offset: 2px;
}

.statistics-landing-app .sc-details > .ak-table-wrap {
    margin-bottom: 0.75rem;
}

.statistics-landing-app .sc-sorted {
    max-height: 14rem;
    margin: 0 0 0.75rem;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

/* Outliers in the sorted data. */
.statistics-landing-app .sc-sorted mark {
    padding: 0.05rem 0.25rem;
    border-radius: 0.25rem;
    background: color-mix(in srgb, var(--ak-warning) 16%, transparent);
    color: var(--ak-warning);
    font-weight: 700;
}
