/* ============================================================
   Magic Garden Kiosk — Avatar Creator Styles (Step 2)
   ============================================================ */

/* ── Container ──────────────────────────────────────────── */
#avatar-creator {
  position: fixed;
  inset: 0;
  z-index: 8000;
  font-family: 'Nunito', 'Comic Sans MS', cursive, sans-serif;
  overflow: hidden;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34,1.3,0.64,1);
}
#avatar-creator.av-hidden  { opacity: 0; pointer-events: none; transform: scale(0.95); }
#avatar-creator.av-visible { opacity: 1; pointer-events: auto; transform: scale(1); }

/* ── Phase containers ────────────────────────────────────── */
.av-phase {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.35s ease;
}
.av-hidden-phase { opacity: 0; pointer-events: none; }

/* ── Shared backgrounds ──────────────────────────────────── */
.av-bg-sky {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 65%;
  background: linear-gradient(180deg, #5BB8F5 0%, #A8DCFA 60%, #C8EEFF 100%);
  z-index: 0;
}
.av-bg-ground {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 38%;
  background: linear-gradient(180deg, #8FD44D 0%, #5EAB2F 60%, #3D8B24 100%);
  border-top: 5px solid #6EC240;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════════
   PHASE A — PREVIEW
   ═══════════════════════════════════════════════════════════ */

/* Header */
.av-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px 10px;
}
.av-back-btn {
  background: rgba(255,255,255,0.88);
  border: 3px solid #4CAF50;
  border-radius: 50px;
  padding: 10px 26px;
  font-family: 'Nunito', cursive;
  font-size: clamp(14px, 1.8vw, 22px);
  font-weight: 900;
  color: #2E7D32;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 0 #388E3C;
}
.av-back-btn:hover  { transform: translateY(-2px); box-shadow: 0 6px 0 #388E3C; }
.av-back-btn:active { transform: translateY(2px);  box-shadow: 0 2px 0 #388E3C; }

.av-title-wrap {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.82);
  border-radius: 24px;
  padding: 10px 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.av-title-icon { font-size: clamp(22px, 2.5vw, 36px); }
.av-title {
  font-size: clamp(18px, 2.4vw, 34px);
  font-weight: 900;
  color: #2D4A1E;
  margin: 0;
}
.av-spacer { width: 140px; } /* match back button width */

/* Content row */
.av-content-row {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(12px, 2vw, 32px);
  padding: 0 20px 16px;
  overflow: hidden;
}

/* ── Overlay selector panel ─────────────────────────────── */
.av-selector-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: clamp(120px, 14vw, 200px);
  flex-shrink: 0;
  padding-top: 6px;
}
.av-selector-label {
  font-size: clamp(12px, 1.4vw, 18px);
  font-weight: 900;
  color: #1B5E20;
  background: rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 5px 12px;
  text-align: center;
  width: 100%;
}
.av-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.av-ov-btn {
  background: rgba(255,255,255,0.88);
  border: 3px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 8px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}
.av-ov-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ov-color);
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: inherit;
}
.av-ov-btn:hover { transform: translateY(-2px) scale(1.04); }
.av-ov-btn:hover::before { opacity: 0.12; }
.av-ov-btn.av-ov-active {
  border-color: var(--ov-color);
  box-shadow: 0 0 0 3px var(--ov-color), 0 4px 12px rgba(0,0,0,0.15);
  transform: scale(1.06);
}
.av-ov-btn.av-ov-active::before { opacity: 0.18; }
.av-ov-emoji { font-size: clamp(22px, 2.8vw, 36px); position: relative; z-index: 1; }
.av-ov-label {
  font-size: clamp(10px, 1.1vw, 14px);
  font-weight: 700;
  color: #3E2723;
  position: relative; z-index: 1;
}

/* Tips box (right panel) */
.av-right-pad { justify-content: center; padding-top: 20px; }
.av-tips-box {
  background: rgba(255,255,255,0.82);
  border-radius: 20px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  width: 100%;
}
.av-tip {
  font-size: clamp(12px, 1.4vw, 18px);
  font-weight: 700;
  color: #2E7D32;
  line-height: 1.3;
}

/* ── Viewfinder ─────────────────────────────────────────── */
.av-viewfinder-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.av-viewfinder {
  position: relative;
  width:  clamp(260px, 34vw, 480px);
  height: clamp(260px, 34vw, 480px);
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 6px #fff,
    0 0 0 12px #4CAF50,
    0 16px 48px rgba(0,0,0,0.3);
  background: #C8E6C9;
  flex-shrink: 0;
}
#av-live-canvas {
  width: 100%; height: 100%;
  display: block;
  border-radius: 50%;
}

