/* ---- 소원 쪽지 카드(js/wishes.js) ----
   촛불 카드와 짝인 떠 있는 유리 카드(.float-card, style.css). 주인공(.wish-stage)은 카드 위 가장자리를 넘어 눈 덮인 전나무 가지가 걸려 있고,
   걸기 화면은 그 아래에 겨울 색 쪽지(--paper)에 바람을 적습니다. 본문 부품(.switch-row·.pill-action·.chip·.meter·.more-menu)은 촛불과 같습니다.
   연출: write 쪽지에 적기 → fold 쪽지가 접혀 가지로 오름 → hung 가지에 매달려 흔들림 → 저절로 닫힘 */
#dlg-wish { --hero-h: 300px; --hero-out: 128px; --card-glow: 196, 222, 255; }
#dlg-wish[data-sky="dusk"] { --card-glow: 255, 196, 170; }
#dlg-wish[data-sky="night"] { --card-glow: 176, 200, 255; }
.wish-pane:not([hidden]) { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.wish-pane[hidden] { display: none; }

.wish-stage { --paper: #f7f8fb; --bloom: 1; position: relative; isolation: isolate; }
.wish-stage .card-glow { bottom: 40px; opacity: 0.7; transition: opacity 0.9s ease; }
.wish-stage[data-phase="hung"] .card-glow { opacity: 1; }

/* 눈 덮인 전나무 가지(js/wishes.js의 boughSvg): 휜 줄기에 짙은 바늘잎 다발, 윗면에 눈덩이 */
.wish-bough {
  position: absolute; z-index: 1; left: -6%; right: -6%; top: 6px; height: 64px;
  transform: rotate(-2.5deg); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
}
.wish-bough svg { display: block; width: 100%; height: 100%; overflow: visible; }
/* 주인공 칸에 천천히 내리는 눈송이 */
.wish-flakes { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; border-radius: 20px 20px 0 0; }
.wish-flakes i { position: absolute; top: -8px; width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); animation: wish-flake 7s linear infinite; }
.wish-flakes i:nth-child(1) { left: 12%; animation-delay: -1s; }
.wish-flakes i:nth-child(2) { left: 30%; width: 3px; height: 3px; animation-delay: -4s; animation-duration: 9s; }
.wish-flakes i:nth-child(3) { left: 47%; animation-delay: -2.5s; }
.wish-flakes i:nth-child(4) { left: 64%; width: 4px; height: 4px; animation-delay: -6s; animation-duration: 8s; }
.wish-flakes i:nth-child(5) { left: 81%; width: 3px; height: 3px; animation-delay: -3.2s; }
.wish-flakes i:nth-child(6) { left: 92%; animation-delay: -5.4s; animation-duration: 10s; }
@keyframes wish-flake {
  from { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  to { transform: translate(-14px, 320px); opacity: 0.2; }
}

/* 걸기 화면의 쪽지: 줄 그은 겨울 색 종이에 질문 · 입력 · 글자 수 */
.wish-note {
  position: absolute; z-index: 3; left: 50%; bottom: 10px; width: min(276px, 84%); box-sizing: border-box; padding: 12px 14px 12px;
  border-radius: 3px; color: #2f2a24;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 30%),
    repeating-linear-gradient(180deg, var(--paper) 0 23px, color-mix(in srgb, var(--paper) 86%, #5a5048) 23px 24px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
  transform: translateX(-50%) rotate(-2deg); transform-origin: 50% 0;
  transition: transform 0.9s cubic-bezier(0.55, 0, 0.3, 1), opacity 0.4s ease 0.55s, background 0.25s ease;
}
.wish-note::before { /* 쪽지 위 가운데의 매듭 구멍과 붉은 실 */
  content: ""; position: absolute; left: 50%; top: 5px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: #c4473f; box-shadow: 0 0 0 2px color-mix(in srgb, var(--paper) 70%, #fff);
}
.wish-note-prompt { display: block; margin-top: 4px; font-family: var(--font-display); font-size: 13px; line-height: 1.35; color: #6c6258; word-break: keep-all; }
.wish-note-input {
  display: block; width: 100%; box-sizing: border-box; margin-top: 6px; padding: 4px 0 3px;
  border: 0; border-bottom: 1px dashed rgba(70, 60, 50, 0.45); background: transparent; color: #26201a;
  font: 16px/1.4 var(--font-ui); caret-color: #b5414a; outline: none; /* 16px: iOS가 확대하지 않습니다 */
}
.wish-note-input::placeholder { color: rgba(70, 60, 50, 0.55); }
.wish-note-input:focus-visible { border-bottom-style: solid; border-bottom-color: #b5414a; }
.wish-note-count { display: block; margin-top: 3px; font-size: 11px; text-align: right; color: #7d7268; }
.wish-note-count[data-over] { color: #b0402a; }
/* 접혀 가지로 오르기: 위아래로 접히듯 납작해지며 작아져 가지 쪽으로 올라가고 사라집니다 */
.wish-stage:is([data-phase="fold"], [data-phase="hung"]) .wish-note {
  transform: translate(-50%, -150px) perspective(500px) rotateX(64deg) rotate(4deg) scale(0.2, 0.32); opacity: 0; pointer-events: none;
}

/* 가지에 매달린 작은 쪽지: 붉은 실에 매달려 흔들립니다(hung에서 나타납니다) */
.wish-hung {
  position: absolute; z-index: 2; left: 50%; top: 34px; width: 0; height: 0;
  opacity: 0; transform: translateY(40px) scale(0.6); transition: opacity 0.35s ease, transform 0.55s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.wish-hung::before { content: ""; position: absolute; left: -1px; top: 0; width: 2px; height: 30px; background: #c4473f; }
.wish-hung-paper {
  position: absolute; left: -24px; top: 28px; width: 48px; height: 78px; box-sizing: border-box; padding: 14px 5px 4px; border-radius: 2px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 51%, rgba(0, 0, 0, 0.1) 51% 53%, rgba(0, 0, 0, 0) 53%), var(--paper);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.35); transform-origin: 50% -28px;
}
.wish-hung-paper::before { content: ""; position: absolute; left: 50%; top: 4px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #c4473f; }
.wish-hung-text { display: block; font-size: 7px; line-height: 1.35; color: #4a4038; overflow: hidden; max-height: 100%; word-break: keep-all; overflow-wrap: anywhere; }
.wish-stage[data-phase="hung"] .wish-hung { opacity: 1; transform: none; }
.wish-stage[data-phase="hung"] .wish-hung-paper { animation: wish-sway 1.8s ease-in-out infinite; }
@keyframes wish-sway {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}
/* 매달리는 순간 가지에서 눈가루가 떨어집니다 */
.wish-stage[data-phase="hung"] .wish-bough svg { animation: wish-shake 0.5s ease-out; }
@keyframes wish-shake {
  0% { transform: translateY(0); }
  30% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}

/* 걸기 본문: 안내 한 줄 · 종이 색 칩 · '남에게 보이지 않게' 토글 · 걸기 · 접은 안내 */
.wish-help { justify-content: center; margin: 10px 0 0; text-align: center; }
.wish-colors { margin: 12px 0 0; padding: 0; border: 0; min-width: 0; }
.wish-color-list { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.wish-color {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; box-sizing: border-box; padding: 0 12px 0 10px;
  border: 1px solid var(--card-line); border-radius: 999px; background: var(--card-chip); font-size: 13px; color: var(--ink-dim); cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.wish-color:hover { background: rgba(255, 255, 255, 0.13); color: var(--ink); }
.wish-color input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.wish-swatch { position: relative; display: block; width: 10px; height: 15px; margin-top: 4px; border-radius: 1px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.3); }
.wish-swatch::before { content: ""; position: absolute; left: 50%; top: -5px; width: 1.5px; height: 6px; margin-left: -0.75px; background: #d0645c; }
.wish-color:has(input:checked) { border-color: rgba(190, 220, 255, 0.75); background: rgba(170, 205, 255, 0.16); color: var(--ink); box-shadow: 0 0 16px -4px rgba(170, 210, 255, 0.5); }
.wish-color:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.wish-color:has(input:disabled) { opacity: 0.6; cursor: default; }
@media (pointer: coarse) { .wish-color { min-height: 44px; } }
#dlg-wish .garden-error { margin: 10px 0 0; }
#dlg-wish .pill-action .icon-svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#dlg-wish .switch:checked { border-color: rgba(190, 220, 255, 0.6); background: linear-gradient(180deg, #8db5e8, #5f8ac4); }

/* 쪽지 카드: 가지에서 실로 내려온 쪽지에 바람 글. 바랠수록(--bloom 1 → 0) 종이 색이 옅어집니다 */
.wish-memo {
  position: absolute; z-index: 2; left: 50%; top: 66px; width: min(250px, 78%); box-sizing: border-box; margin: 0; padding: 18px 16px 14px;
  border-radius: 3px; color: #2f2a24; text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 30%),
    color-mix(in srgb, var(--paper) calc(var(--bloom) * 100%), #dcd8cf);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42), 0 0 26px rgba(190, 215, 255, 0.16);
  transform: translateX(-50%) rotate(-1.5deg); transform-origin: 50% -40px;
  animation: wish-card-sway 5s ease-in-out infinite;
  transition: opacity 0.2s ease;
}
.wish-memo::before { /* 가지에 매단 붉은 실 */
  content: ""; position: absolute; left: 50%; top: -42px; width: 1.5px; height: 46px; margin-left: -0.75px; background: #c4473f;
}
.wish-memo::after { /* 매듭 구멍 */
  content: ""; position: absolute; left: 50%; top: 5px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #c4473f;
}
@keyframes wish-card-sway {
  0%, 100% { transform: translateX(-50%) rotate(-1.5deg); }
  50% { transform: translateX(-50%) rotate(1.5deg); }
}
.wish-memo-prompt { font-size: 11.5px; line-height: 1.35; color: #7d7268; word-break: keep-all; }
.wish-memo-prompt[hidden] { display: none; }
.wish-memo-text {
  margin: 4px 0 0; font-family: var(--font-display); font-size: 18px; line-height: 1.45; color: #2a231c;
  overflow-wrap: anywhere; word-break: keep-all;
}
.wish-memo-text[data-empty] { font-family: var(--font-ui); font-size: 13.5px; color: rgba(70, 60, 50, 0.62); }
.wish-view[data-swap] .wish-memo { opacity: 0; }
.chip-paper::before { content: ""; width: 7px; height: 10px; border-radius: 1px; background: #e8eef6; box-shadow: 0 0 6px rgba(190, 215, 255, 0.7); }
.wish-more .more-menu-list { top: calc(100% + 4px); bottom: auto; }
#wish-bar { background: linear-gradient(90deg, #7fa8d8, #d6e6f8); }
.wish-view[data-fading] ~ .float-card-body #wish-bar { background: linear-gradient(90deg, #a49c90, #d9d5cc); }
.wish-card .meter-value { white-space: normal; }
.wish-card-actions:not(:has(> :not([hidden]))) { display: none; }
#dlg-wish:has(#wish-card:not([hidden])) { --hero-h: 236px; --hero-out: 96px; }

/* 읽을 쪽지가 없거나 연결 전: 주인공 없이 빈 실 하나와 안내 */
#dlg-wish:has(.wish-quiet:not([hidden])) { --hero-out: 0px; }
.wish-quiet { position: relative; margin: 0; padding: 92px 32px 30px; font-size: 14px; line-height: 1.6; text-align: center; color: var(--ink-dim); word-break: keep-all; }
.wish-quiet::before { /* 빈 쪽지 */
  content: ""; position: absolute; left: 50%; top: 40px; width: 26px; height: 40px; margin-left: -13px; border-radius: 2px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 51%, rgba(0, 0, 0, 0.1) 51% 53%, rgba(0, 0, 0, 0) 53%), #e8eef6; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.wish-quiet::after { content: ""; position: absolute; left: 50%; top: 18px; width: 1.5px; height: 24px; margin-left: -0.75px; background: #c4473f; }

@media (max-width: 560px) {
  #dlg-wish { --hero-h: 286px; --hero-out: 120px; }
  #dlg-wish:has(#wish-card:not([hidden])) { --hero-h: 232px; --hero-out: 92px; }
}
@media (max-height: 620px) {
  #dlg-wish { --hero-h: 264px; --hero-out: 104px; }
  #dlg-wish:has(#wish-card:not([hidden])) { --hero-h: 222px; --hero-out: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .wish-note, .wish-hung, .wish-memo, .wish-stage .card-glow { transition-duration: 0.01s; transition-delay: 0s; }
  .wish-flakes i, .wish-stage[data-phase="hung"] .wish-hung-paper, .wish-memo, .wish-stage[data-phase="hung"] .wish-bough svg { animation: none; }
  .wish-flakes { display: none; }
}
