/* =============================================================
   fortune.css · "Wedding Fortune Teller" mini-feature
   A glowing CSS crystal ball + a form that hands back a
   personalised (but deterministic) prophecy for the guest.
   Everything here is namespaced under .fortune / .fortune__*
   so it can't collide with the rest of the site's styles.
   Uses only the design tokens already defined on :root.
   ============================================================= */

.fortune {
  background: linear-gradient(180deg, var(--cream-2), var(--cream));
}

.fortune__head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto clamp(3rem, 6vw, 4.5rem);
}
.fortune__intro {
  margin-top: 1.2rem;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 1.15rem;
  font-weight: 300;
}

/* ============================================================
   PANEL  ·  split layout, dark "stage" + cream form box
   ============================================================ */
.fortune__panel {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.fortune__stage {
  position: relative;
  background: linear-gradient(165deg, #38302a, var(--charcoal));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(2.5rem, 5vw, 4rem) clamp(1.5rem, 3vw, 2.5rem);
  overflow: hidden;
}
/* a scattering of tiny fixed "stars" behind the ball — no image assets */
.fortune__stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(230, 207, 156, 0.55) 0 1px, transparent 1px),
    radial-gradient(circle at 82% 16%, rgba(230, 207, 156, 0.4) 0 1px, transparent 1px),
    radial-gradient(circle at 66% 72%, rgba(230, 207, 156, 0.3) 0 1px, transparent 1px),
    radial-gradient(circle at 24% 82%, rgba(230, 207, 156, 0.4) 0 1px, transparent 1px),
    radial-gradient(circle at 90% 55%, rgba(230, 207, 156, 0.25) 0 1px, transparent 1px),
    radial-gradient(circle at 42% 40%, rgba(230, 207, 156, 0.2) 0 1px, transparent 1px);
  pointer-events: none;
}

.fortune__box {
  background: var(--cream);
  padding: clamp(2.5rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

/* ============================================================
   CRYSTAL BALL  ·  pure CSS, radial gradients + a bit of glass
   ============================================================ */
.fortune__orb-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.fortune__orb-halo {
  position: absolute;
  top: 46%;
  left: 50%;
  width: clamp(200px, 38vw, 300px);
  height: clamp(200px, 38vw, 300px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(195, 155, 82, 0.4), transparent 70%);
  filter: blur(6px);
  animation: fortuneBreathe 5s ease-in-out infinite;
  z-index: 0;
}

.fortune__orb {
  position: relative;
  width: clamp(150px, 30vw, 230px);
  height: clamp(150px, 30vw, 230px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.9), rgba(230, 207, 156, 0.4) 22%,
      rgba(195, 155, 82, 0.3) 46%, rgba(139, 105, 58, 0.55) 74%, rgba(28, 25, 22, 0.78) 100%);
  box-shadow:
    0 0 60px 8px rgba(195, 155, 82, 0.35),
    0 0 120px 40px rgba(195, 155, 82, 0.12),
    inset 0 -22px 40px rgba(28, 25, 22, 0.45),
    inset 0 18px 30px rgba(255, 255, 255, 0.28);
  animation: fortuneFloat 6s ease-in-out infinite;
  z-index: 1;
}

/* a soft rotating wisp of "vapour" trapped inside the glass */
.fortune__orb-mist {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    transparent 0deg, rgba(255, 255, 255, 0.35) 60deg, transparent 140deg,
    rgba(230, 207, 156, 0.4) 220deg, transparent 300deg);
  mix-blend-mode: overlay;
  opacity: 0.85;
  animation: fortuneMistSpin 18s linear infinite;
}

/* glassy shine, top-left, like light catching the surface */
.fortune__orb-highlight {
  position: absolute;
  top: 12%;
  left: 16%;
  width: 36%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.92), transparent 70%);
  filter: blur(1px);
  transform: rotate(-18deg);
}

.fortune__spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 8px 2px rgba(230, 207, 156, 0.8);
  animation: fortuneTwinkle 2.6s ease-in-out infinite;
}
.fortune__spark--1 { top: 4%;  left: 68%; animation-delay: 0s; }
.fortune__spark--2 { top: 72%; left: 84%; width: 4px; height: 4px; animation-delay: .5s; }
.fortune__spark--3 { top: 88%; left: 28%; animation-delay: 1s; }
.fortune__spark--4 { top: 18%; left: 4%;  width: 5px; height: 5px; animation-delay: 1.5s; }
.fortune__spark--5 { top: 44%; left: 94%; width: 3px; height: 3px; animation-delay: 2s; }

/* grounding shadow + pedestal so the ball reads as "resting", not floating in space */
.fortune__orb-shadow {
  width: 58%;
  max-width: 150px;
  height: 18px;
  margin: -4px auto 0;
  background: radial-gradient(ellipse at center, rgba(28, 25, 22, 0.5), transparent 75%);
  filter: blur(2px);
  border-radius: 50%;
}
.fortune__orb-stand {
  position: relative;
  width: 56%;
  max-width: 140px;
  height: 30px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-deep));
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  box-shadow: var(--shadow-sm);
}
.fortune__orb-stand::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 8%;
  width: 84%;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent);
}
.fortune__orb-base {
  width: 74%;
  max-width: 176px;
  height: 10px;
  margin: 4px auto 0;
  background: var(--gold-deep);
  border-radius: 6px;
  opacity: 0.85;
}

.fortune__stage-caption {
  margin-top: 1.4rem;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  color: var(--gold-light);
  text-align: center;
}

