/*
 * apps/quote-draw.css
 * "🍀 오늘의 명언" 포춘쿠키 뽑기 전용 스타일. 모바일 우선으로 작성했고,
 * 쿠키/명언 두 면을 CSS Grid의 같은 칸에 겹쳐서 배치해 - 명언이 길든 짧든
 * 카드 높이가 자동으로 늘어나며 절대 잘리지 않는다(고정 height 없음).
 *
 * 인터랙션: 쿠키를 누르면 살짝 흔들리다가(is-shaking) 깨지면서(is-cracked)
 * 명언이 크로스페이드로 나타난다. 부스러기 2개가 살짝 튀는 정도만 넣었고,
 * 반짝임/파티클/효과음은 넣지 않았다(브랜드 톤 - 도박 느낌 금지).
 */

.quote-cookie-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 4px 0 12px;
}

.quote-cookie {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 340px;
  display: grid;
  border: none;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  padding: 0;
  cursor: pointer;
}

.quote-cookie:disabled {
  cursor: default;
}

/* 두 면을 같은 grid 칸에 겹쳐서, 더 긴 쪽(명언 면)에 맞춰 높이가 자동으로
   정해지게 한다. position:absolute를 안 쓰는 게 핵심(모바일에서도 안 잘림). */
.quote-cookie-face {
  grid-area: 1 / 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  min-height: 220px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.quote-cookie-intact {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.quote-cookie-cracked {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

.quote-cookie.is-cracked .quote-cookie-intact {
  opacity: 0;
  transform: scale(0.2) rotate(20deg);
}

.quote-cookie.is-cracked .quote-cookie-cracked {
  opacity: 1;
  transform: scale(1);
}

.quote-cookie-emoji {
  font-size: 44px;
  line-height: 1;
}

.quote-cookie.is-shaking .quote-cookie-emoji {
  animation: cookie-shake 0.5s ease-in-out;
}

@keyframes cookie-shake {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-10deg);
  }
  40% {
    transform: rotate(9deg);
  }
  60% {
    transform: rotate(-7deg);
  }
  80% {
    transform: rotate(5deg);
  }
}

.quote-cookie-hint {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

/* 부스러기 2개 - 쿠키가 깨지는 순간에만 잠깐 튀어 오르고 사라진다. */
.quote-cookie-crumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c9a15a;
  opacity: 0;
  pointer-events: none;
}

.quote-cookie.is-cracked ~ .quote-cookie-crumb-1 {
  animation: crumb-fly-1 0.55s ease-out;
}

.quote-cookie.is-cracked ~ .quote-cookie-crumb-2 {
  animation: crumb-fly-2 0.55s ease-out;
}

@keyframes crumb-fly-1 {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(-46px, -32px) scale(0.4);
  }
}

@keyframes crumb-fly-2 {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(44px, -26px) scale(0.4);
  }
}

.quote-card-tag {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
  border-radius: 999px;
  padding: 4px 12px;
}

.quote-card-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.6;
  white-space: pre-line;
  word-break: keep-all;
  overflow-wrap: break-word;
  margin: 0;
}

.quote-tier-toast {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #8a6a14;
  background: linear-gradient(180deg, #fff9e8 0%, #fffdf5 100%);
  border: 1px solid rgba(201, 151, 31, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 0 0 10px;
  animation: quote-toast-in 0.35s ease both;
}

@keyframes quote-toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.quote-tier-toast.is-golden-sticky {
  box-shadow: 0 4px 16px rgba(201, 151, 31, 0.18);
}

.quote-golden-bonus[hidden] {
  display: none !important;
}

.quote-golden-bonus:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 4px;
}

.quote-golden-luck-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-sub);
  margin: 0;
}

.quote-golden-luck-value {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  color: #c9971f;
  margin: 0;
  letter-spacing: -0.03em;
}

.quote-share-hint {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-primary-dark);
  margin: 0 0 6px;
}

.quote-cookie-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--radius-md);
  z-index: 0;
}

.quote-fx-star {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(210, 220, 235, 0.95);
  box-shadow:
    0 0 8px rgba(220, 230, 245, 0.95),
    0 0 3px rgba(255, 255, 255, 0.85);
  animation: quote-fx-float linear infinite;
}

.quote-fx-star.is-bright {
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  font-size: 13px;
  line-height: 1;
  color: rgba(235, 240, 250, 0.98);
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.95),
    0 0 4px rgba(200, 210, 225, 0.9);
  box-shadow: none;
}

.quote-fx-gold {
  position: absolute;
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  animation: quote-fx-float linear infinite;
}

