/* qÚčto design system 2026 — auth.css (@layer features; ADR-0224, direction A
 * „Temný rám, plovoucí list", ADR-0225).
 *
 * The standalone pages outside the shell: sign-in, the forced password change
 * and the error pages (templates/auth/_frame.html.twig). Same frame as the
 * app: the whole window is the dark frame (sidebar colour) with a soft brand
 * glow in the top-left corner; the brand panel lies directly on it and the
 * page itself is a light, rounded sheet inset 8px from the window edge.
 * Under 900px the panel shrinks to a header band on the frame and the sheet
 * runs edge to edge with rounded top corners.
 *
 * Only semantic tokens from tokens.css; every derived colour is mixed from the
 * white-label inputs, so a tenant's sidebar/brand colours carry through.
 */
@layer features {
    /* ---------------------------------------------------------------- frame */
    .qucto-auth {
        --auth-panel-w: clamp(340px, 36vw, 540px);
        --auth-control-h: 44px;

        position: relative;
        isolation: isolate;
        display: grid;
        grid-template-columns: var(--auth-panel-w) minmax(0, 1fr);
        min-block-size: 100vh;
        min-block-size: 100dvh;
        padding: var(--sheet-inset) var(--sheet-inset) var(--sheet-inset) 0;
        overflow: clip; /* the glow never widens the page */
        background: var(--frame-bg);
        color: var(--sb-text);
    }

    /* Brand glow in the frame's top-left corner (decoration only). */
    .qucto-auth::before {
        content: '';
        position: absolute;
        inset-block-start: 0;
        inset-inline-start: 0;
        z-index: -1;
        inline-size: calc(var(--frame-glow-w) * 1.5);
        block-size: calc(var(--frame-glow-h) * 1.5);
        background: var(--frame-glow);
        pointer-events: none;
    }

    /* ---------------------------------------------------- brand panel (frame) */
    .qucto-auth-panel {
        display: flex;
        flex-direction: column;
        gap: var(--sp-10);
        padding: var(--sp-8) var(--sp-10) var(--sp-6);
        color: var(--sb-text);
    }

    .qucto-auth-brand {
        display: flex;
        align-items: center;
        gap: var(--sp-3);
    }

    .qucto-auth-brand .qucto-brand-logo {
        display: block;
        block-size: 36px;
        inline-size: auto;
    }

    .qucto-auth-brand-text {
        padding-inline-start: var(--sp-3);
        border-inline-start: 1px solid var(--sb-border);
        font-size: var(--fs-label);
        line-height: var(--lh-label);
        font-weight: var(--fw-medium);
        color: var(--sb-muted);
    }

    .qucto-auth-panel-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: var(--sp-8);
        max-inline-size: 26rem;
    }

    .qucto-auth-lead {
        margin: 0;
        font-size: 2.125rem;
        line-height: 2.5rem;
        font-weight: var(--fw-bold);
        letter-spacing: var(--tracking-h1);
        color: var(--frame-ink);
        text-wrap: balance;
    }

    .qucto-auth-panel-text {
        margin: 0;
        max-inline-size: 34ch;
        font-size: var(--fs-md);
        line-height: var(--lh-md);
        color: var(--sb-text);
        text-wrap: pretty;
    }

    /* Feature points: the sidebar's raised plates — icon tile + label. */
    .qucto-auth-points {
        display: grid;
        gap: var(--sp-2);
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .qucto-auth-points li {
        display: flex;
        align-items: center;
        gap: var(--sp-3);
        padding: var(--sp-2-5) var(--sp-3);
        border: 1px solid transparent; /* forced-colours edge */
        border-radius: var(--r-card-nested);
        background: var(--sb-raised);
        box-shadow: var(--sb-raised-ring);
        font-size: var(--fs-base);
        line-height: var(--lh-base);
        font-weight: var(--fw-medium);
        color: var(--frame-ink);
    }

    .qucto-auth-points svg {
        flex: none;
        box-sizing: content-box;
        inline-size: var(--icon);
        block-size: var(--icon);
        padding: var(--sp-1-5);
        border-radius: var(--r-sm);
        background: var(--sb-raised-hover);
        stroke-width: 1.8;
        color: var(--sb-icon-active);
    }

    .qucto-auth-panel-foot {
        margin: 0;
        font-size: var(--fs-2xs);
        line-height: var(--lh-2xs);
        letter-spacing: var(--tracking-xs);
        color: var(--sb-heading);
    }

    /* Error pages: the status code as a large, quiet figure on the frame. */
    .qucto-auth-code {
        margin: 0;
        font-size: clamp(6rem, 11vw, 10rem);
        line-height: 1;
        font-weight: 250;
        letter-spacing: -0.05em;
        font-variant-numeric: tabular-nums;
        color: color-mix(in oklch, var(--frame-ink) 16%, transparent);
    }

    /* ----------------------------------------------------------- the sheet */
    .qucto-auth-main {
        display: flex;
        align-items: center;
        justify-content: center;
        min-inline-size: 0;
        padding: var(--sp-12) var(--sp-8);
        border: 1px solid transparent; /* forced-colours edge */
        border-radius: var(--r-sheet);
        background: var(--sheet-bg);
        box-shadow: var(--sheet-edge);
        color: var(--text);
    }

    .qucto-auth-inner {
        inline-size: 100%;
        max-inline-size: 24rem;
    }

    .qucto-auth-title {
        margin: 0 0 var(--sp-2);
        font-size: var(--fs-h1);
        line-height: var(--lh-h1);
        font-weight: var(--fw-bold);
        letter-spacing: var(--tracking-h1);
        color: var(--text);
        text-wrap: balance;
    }

    .qucto-auth-subtitle {
        margin: 0 0 var(--sp-8);
        font-size: var(--fs-base);
        line-height: 1.375rem;
        color: var(--text-muted);
        text-wrap: pretty;
    }

    .qucto-auth-subtitle p {
        margin: 0;
    }

    .qucto-auth-subtitle p + p {
        margin-block-start: var(--sp-3);
    }

    .qucto-auth-subtitle strong {
        font-weight: var(--fw-semibold);
        color: var(--text);
        overflow-wrap: anywhere;
    }

    /* ----------------------------------------------------------------- form */
    .qucto-auth-form {
        display: grid;
        gap: var(--sp-5);
    }

    .qucto-auth-field {
        display: grid;
        gap: var(--sp-1-5);
    }

    .qucto-auth-field label {
        font-size: var(--fs-sm);
        line-height: var(--lh-sm);
        font-weight: var(--fw-medium);
        color: var(--text);
    }

    .qucto-auth-hint {
        margin: 0;
        font-size: var(--fs-sm);
        line-height: var(--lh-sm);
        color: var(--text-muted);
    }

    .qucto-auth-field input {
        box-sizing: border-box;
        inline-size: 100%;
        block-size: var(--auth-control-h);
        margin: 0;
        padding: 0 var(--sp-3);
        font: inherit;
        font-size: var(--fs-md);
        line-height: var(--lh-md);
        color: var(--text);
        background-color: var(--surface);
        border: 1px solid var(--border-control);
        border-radius: var(--r-control);
        box-shadow: var(--e1);
        transition: border-color var(--dur-1) var(--ease-out);
    }

    .qucto-auth-field input:hover {
        border-color: var(--border-control-hover);
    }

    .qucto-auth-field input:focus-visible {
        outline: var(--focus-ring);
        outline-offset: var(--focus-offset-input);
        border-color: var(--focus);
    }

    /* Keep autofilled fields on the surface (Chromium paints them blue). */
    .qucto-auth-field input:-webkit-autofill {
        -webkit-text-fill-color: var(--text);
        box-shadow: 0 0 0 100vmax var(--selected) inset;
    }

    /* Password field + „Zobrazit" toggle (added by js/password-toggle.js). */
    .qucto-password {
        position: relative;
    }

    .qucto-password:has(.qucto-password-toggle) > input {
        padding-inline-end: 6rem;
    }

    /* Full field height (44px target); the transparent border keeps the
       field's own border visible under the hover fill. */
    .qucto-password-toggle {
        position: absolute;
        inset-block: 0;
        inset-inline-end: 0;
        min-inline-size: 5.5rem;
        margin: 0;
        padding: 0 var(--sp-3);
        font: inherit;
        font-size: var(--fs-sm);
        font-weight: var(--fw-medium);
        color: var(--text-secondary);
        background: transparent;
        background-clip: padding-box;
        border: 1px solid transparent;
        border-inline-start-color: var(--border-subtle);
        border-start-end-radius: var(--r-control);
        border-end-end-radius: var(--r-control);
        cursor: pointer;
        transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
    }

    .qucto-password-toggle:hover {
        color: var(--text);
        background-color: var(--hover);
    }

    .qucto-password-toggle:focus-visible {
        outline: var(--focus-ring);
        outline-offset: -3px;
    }

    /* Primary action (sign-in, save, error-page way out): the tactile brand
       button of the app (--btn-primary-*), full field height. */
    .qucto-auth-submit {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--sp-2);
        inline-size: 100%;
        min-block-size: var(--auth-control-h);
        margin: var(--sp-1) 0 0;
        padding: 0 var(--sp-5);
        font: inherit;
        font-size: var(--fs-base);
        line-height: var(--lh-base);
        font-weight: var(--fw-semibold);
        color: var(--accent-ink);
        text-decoration: none;
        background: var(--btn-primary-bg);
        border: 0;
        border-radius: var(--r-control);
        box-shadow: var(--btn-primary-shadow);
        cursor: pointer;
        transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
    }

    .qucto-auth-submit:hover {
        background: var(--btn-primary-bg-hover);
    }

    .qucto-auth-submit:active {
        box-shadow: var(--btn-primary-shadow-pressed);
        transform: scale(var(--press-scale));
    }

    .qucto-auth-submit:focus-visible {
        outline: var(--focus-ring);
        outline-offset: var(--focus-offset);
    }

    /* Error summary: soft danger plate + icon, focused on load (GOV.UK). */
    .qucto-auth-error {
        display: flex;
        align-items: flex-start;
        gap: var(--sp-3);
        margin: 0 0 var(--sp-6);
        padding: var(--sp-3) var(--sp-4);
        color: var(--text);
        background-color: var(--danger-wash);
        border: 1px solid var(--danger-border);
        border-radius: var(--r-card-nested);
    }

    .qucto-auth-error:focus-visible {
        outline: var(--focus-ring);
        outline-offset: var(--focus-offset);
    }

    .qucto-auth-error-icon {
        flex: none;
        inline-size: 20px;
        block-size: 20px;
        color: var(--danger-solid);
    }

    .qucto-auth-error-title {
        margin: 0 0 var(--sp-0-5);
        font-size: var(--fs-base);
        line-height: var(--lh-base);
        font-weight: var(--fw-semibold);
        color: var(--danger-ink);
    }

    .qucto-auth-error p {
        margin: 0;
        font-size: var(--fs-base);
        line-height: var(--lh-base);
    }

    .qucto-auth-footer {
        margin: var(--sp-8) 0 0;
        padding-block-start: var(--sp-5);
        border-block-start: 1px solid var(--border);
        font-size: var(--fs-sm);
        line-height: var(--lh-sm);
        color: var(--text-muted);
        text-wrap: pretty;
    }

    .qucto-auth-footer a,
    .qucto-auth-secondary {
        font-weight: var(--fw-medium);
        color: var(--text);
        text-decoration-line: underline;
        text-decoration-thickness: 1px;
        text-decoration-color: var(--link-underline);
        text-underline-offset: 3px;
        transition: text-decoration-color var(--dur-1) var(--ease-out);
    }

    .qucto-auth-footer a:hover,
    .qucto-auth-secondary:hover {
        text-decoration-color: var(--link-underline-hover);
    }

    .qucto-auth-footer a:focus-visible,
    .qucto-auth-secondary:focus-visible {
        border-radius: var(--r-xs);
        outline: var(--focus-ring);
        outline-offset: var(--focus-offset);
    }

    /* ---------------------------------------------------------- error pages */
    /* Eyebrow like the app's task tiles: a state dot + the code. */
    .qucto-error-code {
        display: flex;
        align-items: center;
        gap: var(--sp-1-5);
        margin: 0 0 var(--sp-3);
        font-size: var(--fs-label);
        line-height: var(--lh-label);
        font-weight: var(--fw-medium);
        font-variant-numeric: tabular-nums;
        color: var(--text-muted);
    }

    .qucto-error-code::before {
        content: '';
        flex: none;
        inline-size: 7px;
        block-size: 7px;
        border-radius: 50%;
        background: var(--accent);
    }

    .qucto-error-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--sp-3) var(--sp-6);
        margin-block-start: var(--sp-8);
    }

    .qucto-error-actions .qucto-auth-submit {
        inline-size: auto;
        margin: 0;
    }

    .qucto-auth-secondary {
        display: inline-flex;
        align-items: center;
        min-block-size: var(--auth-control-h);
        font-size: var(--fs-base);
    }

    /* --------------------------------------------------------- phone/tablet */
    @media (max-width: 899.98px) {
        .qucto-auth {
            grid-template-columns: minmax(0, 1fr);
            grid-template-rows: auto 1fr;
            padding: 0;
        }

        .qucto-auth::before {
            inline-size: var(--frame-glow-w);
            block-size: var(--frame-glow-h);
        }

        .qucto-auth-panel {
            gap: 0;
            padding: var(--sp-4) var(--page-px);
        }

        .qucto-auth-panel-body,
        .qucto-auth-panel-foot {
            display: none;
        }

        .qucto-auth-brand .qucto-brand-logo {
            block-size: 30px;
        }

        /* The sheet runs edge to edge, rounded only at the top. */
        .qucto-auth-main {
            align-items: flex-start;
            padding: var(--sp-8) var(--page-px) var(--sp-12);
            border-end-start-radius: 0;
            border-end-end-radius: 0;
        }

        .qucto-auth-title {
            font-size: 1.625rem;
            line-height: 2rem;
        }

        .qucto-auth-subtitle {
            margin-block-end: var(--sp-6);
        }
    }

    /* Windows High Contrast: shadows vanish — keep the sheet and plate edges. */
    @media (forced-colors: active) {
        .qucto-auth-main {
            border-color: CanvasText;
        }

        .qucto-auth-submit {
            border: 1px solid ButtonText;
        }

        .qucto-password-toggle {
            border: 1px solid ButtonText;
        }
    }
}
