/* =========================================================
   Zbraz3D — site-wide base rules
   ========================================================= */

/* ----- Interface is not selectable or draggable ----- */
img,
svg,
a,
button,
label,
nav,
summary,
select,
canvas,
[role='tab'],
[role='button'],
[role='radio'],
[role='switch'],
[role='option'],
.badge {
    -webkit-user-select: none;
    user-select: none;
}

img,
a {
    -webkit-user-drag: none;
}

input,
textarea,
[contenteditable='true'],
.select-text {
    -webkit-user-select: text;
    user-select: text;
}

/* ----- Scrollbars ----- */
html {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--accent) / 0.45) hsl(var(--background));
}

* {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--accent) / 0.35) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--background));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--accent) / 0.35);
    border: 2px solid hsl(var(--background));
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--accent) / 0.6);
}

.dark ::-webkit-scrollbar-track {
    background: hsl(var(--background));
}

.no-scrollbar {
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ----- Scroll reveal (hidden state is only added by script) ----- */
.reveal-init {
    opacity: 0;
    transform: translateY(18px);
}

.reveal-in {
    opacity: 1;
    transform: none;
    transition:
        opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1),
        transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: var(--reveal-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
    .reveal-init,
    .reveal-in {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ----- Hero build-plate floor ----- */
.hero-floor {
    position: absolute;
    left: -30%;
    right: -30%;
    bottom: -6%;
    height: 68%;
    background-image:
        linear-gradient(hsl(var(--accent) / 0.2) 1px, transparent 1px),
        linear-gradient(90deg, hsl(var(--accent) / 0.2) 1px, transparent 1px);
    background-size: 64px 64px;
    transform: perspective(720px) rotateX(64deg);
    transform-origin: 50% 100%;
    -webkit-mask-image: linear-gradient(to top, #000 10%, transparent 85%);
    mask-image: linear-gradient(to top, #000 10%, transparent 85%);
    animation: floor-drift 16s linear infinite;
    pointer-events: none;
}

@keyframes floor-drift {
    to {
        background-position:
            0 64px,
            0 0;
    }
}

.glow-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(80px);
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .hero-floor {
        animation: none;
    }
}

/* ----- Range sliders ----- */
.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: pointer;
}

.range:focus {
    outline: none;
}

.range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(
        to right,
        hsl(var(--accent)) 0 var(--fill, 50%),
        hsl(var(--muted-foreground) / 0.22) var(--fill, 50%) 100%
    );
}

.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border-radius: 999px;
    background: hsl(var(--foreground));
    border: 4px solid hsl(var(--primary));
    box-shadow: 0 0 0 4px hsl(var(--accent) / 0.2);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.range:active::-webkit-slider-thumb {
    transform: scale(1.12);
}

.range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 5px hsl(var(--accent) / 0.55);
}

.range::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: hsl(var(--muted-foreground) / 0.22);
}

.range::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: hsl(var(--accent));
}

.range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: hsl(var(--foreground));
    border: 4px solid hsl(var(--primary));
    box-shadow: 0 0 0 4px hsl(var(--accent) / 0.2);
}

.range:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 5px hsl(var(--accent) / 0.55);
}

.range:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ----- Number fields without browser spinners ----- */
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type='number'] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ----- Switch ----- */
.switch {
    -webkit-appearance: none;
    appearance: none;
    flex: none;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: hsl(var(--muted-foreground) / 0.28)
        radial-gradient(circle at center, hsl(var(--foreground)) 0 7px, transparent 7.5px)
        no-repeat;
    background-size: 22px 22px;
    background-position: 0 0;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        background-position 0.2s ease;
}

.switch:checked {
    background-color: hsl(var(--primary));
    background-position: 18px 0;
}

.switch:focus-visible {
    outline: 2px solid hsl(var(--accent));
    outline-offset: 2px;
}

.switch:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ----- Checkbox ----- */
.check {
    -webkit-appearance: none;
    appearance: none;
    flex: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid hsl(var(--border));
    border-radius: 6px;
    background: hsl(var(--muted));
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.check:checked {
    border-color: hsl(var(--primary));
    background: hsl(var(--primary))
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E")
        center / 12px no-repeat;
}

.check:focus-visible {
    outline: 2px solid hsl(var(--accent));
    outline-offset: 2px;
}

/* ----- Spinner used in buttons ----- */
.spin {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ----- Loading bars: a soft light keeps sweeping across, so a long step never looks frozen.
   The bar itself sets its own position and overflow. ----- */
.load-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, hsl(var(--foreground) / 0.42), transparent);
    transform: translateX(-100%);
    animation: load-sweep 1.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes load-sweep {
    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .load-fill::after {
        animation: none;
        opacity: 0;
    }
}

/* ----- Workspace viewport ----- */
.viewport-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
    outline: none;
}

.viewport-vignette {
    background:
        radial-gradient(120% 80% at 50% 110%, hsl(var(--primary) / 0.22), transparent 60%),
        radial-gradient(80% 60% at 50% -20%, hsl(var(--accent) / 0.08), transparent 70%);
    pointer-events: none;
}

.stripe-bg {
    background-image: repeating-linear-gradient(
        135deg,
        hsl(var(--accent) / 0.08) 0 8px,
        transparent 8px 16px
    );
}

/* ----- Header: on the Workspace it spans the whole screen, logo far left, links in the
   middle, account and Open the tool far right ----- */
[data-variant='wide'] > .header-bar {
    max-width: none;
}

/* ----- Small hover labels for icon buttons ----- */
[data-tip] {
    position: relative;
}

[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    z-index: 60;
    transform: translate(-50%, -4px);
    padding: 4px 8px;
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    font: 600 11px/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 10px 24px -12px hsl(var(--background) / 0.9);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

[data-tip][data-tip-pos='top']::after {
    top: auto;
    bottom: calc(100% + 8px);
    transform: translate(-50%, 4px);
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (hover: none) {
    [data-tip]::after {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-tip]::after {
        transition: none;
    }
}

/* ----- Home hero: faint grid behind the headline ----- */
.hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(hsl(var(--foreground) / 0.05) 1px, transparent 1px),
        linear-gradient(90deg, hsl(var(--foreground) / 0.05) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 75% 65% at 35% 30%, #000 25%, transparent 78%);
    mask-image: radial-gradient(ellipse 75% 65% at 35% 30%, #000 25%, transparent 78%);
    pointer-events: none;
}

/* ----- Home demo: the live pawn animation ----- */
.demo-stage {
    background:
        radial-gradient(60% 42% at 50% 92%, hsl(var(--primary) / 0.3), transparent 72%),
        radial-gradient(80% 60% at 50% -10%, hsl(var(--accent) / 0.08), transparent 70%),
        linear-gradient(180deg, hsl(var(--card)), hsl(var(--background)));
}

.demo-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
