/* Design tokens — dark-only, aligned with ATM / redesign polish */
:root,
html[data-theme="dark"] {
    color-scheme: dark;

    --background: #0b1018;
    --foreground: #f4f6f8;
    --card: #121a24;
    --card-foreground: #f4f6f8;
    --primary: #badfef;
    --primary-foreground: #16212f;
    --muted: #1a2433;
    --muted-foreground: #8ba3b8;
    --border: color-mix(in oklab, #3a5168 50%, transparent);
    --secondary: #1e2a3a;
    --secondary-foreground: #f4f6f8;
    --accent: #243044;
    --accent-foreground: #d4e8f4;
    --destructive: #ff6467;
    --destructive-foreground: #0a0a0a;
    --ring: #91c5ff;
    --input: color-mix(in oklab, #1e3248 70%, transparent);
    --radius-card: 0.75rem;
    --success: #4ade80;
    --warning: #fbbf24;
    --star: #e8b84a;
    --discord: #5865f2;
    --discord-foreground: #f4f6f8;
    --sidebar: #0e1520;
    --sidebar-accent: #1a2433;
    --sidebar-foreground: #f4f6f8;

    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.5);
    --shadow-card-hover: 0 2px 4px rgb(0 0 0 / 0.35), 0 16px 40px -16px rgb(0 0 0 / 0.6);
    --shadow-glow: 0 0 0 1px color-mix(in oklab, var(--primary) 15%, transparent),
        0 12px 32px -12px color-mix(in oklab, var(--primary) 40%, transparent);

    --motion-duration-fast: 150ms;
    --motion-duration: 200ms;
    --motion-duration-slow: 280ms;
    --motion-ease: cubic-bezier(0.22, 1, 0.36, 1);

    /* Bootstrap bridge */
    --bs-body-bg: var(--background);
    --bs-body-color: var(--foreground);
    --bs-body-font-family: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
    --bs-border-color: var(--border);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: color-mix(in oklab, var(--primary) 80%, white);
    --bs-primary: var(--primary);
    --bs-primary-rgb: 186, 223, 239;
    --bs-secondary: #5f8cb6;
    --bs-secondary-rgb: 95, 140, 182;
    --bs-danger: var(--destructive);
    --bs-danger-rgb: 255, 100, 103;
    --bs-focus-ring-color: color-mix(in oklab, var(--ring) 40%, transparent);
}

html {
    --font-inter: "Inter", ui-sans-serif, system-ui, sans-serif;
}

.skip-to-content {
    position: absolute;
    left: 1rem;
    top: 0;
    z-index: 1000;
    transform: translateY(-120%);
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-foreground);
    text-decoration: none;
    transition: transform var(--motion-duration-fast) var(--motion-ease);
}

.skip-to-content:focus {
    transform: translateY(0.75rem);
    outline: none;
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

.invoice-checkout-form__csrf-error {
    margin: 0 0 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--destructive);
    background: color-mix(in oklab, var(--destructive) 12%, transparent);
    border: 1px solid color-mix(in oklab, var(--destructive) 28%, transparent);
}

.invoice-checkout-form__csrf-error[hidden] {
    display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

html,
body {
    font-family: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
}

body {
    margin: 0;
    min-height: 100dvh;
}

a,
.btn-link {
    color: var(--primary);
}

a:hover,
.btn-link:hover {
    color: color-mix(in oklab, var(--primary) 80%, white);
}

.btn-primary {
    --bs-btn-color: var(--primary-foreground);
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-color: var(--primary-foreground);
    --bs-btn-hover-bg: color-mix(in oklab, var(--primary) 90%, transparent);
    --bs-btn-hover-border-color: color-mix(in oklab, var(--primary) 90%, transparent);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-active-color: var(--primary-foreground);
    --bs-btn-active-bg: color-mix(in oklab, var(--primary) 80%, var(--foreground));
    --bs-btn-active-border-color: color-mix(in oklab, var(--primary) 80%, var(--foreground));
    box-shadow: var(--shadow-glow);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--background), 0 0 0 0.25rem var(--ring);
}

.form-control,
.form-select {
    background-color: var(--input);
    border-color: var(--border);
    color: var(--foreground);
}

.form-control::placeholder {
    color: var(--muted-foreground);
}

.card {
    --bs-card-bg: color-mix(in oklab, var(--card) 85%, transparent);
    --bs-card-border-color: color-mix(in oklab, var(--border) 80%, transparent);
    --bs-card-color: var(--card-foreground);
}

