/*
 * Smaoin.Shared.Ui - the look of the shared components, and nothing else.
 *
 * Each site points these custom properties at its own tokens, once, e.g. in its site.css:
 *   :root { --sui-accent: var(--color-accent); --sui-danger: var(--color-sign-red); --sui-radius: .5rem; }
 * Tailwind v4's @theme already exposes tokens as CSS variables, so that is all it takes; a Tailwind v3 or plain-CSS
 * site sets them in :root. Unset, each falls back to a neutral default, so a component never renders unstyled.
 * Library markup carries only these .sui-* classes - never Tailwind utilities, which a site's build cannot see inside
 * a package (2026-10-05).
 */

/* :where() gives the defaults no specificity, so a site's own `:root { --sui-*: ... }` wins whichever stylesheet loads
   last. Plain :root here lost to ScanYerVan's mapping, because this file is linked after site.css (found on 1.0.0). */
:where(:root) {
    --sui-surface: #ffffff;
    --sui-text: #1f2937;
    --sui-accent: #1966ca;
    --sui-danger: #b91c1c;
    --sui-danger-surface: #fef2f2;
    --sui-success: #15803d;
    --sui-success-surface: #f0fdf4;
    --sui-radius: .5rem;
    --sui-shadow: 0 10px 25px rgb(0 0 0 / .15);
    --sui-font: inherit;
    /* The focus ring (A11Y-003): the skip link here, and every focusable element in smaoin-base.css. */
    --sui-focus: var(--sui-accent);
    --sui-focus-width: 3px;
    --sui-focus-offset: 2px;
}

/* Skip link (<skip-link>): off-screen until a keyboard user tabs to it, then pinned top-left above everything. Moved,
   not hidden - display:none or visibility:hidden would take it out of the tab order. */
.sui-skip-link {
    position: absolute;
    left: 1rem;
    top: 1rem;
    z-index: 2147483001;
    padding: .75rem 1rem;
    border-radius: var(--sui-radius);
    background: var(--sui-surface);
    color: var(--sui-text);
    box-shadow: var(--sui-shadow);
    font-family: var(--sui-font);
    font-weight: 600;
    text-decoration: underline;
    transform: translateY(-200%);
}
.sui-skip-link:focus,
.sui-skip-link:focus-visible {
    transform: none;
    outline: var(--sui-focus-width) solid var(--sui-focus);
    outline-offset: var(--sui-focus-offset);
}

/* Failed-request toast (htmx-errors.js): pinned to the bottom of the viewport, above everything, dismissible. */
.sui-toast {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 2147483000;
    max-width: 32rem;
    margin-inline: auto;
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .75rem 1rem;
    border-radius: var(--sui-radius);
    background: var(--sui-surface);
    color: var(--sui-text);
    box-shadow: var(--sui-shadow);
    font-family: var(--sui-font);
}
.sui-toast[hidden] { display: none; }
.sui-toast--error {
    background: var(--sui-danger-surface);
    border-left: 4px solid var(--sui-danger);
}
.sui-toast__text { flex: 1; margin: 0; font-size: .875rem; line-height: 1.4; }
.sui-toast__close {
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .25rem;
}
.sui-toast__close:focus-visible { outline: 2px solid var(--sui-accent); outline-offset: 2px; }

/* Turnstile slot (ScanYerVan's .turnstile-slot, proven in production). The challenge only appears when Cloudflare
   wants an interaction; turnstile-widget.js asks for the 150px 'compact' size when the form is narrower than the
   normal 300px, and this clamp is the backstop so a slot never pushes past its form. Never display:none it - the
   widget has to be able to render into it. */
.sui-turnstile { max-width: 100%; overflow: hidden; }
.sui-turnstile:not(:empty) { margin-top: .5rem; }

/* A form sent with data-busy (behaviours.js): the button's spinner, and the status line below the form. The spinner
   inherits the button's text colour; under reduced motion it holds still and the words carry the meaning. */
.sui-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -.125em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: sui-spin .75s linear infinite;
}
@keyframes sui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sui-spinner { animation: none; border-right-color: currentColor; opacity: .6; } }
.sui-busy-status { margin: .5rem 0 0; font-size: .875rem; line-height: 1.4; color: var(--sui-text); }

/* The outcome of the last POST (<flash />): a success (role=status) or a refusal (role=alert), in the flow of the page
   where the layout puts it. Text in the page's colour on a tinted surface, the kind told by the edge as well as the
   colour (WCAG 1.4.1). */
.sui-flash {
    margin: 0 0 1rem;
    padding: .75rem 1rem;
    border-radius: var(--sui-radius);
    border-left: 4px solid var(--sui-accent);
    background: var(--sui-surface);
    color: var(--sui-text);
    font-family: var(--sui-font);
    font-size: .875rem;
    line-height: 1.4;
}
.sui-flash--success { border-left-color: var(--sui-success); background: var(--sui-success-surface); }
.sui-flash--error { border-left-color: var(--sui-danger); background: var(--sui-danger-surface); }
