/* =============================================================
   wishes.css · "The Wishing Sky" — a sky-lantern guestbook
   Guests write a blessing, sign it, and release a glowing
   kandeel that drifts up into a dusk sky over Lucknow.
   Every wish is kept, so the sky keeps filling across visits.

   Everything is namespaced under .wishes__ so it drops into the
   existing cascade without touching anything else. Colours, type
   and easing all come from the :root tokens in style.css — nothing
   is redefined here. The sky, stars, glow and lanterns are pure
   CSS/SVG — no image assets.
   ============================================================= */

/* ---------- Section shell ---------- */
.wishes {
  background: linear-gradient(180deg, #241f1a, var(--charcoal));
  color: var(--cream);
  overflow: hidden;
}

.wishes__head {
  max-width: 720px;
  margin: 0 auto clamp(2rem, 4vw, 3rem);
  text-align: center;
  position: relative;
  z-index: 3;
}
.wishes__intro {
  margin-top: 1.1rem;
  font-size: clamp(1.05rem, 2.2vw, 1.28rem);
  font-style: italic;
  font-weight: 300;
  color: var(--gold-light);
  opacity: 0.92;
}

/* ---------- The sky stage ---------- */
.wishes__sky {
  position: relative;
  width: 100%;
  min-height: min(78vh, 640px);
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 108%, rgba(195, 155, 82, 0.28), transparent 55%),
    linear-gradient(180deg, #17140f 0%, #241d18 46%, #3a2a1c 82%, #5c3b22 100%);
  border: 1px solid rgba(230, 207, 156, 0.14);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(230, 207, 156, 0.06);
  isolation: isolate;
}

/* CSS-only starfield — echoes the fortune stage, no image assets */
.wishes__sky::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 15% 18%, rgba(230, 207, 156, 0.55) 0 1px, transparent 1px),
    radial-gradient(circle at 82% 14%, rgba(230, 207, 156, 0.45) 0 1px, transparent 1px),
    radial-gradient(circle at 66% 30%, rgba(255, 255, 255, 0.4) 0 1px, transparent 1px),
    radial-gradient(circle at 24% 40%, rgba(230, 207, 156, 0.4) 0 1px, transparent 1px),
    radial-gradient(circle at 90% 42%, rgba(230, 207, 156, 0.28) 0 1px, transparent 1px),
    radial-gradient(circle at 42% 12%, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px),
    radial-gradient(circle at 52% 48%, rgba(230, 207, 156, 0.22) 0 1px, transparent 1px),
    radial-gradient(circle at 8% 55%, rgba(230, 207, 156, 0.3) 0 1px, transparent 1px),
    radial-gradient(circle at 74% 58%, rgba(230, 207, 156, 0.2) 0 1px, transparent 1px);
  animation: wishesTwinkle 6s var(--ease-inout) infinite;
  z-index: 0;
}

/* golden-hour horizon glow hugging the skyline at the bottom */
.wishes__horizon {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34%;
  pointer-events: none;
  background:
    radial-gradient(70% 130% at 50% 100%, rgba(230, 207, 156, 0.5), transparent 70%),
    linear-gradient(180deg, transparent, rgba(181, 98, 63, 0.35) 60%, rgba(195, 155, 82, 0.5));
  z-index: 1;
}

/* a tasteful CSS silhouette of an Awadhi skyline along the horizon */
.wishes__skyline {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 96px;
  pointer-events: none;
  z-index: 2;
  color: #120f0b;
}
.wishes__skyline svg { display: block; width: 100%; height: 100%; }

/* faint shimmer of the palace reflected on the water below */
.wishes__water {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(180deg, rgba(230, 207, 156, 0.12), transparent);
  mix-blend-mode: screen;
}

/* ---------- Lanterns ---------- */
.wishes__lantern {
  position: absolute;
  bottom: -14%;
  left: var(--x, 50%);
  width: calc(30px * var(--scale, 1));
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 4;
  transform: translate(-50%, 0);
  will-change: transform;
  animation: wishesRise var(--dur, 26s) linear var(--delay, 0s) infinite;
}
.wishes__lantern:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 6px;
  border-radius: 12px;
}

