:root {
  --mx: 0; /* pointer x, -1..1 (set by script.js) */
  --my: 0; /* pointer y, -1..1 */
  --sy: 0; /* scroll progress, 0..1 */
  --bg: #0a0a0a;
  --ink: #f4efe9;
  --muted: #a39a92;
  --sun: #ff3d12;
  --sun-2: #ff6a2b;
  --card: rgba(20, 18, 17, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --radius: 24px;
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow-x: clip; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* ---------- Backdrop ---------- */
/* Glow lives inside .hero so it scrolls with the logo instead of staying pinned */
.sun {
  position: absolute;
  width: min(160vw, 1000px);
  aspect-ratio: 1;
  left: 50%;
  top: calc(var(--avatar-size) / 2);
  transform: translate(-50%, -50%);
  translate: calc(var(--mx) * 140px) calc(var(--my) * 120px + var(--sy) * -160px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 61, 18, 0.24), rgba(255, 61, 18, 0.06) 45%, transparent 68%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
  animation: breathe 8s ease-in-out infinite;
}

/* Moving background light: blobs drift with the pointer and scroll at different depths */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  will-change: translate;
}

.b1 {
  width: 55vmax; height: 55vmax;
  left: -18vmax; top: 35%;
  background: radial-gradient(circle, rgba(255, 61, 18, 0.28), transparent 65%);
  translate: calc(var(--mx) * 90px) calc(var(--my) * 70px + var(--sy) * -220px);
}

.b2 {
  width: 45vmax; height: 45vmax;
  right: -15vmax; top: -10%;
  background: radial-gradient(circle, rgba(255, 106, 43, 0.22), transparent 65%);
  translate: calc(var(--mx) * -110px) calc(var(--my) * -80px + var(--sy) * 260px);
}

.b3 {
  width: 40vmax; height: 40vmax;
  right: 5%; bottom: -20vmax;
  background: radial-gradient(circle, rgba(140, 20, 5, 0.35), transparent 65%);
  translate: calc(var(--mx) * 60px) calc(var(--my) * -100px + var(--sy) * -160px);
}

/* tighter halo around the logo, swings further than the big glow for depth */
.sun::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 90, 40, 0.45), transparent 65%);
  filter: blur(10px);
  translate: calc(var(--mx) * 120px) calc(var(--my) * 100px + var(--sy) * -60px);
}

.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-5%, 3%); }
  40% { transform: translate(3%, -6%); }
  60% { transform: translate(-7%, -2%); }
  80% { transform: translate(5%, 5%); }
  100% { transform: translate(0, 0); }
}

/* ---------- Layout ---------- */
.wrap {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vh, 48px);
  padding: clamp(32px, 6vh, 64px) 20px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Hero ---------- */
.hero {
  --avatar-size: clamp(170px, 42vw, 240px);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  animation: rise 0.9s cubic-bezier(.2,.8,.2,1) both;
}

.avatar-wrap {
  position: relative;
  z-index: 2;
  perspective: 700px;
}

.avatar-ring {
  /* reset button styles */
  appearance: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: block;
  -webkit-tap-highlight-color: transparent;
  --rx: 0deg;
  --ry: 0deg;
  --lift: 1;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--lift));
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.25s ease-out;
  position: relative;
  z-index: 1;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  padding: 4px;
  /* shadow drifts opposite the pointer / with scroll, like a light source moving */
  box-shadow:
    0 0 0 8px rgba(255, 61, 18, 0.06),
    calc(var(--mx) * -45px) calc(20px + var(--my) * -45px + var(--sy) * 40px) 80px -10px rgba(255, 61, 18, 0.7),
    calc(var(--mx) * -22px) calc(var(--my) * -22px) 36px -4px rgba(255, 106, 43, 0.45);
}

/* spinning gradient border sits on a pseudo-element so the image itself never rotates */
.avatar-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--sun), #2a0d06, var(--sun-2), #2a0d06, var(--sun));
  animation: spin 14s linear infinite;
}

.avatar-clip {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  border: 4px solid var(--bg);
}

