/*
 * Halloween seasonal themes (Pumpkin, Witch, Vampire).
 *
 * Not part of global.css, so pages without a Halloween theme never download
 * it. `_document` links it on the server when the page renders in one of
 * these themes; `useColorSchemeAttribute` links it on client navigation.
 * Plain CSS: served as is, without Tailwind or PostCSS.
 *
 * Scheme selectors repeat the attribute to raise specificity. Next places
 * this file before its own stylesheets, and these blocks must still win over
 * global.css's `:root` and dark tokens.
 */

/* Brand scales. Always dark: `data-forced-dark` (set with these schemes)
   applies global.css's `.dark` tokens and the `dark:` variant. */
[data-color-scheme="pumpkin"][data-color-scheme="pumpkin"] {
  --brand-50: #fff7ed;
  --brand-100: #ffedd5;
  --brand-200: #fed7aa;
  --brand-300: #fdba74;
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --brand-800: #9a3412;
  --brand-900: #7c2d12;
  --brand-950: #431407;
  --brand-interactive: var(--brand-400);
  --brand-interactive-hover: var(--brand-300);
}

[data-color-scheme="witch"][data-color-scheme="witch"] {
  --brand-50: #f7fee7;
  --brand-100: #ecfccb;
  --brand-200: #d9f99d;
  --brand-300: #bef264;
  --brand-400: #a3e635;
  --brand-500: #84cc16;
  --brand-600: #65a30d;
  --brand-700: #4d7c0f;
  --brand-800: #3f6212;
  --brand-900: #365314;
  --brand-950: #1a2e05;
  --brand-interactive: var(--brand-400);
  --brand-interactive-hover: var(--brand-300);
}

[data-color-scheme="vampire"][data-color-scheme="vampire"] {
  --brand-50: #fef2f2;
  --brand-100: #fee2e2;
  --brand-200: #fecaca;
  --brand-300: #fca5a5;
  --brand-400: #f87171;
  --brand-500: #ef4444;
  --brand-600: #dc2626;
  --brand-700: #b91c1c;
  --brand-800: #991b1b;
  --brand-900: #7f1d1d;
  --brand-950: #450a0a;
  --brand-interactive: var(--brand-400);
  --brand-interactive-hover: var(--brand-300);
}

/* Night-sky surfaces on top of global.css's dark tokens. Keep `--background`
   in sync with `canvasColor` in shared/constants/seasonalThemes.ts. */
[data-color-scheme="witch"][data-color-scheme="witch"],
[data-color-scheme="vampire"][data-color-scheme="vampire"] {
  --background: #120c18;
  --card: #1d1424;
  --popover: #1d1424;
  --secondary: #2c2036;
  --border: color-mix(in srgb, var(--brand-300) 12%, transparent);
  --input: color-mix(in srgb, var(--brand-300) 16%, transparent);
}

[data-color-scheme="pumpkin"][data-color-scheme="pumpkin"] {
  --background: #1c100c;
  --card: #27160f;
  --popover: #27160f;
  --secondary: #3d2418;
  --border: color-mix(in srgb, var(--brand-300) 12%, transparent);
  --input: color-mix(in srgb, var(--brand-300) 16%, transparent);
}

/* Liquid + rising-bubbles primary button for the Witch and Vampire Halloween themes. */
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"],
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"] {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #ffffff;
  background-size: 200% 200%;
  animation: halloween-liquid-flow 5s ease-in-out infinite;
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::before,
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::after,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::before,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

/* Subtle undulating liquid wave layer */
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::before,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::before {
  inset: -25% -15%;
  animation: halloween-liquid-slosh 4.5s ease-in-out infinite;
}

/* Sparse rising bubbles layer */
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::after,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::after {
  inset: 0;
  background-repeat: repeat;
  background-size:
    120px 56px,
    150px 56px,
    180px 56px;
  animation: halloween-liquid-bubbles 4.6s linear infinite;
}