/* the swaying happens on an inner wrapper so it composes with the rise */
.wishes__lantern-sway {
  display: block;
  transform-origin: 50% 0;
  animation: wishesSway var(--sway, 7s) var(--ease-inout) var(--delay, 0s) infinite alternate;
}

/* soft halo of light around each lantern */
.wishes__lantern-halo {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 260%;
  height: 220%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, hsla(var(--tint, 38), 85%, 68%, 0.5), transparent 66%);
  animation: wishesGlow calc(var(--sway, 7s) * 0.7) var(--ease-inout) infinite alternate;
}

/* the paper body of the kandeel */
.wishes__lantern-body {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: calc(40px * var(--scale, 1));
  border-radius: 42% 42% 48% 48% / 30% 30% 70% 70%;
  background:
    radial-gradient(60% 42% at 50% 82%, hsla(var(--tint, 38), 95%, 72%, 0.95), transparent 72%),
    linear-gradient(180deg, hsla(var(--tint, 38), 78%, 60%, 0.95), hsla(calc(var(--tint, 38) - 10), 82%, 48%, 0.98));
  box-shadow:
    inset 0 -6px 10px hsla(var(--tint, 38), 90%, 40%, 0.5),
    inset 0 4px 8px rgba(255, 245, 220, 0.55),
    0 0 20px hsla(var(--tint, 38), 90%, 60%, 0.5);
}
/* the little frame ribs top and bottom */
.wishes__lantern-body::before {
  content: "";
  position: absolute;
  top: -3px; left: 18%; right: 18%;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-deep);
  box-shadow: 0 0 6px rgba(230, 207, 156, 0.6);
}

/* the flame flickering inside */
.wishes__lantern-flame {
  width: 22%;
  height: 26%;
  margin-bottom: 12%;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 70%, #fff7e0, #ffcf6e 55%, #ff9d3c 100%);
  box-shadow: 0 0 10px 2px rgba(255, 190, 90, 0.9);
  animation: wishesFlicker 0.5s steps(3, end) infinite;
}

/* the wisp of string / tassel below */
.wishes__lantern-body::after {
  content: "";
  position: absolute;
  bottom: -8px; left: 50%;
  width: 2px; height: 9px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--gold-deep), transparent);
}

/* the signed name rides just under the glow */
.wishes__lantern-name {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-light);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  opacity: 0.85;
  pointer-events: none;
}

/* a freshly released lantern launches from the form before it joins the drift */
.wishes__lantern.is-launching {
  animation: wishesLaunch 2.8s var(--ease-out) both;
}

/* ---------- Reading popover (fallback if WED.openModal is absent) ---------- */
.wishes__popover {
  position: fixed;
  z-index: 60;
  max-width: min(320px, 82vw);
  padding: 1.15rem 1.3rem 1.25rem;
  background: var(--cream);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.28s var(--ease-out), transform 0.28s var(--ease-out);
  text-align: left;
}
.wishes__popover.is-open { opacity: 1; transform: translateY(0) scale(1); }
.wishes__popover::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg, var(--gold-light), var(--gold-deep), var(--terracotta));
  opacity: 0.8;
}
.wishes__popover-text {
  font-size: 1.12rem;
  line-height: 1.5;
  font-style: italic;
  margin: 0.2rem 0 0.7rem;
}
.wishes__popover-name {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.wishes__popover-close {
  position: absolute;
  top: 0.4rem; right: 0.6rem;
  width: 1.8rem; height: 1.8rem;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}
.wishes__popover-close:hover { color: var(--terracotta); }
.wishes__popover-close:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
.wishes__popover-scrim {
  position: fixed;
  inset: 0;
  z-index: 59;
  background: transparent;
}

/* ---------- Form ---------- */
.wishes__form {
  position: relative;
  z-index: 5;
  max-width: 560px;
  margin: clamp(1.8rem, 4vw, 2.6rem) auto 0;
  background: rgba(28, 25, 22, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(230, 207, 156, 0.18);
  border-radius: 16px;
  padding: clamp(1.4rem, 3vw, 2rem);
  box-shadow: var(--shadow-lg);
}

.wishes__field { position: relative; margin-bottom: 1.2rem; }
.wishes__field:last-of-type { margin-bottom: 1.4rem; }

.wishes__label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 0.5rem;
}

.wishes__textarea,
.wishes__input {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  color: var(--cream);
  background: rgba(251, 247, 240, 0.06);
  border: 1px solid rgba(230, 207, 156, 0.28);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  transition: border-color 0.3s var(--ease-out), background 0.3s var(--ease-out),
              box-shadow 0.3s var(--ease-out);
}
.wishes__textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.5;
}
.wishes__textarea::placeholder,
.wishes__input::placeholder { color: rgba(251, 247, 240, 0.4); font-style: italic; }
.wishes__textarea:focus,
.wishes__input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(251, 247, 240, 0.1);
  box-shadow: 0 0 0 3px rgba(195, 155, 82, 0.18);
}

