/* Perfect Living Spot — palm flow styles
   Accuracy ball, coach bubble, palm viewfinder, camera + analysis overlays.
   Matches the base design system in styles.css (dark navy / gold serif / teal). */

/* ---------- accuracy ball ---------- */
.ball-wrap { text-align: center; padding: 6px 0 2px; }
.ball-stage {
  position: relative;
  width: 228px; height: 228px;
  margin: 10px auto 20px;
}
.ball-stage canvas { width: 100%; height: 100%; display: block; }
.ball-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 46px; color: #fff;
  text-shadow: 0 2px 16px #000a;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ball-stage.full { animation: ballGlow 2.8s ease-in-out infinite; }
@keyframes ballGlow {
  0%, 100% { filter: drop-shadow(0 0 18px #2fd6c088); }
  50%      { filter: drop-shadow(0 0 42px #7c3aedaa); }
}

/* ---------- coach bubble ---------- */
.coach {
  display: flex; gap: 10px; align-items: flex-end;
  margin: 6px auto 4px; max-width: 350px; text-align: left;
}
.coach .avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  border: 1px solid var(--gold-dim);
  background: radial-gradient(circle at 35% 30%, #1c2456, #0a0e2c);
  overflow: hidden;
}
.coach .avatar img { width: 100%; height: 100%; object-fit: cover; }
.bubble {
  background: #f6eeda; color: #3a3350;
  border-radius: 16px 16px 16px 5px;
  padding: 12px 14px;
  font-size: 14.5px; line-height: 1.5;
  box-shadow: 0 10px 26px -12px #000c;
  min-height: 24px; min-width: 54px;
}
.bubble.pop { animation: bubblePop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes bubblePop {
  from { opacity: 0; transform: scale(0.72) translateY(10px); }
}
.typing { display: inline-flex; gap: 5px; padding: 5px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8b91bd; opacity: 0.5;
  animation: tpDot 1s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tpDot {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  40%      { transform: translateY(-5px); opacity: 1; }
}

/* ---------- palm viewfinder ---------- */
.vf-caption { color: var(--ink-dim); font-size: 14px; margin: 2px 0 0; }
.vf-wrap { position: relative; width: 300px; margin: 10px auto 6px; }
.pf-note {
  font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 1.5px;
  text-align: center; margin-bottom: 8px;
}
.vf {
  position: relative;
  width: 210px; height: 280px;
  margin: 0 auto;
}
.vf svg.palm { position: absolute; inset: 0; width: 100%; height: 100%; }
.vf .palm-outline {
  fill: none; stroke: #e9c979; stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px #e9c97955);
  stroke-dasharray: 1500; stroke-dashoffset: 1500;
}
.vf .pfline {
  fill: none; stroke-width: 3; stroke-linecap: round;
  opacity: 0;
  stroke-dasharray: 320; stroke-dashoffset: 320;
}
.vf .pfline.l1 { stroke: #ff8fa3; }
.vf .pfline.l2 { stroke: #f5c518; }
.vf .pfline.l3 { stroke: #2fd6c0; }
.vf .pfline.l4 { stroke: #a78bfa; }
.vf .corner {
  position: absolute; width: 32px; height: 32px;
  border: 3px solid var(--teal); opacity: 0.95;
  filter: drop-shadow(0 0 6px #2fd6c088);
}
.vf .c-tl { top: -6px; left: -6px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.vf .c-tr { top: -6px; right: -6px; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.vf .c-bl { bottom: -6px; left: -6px; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.vf .c-br { bottom: -6px; right: -6px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.vf .scanline {
  position: absolute; left: 4%; right: 4%; top: 8%; height: 3px;
  background: linear-gradient(90deg, transparent, var(--teal) 18%, #d6fff7 50%, var(--teal) 82%, transparent);
  box-shadow: 0 0 16px 3px #2fd6c099;
  border-radius: 3px;
  animation: scanY 3.4s ease-in-out infinite;
}
@keyframes scanY {
  0%, 100% { top: 7%; }
  50%      { top: 89%; }
}
/* draw-on choreography, triggered by .play on .vf-wrap */
.vf-wrap.play .palm-outline { animation: drawOn 2.4s ease forwards; }
.vf-wrap.play .pfline { opacity: 1; animation: drawOn 0.9s ease forwards; }
.vf-wrap.play .pfline.l1 { animation-delay: 1.7s; }
.vf-wrap.play .pfline.l2 { animation-delay: 2.0s; }
.vf-wrap.play .pfline.l3 { animation-delay: 2.3s; }
.vf-wrap.play .pfline.l4 { animation-delay: 2.6s; }
@keyframes drawOn { to { stroke-dashoffset: 0; } }
.vf-wrap.play .scanline { animation: scanY 3.4s ease-in-out infinite; }

/* country pills */
.pill {
  position: absolute; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  background: #12173dee; border: 1px solid #ffffff2e;
  border-radius: 999px; padding: 6px 11px;
  font-size: 12px; color: var(--cream);
  box-shadow: 0 8px 20px -8px #000c;
  opacity: 0; transform: translateY(10px); white-space: nowrap;
}
.vf-wrap.play .pill { animation: pillIn 0.5s ease forwards; }
.vf-wrap.play .pill.p1 { animation-delay: 0.5s; }
.vf-wrap.play .pill.p2 { animation-delay: 0.8s; }
.vf-wrap.play .pill.p3 { animation-delay: 1.1s; }
.vf-wrap.play .pill.p4 { animation-delay: 1.4s; }
.vf-wrap.play .pill.p5 { animation-delay: 1.7s; }
@keyframes pillIn { to { opacity: 1; transform: translateY(0); } }
.pill.p1 { top: 26px; left: 50%; transform: translate(-50%, 10px); }
.vf-wrap.play .pill.p1 { animation-name: pillInC; }
@keyframes pillInC { to { opacity: 1; transform: translate(-50%, 0); } }
.pill.p2 { top: 110px; left: -4px; }
.pill.p3 { top: 110px; right: -4px; }
.pill.p4 { bottom: 44px; left: -2px; }
.pill.p5 { bottom: 44px; right: -2px; }

/* ---------- camera overlay ---------- */
.cam-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: #000; display: none;
}
.cam-overlay.open { display: block; animation: stepIn 0.25s ease; }
.cam-overlay video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #0a0e2c;
}
.cam-guide {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.cam-guide svg {
  width: 64%; max-width: 300px;
  opacity: 0.9; filter: drop-shadow(0 0 8px #000c);
}
.cam-guide .palm-outline { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.cam-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0;
  display: flex; justify-content: flex-start;
}
.cam-back {
  background: #000a; color: #fff; border: 1px solid #ffffff33;
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 18px; cursor: pointer;
}
.cam-hint {
  position: absolute; left: 0; right: 0; bottom: 128px;
  text-align: center; color: #fff; font-size: 14px;
  padding: 0 36px; text-shadow: 0 1px 10px #000;
}
.cam-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 30px calc(env(safe-area-inset-bottom, 0px) + 30px);
  display: flex; align-items: center; justify-content: space-between;
}
.cam-flash {
  width: 48px; height: 48px; border-radius: 50%;
  background: #ffffff1c; color: #fff; font-size: 21px;
  border: 1px solid #ffffff44; cursor: pointer;
}
.cam-flash.on { background: var(--teal); color: #06231f; border-color: var(--teal); }
.cam-shutter {
  width: 76px; height: 76px; border-radius: 50%;
  border: 5px solid #fff; background: var(--teal);
  cursor: pointer; box-shadow: 0 0 0 6px #ffffff22, 0 8px 30px #000a;
  transition: transform 0.1s;
}
.cam-shutter:active { transform: scale(0.92); }
.cam-spacer { width: 48px; }
.cam-flashbang {
  position: absolute; inset: 0; background: #fff;
  opacity: 0; pointer-events: none;
}
.cam-flashbang.go { animation: flashBang 0.35s ease; }
@keyframes flashBang { 15% { opacity: 0.85; } 100% { opacity: 0; } }
.cam-fallback {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: #070a22; padding: 32px; text-align: center; gap: 14px;
}
.cam-overlay.nocam .cam-fallback { display: flex; }
.cam-overlay.nocam video, .cam-overlay.nocam .cam-guide,
.cam-overlay.nocam .cam-hint, .cam-overlay.nocam .cam-bar { display: none; }
.cam-fallback p { color: var(--ink-dim); font-size: 15px; max-width: 300px; }

/* ---------- analysis overlay ---------- */
.an-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: #070a22f7;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 24px calc(env(safe-area-inset-bottom, 0px) + 28px);
}
.an-overlay.open { display: flex; animation: stepIn 0.25s ease; }
.an-photo-wrap {
  position: relative;
  width: min(76vw, 290px);
  border-radius: 18px; overflow: hidden;
  border: 1px solid #ffffff2e;
  box-shadow: 0 24px 70px -20px #000;
  background: #0a0e2c;
}
.an-photo-wrap img { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.an-band {
  position: absolute; left: 0; right: 0; top: -32%; height: 30%;
  background: linear-gradient(180deg, transparent, #2fd6c04d 28%, #2fd6c0d9 50%, #2fd6c04d 72%, transparent);
  pointer-events: none;
}
.an-overlay.sweep .an-band { animation: bandSweep 3.4s linear forwards; }
@keyframes bandSweep { to { top: 108%; } }
.an-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.an-lines path {
  fill: none; stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 200; stroke-dashoffset: 200; opacity: 0;
  filter: drop-shadow(0 0 5px currentColor);
}
.an-overlay.lines .an-lines path { animation: drawOn 1s ease forwards; }
.an-overlay.lines .an-lines path.l1 { stroke: #ff8fa3; color: #ff8fa3; animation-delay: 0.1s; }
.an-overlay.lines .an-lines path.l2 { stroke: #f5c518; color: #f5c518; animation-delay: 0.5s; }
.an-overlay.lines .an-lines path.l3 { stroke: #2fd6c0; color: #2fd6c0; animation-delay: 0.9s; }
.an-overlay.lines .an-lines path.l4 { stroke: #a78bfa; color: #a78bfa; animation-delay: 1.3s; }
.an-dots i {
  position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 10px #fff, 0 0 20px #2fd6c0;
  transform: scale(0);
}
.an-overlay.dots .an-dots i { animation: dotPop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) forwards; }
.an-dots i:nth-child(1) { left: 16%; top: 7%; animation-delay: 0s; }
.an-dots i:nth-child(2) { left: 33%; top: 3%; animation-delay: 0.15s; }
.an-dots i:nth-child(3) { left: 50%; top: 2%; animation-delay: 0.3s; }
.an-dots i:nth-child(4) { left: 67%; top: 4%; animation-delay: 0.45s; }
.an-dots i:nth-child(5) { left: 83%; top: 9%; animation-delay: 0.6s; }
@keyframes dotPop { to { transform: scale(1); } }
.an-pct {
  font-family: var(--serif); font-size: 42px; color: var(--cream);
  margin-top: 20px; font-variant-numeric: tabular-nums;
}
.an-bar {
  width: min(76vw, 290px); height: 8px; border-radius: 8px;
  background: #ffffff1c; overflow: hidden; margin-top: 12px;
}
.an-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  border-radius: 8px; transition: width 0.35s ease;
}
.an-status {
  font-family: var(--serif); font-size: 16px; color: var(--gold);
  margin-top: 12px; min-height: 26px; text-align: center;
  transition: opacity 0.3s;
}
.an-skip { margin-top: 18px; }

/* ---------- email gate: blurred report + frosted card ---------- */
.report-blur {
  filter: blur(7px); opacity: 0.55;
  pointer-events: none; user-select: none; -webkit-user-select: none;
}
.gate-card {
  position: relative;
  background: #12173df2;
  border: 1px solid #ffffff2a;
  border-radius: 20px;
  padding: 20px 18px;
  margin-top: -26px;
  box-shadow: 0 24px 60px -18px #000;
}
.gate-card .lbl:first-child { margin-top: 0; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .vf .scanline, .ball-stage.full,
  .typing i, .chart-wheel, .chart-wheel::after { animation: none !important; }
  .vf-wrap.play .palm-outline, .vf-wrap.play .pfline,
  .an-overlay.lines .an-lines path { animation-duration: 0.01s !important; animation-delay: 0s !important; }
  .vf-wrap.play .pill, .an-overlay.dots .an-dots i { animation-duration: 0.01s !important; }
  .an-overlay.sweep .an-band { animation: none !important; top: 40%; }
  .step, .bubble.pop { animation-duration: 0.01s !important; }
}