@keyframes quote-fx-float {
  0% { transform: translateY(8px); opacity: 0; }
  15% { opacity: 0.85; }
  85% { opacity: 0.65; }
  100% { transform: translateY(-42px); opacity: 0; }
}

/* ── 프리미엄 뽑기(흔들림) — 별빛/황금만 ───────────────── */
.quote-cookie-wrap.is-premium-crack {
  animation: premium-crack-pulse 0.45s ease-in-out infinite;
}

@keyframes premium-crack-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.35)); }
}

.quote-cookie-wrap.is-premium-crack:has(.is-premium-starlight)::before {
  content: "";
  position: absolute;
  inset: -20px;
  border-radius: calc(var(--radius-lg) + 6px);
  background: radial-gradient(circle at 50% 55%, rgba(220, 230, 245, 0.55), transparent 68%);
  z-index: -2;
  animation: premium-starlight-leak 0.5s ease-in-out infinite;
  pointer-events: none;
}

.quote-cookie-wrap.is-premium-crack:has(.is-premium-golden)::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: calc(var(--radius-lg) + 4px);
  background: radial-gradient(circle at 50% 55%, rgba(255, 215, 100, 0.42), transparent 65%);
  z-index: -2;
  animation: premium-golden-leak 0.45s ease-in-out infinite;
  pointer-events: none;
}

@keyframes premium-starlight-leak {
  0%, 100% { opacity: 0.55; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.04); }
}

@keyframes premium-golden-leak {
  0%, 100% { opacity: 0.5; transform: scale(0.97); }
  50% { opacity: 1; transform: scale(1.05); }
}

.quote-cookie.is-premium-starlight.is-shaking .quote-cookie-intact {
  border-color: rgba(180, 195, 215, 0.75);
  box-shadow:
    inset 0 0 28px rgba(210, 220, 235, 0.55),
    0 0 22px rgba(190, 205, 225, 0.45);
  animation: premium-intact-leak-star 0.5s ease-in-out;
}

.quote-cookie.is-premium-golden.is-shaking .quote-cookie-intact {
  border-color: rgba(201, 151, 31, 0.55);
  box-shadow:
    inset 0 0 24px rgba(255, 215, 100, 0.4),
    0 0 26px rgba(201, 151, 31, 0.38);
  animation: premium-intact-leak-gold 0.5s ease-in-out;
}

@keyframes premium-intact-leak-star {
  0%, 100% { box-shadow: inset 0 0 16px rgba(210, 220, 235, 0.35), 0 0 12px rgba(190, 205, 225, 0.25); }
  50% { box-shadow: inset 0 0 32px rgba(230, 238, 248, 0.65), 0 0 28px rgba(200, 215, 235, 0.55); }
}

@keyframes premium-intact-leak-gold {
  0%, 100% { box-shadow: inset 0 0 14px rgba(255, 215, 100, 0.25), 0 0 14px rgba(201, 151, 31, 0.22); }
  50% { box-shadow: inset 0 0 30px rgba(255, 225, 130, 0.55), 0 0 32px rgba(201, 151, 31, 0.45); }
}

.quote-cookie.is-premium-starlight.is-shaking .quote-cookie-emoji,
.quote-cookie.is-premium-golden.is-shaking .quote-cookie-emoji {
  animation: cookie-shake 0.35s ease-in-out infinite;
}

/* ── 등급별 연출 ───────────────────────────────── */
/* 기본쿠키(60%): 갈색 테두리 */
.quote-cookie.is-tier-basic .quote-cookie-cracked {
  border: 1.5px solid #c49a6c;
  background: linear-gradient(180deg, #fffaf6 0%, #ffffff 100%);
}

/* 행운쿠키(22%): 초록 테두리 + 은은한 반짝 */
.quote-cookie-wrap.is-tier-lucky::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-lg);
  background: radial-gradient(closest-side, rgba(61, 154, 90, 0.14), transparent);
  z-index: -1;
}

.quote-cookie.is-tier-lucky .quote-cookie-cracked {
  border: 1.5px solid #3d9a5a;
  background: linear-gradient(180deg, #f5fbf7 0%, #ffffff 100%);
  animation: lucky-sparkle 2.4s ease-in-out infinite;
}

@keyframes lucky-sparkle {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(61, 154, 90, 0.1); }
  50% { box-shadow: inset 0 0 0 1px rgba(61, 154, 90, 0.28), 0 0 12px rgba(61, 154, 90, 0.12); }
}

.quote-cookie.is-tier-lucky .quote-card-tag {
  color: #1f6b3a;
  background: #e8f5ec;
  border: 1px solid rgba(61, 154, 90, 0.3);
}

