/*
 * Club Nikon text size 0.1.0 (docs/phpbb-text-size.md).
 *
 * The head script sets the class cn-text-scaled and --cn-text-delta (1px per
 * step, for example -2px or 8px) on html before the first paint, only for a
 * step other than 0, so step 0 leaves the style's own body size alone. The
 * calc() only adds two lengths, the oldest calc() form, so no browser that
 * reads custom properties drops the rule. prosilver 3.3 sets body to 10px and
 * derives almost every text size from it in em; each step adds 1px to that
 * base and the layout follows. Pixels still zoom with the browser and the browser's own
 * minimum font size still applies. --cn-text-base is there for a style whose
 * body base is not 10px. phpBB links this sheet with media="screen", so
 * printing keeps the style's own size; the media query says so here too. For
 * the same reason the print rule that hides the control is inlined by the head
 * events, not written here.
 */
@media screen {
    html.cn-text-scaled body {
        font-size: calc(var(--cn-text-base, 10px) + var(--cn-text-delta, 0px));
    }
}

/* The control: the last item of the Quick links menu, or a row above the
   footer copyright on pages without that menu. Colours are Viewfinder tokens;
   the fallbacks are what prosilver shows. */
.cn-text-size-home[hidden] {
    display: none;
}

.cn-text-size-home {
    margin: 4px 0;
    font-size: 1.1em;
}

.cn-text-size-list {
    display: flex;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cn-text-size-status {
    display: flex;
    justify-content: space-between;
    gap: 0.6em;
    padding: 5px 5px 3px;
    line-height: 1.3;
}

.cn-text-size-label {
    font-weight: bold;
}

.cn-text-size-value {
    min-width: 2ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cn-text-size-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 5px 5px;
}

.cn-text-size-button {
    min-width: 2.6em;
    min-height: 2.4em;
    margin: 0;
    padding: 0 0.6em;
    border: 1px solid var(--vf-line, #b4bac0);
    border-radius: 3px;
    background: var(--vf-input, #fff);
    color: var(--vf-text, #333);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
}

.cn-text-size-button:focus-visible {
    outline: 2px solid var(--vf-link, #0b62a2);
    outline-offset: 1px;
}

.cn-text-size-button[aria-disabled="true"] {
    opacity: 0.45;
    cursor: default;
}

/* Touch screens and narrow layouts: 44px targets. */
@media (max-width: 700px), (pointer: coarse) {
    .cn-text-size-button {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (forced-colors: active) {
    .cn-text-size-button {
        border-color: ButtonText;
    }

    .cn-text-size-button[aria-disabled="true"] {
        opacity: 1;
        border-color: GrayText;
        color: GrayText;
    }
}