/* Optional section grid (unused on storefront pages by default) */
.atm-grid-bg {
    background-image:
        linear-gradient(to right, rgb(120 150 180 / 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgb(120 150 180 / 0.05) 1px, transparent 1px);
    background-size: 56px 56px;
}

.atm-hero-gradient {
    background: linear-gradient(
        to bottom right,
        var(--background),
        var(--background),
        var(--card)
    );
}

/* Inner customer routes — one shared grid layer (do not also put .atm-grid-bg on sections) */
.atm-customer-page {
    position: relative;
    isolation: isolate;
    display: flex;
    width: 100%;
    flex: 1;
    flex-direction: column;
    min-height: 100%;
    background-color: var(--background);
}

.atm-customer-page__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

main:has(.atm-customer-page) {
    display: flex;
    flex-direction: column;
    background-color: var(--background);
}

.atm-customer-page-backdrop {
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: var(--background);
    background-image:
        linear-gradient(to right, rgb(120 150 180 / 0.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgb(120 150 180 / 0.045) 1px, transparent 1px);
    background-size: 56px 56px;
    background-position: 0 0;
}

.atm-panel-elevated {
    border-radius: var(--radius-card);
    border: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
    background: var(--card);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(4px);
    transition:
        transform var(--motion-duration) var(--motion-ease),
        border-color var(--motion-duration) var(--motion-ease),
        box-shadow var(--motion-duration) var(--motion-ease);
}

.atm-panel-elevated:hover {
    border-color: color-mix(in oklab, var(--primary) 40%, transparent);
    box-shadow: var(--shadow-card-hover);
}

/* Scroll reveal — armed by atmStoreUi.observeReveals (visible until then) */
.atm-reveal {
    transition:
        opacity var(--motion-duration-slow) var(--motion-ease),
        transform var(--motion-duration-slow) var(--motion-ease);
}

.atm-reveal.atm-reveal--pending:not(.is-visible) {
    opacity: 0;
    transform: translateY(8px);
}

.atm-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.atm-reveal.is-visible .atm-reveal-stagger > *:nth-child(1) { transition-delay: 0ms; }
.atm-reveal.is-visible .atm-reveal-stagger > *:nth-child(2) { transition-delay: 40ms; }
.atm-reveal.is-visible .atm-reveal-stagger > *:nth-child(3) { transition-delay: 60ms; }

.atm-content-fade-in {
    animation: atm-content-fade-in var(--motion-duration-slow) var(--motion-ease);
}

@keyframes atm-content-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.atm-panel-elevated-inner {
    border-radius: calc(var(--radius-card) - 2px);
    border: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
    background: color-mix(in oklab, var(--muted) 40%, transparent);
    backdrop-filter: blur(4px);
}

/* Admin routes only: flat background (no top glow) */
.atm-admin-shell {
    background: var(--background);
}

.atm-admin-shell-main {
    max-width: 72rem;
}

/* Product gallery: main image swap + lightbox */
@keyframes atm-product-gallery-fade-in {
    from {
        opacity: 0;
        transform: scale(0.985);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.atm-product-gallery-main-img {
    animation: atm-product-gallery-fade-in var(--motion-duration-slow) var(--motion-ease);
}

@keyframes atm-product-gallery-thumb-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.atm-product-gallery-thumb-animate {
    animation: atm-product-gallery-thumb-in var(--motion-duration-slow) var(--motion-ease) backwards;
}

@keyframes atm-product-lightbox-reveal {
    from {
        opacity: 0;
        transform: scale(0.97);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.atm-product-lightbox-overlay .atm-product-lightbox-content {
    animation: atm-product-lightbox-reveal var(--motion-duration-slow) var(--motion-ease);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.atm-page-transition__content {
    animation: atm-page-enter var(--motion-duration-slow) var(--motion-ease);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .atm-product-gallery-main-img,
    .atm-product-gallery-thumb-animate,
    .atm-product-lightbox-overlay .atm-product-lightbox-content,
    .atm-page-transition__content,
    .atm-content-fade-in {
        animation: none;
    }

    .atm-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .atm-reveal.atm-reveal--pending:not(.is-visible) {
        opacity: 1;
        transform: none;
    }

    .atm-panel-elevated {
        transition: none;
    }

    .atm-panel-elevated:hover {
        transform: none;
    }
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid var(--destructive);
}

.validation-message {
    color: var(--destructive);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYg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zLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--destructive);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.darker-border-checkbox.form-check-input {
    border-color: var(--border);
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--muted-foreground);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.app-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    background: var(--background);
    color: var(--muted-foreground);
    font-size: 0.9375rem;
    font-weight: 500;
}

/* Listing disclaimer */
.store-disclaimer {
    box-sizing: border-box;
    display: block;
    border-radius: 0.75rem;
    border: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
    background: color-mix(in oklab, var(--muted) 35%, var(--card));
    overflow: hidden;
}

.store-disclaimer__inner {
    box-sizing: border-box;
    padding: 1.5rem 1.75rem !important;
}

.store-disclaimer__lead,
.store-disclaimer__paragraph {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.625;
    color: var(--muted-foreground);
}

.store-disclaimer__paragraph {
    margin-top: 0.75rem;
}

@media (min-width: 640px) {
    .store-disclaimer__inner {
        padding: 1.75rem 2rem !important;
    }

    .store-disclaimer__lead,
    .store-disclaimer__paragraph {
        font-size: 0.875rem;
    }
}
