/*
 * William Walker UI foundation — scoped primitives and accessibility.
 *
 * Apply .ww-ui to the new application shell (or a migrated page root). This
 * keeps the foundation opt-in while legacy templates are migrated gradually.
 */

.ww-ui {
    color: var(--ww-color-text);
    font-family: var(--ww-font-sans);
    font-size: var(--ww-font-size-base);
    line-height: var(--ww-line-height-normal);
    text-rendering: optimizeLegibility;
}

.ww-ui *,
.ww-ui *::before,
.ww-ui *::after {
    box-sizing: border-box;
}

.ww-ui :where(button, input, select, textarea) {
    font: inherit;
}

/* iOS zoomt beim Fokus in Felder unter 16 px (RM-21, G-0572); Seiten mit
   eigener Feldgröße setzen sie selbst. */
@media (max-width: 44rem) {
    .ww-ui :where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), select, textarea) {
        font-size: max(var(--ww-font-size-lg), 1em);
    }
}

.ww-ui :where(button, [role="button"], a, input, select, textarea, summary):focus-visible,
.ww-focus-ring:focus-visible {
    outline: 2px solid var(--ww-color-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--ww-color-focus-ring);
}

/* Do not style every anchor under .ww-ui: the shell deliberately wraps legacy
 * pages during migration, and their button/link classes own their foreground
 * colours. New ordinary text links opt in with .ww-link instead. */
.ww-ui .ww-link {
    color: var(--ww-color-brand);
    text-underline-offset: .14em;
}

.ww-ui .ww-link:hover {
    color: var(--ww-color-brand-strong);
}

/* Verlinkte Kennungen (services/links.py, WwLinks): dezent, unterstrichen bei
 * Hover, Monospace-Kennungen bleiben Monospace. Gilt auch außerhalb .ww-ui,
 * weil JS-gerenderte Listen in Altseiten dieselben Links bekommen. */
.ww-link,
.ww-ui .ww-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: .16em;
    border-radius: 2px;
}

.ww-link:hover,
.ww-link:focus-visible,
.ww-ui .ww-link:hover,
.ww-ui .ww-link:focus-visible {
    color: var(--ww-color-brand, #2d6a4f);
    text-decoration-color: currentColor;
}

.ww-link--mono,
.ww-ident.ww-link--mono {
    font-family: var(--ww-font-mono);
    font-variant-numeric: tabular-nums;
}

.ww-link-wrap {
    display: inline;
    white-space: nowrap;
}

/* "In neuem Tab öffnen": klein, erscheint deutlich bei Hover; auf Touch-Geräten
 * und an Lagerstationen dauerhaft sichtbar mit 44 px Tippfläche. */
.ww-link__newtab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: baseline;
    inline-size: 1.1em;
    block-size: 1.1em;
    margin-inline-start: .15em;
    color: inherit;
    opacity: .45;
    border-radius: 3px;
    text-decoration: none;
}

.ww-link__newtab svg {
    inline-size: .8em;
    block-size: .8em;
}

.ww-link-wrap:hover .ww-link__newtab,
.ww-link__newtab:hover,
.ww-link__newtab:focus-visible {
    opacity: 1;
    color: var(--ww-color-brand, #2d6a4f);
}

@media (pointer: coarse) {
    .ww-link__newtab {
        opacity: .7;
        inline-size: 44px;
        block-size: 44px;
        margin: -12px 0 -12px .1em;
        vertical-align: middle;
    }

    .ww-link__newtab svg {
        inline-size: 1.05em;
        block-size: 1.05em;
    }
}

html.ww-lager-station .ww-link__newtab {
    opacity: .7;
}

@media print {
    .ww-link__newtab { display: none !important; }
    .ww-link { text-decoration: none; }
}

.ww-stack {
    display: flex;
    flex-direction: column;
    gap: var(--ww-stack-gap, var(--ww-space-4));
}

.ww-inline {
    align-items: center;
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--ww-inline-gap, var(--ww-space-2));
}

.ww-cluster {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--ww-cluster-gap, var(--ww-space-3));
}

.ww-split {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: var(--ww-space-3);
    justify-content: space-between;
}

.ww-visually-hidden,
.ww-sr-only {
    block-size: 1px;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    inline-size: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
}

.ww-visually-hidden:focus,
.ww-sr-only:focus {
    block-size: auto;
    clip: auto;
    clip-path: none;
    inline-size: auto;
    margin: var(--ww-space-2);
    overflow: visible;
    padding: var(--ww-space-2) var(--ww-space-3);
    z-index: var(--ww-z-toast);
}

.ww-skip-link {
    background: var(--ww-color-surface);
    border: 1px solid var(--ww-color-border);
    border-radius: var(--ww-radius-sm);
    color: var(--ww-color-text);
    font-weight: var(--ww-font-weight-semibold);
    inset-block-start: var(--ww-space-3);
    inset-inline-start: var(--ww-space-3);
    padding: var(--ww-space-2) var(--ww-space-3);
    position: fixed;
    transform: translateY(-180%);
    transition: transform var(--ww-duration-fast) var(--ww-ease-standard);
    z-index: var(--ww-z-toast);
}

.ww-skip-link:focus {
    transform: translateY(0);
}

.ww-muted {
    color: var(--ww-color-text-muted);
}

.ww-text-danger {
    color: var(--ww-color-danger);
}

.ww-text-success {
    color: var(--ww-color-success);
}

@media (prefers-reduced-motion: reduce) {
    .ww-ui *,
    .ww-ui *::before,
    .ww-ui *::after {
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

@media (prefers-contrast: more) {
    .ww-ui {
        --ww-color-border: #73736c;
        --ww-color-text-muted: #42423e;
        --ww-color-focus-ring: rgba(0, 0, 0, .18);
    }
}
