/* 생일: 낙서 그림체 — 페이지 스크롤과 함께 움직임 */

body.birthday-celebrate {
  position: relative;
}

.birthday-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  overflow: hidden;
  width: 100%;
  min-height: 100%;
}

body.theme-birthday > .birthday-overlay {
  position: absolute;
  z-index: 35;
}

.birthday-doodle-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* 상단 가랜드 — 가운데에서 좌·우 끝까지 (문서 기준) */
.birthday-garlands {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 84px;
  filter: drop-shadow(0 3px 0 rgb(255 255 255 / 65%));
  /* 부모 pointer-events:none 은 상속되지 않음 — 컨테이너가 클릭을 가로채지 않게 */
  pointer-events: none;
}

.birthday-garland {
  flex: 1 1 50%;
  min-width: 0;
  height: 100%;
}

.birthday-garland-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.birthday-garland-knot {
  position: absolute;
  left: 50%;
  top: 2px;
  width: 14px;
  height: 14px;
  border: 2.5px solid #2b3340;
  border-radius: 50%;
  background: #ffda6c;
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px #fff;
}

/* 풍선 */
.birthday-balloons {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* 전체 화면 투명 레이어가 캘린더/링크 클릭을 가로채지 않게 */
  pointer-events: none;
}

.birthday-balloon {
  position: absolute;
  left: clamp(10px, var(--left), calc(100% - var(--size) - 10px));
  top: clamp(8px, var(--top), calc(100% - calc(var(--size) * 1.85) - 8px));
  width: var(--size);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transform: rotate(var(--rot));
  animation: birthday-balloon-bob 4s ease-in-out infinite;
  animation-delay: var(--delay);
  filter: drop-shadow(0 4px 0 rgb(255 255 255 / 55%));
  transition: transform .12s ease;
}

/* 타일 배치(px): 하단 clamp 로 한곳에 몰리지 않게 좌표 그대로 사용 */
.birthday-balloon--abs {
  top: var(--top);
}

.birthday-balloon:hover {
  transform: translateY(-4px) rotate(var(--rot)) scale(1.06);
}

.birthday-balloon:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand, #4a60a9) 55%, #fff);
  outline-offset: 4px;
  border-radius: 50%;
}

.birthday-balloon.is-popping {
  animation: birthday-balloon-pop .42s ease-out forwards;
  pointer-events: none;
}

/* 이스터 풍선 — 살짝만 반짝 (너무 티 나지 않게) */
.birthday-balloon--easter {
  filter:
    drop-shadow(0 4px 0 rgb(255 255 255 / 55%))
    drop-shadow(0 0 8px rgb(255 214 109 / 45%));
}

.birthday-easter-burst {
  position: absolute;
  z-index: 6;
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.birthday-easter-confetti {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 13px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  box-shadow: 0 0 0 1px rgb(43 51 64 / 12%);
}

.birthday-easter-confetti--burst {
  animation: birthday-easter-burst 1.15s cubic-bezier(.12,.75,.28,1) both;
  animation-delay: calc(var(--i) * 8ms);
}

.birthday-easter-confetti--fall {
  width: 8px;
  height: 10px;
  animation: birthday-easter-fall 1.55s cubic-bezier(.2,.6,.25,1) both;
  animation-delay: calc(40ms + var(--i) * 14ms);
}

.birthday-easter-confetti--ribbon {
  width: 14px;
  height: 5px;
  border-radius: 999px;
  animation: birthday-easter-burst 1.35s cubic-bezier(.12,.75,.28,1) both;
  animation-delay: calc(30ms + var(--i) * 16ms);
}

.birthday-easter-confetti--burst:nth-child(3n),
.birthday-easter-confetti--fall:nth-child(3n) {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.birthday-easter-confetti--burst:nth-child(5n) {
  width: 12px;
  height: 5px;
  border-radius: 2px;
}

.birthday-easter-confetti--fall:nth-child(4n) {
  width: 11px;
  height: 4px;
  border-radius: 2px;
}

@keyframes birthday-easter-burst {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
  70% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--spin)) scale(.4);
  }
}

@keyframes birthday-easter-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
  35% { opacity: 1; transform: translate(calc(var(--dx) * .35), var(--rise)) rotate(calc(var(--spin) * .4)) scale(1.05); }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--fall)) rotate(var(--spin)) scale(.5);
  }
}

@keyframes birthday-balloon-bob {
  0%, 100% { transform: translateY(0) rotate(var(--rot)); }
  50% { transform: translateY(-8px) rotate(calc(var(--rot) + 3deg)); }
}

@keyframes birthday-balloon-pop {
  0% { opacity: 1; transform: scale(1) rotate(var(--rot)); }
  35% { opacity: 1; transform: scale(1.18) rotate(var(--rot)); }
  100% { opacity: 0; transform: scale(.2) rotate(calc(var(--rot) + 18deg)); }
}