/* 별빛쿠키(12%): 빛 퍼짐 + 은색 파티클 */
.quote-cookie-wrap.is-tier-starlight {
  filter: drop-shadow(0 6px 20px rgba(120, 136, 160, 0.16));
}

.quote-cookie-wrap.is-tier-starlight::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: calc(var(--radius-lg) + 4px);
  background:
    radial-gradient(circle at 50% 40%, rgba(220, 228, 240, 0.55), transparent 62%),
    radial-gradient(closest-side, rgba(160, 178, 200, 0.22), transparent 72%);
  z-index: -2;
  animation: starlight-glow 3s ease-in-out infinite;
}

@keyframes starlight-glow {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.quote-cookie-wrap.is-tier-starlight::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--radius-md) + 4px);
  border: 1px solid rgba(180, 192, 210, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  z-index: -1;
  pointer-events: none;
}

.quote-cookie.is-tier-starlight .quote-cookie-cracked {
  border: 2px solid transparent;
  background:
    linear-gradient(#f7f9fc, #ffffff) padding-box,
    linear-gradient(135deg, #dfe6ee, #8fa3b8, #eef2f6, #7d8fa3) border-box;
  box-shadow: 0 8px 28px rgba(120, 136, 160, 0.16);
}

.quote-cookie.is-tier-starlight .quote-card-tag {
  color: #3d4a57;
  background: linear-gradient(180deg, #f3f6fa 0%, #e3eaf2 100%);
  border: 1px solid rgba(143, 163, 184, 0.45);
}

/* 황금쿠키(6%): 금가루 + 흔들림 + 딩 */
.quote-cookie-wrap.is-tier-golden::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: var(--radius-lg);
  background: radial-gradient(closest-side, rgba(201, 151, 31, 0.24), transparent);
  z-index: -1;
}

.quote-cookie-wrap.is-golden-reveal {
  animation: golden-wrap-shake 0.65s ease;
}

@keyframes golden-wrap-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px) rotate(-0.4deg); }
  40% { transform: translateX(3px) rotate(0.4deg); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.quote-cookie.is-tier-golden .quote-cookie-cracked {
  border: 2px solid #c9971f;
  background: linear-gradient(180deg, #fffdf7 0%, #ffffff 100%);
  box-shadow:
    inset 0 0 0 1px rgba(201, 151, 31, 0.2),
    0 8px 28px rgba(201, 151, 31, 0.18);
}

.quote-cookie.is-tier-golden .quote-card-tag {
  color: #8a6a14;
  background: linear-gradient(180deg, #f7ecd4 0%, #f0dfaa 100%);
  border: 1px solid rgba(201, 151, 31, 0.35);
}

.quote-cookie.is-tier-golden .quote-card-text {
  color: #5c4a12;
}

.quote-cookie-reset {
  display: block;
  margin: 0 auto 4px;
  background: none;
  border: none;
  color: var(--color-primary-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
}

.quote-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.quote-toolbar .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

#quoteCanvas {
  display: none;
}

@media (max-width: 560px) {
  .quote-cookie-face {
    padding: 22px 16px;
    min-height: 200px;
  }

  .quote-cookie-emoji {
    font-size: 40px;
  }

  .quote-card-text {
    font-size: 16px;
  }

  .quote-golden-luck-value {
    font-size: 36px;
  }
}

/* 애니메이션을 줄이도록 설정한 사용자에게는 흔들림/전환을 생략한다. */
@media (prefers-reduced-motion: reduce) {
  .quote-cookie-face,
  .quote-cookie.is-shaking .quote-cookie-emoji,
  .quote-cookie.is-cracked ~ .quote-cookie-crumb-1,
  .quote-cookie.is-cracked ~ .quote-cookie-crumb-2,
  .quote-cookie.is-tier-lucky .quote-cookie-cracked,
  .quote-cookie-wrap.is-tier-starlight::before,
  .quote-cookie-wrap.is-golden-reveal,
  .quote-cookie-wrap.is-premium-crack,
  .quote-cookie-wrap.is-premium-crack::before,
  .quote-cookie.is-premium-starlight.is-shaking .quote-cookie-intact,
  .quote-cookie.is-premium-golden.is-shaking .quote-cookie-intact,
  .quote-cookie.is-premium-starlight.is-shaking .quote-cookie-emoji,
  .quote-cookie.is-premium-golden.is-shaking .quote-cookie-emoji,
  .quote-fx-star,
  .quote-fx-gold,
  .quote-tier-toast {
    animation: none;
    transition: none;
  }
}