/* Witch: green potion liquid with subtle white bubbles */
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"] {
  background-image: linear-gradient(
    120deg,
    #5b940c 0%,
    #65a30d 35%,
    #72b611 65%,
    #5b940c 100%
  );
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::before {
  background-image:
    radial-gradient(ellipse 60% 55% at 30% 60%, rgba(163, 230, 53, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 55% 50% at 75% 40%, rgba(77, 124, 15, 0.22) 0%, transparent 70%);
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::after {
  background-image:
    radial-gradient(circle at 28px 42px, rgba(255, 255, 255, 0.55) 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 86px 20px, rgba(255, 255, 255, 0.45) 0 1.4px, transparent 2.3px),
    radial-gradient(circle at 134px 36px, rgba(255, 255, 255, 0.5) 0 2px, transparent 3px);
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]:hover {
  background-image: linear-gradient(
    120deg,
    #65a30d 0%,
    #72b611 35%,
    #80c816 65%,
    #65a30d 100%
  );
}

/* Vampire: blood liquid with subtle bubbles */
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"] {
  background-image: linear-gradient(
    120deg,
    #c42020 0%,
    #dc2626 35%,
    #e53535 65%,
    #c42020 100%
  );
}

[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::before {
  background-image:
    radial-gradient(ellipse 60% 55% at 30% 60%, rgba(248, 113, 113, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 55% 50% at 75% 40%, rgba(153, 27, 27, 0.24) 0%, transparent 70%);
}

[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::after {
  background-image:
    radial-gradient(circle at 28px 42px, rgba(254, 202, 202, 0.55) 0 1.8px, transparent 2.8px),
    radial-gradient(circle at 86px 20px, rgba(252, 165, 165, 0.45) 0 1.4px, transparent 2.3px),
    radial-gradient(circle at 134px 36px, rgba(254, 202, 202, 0.5) 0 2px, transparent 3px);
}

[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]:hover {
  background-image: linear-gradient(
    120deg,
    #dc2626 0%,
    #e53535 35%,
    #ef4444 65%,
    #dc2626 100%
  );
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]:hover::after,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]:hover::after {
  animation-duration: 3.4s;
}

[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]:disabled,
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]:disabled::before,
[data-color-scheme="witch"] [data-slot="button"][data-variant="default"]:disabled::after,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]:disabled,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]:disabled::before,
[data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]:disabled::after {
  animation: none;
}