/* the gentle nudge when the wish is empty — mirrors fortune.js's wiggle */
.wishes__field.is-nudged .wishes__textarea {
  border-color: var(--terracotta);
  animation: wishesNudge 0.4s var(--ease-out);
}

.wishes__counter {
  display: block;
  margin-top: 0.4rem;
  text-align: right;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  opacity: 0.7;
}
.wishes__counter.is-limit { color: var(--terracotta); opacity: 1; }

.wishes__form .btn { width: 100%; justify-content: center; }

.wishes__count {
  display: block;
  margin: 1.3rem auto 0;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-light);
  position: relative;
  z-index: 5;
}
.wishes__count b { color: var(--cream); font-weight: 600; }

/* ---------- Keyframes ---------- */
@keyframes wishesRise {
  0%   { transform: translate(-50%, 0); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translate(-50%, -128vh); opacity: 0; }
}
@keyframes wishesSway {
  from { transform: translateX(calc(var(--drift, 12px) * -1)) rotate(-2deg); }
  to   { transform: translateX(var(--drift, 12px)) rotate(2deg); }
}
@keyframes wishesGlow {
  from { opacity: 0.55; transform: translate(-50%, -50%) scale(0.94); }
  to   { opacity: 0.9;  transform: translate(-50%, -50%) scale(1.08); }
}
@keyframes wishesFlicker {
  0%, 100% { transform: scaleY(1)    translateX(0);    opacity: 1; }
  33%      { transform: scaleY(0.86) translateX(-0.5px); opacity: 0.9; }
  66%      { transform: scaleY(1.08) translateX(0.5px);  opacity: 1; }
}
@keyframes wishesTwinkle {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.55; }
}
@keyframes wishesLaunch {
  0%   { bottom: 8%;  opacity: 0; transform: translate(-50%, 40px) scale(0.7); }
  14%  { opacity: 1; }
  100% { bottom: 70%; opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes wishesNudge {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

/* ---------- Pause when offscreen / tab hidden (perf) ---------- */
.wishes__sky.is-paused .wishes__lantern,
.wishes__sky.is-paused .wishes__lantern-sway,
.wishes__sky.is-paused .wishes__lantern-halo,
.wishes__sky.is-paused .wishes__lantern-flame,
.wishes__sky.is-paused::before {
  animation-play-state: paused;
}

/* ---------- Static cluster for reduced motion ---------- */
.wishes__sky.wishes__sky--static {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: clamp(1.6rem, 5vw, 3rem) clamp(1.4rem, 5vw, 2.6rem);
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem 5rem;
}
.wishes__sky--static .wishes__lantern {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  animation: none;
  margin-top: 1.4rem;
}
.wishes__sky--static .wishes__lantern-sway { animation: none; }
.wishes__sky--static .wishes__lantern-halo { animation: none; opacity: 0.7; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .wishes__sky { min-height: 62vh; border-radius: 16px; }
  .wishes__skyline { height: 66px; }
  .wishes__form { border-radius: 14px; }
  .wishes__lantern-name { font-size: 0.55rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .wishes__sky::before,
  .wishes__lantern,
  .wishes__lantern-sway,
  .wishes__lantern-halo,
  .wishes__lantern-flame,
  .wishes__lantern.is-launching {
    animation: none !important;
  }
  .wishes__textarea,
  .wishes__input,
  .wishes__popover { transition: none !important; }
  .wishes__field.is-nudged .wishes__textarea { animation: none !important; }
}