.birthday-pop {
  position: absolute;
  left: 50%;
  top: 28%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.birthday-pop-shard {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 12px;
  border-radius: 2px;
  background: var(--c);
  box-shadow: 0 0 0 1.5px #2b3340;
  animation: birthday-shard .42s ease-out forwards;
  animation-delay: calc(var(--i) * 8ms);
}

.birthday-pop-shard:nth-child(3n) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

@keyframes birthday-shard {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0); }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(.4) rotate(140deg);
  }
}

/* UFO — JS가 --prop-left / --prop-top 으로 랜덤 배치 (벽 안쪽 clamp) */
.birthday-prop--ufo {
  position: absolute;
  left: clamp(12px, var(--prop-left), calc(100% - min(118px, 14vw) - 12px));
  top: clamp(52px, var(--prop-top), calc(100% - 110px));
  z-index: 2;
  width: min(118px, 14vw);
  animation: birthday-prop-bob 4.2s ease-in-out infinite;
  animation-delay: -0.8s;
  filter: drop-shadow(0 4px 0 rgb(255 255 255 / 55%));
}

.birthday-prop--ufo img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  transform: rotate(var(--ufo-tilt, -10deg));
  user-select: none;
}

/* 빔은 UFO 몸체 아래에서만, 위로는 안 보이게 */
.birthday-ufo-beam {
  position: absolute;
  left: 50%;
  top: calc(100% - 10px);
  z-index: 0;
  width: 58%;
  height: 44px;
  transform: translateX(-50%) rotate(var(--ufo-tilt, -10deg));
  transform-origin: top center;
  background: linear-gradient(
    180deg,
    rgb(255 217 131 / 48%) 0%,
    rgb(255 217 131 / 22%) 40%,
    rgb(255 217 131 / 8%) 70%,
    rgb(255 217 131 / 0%) 100%
  );
  clip-path: polygon(34% 0, 66% 0, 100% 100%, 0 100%);
  pointer-events: none;
  animation: birthday-ufo-beam 2.8s ease-in-out infinite;
}

@keyframes birthday-ufo-beam {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 0.95; }
}

/* 케이크 — JS 랜덤 배치 (left/top %, 벽·하단 안쪽 clamp) */
.birthday-cake {
  position: absolute;
  left: clamp(12px, var(--prop-left), calc(100% - min(168px, 19vw) - 14px));
  top: clamp(52px, var(--prop-top), calc(100% - min(168px, 19vw) - 16px));
  right: auto;
  bottom: auto;
  z-index: 2;
  width: min(168px, 19vw);
  animation: birthday-prop-bob 4.8s ease-in-out infinite;
  animation-delay: -1.4s;
  filter: drop-shadow(0 4px 0 rgb(255 255 255 / 55%));
}

@keyframes birthday-prop-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@media (max-width: 1100px) {
  .birthday-garlands { height: 68px; }
  .birthday-balloon { --size: 48px; }
  .birthday-prop--ufo { width: 82px; }
  .birthday-cake { width: 124px; }
}