/* ---------- casting state — the ball swirls while the fortune "loads" ---------- */
.fortune__orb-wrap.is-casting .fortune__orb-halo { animation: fortuneHaloBurst 1.1s var(--ease-out); }
.fortune__orb-wrap.is-casting .fortune__orb { animation: fortuneSwirl 1.1s var(--ease-inout); }
.fortune__orb-wrap.is-casting .fortune__orb-mist { animation: fortuneMistSpin 1.1s linear; }

/* ============================================================
   FORM
   ============================================================ */
.fortune__form { display: flex; flex-direction: column; }

.fortune__field { position: relative; margin-bottom: 1.7rem; }
.fortune__field input {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.9rem 0.2rem;
  border-radius: 0;
  transition: border-color 0.4s;
}
.fortune__field input:focus { outline: none; border-color: var(--gold-deep); }
/* Direct child only — the choice chips below are <label>s too, and an
   unscoped rule stacks them all at this same absolute position. */
.fortune__field > label {
  position: absolute;
  left: 0.2rem;
  top: 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  pointer-events: none;
  transform-origin: left;
  transition: transform 0.35s var(--ease-out), color 0.35s;
}
.fortune__field input:focus + label,
.fortune__field input:not(:placeholder-shown) + label {
  transform: translateY(-1.7rem) scale(0.82);
  color: var(--gold-deep);
}

/* gentle nudge instead of a hard error — the name field just gets a soft wiggle */
.fortune__hint {
  display: block;
  min-height: 1rem;
  margin-top: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--gold-deep);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s, transform 0.3s;
}
.fortune__field.is-nudged .fortune__hint { opacity: 1; transform: translateY(0); }
.fortune__field.is-nudged input { border-color: var(--gold); animation: fortuneNudge 0.4s var(--ease-out); }

.fortune__field--choice { border: 0; padding: 0; margin: 0 0 1.9rem; }
.fortune__legend {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.8rem;
}

.fortune__choice {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.fortune__opt { position: relative; flex: 1; min-width: 130px; }
.fortune__opt input { position: absolute; opacity: 0; pointer-events: none; }
.fortune__opt span {
  display: block;
  text-align: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.35s var(--ease-out);
}
.fortune__opt:hover span { border-color: var(--gold); color: var(--ink); }
.fortune__opt input:checked + span {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: var(--cream);
}
.fortune__opt input:focus-visible + span {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

.fortune__form .btn { align-self: flex-start; margin-top: 0.3rem; }
.fortune .btn:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

.fortune__note {
  margin-top: 1.1rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 300;
}

/* ============================================================
   RESULT  ·  the fortune card
   ============================================================ */
/* The result region stays mounted at all times (never display:none) so its
   aria-live="polite" announcement actually fires when the text changes —
   it's just visually collapsed via max-height until a fortune exists,
   the same trick the RSVP form uses for its conditional fields. */
.fortune__result {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.7s var(--ease-inout), opacity 0.5s;
}
.fortune__box.is-revealed .fortune__form { display: none; }
.fortune__box.is-revealed .fortune__result { max-height: 900px; opacity: 1; }

.fortune__card {
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(1.8rem, 4vw, 2.6rem);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.fortune__card.is-visible { opacity: 1; transform: translateY(0); }

.fortune__card-header {
  font-family: var(--font-script);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  color: var(--gold-deep);
  margin-bottom: 1.1rem;
  line-height: 1.1;
}
.fortune__line {
  font-size: 1.1rem;
  color: var(--ink);
  line-height: 1.55;
  margin-bottom: 0.9rem;
}
.fortune__line:last-child {
  margin-bottom: 0;
  font-style: italic;
  color: var(--ink-soft);
}

.fortune__actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1.7rem;
}
.fortune__copied {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--sage);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.3s, transform 0.3s;
}
.fortune__copied.is-visible { opacity: 1; transform: translateY(0); }

/* ============================================================
   RESPONSIVE  ·  ball stacks above the form on narrow screens
   ============================================================ */
@media (max-width: 720px) {
  .fortune__panel { grid-template-columns: 1fr; border-radius: 14px; }
  .fortune__stage { padding: 2.4rem 1.5rem; }
  .fortune__box { padding: 2.2rem 1.6rem; }
  .fortune__opt { min-width: 100%; }
  .fortune__actions { flex-direction: column; align-items: stretch; }
  .fortune__actions .btn { width: 100%; justify-content: center; }
  .fortune__copied { text-align: center; }
}

@media (max-width: 400px) {
  .fortune__stage-caption { font-size: 1.3rem; }
}

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes fortuneFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}
@keyframes fortuneBreathe {
  0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.08); }
}
@keyframes fortuneHaloBurst {
  0%   { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
  40%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.35); }
  100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
}
@keyframes fortuneSwirl {
  0%   { transform: translateY(-6px)  scale(1)    rotate(0deg);  filter: brightness(1)    saturate(1); }
  30%  { transform: translateY(-10px) scale(1.07) rotate(10deg); filter: brightness(1.3)  saturate(1.35); }
  60%  { transform: translateY(-4px)  scale(0.95) rotate(-8deg); filter: brightness(1.45) saturate(1.4); }
  100% { transform: translateY(-6px)  scale(1)    rotate(0deg);  filter: brightness(1)    saturate(1); }
}
@keyframes fortuneMistSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fortuneTwinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1.15); }
}
@keyframes fortuneNudge {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ============================================================
   REDUCED MOTION  ·  keep the magic, lose the movement
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .fortune__orb,
  .fortune__orb-halo,
  .fortune__orb-mist,
  .fortune__spark,
  .fortune__field.is-nudged input {
    animation: none !important;
  }
  .fortune__card {
    transition-duration: 0.001ms;
  }
}
