/* ── Base: 1080×1920 세로형 모바일 ───────────────────────────── */
:root {
  --canvas-w: 1080;
  --canvas-h: 1920;
  --color-primary: #0055a5;
  --color-primary-dark: #003d78;
  --color-accent: #ffd100;
  --color-text: #ffffff;
  --color-overlay: rgba(0, 0, 0, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: #1a1a2e;
}

/* ── Step layout ─────────────────────────────────────────────── */
.step {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.step--active { display: flex; }

.step-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(160deg, #0d1b3e 0%, #1a3a6b 50%, #0d2847 100%);
}

.step-bg__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.step-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 16px) 20px calc(var(--safe-bottom) + 24px);
}

/* ── 1. 시작 페이지 ─────────────────────────────────────────── */
.step-content--start {
  justify-content: flex-end;
  padding-bottom: calc(var(--safe-bottom) + 48px);
}

/* ── 2. 미리보기 ─────────────────────────────────────────────── */
.step-content--preview {
  justify-content: center;
  gap: 24px;
  background: #0f0f1a;
}

#btn-transform {
  transform: translateY(-20vh);
}

#btn-transform:active {
  transform: translateY(-20vh) scale(0.97);
}

#btn-transform:disabled {
  transform: translateY(-20vh);
}

.preview-frame {
  width: 100%;
  flex: 1;
  max-height: calc(100% - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  aspect-ratio: 1080 / 1920;
}

/* ── 3. 결과 페이지 ─────────────────────────────────────────── */
.step-content--result {
  justify-content: flex-end;
  gap: 16px;
  padding-bottom: calc(var(--safe-bottom) + 32px);
}

.result-composite {
  position: relative;
  width: 100%;
  aspect-ratio: 1080 / 1920;
  max-height: calc(100% - 120px);
  overflow: hidden;
  border-radius: 8px;
}

.result-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.result-layer--photo {
  object-fit: contain;
  z-index: 1;
}

.result-layer--frame {
  z-index: 2;
  object-fit: fill;
}

.result-layer--bg {
  z-index: 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  max-width: 320px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: var(--color-accent);
  color: #1a1a1a;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 209, 0, 0.35);
  transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  width: 100%;
  max-width: 320px;
  padding: 12px 24px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:active { opacity: 0.7; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] { display: none !important; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 28px 24px calc(var(--safe-bottom) + 28px);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
}

.modal__desc {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 20px;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-modal {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-modal--outline {
  background: #fff;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-modal--ghost {
  background: transparent;
  color: #888;
  font-weight: 500;
}

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] { display: none !important; }

.loading-overlay__box {
  text-align: center;
  color: #fff;
  padding: 32px;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.7);
}

/* ── 이미지 미등록 시 placeholder ─────────────────────────────── */
img[src=""], img:not([src]) {
  opacity: 0;
}
