/* Global element and Bootstrap structure styles for the SCHEU portal "Leicht" look.
   Tokens and shared sd- primitives live in css/portal-ui.css. Colour variables come from css/bootstrap-theme.css. */

html {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    background: rgb(var(--sd-canvas-rgb));
}

body {
    min-width: 320px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    background: rgb(var(--sd-canvas-rgb));
    color: rgb(var(--sd-ink-rgb));
    font-family: var(--sd-font-family);
    font-size: var(--sd-fs-base, 0.875rem);
    font-weight: 400;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: rgb(var(--sd-navy-rgb));
    color: #fff;
}

/* ---------- Page frame ---------- */

/* One content width for header, page and footer. The logo, the page title and the footer share the gutter. */
.portal-container {
    width: 100%;
    max-width: var(--sd-page-max, 1440px);
    margin-inline: auto;
    padding-inline: var(--sd-gutter, 32px) !important;
}

/* Phones in landscape: the gutter keeps clear of the notch and the rounded screen corners (viewport-fit=cover). */
@supports (padding: max(0px)) {
    .portal-container {
        padding-left: max(var(--sd-gutter, 32px), env(safe-area-inset-left)) !important;
        padding-right: max(var(--sd-gutter, 32px), env(safe-area-inset-right)) !important;
    }
}

/* ---------- Type ---------- */

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
.card-title,
.modal-title {
    color: rgb(var(--sd-ink-rgb));
    font-family: var(--sd-font-family);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h1,
.h1 {
    font-size: var(--sd-fs-h1, 1.75rem);
    letter-spacing: -0.02em;
}

h2,
.h2 {
    font-size: var(--sd-fs-h2, 1.25rem);
}

h3,
.h3 {
    font-size: var(--sd-fs-h3, 1.0625rem);
}

h4,
.h4,
h5,
.h5 {
    font-size: var(--sd-fs-md, 0.9375rem);
}

h6,
.h6 {
    font-size: var(--sd-fs-sm, 0.8125rem);
}

b,
strong,
th {
    font-weight: 500;
}

small,
.small {
    font-size: var(--sd-fs-sm, 0.8125rem);
}

.text-muted,
.text-body-secondary {
    color: rgb(var(--sd-muted-rgb)) !important;
}

a {
    color: rgb(var(--sd-navy-rgb));
    text-decoration-color: rgb(var(--sd-line-strong-rgb));
    text-underline-offset: 3px;
}

a:hover {
    color: rgb(var(--sd-sky-ink-rgb));
}

/* Route headings receive programmatic focus; interactive controls keep their focus indicators. */
h1[tabindex="-1"]:focus,
h1:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 2px solid rgb(var(--sd-sky-ink-rgb));
    outline-offset: 2px;
}

/* ---------- Buttons ---------- */

