/* Create screen — 4-step wizard.
   Bottom button bar from the old layout is no longer used; the flow is
   driven by per-step next/back controls inside each .wizard-step. */

/* Full-screen wizard container — applied only when the screen is active
   so it doesn't override .modal-screen's default display:none. */
#createScreen.active {
  position: fixed;
  inset: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header: Back | title + dots | step label */
#createScreen .wizard-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 3vw, 1.5rem);
}

#createScreen .modal-close-button {
  position: static;
  transform: none;
}

#createScreen .modal-header-center {
  text-align: center;
  min-width: 0;
}

#createScreen .modal-title {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  margin: 0 0 0.35rem;
}

.wizard-progress {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
}

.wizard-progress .wizard-dot {
  width: 28px;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  transition: background 0.2s ease, width 0.2s ease;
}

.wizard-progress .wizard-dot.done {
  background: var(--brand-strong);
}

.wizard-progress .wizard-dot.current {
  background: var(--brand);
  width: 40px;
}

.wizard-step-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Wizard body — fills the remaining viewport height. */
.wizard {
  flex: 1;
  min-height: 0;
  display: flex;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.wizard-step {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  width: 100%;
  padding: clamp(1rem, 2vw, 1.5rem) clamp(1rem, 3vw, 2rem);
  box-sizing: border-box;
  overflow: hidden;
  animation: wizardFade 0.25s ease;
}

.wizard-step.active {
  display: flex;
}

@keyframes wizardFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wizard-step-head {
  flex: 0 0 auto;
  margin-bottom: 0.25rem;
  text-align: center;
}

.wizard-step-head h2 {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}

.wizard-step-head p {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.55;
}

/* --- Step 1: Camera (full-bleed with overlayed capture button) ------ */
.wizard-step[data-step="1"] {
  padding: 0;
  gap: 0;
  position: relative;
}

.wizard-step[data-step="1"] .wizard-step-head {
  display: none;
}

.wizard-step[data-step="1"] .create-status {
  position: absolute;
  top: clamp(0.5rem, 1.5vw, 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.4rem 0.9rem;
  background: rgba(20, 16, 11, 0.78);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

.wizard-step[data-step="1"] .create-camera-box {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.wizard-step[data-step="1"] .wizard-actions {
  position: absolute;
  bottom: clamp(1rem, 3vh, 2.25rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  margin: 0;
  padding: 0;
}

/* Fallback styling for .create-status elsewhere (not overlayed) */
.create-status {
  padding: 0.6rem 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 500;
}

.create-camera-box,
.wizard-camera-box {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

#createVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.create-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  pointer-events: none;
  z-index: 10;
}

.create-cell {
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.create-golden {
  border: 2px solid #FFD180;
  background: rgba(255, 209, 128, 0.12);
  box-shadow: inset 0 0 12px rgba(255, 209, 128, 0.26);
}

/* --- Step 2: Save or Scratch --------------------------------------- */
.create-results {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-content: flex-start;
  justify-content: center;
  padding: 1rem;
  min-height: 0;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.create-result-img {
  width: clamp(80px, 15vw, 120px);
  height: clamp(60px, 11vw, 90px);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.create-result-img:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}

/* Hide any dynamically-injected Save button inside #createResults — the
   wizard now supplies its own Save-to-Library button. */
#createResults > button {
  display: none !important;
}

/* --- Step 3: Animation preview ------------------------------------- */
.create-animation-box {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-animation-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.create-animation-overlay {
  position: absolute;
  inset: 0;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text-soft);
  font-size: 0.9rem;
  text-align: center;
}

.create-animation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.create-animation-controls button {
  min-width: 80px;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.create-animation-controls button:hover:not(:disabled) {
  background: rgba(255, 140, 0, 0.18);
  color: #ffffff;
  border-color: rgba(255, 140, 0, 0.5);
}

.create-animation-controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.create-animation-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-soft);
  font-size: 0.85rem;
  font-weight: 500;
}

.create-animation-controls input[type="range"] {
  width: clamp(120px, 22vw, 180px);
  accent-color: var(--brand);
}

/* --- Step 4: Exit choices ------------------------------------------ */
.wizard-exit {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-content: center;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.wizard-exit-btn {
  padding: 1.5rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.wizard-exit-btn:hover {
  background: var(--bg-elev-2);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.wizard-exit-btn-primary {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.wizard-exit-btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

/* --- Shared wizard-action buttons ---------------------------------- */
.wizard-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: auto;
  padding-top: 0.75rem;
}

.wizard-actions-split {
  justify-content: space-between;
}

.wizard-next,
.wizard-back,
.wizard-secondary,
.wizard-tertiary,
.wizard-primary {
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* Primary step-forward button */
.wizard-next {
  background: var(--brand);
  color: #ffffff;
  border: 1px solid var(--brand);
}

.wizard-next:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

/* Back step button — neutral outline */
.wizard-back,
.wizard-secondary,
.wizard-tertiary {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--hairline-strong);
}

.wizard-back:hover,
.wizard-secondary:hover,
.wizard-tertiary:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: rgba(255, 140, 0, 0.45);
}

/* Inline primary (e.g. Save to Library) — orange solid */
.wizard-primary {
  background: var(--brand);
  color: #ffffff;
  border: 1px solid var(--brand);
}

.wizard-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

/* Capture button — floating primary action overlayed on the live camera */
.create-capture-btn {
  padding: 0.9rem 2rem;
  background: var(--brand);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.create-capture-btn:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: #ffffff;
  transform: translateY(-2px);
}

.create-capture-btn:active:not(:disabled) {
  transform: translateY(0);
}

.create-capture-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* "Scratch" button reuses .create-clear-btn ID but now sits inline in step 2 */
.create-clear-btn {
  display: inline-block !important;
  padding: 0.65rem 1.4rem;
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.create-clear-btn:hover {
  background: rgba(255, 140, 0, 0.12);
  color: #ffffff;
  border-color: rgba(255, 140, 0, 0.5);
}

/* Mobile polish */
@media (max-width: 600px) {
  #createScreen .wizard-header {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.5rem;
  }
  .wizard-step-label {
    grid-column: 1 / -1;
    text-align: center;
  }
  .wizard-actions-split {
    flex-direction: column;
    align-items: stretch;
  }
}