/* Corner decorations (outside the circle) */
.av-corner {
  position: absolute;
  width: 32px; height: 32px;
  pointer-events: none;
  z-index: 3;
}
.av-corner::before, .av-corner::after {
  content: '';
  position: absolute;
  background: #FFD700;
  border-radius: 4px;
}
.av-corner-tl { top: 6%; left: 6%; }
.av-corner-tr { top: 6%; right: 6%; }
.av-corner-bl { bottom: 6%; left: 6%; }
.av-corner-br { bottom: 6%; right: 6%; }
.av-corner-tl::before, .av-corner-tr::before,
.av-corner-bl::before, .av-corner-br::before { width: 22px; height: 4px; top: 0; left: 0; }
.av-corner-tl::after, .av-corner-tr::after,
.av-corner-bl::after, .av-corner-br::after  { width: 4px; height: 22px; top: 0; left: 0; }
.av-corner-tr::before { left: auto; right: 0; }
.av-corner-tr::after  { left: auto; right: 0; }
.av-corner-bl::before { top: auto; bottom: 0; }
.av-corner-bl::after  { top: auto; bottom: 0; }
.av-corner-br::before { left: auto; right: 0; top: auto; bottom: 0; }
.av-corner-br::after  { left: auto; right: 0; top: auto; bottom: 0; }

/* Aim guide overlay */
.av-aim-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.av-aim-guide svg { width: 100%; height: 100%; }

/* Flash */
.av-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  border-radius: 50%;
  transition: opacity 0.08s ease;
}
.av-flash.av-flash-go {
  animation: flashAnim 0.4s ease forwards;
}
@keyframes flashAnim {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

/* Countdown badge */
.av-countdown-badge {
  position: absolute;
  bottom: 10%;
  right: 8%;
  width: 70px; height: 70px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.av-countdown-badge.av-cd-visible { opacity: 1; }
.av-cd-svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  position: absolute; top: 0; left: 0;
}
.av-cd-bg   { fill:none; stroke:rgba(255,255,255,0.3); stroke-width:7; }
.av-cd-fill {
  fill:none; stroke:#4CAF50; stroke-width:7;
  stroke-linecap:round;
  stroke-dasharray:214; stroke-dashoffset:0;
  transition: stroke-dashoffset 0.05s linear;
}
.av-cd-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.45);
}

/* Snap button */
.av-snap-btn {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #FFF176 0%, #FFD740 100%);
  color: #4E342E;
  border: none; border-radius: 60px;
  padding: 16px 44px;
  font-family: 'Nunito', cursive;
  font-size: clamp(16px, 2vw, 28px);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 7px 0 #F57F17, 0 10px 24px rgba(0,0,0,0.22);
  transition: transform 0.12s, box-shadow 0.12s;
}
.av-snap-btn:hover  { transform: translateY(-3px); box-shadow: 0 10px 0 #F57F17, 0 14px 28px rgba(0,0,0,0.25); }
.av-snap-btn:active { transform: translateY(4px);  box-shadow: 0 3px 0  #F57F17, 0  5px 12px rgba(0,0,0,0.2); }
.av-snap-icon { font-size: 1.3em; }

.av-auto-snap-hint {
  font-size: clamp(12px, 1.5vw, 18px);
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.35);
  text-align: center;
}
.av-auto-snap-hint strong { color: #FFF176; }

/* ═══════════════════════════════════════════════════════════
   PHASE B — CONFIRM
   ═══════════════════════════════════════════════════════════ */
#av-confirm {
  align-items: center;
  justify-content: center;
}
.av-confirm-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 4vw, 72px);
  width: 100%;
  padding: 0 40px;
  flex-wrap: wrap;
}