.btn {
    --bs-btn-padding-x: 1.125rem;
    --bs-btn-padding-y: 0.6875rem;
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 500;
    --bs-btn-line-height: 1.4;
    --bs-btn-border-radius: var(--sd-r-sm, 6px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    font-family: var(--sd-font-family);
    letter-spacing: 0;
    white-space: nowrap;
    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.2s ease,
        box-shadow 0.3s ease,
        transform 0.25s var(--sd-ease, ease);
}

.btn .nf,
.btn .hx-icon {
    font-size: 1.125rem;
    line-height: 1;
}

.btn-sm {
    --bs-btn-padding-x: 0.75rem;
    --bs-btn-padding-y: 0.375rem;
    --bs-btn-font-size: 0.8125rem;
    min-height: 32px;
}

.btn-lg {
    --bs-btn-padding-x: 1.5rem;
    --bs-btn-padding-y: 0.75rem;
    --bs-btn-font-size: 0.9375rem;
    --bs-btn-border-radius: var(--sd-r-md, 10px);
    min-height: 48px;
}

.btn-link {
    min-height: 0;
    padding-inline: 0.25rem;
}

.btn:not(.btn-link):not(:disabled):not(.disabled):active {
    transform: translateY(1px) scale(0.98);
}

.btn-outline-primary:not(:disabled):hover,
.btn-outline-secondary:not(:disabled):hover,
.btn-light:not(:disabled):hover,
.btn-secondary:not(:disabled):hover {
    transform: translateY(-1px);
}

.btn:focus-visible,
.btn-check:focus-visible + .btn {
    outline: 2px solid rgb(var(--sd-sky-ink-rgb));
    outline-offset: 2px;
    box-shadow: none;
}

.btn-close:focus {
    box-shadow: none;
}

.btn-close:focus-visible {
    outline: 2px solid rgb(var(--sd-sky-ink-rgb));
    outline-offset: 2px;
}

/* ---------- Cards and panels ---------- */

.card,
.hx-card,
.sd-content-panel {
    --bs-card-border-color: rgb(var(--sd-line-rgb));
    --bs-card-border-radius: var(--sd-r-card, 12px);
    --bs-card-inner-border-radius: calc(var(--sd-r-card, 12px) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-padding-y: 1rem;
    --bs-card-cap-padding-x: 1.25rem;
    --bs-card-spacer-y: 1.25rem;
    --bs-card-spacer-x: 1.25rem;
    overflow: hidden;
    border: 1px solid rgb(var(--sd-line-rgb));
    border-radius: var(--sd-r-card, 12px);
    background: rgb(var(--sd-surface-rgb));
    box-shadow: none;
}

.card-header,
.card-footer {
    border-color: rgb(var(--sd-line-rgb));
    background: transparent;
}

.card-header {
    border-bottom: 0;
    padding-bottom: 0.25rem;
    font-weight: 500;
}

/* ---------- Form controls ---------- */

.form-label,
.col-form-label {
    margin-bottom: 0.3125rem;
    color: rgb(var(--sd-muted-rgb));
    font-size: var(--sd-fs-sm, 0.8125rem);
    font-weight: 500;
}

.form-text {
    color: rgb(var(--sd-muted-rgb));
    font-size: var(--sd-fs-xs, 0.75rem);
}

.form-control,
.form-select {
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    border: 1px solid transparent;
    border-radius: var(--sd-r-md, 10px);
    background-color: var(--sd-fill, #f5f7fa);
    color: rgb(var(--sd-ink-rgb));
    font-size: var(--sd-fs-base, 0.875rem);
    box-shadow: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.form-select {
    padding-right: 2.5rem;
}

.form-control-sm,
.form-select-sm {
    min-height: 36px;
    padding-block: 0.375rem;
    border-radius: var(--sd-r-sm, 6px);
    font-size: var(--sd-fs-sm, 0.8125rem);
}

textarea.form-control {
    min-height: 88px;
}

.form-control:hover:not(:disabled):not([readonly]),
.form-select:hover:not(:disabled) {
    background-color: var(--sd-fill-2, #eef2f7);
}

.form-control:focus,
.form-select:focus {
    border-color: transparent;
    background-color: rgb(var(--sd-surface-rgb));
    color: rgb(var(--sd-ink-rgb));
    box-shadow: var(--sd-focus-ring, 0 0 0 2px #2f5f9e, 0 0 0 6px rgba(47, 95, 158, 0.12));
}

.form-control::placeholder {
    color: var(--sd-subtle, #7d8ea0);
    opacity: 1;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    border-color: transparent;
    background-color: var(--sd-fill, #f5f7fa);
    color: rgb(var(--sd-muted-rgb));
    opacity: 1;
}

.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid {
    border-color: rgb(var(--sd-red-rgb));
    background-color: rgb(var(--sd-surface-rgb));
}

.invalid-feedback {
    color: rgb(var(--sd-rose-ink-rgb));
    font-size: var(--sd-fs-xs, 0.75rem);
}

.form-check-input {
    border-color: rgb(var(--sd-line-strong-rgb));
    background-color: rgb(var(--sd-surface-rgb));
}

.form-check-input[type="checkbox"] {
    border-radius: 4px;
}

.input-group-text {
    border-color: transparent;
    border-radius: var(--sd-r-md, 10px);
    background: var(--sd-fill, #f5f7fa);
    color: rgb(var(--sd-muted-rgb));
}

.hx-form-group,
.hx-input-group {
    min-width: 0;
}

/* ---------- Tables: the zebra list of the prototype ---------- */

.table {
    margin-bottom: 0;
    font-size: var(--sd-fs-base, 0.875rem);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 0.8125rem 0.75rem;
    border-bottom-color: rgb(var(--sd-line-rgb));
}

.table > thead > tr > th,
.table > thead > tr > td {
    padding-block: 0.5625rem;
    border-bottom: 1px solid rgb(var(--sd-navy-rgb));
    background-color: transparent;
    color: rgb(var(--sd-muted-rgb));
    font-size: var(--sd-fs-sm, 0.8125rem);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    --bs-table-bg-type: transparent;
}

/* Every table gets alternating rows so the eye can follow a line. */
.table > tbody > tr:nth-of-type(even) > * {
    --bs-table-bg-type: var(--bs-table-striped-bg);
}

/* Bootstrap paints the cell tint as an inset box-shadow. Rows fade their tint in and out instead of flipping. */
.table > tbody > tr > * {
    transition: background-color 0.35s ease, box-shadow 0.35s ease;
}

.table > tbody > tr:hover > * {
    transition-duration: 0.18s;
}

.table-hover > tbody > tr:hover > *,
.table > tbody > tr.sd-row-link:hover > * {
    --bs-table-bg-state: var(--bs-table-hover-bg);
}

.table .table-light,
.table thead.table-light {
    --bs-table-bg: transparent;
    --bs-table-color: rgb(var(--sd-muted-rgb));
}

.table-responsive {
    background: transparent;
}

/* ---------- Overlays ---------- */

.dropdown-menu,
.popover,
.toast {
    border: 1px solid rgb(var(--sd-line-rgb));
    border-radius: var(--sd-r-card, 12px);
    background: rgb(var(--sd-surface-rgb));
    box-shadow: var(--sd-overlay-shadow);
}

.dropdown-menu {
    overflow: hidden;
    font-size: var(--sd-fs-base, 0.875rem);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 500;
    transition: background-color 0.2s ease, padding-left 0.2s var(--sd-ease, ease);
}

.dropdown-item .nf,
.dropdown-item .hx-icon {
    font-size: 1.125rem;
    color: rgb(var(--sd-muted-rgb));
}

.dropdown-item:focus-visible {
    outline: 2px solid rgb(var(--sd-sky-ink-rgb));
    outline-offset: -2px;
}

.toast {
    border-left: 3px solid rgb(var(--sd-mint-ink-rgb));
    box-shadow: 0 14px 36px rgba(34, 56, 78, 0.16);
}

/* Warnings use the soft amber of the design instead of the strong Bootstrap warning colour. */
.toast.text-bg-warning {
    border-left-color: var(--sd-amber-edge);
    background: var(--sd-amber) !important;
    color: var(--sd-amber-ink) !important;
}

/* The tint goes into the background colour: element opacity below 1 would also fade the blur. */
.modal-backdrop.show {
    opacity: 1;
    background-color: rgba(22, 36, 52, 0.28);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* No clipping here: dropdowns such as the date picker must be able to leave the dialog. Long dialogs scroll as a
   whole; .modal-dialog-scrollable keeps Bootstrap's own height limit and inner scroll area. */
.modal-content {
    border: 0;
    border-radius: var(--sd-r-dialog, 20px);
    background: rgb(var(--sd-surface-rgb));
    color: var(--bs-body-color);
    box-shadow: 0 30px 80px rgba(22, 36, 52, 0.28);
}

/* Without clipping, the first and last part of a dialog carry the rounded corners themselves. */
.modal-content > :first-child {
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.modal-content > :last-child {
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.modal-header,
.modal-footer {
    flex-shrink: 0;
    border: 0;
    background: rgb(var(--sd-surface-rgb));
}

.modal-header .modal-title {
    font-size: 1.3125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-header .btn-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background-color: var(--sd-fill, #f5f7fa);
    background-size: 0.75rem;
    opacity: 1;
    transition: background-color 0.15s ease, transform 0.25s var(--sd-spring, ease);
}

.modal-header .btn-close:hover {
    background-color: var(--sd-fill-2, #eef2f7);
    transform: rotate(90deg);
}

.modal-body {
    background: rgb(var(--sd-surface-rgb));
}

.modal-footer {
    padding: 0.375rem 1.875rem 1.75rem;
}

.modal-header .modal-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.modal-body {
    min-width: 0;
    overflow-wrap: break-word;
}

.modal-body img,
.modal-body video,
.modal-body canvas {
    max-width: 100%;
}

/* Phones: the dialog uses the full width with safe margins. Long dialogs scroll; with .modal-dialog-scrollable the
   body scrolls and header and footer stay visible. Footer buttons share the width and stack when they do not fit. */
@media (max-width: 575.98px) {
    .modal {
        --bs-modal-margin: 0.75rem;
        --bs-modal-padding: 0.5rem 1rem 1rem;
        --bs-modal-header-padding: 1.25rem 1rem 0.375rem 1.25rem;
        padding-right: env(safe-area-inset-right) !important;
        padding-left: env(safe-area-inset-left) !important;
    }

    .modal-dialog {
        margin-top: max(var(--bs-modal-margin), env(safe-area-inset-top));
        margin-bottom: max(var(--bs-modal-margin), env(safe-area-inset-bottom));
    }

    .modal-header .modal-title {
        font-size: 1.1875rem;
    }

    .modal-footer {
        flex-wrap: wrap;
        padding: 0.5rem 1rem max(1rem, env(safe-area-inset-bottom));
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
    }
}

/* Phones in landscape (short screens): less space around and in the dialog, so that more of the body shows. */
@media (max-height: 499.98px) {
    .modal {
        --bs-modal-margin: 0.5rem;
        --bs-modal-header-padding: 0.875rem 1rem 0.25rem 1.5rem;
    }

    .modal-header .modal-title {
        font-size: 1.125rem;
    }

    .modal-footer {
        padding-top: 0.25rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
}

/* Toasts keep clear of the home indicator and the rounded screen corners. */
.toast-container.position-fixed {
    margin-right: env(safe-area-inset-right);
    margin-bottom: env(safe-area-inset-bottom);
}

/* ---------- Alerts, tabs, pills ---------- */

.alert {
    border: 0;
    border-radius: var(--sd-r-card, 12px);
    box-shadow: none;
}

.nav-tabs {
    gap: 1.125rem;
    margin-bottom: 1.375rem;
}

.nav-tabs .nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: -1px;
    padding: 0.625rem 0.125rem;
    border: 0;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-tabs .nav-link::after {
    position: absolute;
    right: 50%;
    bottom: 0;
    left: 50%;
    height: 2px;
    content: "";
    background: rgb(var(--sd-line-strong-rgb));
    transition: left 0.25s var(--sd-ease, ease), right 0.25s var(--sd-ease, ease);
}

.nav-tabs .nav-link:hover::after {
    right: 0;
    left: 0;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    box-shadow: inset 0 -2px 0 rgb(var(--sd-sky-ink-rgb));
}

.nav-tabs .nav-link.active::after {
    display: none;
}

.nav-pills .nav-link {
    font-weight: 500;
    color: rgb(var(--sd-muted-rgb));
}

.badge {
    --bs-badge-font-weight: 500;
    --bs-badge-font-size: 0.75rem;
    --bs-badge-padding-x: 0.5rem;
    --bs-badge-padding-y: 0.25rem;
    --bs-badge-border-radius: var(--sd-r-sm, 6px);
}

.list-group {
    --bs-list-group-border-radius: var(--sd-r-card, 12px);
}

.progress {
    height: 6px;
}

/* ---------- Legacy helpers kept for existing pages ---------- */

.fs-75 > textarea {
    font-size: 0.75rem;
}

.hx-icon .nf {
    display: inline-block;
    line-height: 1;
}

.hx-sidebar-item-icon .nf {
    width: 1.25em;
    text-align: center;
}

/* TreatmentDigDown panel list normalization: 5 visible items and scrolling beyond. */
.oa-panel-list {
    height: 280px;
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
}

.oa-panel-list > .oa-panel-list-item {
    display: flex;
    align-items: center;
    min-height: 56px;
    height: 56px;
    max-height: 56px;
}

.oa-panel-list > .list-group-item:not(.oa-panel-list-item) {
    display: flex;
    align-items: center;
    min-height: 56px;
}

.oa-panel-list .oa-list-item-main {
    min-width: 0;
}

.oa-panel-list .oa-list-item-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.125rem;
}

.oa-panel-list .oa-list-item-title,
.oa-panel-list .oa-list-item-subtitle {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Keep native HAVIT directory controls on the same input baseline. */
.admin-directory > .card > .card-body {
    padding: 1rem !important;
}

.admin-directory .hx-list-layout-header {
    gap: 1rem;
}

.admin-directory .hx-list-layout-title,
.admin-directory .hx-list-layout-header-buttons {
    align-self: end;
}

.admin-directory .hx-list-layout-title {
    min-width: 0;
    min-height: 44px;
    margin: 0;
}

@container hx-list-layout-card (max-width: 575.98px) {
    .admin-directory.user-directory-layout .hx-list-layout-header {
        grid-template-areas: "title title" "search search" "buttons buttons";
    }

    .user-directory-layout .hx-list-layout-title {
        grid-area: title;
        min-height: 0;
    }
}

.admin-directory .hx-list-layout-header-search .form-control,
.admin-directory .hx-list-layout-header-buttons .btn {
    min-height: 44px;
}

.admin-directory .hx-list-layout-header-buttons {
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 767.98px) {
    .admin-directory > .card > .card-body {
        padding-inline: 0 !important;
    }

    .admin-directory .hx-grid tbody tr > td:first-child,
    .admin-directory .hx-grid tbody tr > td:last-child {
        padding-inline: 0;
    }
}

/* ---------- Touch screens ----------
   On a coarse pointer (finger, stylus) every control is at least 44 x 44 px. Small buttons and fields grow;
   checkboxes and radios get a larger box, and their label gets a taller hit area without a change of the layout. */
@media (pointer: coarse) {
    .btn-sm,
    .btn-link,
    .form-control-sm,
    .form-select-sm {
        min-height: 44px;
    }

    .dropdown-item {
        min-height: 44px;
    }

    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        min-height: 44px;
    }

    .modal-header .btn-close {
        width: 44px;
        height: 44px;
    }

    /* Checkbox and radio rows: a 22 px box and a label of at least 44 px height in one flex row. The box sits on
       the middle of the first label line. Other children (validation text, hint) go to a new line under the label. */
    .form-check:not(.form-switch):not(.form-check-inline):not(.form-check-reverse) {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        column-gap: 10px;
        min-height: 44px;
        padding-left: 0;
    }

    .form-check:not(.form-switch):not(.form-check-inline):not(.form-check-reverse) > .form-check-input {
        flex: none;
        float: none;
        width: 22px;
        height: 22px;
        margin: 11px 0 0;
    }

    .form-check:not(.form-switch):not(.form-check-inline):not(.form-check-reverse) > .form-check-label {
        flex: 1 1 0;
        min-width: 0;
        padding-block: 11px;
    }

    .form-check:not(.form-switch):not(.form-check-inline):not(.form-check-reverse)
        > :not(.form-check-input):not(.form-check-label) {
        flex-basis: 100%;
        margin-left: 32px;
    }
}

/* The 16 px font keeps iOS from zooming the page when a field gets the focus (phones and tablets). */
@media (pointer: coarse) and (max-width: 1023.98px) {
    input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="button"],
              [type="submit"], [type="reset"], [type="image"], .ff-auth-code),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ---------- Motion of prototype version 3 ----------
   Durations, delays and curves come from the prototype. Movement uses only transform and opacity.
   The reduced-motion block at the end of this file keeps short fades and colour changes and removes movement. */

@keyframes sd-fade {
    from { opacity: 0; }
}

@keyframes sd-page {
    from { opacity: 0; transform: translateY(6px); }
}

@keyframes joy-check {
    from { opacity: 0; transform: scale(0.4); }
}

@keyframes joy-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    70% { transform: translateY(1px); }
}

@keyframes joy-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

@keyframes joy-toast {
    from { opacity: 0; transform: translateX(40px) scale(0.96); }
}

/* Background position, not transform: the edge marches only while a file is over the zone. */
@keyframes sd-ants {
    to { background-position: 14px 0, -14px 100%, 0 -14px, 100% 14px; }
}

/* Page enter: once per route change. js/portal-motion.js sets the class; Blazor re-renders do not replay it. */
html.sd-page-enter .fluxforge-shell__page {
    animation: sd-page 0.28s var(--sd-ease, ease) backwards;
}

/* Dialogs pop in, the backdrop fades (Bootstrap modal classes used by HxModal). */
.modal.fade,
.modal-backdrop.fade {
    transition: opacity 0.2s ease;
}

.modal.fade .modal-dialog {
    transform: translateY(14px) scale(0.96);
    transition: transform 0.32s var(--sd-spring, ease);
}

.modal.show .modal-dialog {
    transform: none;
}

/* Keep the Bootstrap nudge of a static dialog after the rule above. */
.modal.modal-static .modal-dialog {
    transform: scale(1.02);
}

/* Dropdown menus rise a little. Popper positions them with transform, so the rise uses translate. */
.dropdown-menu.show {
    animation: sd-menu-in 0.22s var(--sd-ease, ease);
}

@keyframes sd-menu-in {
    from { opacity: 0; translate: 0 10px; }
}

/* Toasts (HxMessenger) slide in from the right edge. */
.toast.show {
    animation: joy-toast 0.45s var(--sd-spring, ease);
}

/* Checkboxes: the check pops, the box grows a little under the pointer. Switches keep their slide. */
.form-check-input[type="checkbox"]:not(.form-switch .form-check-input) {
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
                transform 0.2s var(--sd-spring, ease);
}

.form-check-input[type="checkbox"]:checked:not(.form-switch .form-check-input) {
    animation: joy-check 0.25s var(--sd-spring, ease);
}

/* Button icons answer the pointer: plus turns, arrows move, downloads bounce, the unlock icon wiggles. */
.btn .nf,
.btn .hx-icon {
    transition: transform 0.3s var(--sd-spring, ease);
}

@media (hover: hover) and (pointer: fine) {
    .form-check-input[type="checkbox"]:not(:disabled):not(.form-switch .form-check-input):hover {
        transform: scale(1.15);
    }

    .btn:not(:disabled):not(.disabled):hover .nf-md-plus {
        transform: rotate(90deg) scale(1.1);
    }

    .btn:not(:disabled):not(.disabled):hover .nf-md-check {
        transform: scale(1.18);
    }

    .btn:not(:disabled):not(.disabled):hover :is(.nf-md-arrow_right, .nf-md-open_in_new, .nf-md-launch) {
        transform: translateX(3px);
    }

    .btn:not(:disabled):not(.disabled):hover .nf-md-arrow_left {
        transform: translateX(-3px);
    }

    .btn:not(:disabled):not(.disabled):hover .nf-md-cogs {
        transform: rotate(60deg);
    }

    .btn:not(:disabled):not(.disabled):hover :is(.nf-md-download, .nf-md-download_multiple, .nf-md-tray_arrow_up) {
        animation: joy-bounce 0.5s ease;
    }

    .btn:not(:disabled):not(.disabled):hover :is(.nf-md-lock_open_variant_outline, .nf-md-cart_outline) {
        animation: joy-wiggle 0.45s ease;
    }
}

/* Drop zone while a file is dragged over it: a marching edge in sky ink.
   js/portal-motion.js sets data-sd-dragover on the Hx drop zone. */
.hx-input-file-drop-zone[data-sd-dragover] {
    border-color: transparent !important;
}

.hx-input-file-drop-zone[data-sd-dragover]::after {
    position: absolute;
    inset: 0;
    z-index: 3;
    content: "";
    border-radius: inherit;
    background-image: linear-gradient(90deg, var(--sd-sky-ink, #2f5f9e) 50%, transparent 0),
                      linear-gradient(90deg, var(--sd-sky-ink, #2f5f9e) 50%, transparent 0),
                      linear-gradient(0deg, var(--sd-sky-ink, #2f5f9e) 50%, transparent 0),
                      linear-gradient(0deg, var(--sd-sky-ink, #2f5f9e) 50%, transparent 0);
    background-position: 0 0, 0 100%, 0 0, 100% 0;
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    background-size: 14px 2px, 14px 2px, 2px 14px, 2px 14px;
    pointer-events: none;
    animation: sd-ants 0.7s linear infinite;
}

/* Windows "Animationseffekte" off makes browsers report reduced motion.
   Keep short fades and colour changes so that state changes stay readable. Remove every movement:
   no slide, scale, rotation, drawing, bounce, wiggle, pulse, loop or confetti. Component files only add
   opt-in fades (with !important to pass the rule below) and reset hover transforms. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition-property: color, background-color, border-color, outline-color, text-decoration-color,
                             fill, stroke, opacity, box-shadow !important;
        scroll-behavior: auto !important;
    }

    html.sd-page-enter .fluxforge-shell__page,
    .dropdown-menu.show,
    .toast.show {
        animation: sd-fade 0.2s ease backwards !important;
    }

    /* Bootstrap turns its fades off under reduced motion. Keep them as short opacity fades. */
    .fade {
        transition: opacity 0.15s linear;
    }

    .modal.fade .modal-dialog,
    .btn:hover .nf,
    .btn:hover .hx-icon,
    .btn:not(.btn-link):active,
    .btn:hover,
    .form-check-input:hover,
    .modal-header .btn-close:hover {
        transform: none !important;
    }
}
