/* Perfect Number Finder (/perfect-number-finder): the colours of the three classes (deficient, abundant, perfect),
   the sum and formula lines, the list of divisors, the table of the aliquot sequence, the notable numbers of a range as
   small buttons and the table of the known perfect numbers. Tiles, panels, charts, fields and the theme come from the
   app kit (css/app-kit, docs/app-kit.md). Loaded only on this app's page (StylePaths). */

/* Declared on the stage, so that they follow the stage's own light or dark series colours. */
.pn-landing-app > .filter-landing-stage {
    --pn-deficient: var(--ak-series-1);
    --pn-abundant: var(--ak-series-2);
    --pn-perfect: var(--ak-series-3);
}

/* Four views: a little less padding keeps them on one row in the control panel. */
.pn-landing-app .pn-views > .ak-seg-btn { padding-inline: 0.4rem; }

.pn-landing-app .pn-panel { display: flex; flex-direction: column; gap: var(--ak-space-2, 0.6rem); }
.pn-landing-app .pn-note { margin: 0; }

.pn-landing-app .pn-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ak-space-2, 0.5rem); }
.pn-landing-app .pn-head > .ak-btn { flex: none; }

/* 1 + 2 + 4 + 7 + 14 = 28, and σ(n) worked out from the factors. */
.pn-landing-app .pn-sum {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.pn-landing-app .pn-formula {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0;
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm, 0.88rem);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.pn-landing-app .pn-status { margin: 0; line-height: 1.5; }

/* The divisors: n itself outlined. */
.pn-landing-app .pn-divs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 13rem;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.pn-landing-app .pn-div {
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm, 6px);
    background: var(--ak-field);
    font-size: var(--ak-fs-sm);
    font-variant-numeric: tabular-nums;
}

.pn-landing-app .pn-div--n {
    border-color: var(--ak-text);
    background: transparent;
    font-weight: 700;
}

/* The aliquot sequence: long ones scroll; the terms of the cycle are marked. */
.pn-landing-app .pn-seq-wrap,
.pn-landing-app .pn-known-wrap {
    max-height: 22rem;
    overflow-y: auto;
}

.pn-landing-app .pn-seq td,
.pn-landing-app .pn-known td { font-variant-numeric: tabular-nums; }
.pn-landing-app .pn-seq td:nth-child(2) { white-space: nowrap; }
.pn-landing-app .pn-seq th:first-child { width: 4.5rem; }
.pn-landing-app .pn-seq th:nth-child(2) { width: 40%; }

/* The grid draws deficient numbers faintly; the legend matches. */
.pn-landing-app .ak-swatch.pn-faint { opacity: 0.45; }
.pn-landing-app .pn-seq tr.pn-cycle td { background: color-mix(in srgb, var(--ak-series-3) 12%, transparent); }

.pn-landing-app .pn-kind { font-weight: 600; }
.pn-landing-app .pn-kind--deficient { color: var(--pn-deficient); }
.pn-landing-app .pn-kind--abundant { color: var(--pn-abundant); }
.pn-landing-app .pn-kind--perfect { color: var(--pn-perfect); }

/* Notable numbers in a range: each one opens the number. */
.pn-landing-app .pn-notable {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 0.9rem;
    align-items: baseline;
    margin: 0;
}

.pn-landing-app .pn-notable dt { color: var(--ak-muted); font-size: var(--ak-fs-sm); }
.pn-landing-app .pn-notable dd { margin: 0; min-width: 0; }

.pn-landing-app .pn-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pn-landing-app .pn-chip,
.pn-landing-app .pn-open {
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm, 6px);
    background: var(--ak-field);
    color: var(--ak-text);
    font: inherit;
    font-size: var(--ak-fs-sm);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.pn-landing-app .pn-chip:hover,
.pn-landing-app .pn-open:hover { background: var(--ak-hover); }
.pn-landing-app .pn-chip:focus-visible,
.pn-landing-app .pn-open:focus-visible { outline: 2px solid var(--ak-accent); outline-offset: 1px; }

.pn-landing-app .pn-none { color: var(--ak-muted); font-size: var(--ak-fs-sm); }

/* The known perfect numbers: long values wrap, the larger ones show their last digits. */
.pn-landing-app .pn-known td.pn-num { overflow-wrap: anywhere; word-break: break-all; }
.pn-landing-app .pn-tail { color: var(--ak-muted); }

@media (max-width: 520px) {
    .pn-landing-app .pn-notable { grid-template-columns: 1fr; gap: 0.25rem; }
    .pn-landing-app .pn-notable dd { margin-bottom: 0.4rem; }
}