@keyframes halloween-liquid-flow {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes halloween-liquid-slosh {
  0%,
  100% {
    transform: translate3d(-5%, -3%, 0) rotate(-1deg) scale(1.03, 0.97);
  }
  50% {
    transform: translate3d(5%, 3%, 0) rotate(1deg) scale(0.97, 1.03);
  }
}

@keyframes halloween-liquid-bubbles {
  0% {
    background-position:
      0px 0px,
      0px 0px,
      0px 0px;
  }
  50% {
    background-position:
      2px -28px,
      -2px -28px,
      1px -28px;
  }
  100% {
    background-position:
      0px -56px,
      0px -56px,
      0px -56px;
  }
}

/* Animation utilities for components/seasonal-themes/halloween. They keep
   Tailwind's class names, so the components read like any other Tailwind
   code. Movement is `motion-safe:`; twinkle, glow and the blinks (opacity or
   a quick squash) run for everyone. The flap, wave and arm keyframes read
   `--dir` (1 or -1) so one keyframe drives both mirrored sides. */
.animate-halloween-bat-blink {
  animation: halloween-bat-blink 3.6s ease-in-out infinite;
}

.animate-halloween-blink {
  animation: halloween-blink 6s ease-in-out infinite;
}

.animate-halloween-glow {
  animation: halloween-glow 1.6s ease-in-out infinite alternate;
}

.animate-halloween-twinkle {
  animation: halloween-twinkle 3s ease-in-out infinite;
}

@media (prefers-reduced-motion: no-preference) {
  .motion-safe\:animate-halloween-bat-heart-eyes {
    animation: halloween-bat-heart-eyes 1.4s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-bat-look {
    animation: halloween-bat-look 3.2s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-bat-wink-open {
    animation: halloween-bat-wink-open 3.8s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-bat-wink-shut {
    animation: halloween-bat-wink-shut 3.8s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-bob {
    animation: halloween-bob 1.1s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-cape {
    animation: halloween-cape 2s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-cauldron-boil {
    animation: halloween-cauldron-boil 0.32s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-flap {
    animation: halloween-flap 0.28s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-fly {
    animation: halloween-fly 22s linear infinite;
  }

  .motion-safe\:animate-halloween-ghost-float {
    animation: halloween-ghost-float 3s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-ghost-wave {
    animation: halloween-ghost-wave 2.2s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-lid-blink {
    animation: halloween-lid-blink 6s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-pumpkin-bob {
    animation: halloween-pumpkin-bob 2.8s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-scarecrow-arm {
    animation: halloween-scarecrow-arm 0.55s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-scarecrow-hat {
    animation: halloween-scarecrow-hat 0.7s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-scarecrow-head {
    animation: halloween-scarecrow-head 0.7s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-scarecrow-sway {
    animation: halloween-scarecrow-sway 0.9s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-spider-drop {
    animation: halloween-spider-drop 3.6s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-swoop {
    animation: halloween-swoop 3.4s ease-in-out infinite alternate;
  }

  .motion-safe\:animate-halloween-twinkle {
    animation: halloween-twinkle 3s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-vampire-float {
    animation: halloween-vampire-float 3.4s ease-in-out infinite;
  }

  .motion-safe\:animate-halloween-vampire-peek {
    animation: halloween-vampire-peek 7.5s cubic-bezier(0.22, 1, 0.36, 1) infinite;
  }

  .motion-safe\:animate-halloween-witch-flight {
    animation: halloween-witch-flight 26s linear infinite;
  }

  .motion-safe\:animate-halloween-witch-hover {
    animation: halloween-witch-hover 4.2s linear infinite;
  }
}

@keyframes halloween-flap {
  from {
    transform: rotate(calc(-18deg * var(--dir, 1))) scaleY(1);
  }
  to {
    transform: rotate(calc(30deg * var(--dir, 1))) scaleY(0.8);
  }
}

/* An even crossing that starts and ends fully off screen whatever the
   flock's width, then a pause before the next pass. The swoop is layered
   on separately so the speed stays steady. */
@keyframes halloween-fly {
  from {
    transform: translateX(-110%);
  }
  70%,
  to {
    transform: translateX(105vw);
  }
}

@keyframes halloween-swoop {
  from {
    transform: translateY(-12%);
  }
  to {
    transform: translateY(12%);
  }
}

@keyframes halloween-blink {
  0%,
  90%,
  100% {
    transform: scaleY(1);
  }
  94% {
    transform: scaleY(0.08);
  }
}

@keyframes halloween-lid-blink {
  0%,
  90%,
  100% {
    transform: scaleY(0);
  }
  94% {
    transform: scaleY(1);
  }
}

@keyframes halloween-bat-blink {
  0%,
  42%,
  48%,
  84%,
  90%,
  96%,
  100% {
    transform: scaleY(1);
  }
  45%,
  87%,
  93% {
    transform: scaleY(0.08);
  }
}

@keyframes halloween-bat-look {
  0%,
  18%,
  100% {
    transform: translate(0, 0);
  }
  28%,
  46% {
    transform: translate(2.4px, -1px);
  }
  58%,
  76% {
    transform: translate(-2.4px, 0.6px);
  }
  84%,
  92% {
    transform: translate(1.4px, 1px);
  }
}

@keyframes halloween-bat-wink-shut {
  0%,
  42%,
  86%,
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
  48%,
  80% {
    opacity: 0;
    transform: scaleY(0.2);
  }
}

@keyframes halloween-bat-wink-open {
  0%,
  42%,
  86%,
  100% {
    opacity: 0;
    transform: scaleY(0.2);
  }
  48%,
  80% {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes halloween-bat-heart-eyes {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.18) translateY(-1px);
  }
  55% {
    transform: scale(0.95);
  }
  80% {
    transform: scale(1.14) translateY(-0.5px);
  }
}

@keyframes halloween-bob {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(4px, -10px);
  }
}

@keyframes halloween-cauldron-boil {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(6px, -22px) scale(1.2);
  }
}

@keyframes halloween-twinkle {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

@keyframes halloween-ghost-float {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-12px) rotate(3deg);
  }
}

@keyframes halloween-ghost-wave {
  from {
    transform: rotate(calc(-3deg * var(--dir, 1)));
  }
  to {
    transform: rotate(calc(7deg * var(--dir, 1)));
  }
}

@keyframes halloween-pumpkin-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-4px) rotate(1deg);
  }
}

@keyframes halloween-scarecrow-sway {
  from {
    transform: translateY(0) rotate(-7deg);
  }
  50% {
    transform: translateY(-6px) rotate(0deg);
  }
  to {
    transform: translateY(0) rotate(7deg);
  }
}

@keyframes halloween-scarecrow-arm {
  from {
    transform: rotate(calc(-16deg * var(--dir, 1)));
  }
  to {
    transform: rotate(calc(18deg * var(--dir, 1)));
  }
}

@keyframes halloween-scarecrow-head {
  from {
    transform: translateY(-2px) rotate(-6deg);
  }
  to {
    transform: translateY(2px) rotate(6deg);
  }
}

@keyframes halloween-scarecrow-hat {
  from {
    transform: translateY(0) rotate(-4deg);
  }
  to {
    transform: translateY(-5px) rotate(5deg);
  }
}

@keyframes halloween-spider-drop {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(8px) rotate(2deg);
  }
}

@keyframes halloween-witch-flight {
  0% {
    transform: translate3d(0, 0, 0);
  }
  76%,
  100% {
    transform: translate3d(calc(100vw + 36rem), 0, 0);
  }
}

/* Sine-wave vertical trajectory + tangent pitch angle while flying across. */
@keyframes halloween-witch-hover {
  0% {
    transform: translateY(0) rotate(-9deg);
  }
  12.5% {
    transform: translateY(-38px) rotate(-6deg);
  }
  25% {
    transform: translateY(-54px) rotate(0deg);
  }
  37.5% {
    transform: translateY(-38px) rotate(6deg);
  }
  50% {
    transform: translateY(0) rotate(9deg);
  }
  62.5% {
    transform: translateY(38px) rotate(6deg);
  }
  75% {
    transform: translateY(54px) rotate(0deg);
  }
  87.5% {
    transform: translateY(38px) rotate(-6deg);
  }
  100% {
    transform: translateY(0) rotate(-9deg);
  }
}

@keyframes halloween-vampire-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-8px) rotate(1deg);
  }
}

@keyframes halloween-vampire-peek {
  0%,
  18% {
    transform: translateY(115%);
  }
  34%,
  68% {
    transform: translateY(0%);
  }
  84%,
  100% {
    transform: translateY(115%);
  }
}

@keyframes halloween-cape {
  from {
    transform: rotate(calc(-3deg * var(--dir, 1))) scaleX(0.98);
  }
  to {
    transform: rotate(calc(5deg * var(--dir, 1))) scaleX(1.03);
  }
}

@keyframes halloween-glow {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-color-scheme="witch"] [data-slot="button"][data-variant="default"],
  [data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::before,
  [data-color-scheme="witch"] [data-slot="button"][data-variant="default"]::after,
  [data-color-scheme="vampire"] [data-slot="button"][data-variant="default"],
  [data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::before,
  [data-color-scheme="vampire"] [data-slot="button"][data-variant="default"]::after {
    animation: none;
  }
}
