/**
 * Animate Wizard - 2-step modal for animating a created image.
 *
 * Mounted by static/js/create/animate-wizard/open.js into document.body
 * as div.animate-wizard-root (backdrop) containing div.animate-wizard-modal.
 */

/* ===== Backdrop ===== */
.animate-wizard-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Top padding clears Telegram WebApp native header (× Close + balance badge).
     TG overlay is ~80-100px on iOS/Android depending on notch + status bar. */
  padding: calc(env(safe-area-inset-top, 0px) + 96px) 16px 16px 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: animateWizardFadeIn 0.2s ease-out;
  overflow-y: auto;
}

@keyframes animateWizardFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== Modal container ===== */
.animate-wizard-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 20px 20px 24px;
  color: var(--text-primary);
  animation: animateWizardScaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - 112px);
  overflow-y: auto;
  box-sizing: border-box;
}

@keyframes animateWizardScaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* ===== Header ===== */
.animate-wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.animate-wizard-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.animate-wizard-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.animate-wizard-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.animate-wizard-close:active {
  transform: rotate(90deg) scale(0.9);
}

/* ===== Preview image ===== */
.animate-wizard-preview-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.animate-wizard-preview {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(106, 106, 255, 0.3);
  box-shadow: 0 8px 24px rgba(106, 106, 255, 0.15);
  transition: width 0.25s, height 0.25s;
}

.animate-wizard-preview.small {
  width: 80px;
  height: 80px;
  border-radius: 12px;
}

/* ===== Info lines ===== */
.animate-wizard-info {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 14px;
}

.animate-wizard-info.success {
  color: #7fd97f;
}

.animate-wizard-summary {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.animate-wizard-summary span {
  white-space: nowrap;
}

.animate-wizard-summary b {
  color: var(--text-primary);
  font-weight: 600;
}

.animate-wizard-label {
  text-align: center;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== Duration buttons ===== */
.animate-wizard-duration-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.animate-wizard-duration-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.animate-wizard-duration-btn:hover {
  background: linear-gradient(135deg, rgba(106, 106, 255, 0.2), rgba(74, 74, 170, 0.15));
  border-color: rgba(106, 106, 255, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(106, 106, 255, 0.25);
}

.animate-wizard-duration-btn:active {
  transform: translateY(0) scale(0.98);
}

.animate-wizard-duration-btn .emo {
  font-size: 20px;
  line-height: 1;
}

/* ===== Step 2 actions ===== */
.animate-wizard-prompt-hint {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
  text-align: center;
}

.animate-wizard-textarea {
  width: 100%;
  min-height: 90px;
  max-height: 180px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.animate-wizard-textarea::placeholder {
  color: var(--text-muted);
}

.animate-wizard-textarea:focus {
  border-color: rgba(106, 106, 255, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.animate-wizard-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.animate-wizard-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  -webkit-tap-highlight-color: transparent;
}

.animate-wizard-btn-primary {
  background: linear-gradient(135deg, #6a6aff, #4a4aaa);
  color: #fff;
  box-shadow: 0 4px 16px rgba(106, 106, 255, 0.3);
}

.animate-wizard-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(106, 106, 255, 0.45);
}

.animate-wizard-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.animate-wizard-btn-primary[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.animate-wizard-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.animate-wizard-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.animate-wizard-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
}

.animate-wizard-btn-ghost:hover {
  color: var(--text-primary);
}

.animate-wizard-btn.hidden {
  display: none;
}

/* ===== Loading state ===== */
.animate-wizard-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.animate-wizard-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(106, 106, 255, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: animateWizardSpin 0.8s linear infinite;
}

@keyframes animateWizardSpin {
  to { transform: rotate(360deg); }
}

/* ===== Pending card (inline notification after submit) ===== */
.animate-pending-card {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 9500;
  width: calc(100% - 32px);
  max-width: 420px;
  background: linear-gradient(135deg, rgba(35, 35, 71, 0.98), rgba(26, 26, 46, 0.98));
  border: 1px solid rgba(106, 106, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35),
              0 0 24px rgba(106, 106, 255, 0.18);
  padding: 16px 18px 14px;
  color: var(--text-primary);
  animation: animatePendingCardIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

@keyframes animatePendingCardIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.animate-pending-card.hiding {
  animation: animatePendingCardOut 0.25s ease-in forwards;
}

@keyframes animatePendingCardOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, 20px); }
}

.animate-pending-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.animate-pending-body {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.animate-pending-ok {
  display: block;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #6a6aff, #4a4aaa);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}

.animate-pending-ok:active {
  transform: scale(0.97);
}

/* ===== Mobile: full-screen modal ===== */
@media (max-width: 480px) {
  .animate-wizard-root {
    padding: 0;
    align-items: stretch;
  }

  .animate-wizard-modal {
    max-width: 100%;
    border-radius: 0;
    max-height: 100vh;
    min-height: 100vh;
    padding: 16px 16px 20px;
    padding-top: calc(16px + var(--tg-safe-area-inset-top, 0px));
    padding-bottom: calc(20px + var(--tg-safe-area-inset-bottom, 0px));
  }

  .animate-wizard-preview {
    width: 120px;
    height: 120px;
  }
}

/* ===== Body scroll lock helper ===== */
body.animate-wizard-open {
  overflow: hidden;
}