.avatar {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* zoom slightly from the top edge so a bit of the bottom gets cropped */
  transform: scale(1.1);
  transform-origin: 50% 12%;
  filter: saturate(1.18) contrast(1.08) brightness(1.1);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Logo hover / click ---------- */
.avatar-ring:hover,
.avatar-ring:focus-visible { --lift: 1.06; outline: none; }
.avatar-ring.tilting { transition: transform 0.08s linear, box-shadow 0.25s ease-out; }

.avatar-ring:hover::before,
.avatar-ring:focus-visible::before {
  filter: brightness(1.35) saturate(1.2);
  box-shadow: 0 0 40px 6px rgba(255, 61, 18, 0.55);
}
.avatar-ring::before { transition: filter 0.3s, box-shadow 0.3s; }

.avatar { transition: transform 0.5s cubic-bezier(.2,.8,.2,1), filter 0.3s; }
.avatar-ring:hover .avatar,
.avatar-ring:focus-visible .avatar {
  transform: scale(1.16);
  filter: saturate(1.3) contrast(1.1) brightness(1.18);
}

/* expanding rings that pulse out while hovered */
.ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--sun);
  opacity: 0;
  pointer-events: none;
}
.avatar-ring:hover .ripple,
.avatar-ring:focus-visible .ripple { animation: ripple 1.8s ease-out infinite; }
.avatar-ring:hover .r2,
.avatar-ring:focus-visible .r2 { animation-delay: 0.9s; }

@keyframes ripple {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.45); opacity: 0; }
}

.avatar-ring.pecked { animation: peck 0.45s cubic-bezier(.3,1.6,.5,1); }
@keyframes peck {
  0% { transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--lift)); }
  35% { transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(0.92) rotate(-6deg); }
  100% { transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--lift)); }
}

/* speech bubble */
.bubble {
  position: absolute;
  left: 72%;
  bottom: 86%;
  z-index: 3;
  white-space: nowrap;
  padding: 10px 16px;
  border-radius: 18px 18px 18px 4px;
  background: #fff;
  color: #111;
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: clamp(0.85rem, 3.2vw, 1rem);
  letter-spacing: 0.02em;
  box-shadow: 0 12px 30px -8px rgba(255, 61, 18, 0.6);
  transform-origin: 0% 100%;
  transform: scale(0.4) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(.3,1.6,.5,1), opacity 0.2s ease;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 6px;
  bottom: -8px;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-left-color: #fff;
  border-bottom: 0;
}
.bubble.show { opacity: 1; transform: scale(1) translateY(0); }

/* ---------- Angry crow ---------- */
.bubble.angry {
  background: var(--sun);
  color: #fff;
  box-shadow: 0 12px 34px -6px rgba(255, 61, 18, 0.9);
}
.bubble.angry::after { border-top-color: var(--sun); border-left-color: var(--sun); }
.bubble.angry.show { animation: rage 0.12s linear 6 0.35s; }

.angry-face {
  position: relative;
  display: inline-block;
  font-size: 1.35em;
  margin-left: 4px;
  vertical-align: -0.12em;
}

/* steam puffs blowing out of the nose, left and right */
.fume {
  position: absolute;
  top: 58%;
  left: 50%;
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  opacity: 0;
  pointer-events: none;
}
.f1 { --dx: -1.3em; animation: fume 0.9s ease-out infinite; }
.f2 { --dx: 1.3em;  animation: fume 0.9s ease-out infinite 0.3s; }
.f3 { --dx: -0.9em; animation: fume 0.9s ease-out infinite 0.6s; }

@keyframes fume {
  0%   { transform: translate(-50%, 0) scale(0.3); opacity: 0.95; }
  100% { transform: translate(calc(-50% + var(--dx)), 0.35em) scale(1.6); opacity: 0; }
}

@keyframes rage {
  0%, 100% { translate: 0 0; }
  25% { translate: -3px 1px; }
  75% { translate: 3px -1px; }
}