/* Avatar frame */
.av-avatar-frame-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.av-avatar-frame {
  position: relative;
  width:  clamp(200px, 28vw, 380px);
  height: clamp(200px, 28vw, 380px);
  border-radius: 50%;
  overflow: visible;
}
.av-avatar-frame.av-pop {
  animation: avatarPop 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes avatarPop {
  0%   { transform: scale(0.5) rotate(-6deg); opacity: 0; }
  100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}
.av-avatar-frame img {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  box-shadow:
    0 0 0 6px #fff,
    0 0 0 12px #FFD700,
    0 0 0 18px #4CAF50,
    0 20px 60px rgba(0,0,0,0.3);
  object-fit: cover;
}
/* Sparkles around avatar */
.av-sparkle {
  position: absolute;
  font-size: clamp(18px, 2.2vw, 32px);
  animation: sparklePop 1.8s ease-in-out infinite;
  pointer-events: none;
}
.sp1 { top:   -8%; left:  10%; animation-delay: 0.0s; }
.sp2 { top:    5%; right: -4%; animation-delay: 0.4s; }
.sp3 { bottom:-6%; right: 14%; animation-delay: 0.8s; }
.sp4 { bottom: 8%; left: -2%;  animation-delay: 1.2s; }
@keyframes sparklePop {
  0%,100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
  50%      { transform: scale(1.4) rotate(20deg); opacity: 0.7; }
}

.av-avatar-label-wrap {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.85);
  border-radius: 50px;
  padding: 10px 28px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.av-avatar-emoji { font-size: clamp(20px, 2.5vw, 32px); }
.av-avatar-name  {
  font-size: clamp(16px, 2.2vw, 28px);
  font-weight: 900;
  color: #2E7D32;
  margin: 0;
}

/* Confirm bubble */
.av-confirm-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.av-confirm-bubble {
  background: rgba(255,255,255,0.93);
  border-radius: 36px;
  padding: 36px 48px 32px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18), 0 0 0 5px rgba(255,255,255,0.6);
  animation: bubblePop 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.1s both;
  max-width: 480px;
}
@keyframes bubblePop {
  0%   { transform: scale(0.7) translateY(20px); opacity: 0; }
  100% { transform: scale(1)   translateY(0);    opacity: 1; }
}
.av-confirm-emoji { font-size: clamp(44px, 6vw, 80px); line-height: 1; margin-bottom: 6px; }
.av-confirm-title {
  font-size: clamp(32px, 5vw, 68px);
  font-weight: 900;
  color: #2E7D32;
  margin: 0 0 8px;
}
.av-confirm-sub {
  font-size: clamp(16px, 2vw, 28px);
  font-weight: 700;
  color: #5D4037;
  margin: 0 0 28px;
}

/* Confirm buttons */
.av-confirm-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.av-btn {
  font-family: 'Nunito', cursive;
  font-size: clamp(14px, 1.8vw, 24px);
  font-weight: 900;
  border: none; border-radius: 50px;
  padding: 16px 36px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.av-btn-retake {
  background: linear-gradient(135deg, #FFCC02 0%, #FF8F00 100%);
  color: #3E2723;
  box-shadow: 0 6px 0 #E65100;
}
.av-btn-retake:hover  { transform: translateY(-2px); box-shadow: 0 8px 0 #E65100; }
.av-btn-retake:active { transform: translateY(3px);  box-shadow: 0 3px 0 #E65100; }

.av-btn-confirm {
  background: linear-gradient(135deg, #66BB6A 0%, #2E7D32 100%);
  color: #fff;
  box-shadow: 0 6px 0 #1B5E20;
}
.av-btn-confirm:hover  { transform: translateY(-2px); box-shadow: 0 8px 0 #1B5E20; }
.av-btn-confirm:active { transform: translateY(3px);  box-shadow: 0 3px 0 #1B5E20; }

/* Floating garden deco on confirm */
.av-confirm-decos { position: absolute; inset: 0; pointer-events: none; }
.av-deco {
  position: absolute;
  font-size: clamp(20px, 2.5vw, 38px);
  animation: decoFloat linear infinite;
}
.d1 { top: 5%;   left: -12%; animation-duration:  8s; animation-delay: 0s; }
.d2 { top: 20%;  right:-10%; animation-duration: 11s; animation-delay: 2s; }
.d3 { bottom:15%;left: -8%;  animation-duration:  9s; animation-delay: 4s; }
.d4 { bottom: 5%;right: -6%; animation-duration: 12s; animation-delay: 1s; }
.d5 { top: 50%;  left: -14%; animation-duration: 10s; animation-delay: 6s; }

@keyframes decoFloat {
  0%   { transform: translate(0,0) rotate(0deg); }
  25%  { transform: translate(12px,-10px) rotate(30deg); }
  50%  { transform: translate(-6px, 14px) rotate(60deg); }
  75%  { transform: translate(10px, -4px) rotate(90deg); }
  100% { transform: translate(0,0) rotate(120deg); }
}