@media (max-width: 720px) {
  /* 풍선·UFO·케이크 좌표는 js/birthday.js LAYOUTS_MOBILE 전용 프리셋 */
  .birthday-garlands { height: 54px; }
  .birthday-prop--ufo { width: 58px; }
  .birthday-cake { width: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  .birthday-balloon,
  .birthday-prop--ufo,
  .birthday-cake,
  .birthday-ufo-beam { animation: none; }
  .birthday-balloon.is-popping { animation: none; opacity: 0; }
  .birthday-pop-shard { animation: none; opacity: 0; }
}

/* ── 캘린더: 데스크톱은 뷰포트 고정, 모바일은 문서와 함께 스크롤 ── */
body.theme-birthday > .birthday-overlay.birthday-overlay--calendar,
body.calendar-page > .birthday-overlay--calendar {
  position: fixed;
  inset: 0;
  /* 사이드바(z-index:20)보다 위 — 가랜드·풍선이 오른쪽 박스에 가리지 않게 */
  z-index: 25;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

body.calendar-page.birthday-celebrate {
  /* 데스크톱: fixed 오버레이 기준. 모바일은 아래 media에서 relative */
  position: static;
}

@media (max-width: 768px) {
  /* 스크롤과 함께 움직이되, JS가 문서 높이만큼 늘리고 구간마다 풍선 타일링 */
  body.calendar-page.birthday-celebrate {
    position: relative;
  }

  body.theme-birthday > .birthday-overlay.birthday-overlay--calendar,
  body.calendar-page > .birthday-overlay--calendar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    z-index: 25;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow: hidden;
  }
}

.birthday-overlay--calendar .birthday-garlands {
  height: 52px;
  opacity: 0.9;
  filter: drop-shadow(0 2px 0 rgb(255 255 255 / 55%));
}

.birthday-overlay--calendar .birthday-balloon {
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.9;
  filter: drop-shadow(0 2px 0 rgb(255 255 255 / 45%));
}

.birthday-overlay--calendar .birthday-prop--ufo {
  width: min(72px, 7.5vw);
  opacity: 0.88;
}

.birthday-overlay--calendar .birthday-cake {
  width: min(92px, 9vw);
  opacity: 0.88;
}

.birthday-overlay--calendar .birthday-ufo-beam {
  height: 28px;
  opacity: 0.75;
}

@media (max-width: 1100px) {
  .birthday-overlay--calendar .birthday-prop--ufo { width: 56px; }
  .birthday-overlay--calendar .birthday-cake { width: 72px; }
  .birthday-overlay--calendar .birthday-balloon { opacity: 0.85; }
}

@media (max-width: 720px) {
  /* 캘린더 풍선 좌표는 CALENDAR_LAYOUTS_MOBILE */
  .birthday-overlay--calendar .birthday-prop--ufo { width: 44px; }
  .birthday-overlay--calendar .birthday-cake { width: 58px; }
  .birthday-overlay--calendar .birthday-garlands { height: 40px; opacity: 0.82; }
}

/* ── 홈 전용 생일 테마 (부제·배경) ── */
body.links-page.theme-birthday {
  --birthday-gold: #c9a24a;
  --birthday-rose: #d4788c;
  --birthday-sky: #7eb6ff;
  --bg: #eef2f8;
  background:
    radial-gradient(ellipse 90% 55% at 8% 18%, rgb(255 176 200 / 22%), transparent 62%),
    radial-gradient(ellipse 85% 50% at 94% 12%, rgb(255 214 109 / 20%), transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% -8%, rgb(126 182 255 / 18%), transparent 58%),
    radial-gradient(ellipse 120% 80% at 50% -20%, color-mix(in srgb, var(--brand, #4a60a9) 10%, transparent), transparent),
    linear-gradient(165deg, #eef2f9 0%, #f7f0ea 46%, #eef0f8 100%);
}

body.links-page.theme-birthday .links-hero.panel {
  border-color: color-mix(in srgb, var(--birthday-gold, #c9a24a) 28%, var(--border, #d7deea));
  box-shadow:
    0 10px 28px rgb(36 56 91 / 8%),
    0 0 0 1px color-mix(in srgb, var(--birthday-rose, #d4788c) 14%, transparent);
}

body.links-page.theme-birthday .links-subtitle:not(.links-subtitle--editable) {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  color: #5a4a6e;
  font-weight: 600;
  letter-spacing: -0.01em;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 92%), rgb(255 244 248 / 88%));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--birthday-rose, #d4788c) 28%, transparent),
    0 4px 12px rgb(212 120 140 / 12%);
}

/* ── 캘린더 전용 생일 테마 (파스텔 배경 + 약한 액센트) ── */
body.calendar-page.theme-birthday {
  --birthday-gold: #c9a24a;
  --birthday-rose: #d4788c;
  --birthday-sky: #7eb6ff;
  --bg: #eef2f8;
  --cal-bg: color-mix(in srgb, #b8c8de 82%, #f4e8d4);
  --cal-border: color-mix(in srgb, #a8bcd4 70%, #c9a24a);
  background:
    radial-gradient(ellipse 90% 55% at 8% 18%, rgb(255 176 200 / 16%), transparent 62%),
    radial-gradient(ellipse 85% 50% at 94% 12%, rgb(255 214 109 / 14%), transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% -8%, rgb(126 182 255 / 14%), transparent 58%),
    linear-gradient(165deg, #eef2f9 0%, #f7f0ea 46%, #eef0f8 100%);
}

body.calendar-page.theme-birthday .calendar-wrap {
  box-shadow:
    var(--shadow),
    0 0 0 1px color-mix(in srgb, var(--birthday-rose, #d4788c) 12%, transparent);
}

body.calendar-page.theme-birthday .header.panel,
body.calendar-page.theme-birthday .calendar-subscribe-panel,
body.calendar-page.theme-birthday .calendar-live-panel {
  border-color: color-mix(in srgb, var(--birthday-gold, #c9a24a) 22%, var(--border, #d7deea));
}

/* 달(월) 표시 박스 — 생일 테마 */
body.calendar-page.theme-birthday .header-month {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--birthday-gold, #c9a24a) 36%, var(--border, #d7deea));
  background:
    linear-gradient(
      165deg,
      rgb(255 252 246 / 96%) 0%,
      rgb(255 244 248 / 92%) 48%,
      rgb(247 239 216 / 90%) 100%
    );
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--birthday-rose, #d4788c) 16%, transparent),
    0 4px 14px rgb(201 162 74 / 12%);
}

body.calendar-page.theme-birthday .header-month .month-title {
  color: #5a4468;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 0 rgb(255 255 255 / 70%);
}

body.calendar-page.theme-birthday .header-month .month-title::before {
  content: "🎂 ";
  font-size: 0.78em;
}

body.calendar-page.theme-birthday .header-month .nav-btn {
  border-color: color-mix(in srgb, var(--birthday-gold, #c9a24a) 40%, var(--border, #d7deea));
  background: color-mix(in srgb, #fff8ef 70%, var(--surface-2, #eef1f8));
  color: #6a5478;
}

body.calendar-page.theme-birthday .header-month .nav-btn:hover {
  border-color: color-mix(in srgb, var(--birthday-rose, #d4788c) 45%, var(--border, #d7deea));
  background: color-mix(in srgb, #ffe8f0 55%, #fff);
}