.avatar-ring.angry .avatar { filter: saturate(1.6) contrast(1.2) brightness(1.05) hue-rotate(-8deg); }
.avatar-ring.angry::before { animation-duration: 1.2s; filter: brightness(1.5); }
.avatar-ring.angry .ripple { animation: ripple 0.6s ease-out infinite; border-color: #ff2200; }
.avatar-ring.angry.pecked { animation: peck 0.45s cubic-bezier(.3,1.6,.5,1), shake 0.08s linear 8; }
@keyframes shake {
  0%, 100% { translate: 0 0; }
  50% { translate: 4px 0; }
}

@media (max-width: 420px) {
  .bubble { left: 58%; bottom: 92%; }
}

.title {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1;
}

.brand {
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: clamp(2.4rem, 9vw, 4.2rem);
  letter-spacing: -0.03em;
  color: #ffffff;
  text-shadow:
    calc(var(--mx) * -6px) calc(var(--my) * -6px + var(--sy) * 4px) 22px rgba(255, 61, 18, 0.6),
    0 0 2px rgba(255, 255, 255, 0.3);
}

.tagline {
  font-size: clamp(1rem, 3.6vw, 1.3rem);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---------- Card ---------- */
.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(22px, 5vw, 36px);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    calc(var(--mx) * -14px) calc(30px + var(--my) * -14px + var(--sy) * 12px) 80px -30px rgba(0, 0, 0, 0.9),
    calc(var(--mx) * -10px) calc(var(--my) * -10px) 60px -40px rgba(255, 61, 18, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.05);
  transition: box-shadow 0.25s ease-out;
  animation: rise 0.9s 0.15s cubic-bezier(.2,.8,.2,1) both;
  position: relative;
  overflow: hidden;
}

.progress { margin-bottom: 26px; }

.progress-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.progress-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--sun), var(--sun-2));
  border-radius: inherit;
  box-shadow: 0 0 12px var(--sun);
  transition: width 2.6s cubic-bezier(.4,0,.2,1);
}

/* ---------- Steps ---------- */
.step { display: none; }
.step.active { display: block; animation: fadeIn 0.5s ease both; }

.q-num {
  font-family: "Unbounded", sans-serif;
  color: var(--sun);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.question {
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 26px;
}

.hl { color: var(--sun); }

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.opt {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 20px 14px;
  border-radius: 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.opt .emoji {
  font-size: 2.2rem;
  transition: transform 0.3s cubic-bezier(.3,1.6,.5,1);
}

.opt:hover,
.opt:focus-visible {
  transform: translateY(-3px);
  outline: none;
}
.opt:hover .emoji,
.opt:focus-visible .emoji { transform: scale(1.2) rotate(-8deg); }

.opt.yes:hover, .opt.yes:focus-visible {
  border-color: var(--sun);
  background: rgba(255, 61, 18, 0.12);
  box-shadow: 0 10px 40px -12px rgba(255, 61, 18, 0.7);
}
.opt.no:hover, .opt.no:focus-visible {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
.opt:active { transform: scale(0.97); }

/* ---------- Loading ---------- */
#stepLoading { text-align: center; padding: 10px 0 6px; }

.crow-loader {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}
.crow-loader span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 14px var(--sun);
  animation: hop 0.9s ease-in-out infinite;
}
.crow-loader span:nth-child(2) { animation-delay: 0.15s; }
.crow-loader span:nth-child(3) { animation-delay: 0.3s; }

@keyframes hop {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-14px); opacity: 1; }
}

.kak {
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.dots i {
  font-style: normal;
  display: inline-block;
  margin-left: 0.18em;
  color: var(--sun);
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 20% { opacity: 0; transform: translateY(4px); }
  40%, 100% { opacity: 1; transform: translateY(0); }
}

.sub {
  color: var(--muted);
  margin-top: 10px;
  font-size: 0.95rem;
}

/* ---------- Result ---------- */
#stepResult { text-align: center; padding-top: 4px; }

.lotus {
  font-size: clamp(4rem, 18vw, 5.5rem);
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 10px 30px rgba(255, 105, 180, 0.45));
  animation: bloom 0.9s cubic-bezier(.3,1.6,.5,1) both, float 3.5s 0.9s ease-in-out infinite;
}

@keyframes bloom {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.result {
  font-size: clamp(1.45rem, 6vw, 1.95rem);
  font-weight: 700;
  line-height: 1.2;
}

.again {
  margin-top: 24px;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 22px;
  border-radius: 99px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.again:hover, .again:focus-visible { color: var(--ink); border-color: var(--sun); outline: none; }

/* ---------- Confetti petals ---------- */
.petal {
  position: fixed;
  top: -40px;
  z-index: 5;
  pointer-events: none;
  font-size: 1.6rem;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.2; }
}

/* ---------- Footer ---------- */
.foot {
  font-size: 0.78rem;
  color: #5d5550;
  letter-spacing: 0.08em;
  animation: rise 0.9s 0.3s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  .options { grid-template-columns: 1fr; }
}

/* ---------- Large screens ---------- */
@media (min-width: 1024px) {
  .card { max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
