/*
 * File: main.css
 * Main responsibility: Part of the CNC Wizard Stepper.
 * Related files: See others in this project.
 * TODO: Extend documentation.
 */

/* Global imports */
@import url('../settings/_variables.css');
@import url('../generic/reset.css');
@import url('../elements/_typography.css');
@import url('./_common.css');
@import url('./_button.css');
@import url('./_slider.css');
@import url('./_fresa-card.css');
@import url('./_stepper-error.css');
@import url('./_step6.css');
@import url('./_bottom_sheet.css');
@import url('./_wizard_mobile_filterbar.css');
@import url('./_onboarding-tutorial.css');

html,
body {
  min-height: 100vh;
  background-color: var(--bg-body);
  background: var(--app-surface-background, var(--bg-body));
}


:root {
  --wizard-floating-panel-padding-inline: 1rem;
  --wizard-floating-panel-padding-block: 0.875rem;
  --wizard-floating-panel-section-gap: 0.75rem;
  --wizard-slider-inline-padding: 0.25rem;
  --wizard-layer-shell: 1;
  --wizard-layer-step-content: 2;
  --wizard-layer-transition-mask: 30;
  --wizard-layer-loader: 40;
  --wizard-layer-overlay: 2200;
  --wizard-layer-overlay-backdrop: 2190;
}

@media (max-width: 575.98px) {
  :root {
    --wizard-floating-panel-padding-inline: 0.875rem;
    --wizard-floating-panel-padding-block: 0.75rem;
    --wizard-floating-panel-section-gap: 0.625rem;
    --wizard-slider-inline-padding: 0.125rem;
  }
}

body {
  display: flex;
  flex-direction: column;

  /* leave space for the fixed stepper */
  padding-top: 3.5rem;
}

.wizard-surface {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.wizard-surface__glow {
  position: absolute;
  width: 40rem;
  height: 40rem;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.55;
}

.wizard-surface__glow--primary {
  top: -10rem;
  left: -12rem;
  background: radial-gradient(circle, rgba(79, 195, 247, 0.7), transparent 70%);
}

.wizard-surface__glow--secondary {
  bottom: -14rem;
  right: -18rem;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.5), transparent 75%);
}

.wizard-surface__grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--app-surface-grid-color, rgba(148, 163, 184, 0.06)) 1px, transparent 1px),
    linear-gradient(90deg, var(--app-surface-grid-color, rgba(148, 163, 184, 0.06)) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.4;
}

.wizard-body {
  flex: 1 0 auto;
  padding: 0;
}

/*
 * When each step is injected into #step-content it brings its own <main class="container">.
 * We expand that shell so the visible program matches the visual width of the stepper header
 * without having to touch the stepper itself.
 */
/* Smooth fade + directional slide transition for step content */
#step-content {
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-standard),
    transform var(--dur-4) var(--ease-standard);
  position: relative;
  overflow: visible;
  transform: none;
  isolation: isolate;
  z-index: var(--wizard-layer-step-content);
  min-height: clamp(18rem, 42vh, 42rem);
}

.stepper-initial-loader-host {
  position: relative;
  z-index: 1;
}

#step-transition-layer {
  will-change: transform;
  transition: transform var(--dur-4) var(--ease-standard);
  position: relative;
  z-index: var(--wizard-layer-step-content);
  min-height: inherit;
}

#step-content[data-transition-direction="forward"] #step-transition-layer {
  transform: translateX(var(--space-5));
}

#step-content[data-transition-direction="backward"] #step-transition-layer {
  transform: translateX(calc(-1 * var(--space-5)));
}

#step-content.show {
  opacity: 1;
}

#step-content.is-transitioning {
  overflow: clip;
  min-height: max(var(--wizard-frozen-shell-height, 0px), clamp(18rem, 42vh, 42rem));
}

#step-content.is-transitioning::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-card, #161b22) 58%, transparent),
    color-mix(in srgb, var(--bg-card, #161b22) 74%, transparent)
  );
  z-index: var(--wizard-layer-transition-mask);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s ease;
}

#step-content.is-transitioning #step-transition-layer {
  opacity: 0.3;
  filter: saturate(0.9) blur(1px);
  transition: opacity 0.18s ease;
}

#step-content.show #step-transition-layer {
  transform: none;
}

.stepper-header.is-transition-frozen {
  min-height: var(--wizard-frozen-header-height, auto);
  contain: layout paint;
}

.stepper-header.is-transition-frozen,
.stepper-header.is-transition-frozen * {
  transition: none !important;
  animation: none !important;
}

body.wizard-step-transitioning .stepper-header {
  transform: translateZ(0);
}

body.wizard-step-transitioning .stepper-loading-overlay {
  z-index: var(--wizard-layer-loader);
}

body.modal-open #step-content.is-transitioning::before,
body.modal-open .stepper-loading-overlay.is-visible {
  opacity: 0;
  pointer-events: none;
}

#sessionExpiredNotice,
#resetWizardModal,
#wizardAlertModal,
#idleWarningModal,
.modal-backdrop {
  isolation: isolate;
}

#sessionExpiredNotice {
  z-index: calc(var(--wizard-layer-overlay) + 10);
}

#resetWizardModal,
#wizardAlertModal,
#idleWarningModal {
  z-index: var(--wizard-layer-overlay);
}

.modal-backdrop.show {
  z-index: var(--wizard-layer-overlay-backdrop);
}

@media (prefers-reduced-motion: reduce) {
  #step-content {
    transition: opacity var(--dur-2) linear;
    transform: none !important;
  }

  #step-transition-layer {
    transition: none;
    transform: none !important;
  }

  #step-content.show {
    transform: none !important;
  }
}

.stepper-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3, 1rem);
  min-height: clamp(12.5rem, 40vh, 26rem);
  padding: var(--space-5, 2rem) var(--space-4, 1.5rem);
  text-align: center;
  color: var(--text-muted, rgba(255, 255, 255, 0.72));
}

.stepper-loader__spinner {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 0.35rem solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--step6-accent, #38bdf8);
  animation: stepper-loader-spin 1s linear infinite;
}

.stepper-loader__skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(20rem, 100%);
}

.stepper-skeleton-line {
  display: block;
  height: 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.stepper-skeleton-line--wide {
  width: 100%;
}

.stepper-skeleton-line--short {
  width: 60%;
  align-self: center;
}

.stepper-loader__text {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.82;
}

@keyframes stepper-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Sticky base styles for Step 6 panels (loaded globally for SPA navigation)
   -------------------------------------------------------------------------- */
#panelAjustes {
  position: sticky;
  top: calc(var(--stepper-sticky-offset, var(--stepper-header-offset, 0px)) + var(--space-2, 0.5rem));
  z-index: var(--stepper-sticky-z, 10);
}

.step6-sticky-controls {
  position: sticky;
  top: calc(var(--stepper-sticky-offset, var(--stepper-header-offset, 0px)) + var(--space-2, 0.5rem));
  z-index: var(--stepper-sticky-z, 10);
}
