/*
 * Thanksgiving seasonal themes (Harvest, Cozy Dark, Cozy Light, Fall Light,
 * Fall Dark).
 *
 * Not part of global.css, so pages without this theme never download it.
 * `_document` links it on the server when the page renders in this theme;
 * `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.
 */

/*
 * Harvest changes through the day: `data-season-mode` on <html> (see
 * lib/utils/theme/timeOfDayMode.ts) is "day", "evening" or "night". Night is
 * the base block, so a page with no mode yet renders as night. It is not
 * force-dark: the page is dark (or mustard) but components keep the app's
 * light tokens, so cards, tiles and pills are white as in the design. Values
 * are the handoff's `--tg-*` tokens mapped onto the app's.
 */
[data-color-scheme="harvest"][data-color-scheme="harvest"] {
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-strong: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-in-out-sine: cubic-bezier(0.37, 0, 0.63, 1);
  --ease-in-gravity: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-in-exit: cubic-bezier(0.5, 0, 0.75, 0);
  /* Springs, approximated with an overshooting curve. */
  --spring-arrive: cubic-bezier(0.34, 1.3, 0.64, 1);
  --spring-settle: cubic-bezier(0.34, 1.45, 0.64, 1);

  /* Sky layers crossfade by mode, see HarvestScenery.module.css. */
  --harvest-sky-night: #3e160e;
  --harvest-sky-day: #edab23;
  /* Evening's sunset runs over the whole page: espresso at the top down to
     pumpkin at 22% of its height, then pumpkin to the bottom. */
  --harvest-evening-page: linear-gradient(
    180deg,
    #3a1f10 0%,
    #5c3018 4%,
    #8e4a1f 9%,
    #c46a22 16%,
    #e58f35 22%,
    #e58f35 100%
  );

  /* Night (Harvest Night): espresso page, marigold type, burnt-orange actions. */
  --tg-text-strong: #edab23;
  --tg-text-muted: #d8de62;
  --tg-surface-text: #3e160e;
  --tg-surface-meta: #673d0d;
  /* Mountains and pines: three gradient layers (color, opacity top and bottom). */
  --harvest-ls1-color: #5e2e17;
  --harvest-ls1-from: 0.6;
  --harvest-ls1-to: 0;
  --harvest-ls2-color: #74391c;
  --harvest-ls2-from: 0.7;
  --harvest-ls2-to: 0.1;
  --harvest-ls3-color: #9a5530;
  --harvest-ls3-from: 0.85;
  --harvest-ls3-to: 0.35;
  --tg-landscape-opacity: 0.6;

  /* The banner's color where the creator has no picture. */
  --banner-fallback: #5c290e;

  --brand-500: #d3662d;
  --brand-50: color-mix(in srgb, var(--brand-500) 6%, white);
  --brand-100: color-mix(in srgb, var(--brand-500) 12%, white);
  --brand-200: color-mix(in srgb, var(--brand-500) 24%, white);
  --brand-300: color-mix(in srgb, var(--brand-500) 44%, white);
  --brand-400: color-mix(in srgb, var(--brand-500) 68%, white);
  --brand-600: color-mix(in srgb, var(--brand-500) 88%, black);
  --brand-700: color-mix(in srgb, var(--brand-500) 72%, black);
  --brand-800: color-mix(in srgb, var(--brand-500) 58%, black);
  --brand-900: color-mix(in srgb, var(--brand-500) 44%, black);
  --brand-950: color-mix(in srgb, var(--brand-500) 28%, black);
  --brand-interactive: var(--brand-400);
  --brand-interactive-hover: var(--brand-300);

  --primary: #d3662d;
  --primary-foreground: #ffffff;

  /* Keep `--background` in sync with `canvasColor` in
     shared/constants/seasonalThemes.ts. */
  --background: #3e160e;
  --foreground: var(--tg-text-strong);
  --muted-foreground: var(--tg-text-muted);
  --card: #ffffff;
  --tile: var(--card);
  --card-foreground: var(--tg-surface-text);
  --popover: #ffffff;
  --popover-foreground: var(--tg-surface-text);
  --secondary: #ffffff;
  --secondary-foreground: var(--tg-surface-text);
  /* Hover and selected rows on the page (settings menu, lists). */
  --accent: color-mix(in srgb, var(--tg-text-strong) 12%, transparent);
  --accent-foreground: var(--tg-text-strong);
  --border: color-mix(in srgb, var(--tg-text-strong) 20%, transparent);
  --input: color-mix(in srgb, var(--tg-text-strong) 24%, transparent);
}

/* Golden Hour: mustard page, espresso type, mahogany actions. Light. */
[data-color-scheme="harvest"][data-color-scheme="harvest"][data-season-mode="day"] {
  --tg-text-strong: #3e160e;
  --tg-text-muted: #673d0d;
  --harvest-ls1-color: #c98a16;
  --harvest-ls1-from: 0.55;
  --harvest-ls1-to: 0;
  --harvest-ls2-color: #b07410;
  --harvest-ls2-from: 0.6;
  --harvest-ls2-to: 0.05;
  --harvest-ls3-color: #94600c;
  --harvest-ls3-from: 0.7;
  --harvest-ls3-to: 0.1;
  --tg-landscape-opacity: 0.55;

  --brand-500: #6e332f;
  --primary: #6e332f;
  --primary-foreground: #faf1e0;

  --background: #edab23;
  --foreground: var(--tg-text-strong);
  --muted-foreground: var(--tg-text-muted);
  --border: color-mix(in srgb, var(--tg-text-strong) 16%, transparent);
  --input: color-mix(in srgb, var(--tg-text-strong) 20%, transparent);
}

/* Cozy Harvest: sunset gradient, cream cards, pumpkin actions. Dark chrome. */
[data-color-scheme="harvest"][data-color-scheme="harvest"][data-season-mode="evening"] {
  --tg-text-strong: #fff1d6;
  --tg-text-muted: #f7c98c;
  --tg-surface-text: #4a2a17;
  --tg-surface-meta: #8a5a35;
  --harvest-ls1-color: #8a4418;
  --harvest-ls1-from: 0.55;
  --harvest-ls1-to: 0;
  --harvest-ls2-color: #6e3412;
  --harvest-ls2-from: 0.6;
  --harvest-ls2-to: 0.05;
  --harvest-ls3-color: #57270c;
  --harvest-ls3-from: 0.7;
  --harvest-ls3-to: 0.1;
  --tg-landscape-opacity: 0.55;

  --brand-500: #d9621e;
  --primary: #d9621e;
  --primary-foreground: #fff8ec;

  --background: #3a1f10;
  --card: #fff4e0;
  --popover: #fff4e0;
  --secondary: #fff4e0;
}

/* The canvas painted before the stylesheet loads (`_document`) is the night
   color. Once the mode is known the root follows `--background`, so pages
   shorter than the window don't show a night strip under day or evening. */
html[data-color-scheme="harvest"][data-season-mode] {
  background: var(--background);
}

/* Evening: the gradient is the root's background, which spans the whole
   document whatever the layout's containers do, with its stops as percentages
   of the page height. The page container and body are transparent so it shows
   (the sky layers are hidden in this mode, see HarvestScenery.module.css), and
   the top bar is transparent until the page scrolls. */
html[data-color-scheme="harvest"][data-season-mode="evening"] {
  background: var(--harvest-evening-page);
}

[data-color-scheme="harvest"][data-season-mode="evening"] body,
[data-color-scheme="harvest"][data-season-mode="evening"] #scrollableContainer {
  background-color: transparent;
}

[data-color-scheme="harvest"][data-season-mode="evening"] section.sticky.z-500.bg-background {
  background-color: transparent;
}

/* Cards and tiles are light in every mode, so inside one the tokens behave like
   the regular light theme: buttons and pills that use `bg-background` and
   `text-foreground` stay readable. Tiles and the Add Wish card (`bg-tile`)
   take their text from the page, so the color is set too. Popovers, sheets
   and drawers (`bg-popover`) are light as well. */
[data-color-scheme="harvest"] :is(.bg-card, .bg-tile, .bg-popover),
[data-color-scheme="cozy"] :is(.bg-card, .bg-tile, .bg-popover),
[data-color-scheme="cozyLight"] :is(.bg-card, .bg-tile, .bg-popover) {
  --background: var(--card);
  --foreground: var(--tg-surface-text);
  --muted-foreground: var(--tg-surface-meta);
  --accent: color-mix(in srgb, var(--tg-surface-text) 5%, transparent);
  --accent-foreground: var(--tg-surface-text);
  --border: color-mix(in srgb, var(--tg-surface-text) 14%, transparent);
  --input: color-mix(in srgb, var(--tg-surface-text) 18%, transparent);
  color: var(--tg-surface-text);
}

/* Outline buttons (Suggestions, Edit on some pages) are white pills in the
   design; their `bg-background` would otherwise be the page color. */
[data-color-scheme="harvest"] .bg-background.shadow-xs,
[data-color-scheme="cozy"] .bg-background.shadow-xs,
[data-color-scheme="cozyLight"] .bg-background.shadow-xs,
[data-color-scheme="fallLight"] .bg-background.shadow-xs,
[data-color-scheme="fallDark"] .bg-background.shadow-xs {
  background-color: var(--card);
  color: var(--tg-surface-text);
}

/* The banner's fallback, for a creator with no banner picture: a color, or
   the Fall themes' gradient cover. */
[data-color-scheme="harvest"] [data-slot="profile-banner"],
[data-color-scheme="cozy"] [data-slot="profile-banner"],
[data-color-scheme="cozyLight"] [data-slot="profile-banner"],
[data-color-scheme="fallLight"] [data-slot="profile-banner"],
[data-color-scheme="fallDark"] [data-slot="profile-banner"] {
  background: var(--banner-fallback);
}

/* Smooth the change between modes. */
@media (prefers-reduced-motion: no-preference) {
  [data-color-scheme="harvest"] body,
  [data-color-scheme="harvest"] .bg-card,
  [data-color-scheme="harvest"] .bg-tile,
  [data-color-scheme="harvest"] .bg-popover,
  [data-color-scheme="harvest"] .bg-primary,
  [data-color-scheme="harvest"] button {
    transition:
      background-color 0.8s ease,
      color 0.8s ease,
      border-color 0.8s ease;
  }
}

/*
 * Cozy Season, Cozy Dark and Cozy Light (the handoff's "Cozy dark" and "Cozy
 * day" color pages): Harvest Night's markup and motion on a new page, with a
 * cabin. Both are always "night" for the art (`useColorSchemeAttribute` sets
 * `data-season-mode="night"`), so there are no mode blocks; each block sets the
 * page colors. Dark is force-dark: the app's dark tokens apply (cards and nav
 * #171717, chips #404040, white text), with the page text in marigold, and
 * only what differs is set here. Light is force-light: the app's light tokens
 * apply. Rules shared with Harvest select the schemes by name.
 */
[data-color-scheme="cozy"][data-color-scheme="cozy"],
[data-color-scheme="cozyLight"][data-color-scheme="cozyLight"] {
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-strong: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-in-out-sine: cubic-bezier(0.37, 0, 0.63, 1);
  --ease-in-gravity: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-in-exit: cubic-bezier(0.5, 0, 0.75, 0);
  --spring-arrive: cubic-bezier(0.34, 1.3, 0.64, 1);
  --spring-settle: cubic-bezier(0.34, 1.45, 0.64, 1);

  /* Mountains and pines: the three layers' opacity is the same in both. */
  --harvest-ls1-from: 0.6;
  --harvest-ls1-to: 0;
  --harvest-ls2-from: 0.7;
  --harvest-ls2-to: 0.1;
  --harvest-ls3-from: 0.85;
  --harvest-ls3-to: 0.35;
  --tg-landscape-opacity: 0.65;

  /* Brand scale of the handoff's `data-color-scheme="thanksgiving"`. */
  --brand-50: #fdf3ec;
  --brand-100: #fae1d0;
  --brand-200: #f4c3a1;
  --brand-300: #eda178;
  --brand-400: #d36620;
  --brand-500: #b4501b;
  --brand-600: #9a4416;
  --brand-700: #7c3712;
  --brand-800: #5c290e;
  --brand-900: #3e1809;
  --brand-950: #24100a;
}

/* Cozy Dark: the night scene in pine green. */
[data-color-scheme="cozy"][data-color-scheme="cozy"] {
  /* Page: pine-green gradient, top to bottom (#151B19, #1C211A at 22%,
     #151A17). */
  --harvest-sky-night: linear-gradient(
    180deg,
    #151b19 0%,
    #1c211a 22%,
    #151a17 100%
  );
  /* Amber light pools around the cabin: #ED9D3C fading out. */
  --cozy-amber-pool: radial-gradient(
    closest-side,
    rgb(237 157 60 / 0.22) 0%,
    rgb(193 120 40 / 0.08) 38%,
    rgb(168 99 34 / 0) 100%
  );
  --cozy-amber-lantern: radial-gradient(
    closest-side,
    rgb(237 157 60 / 0.28) 0%,
    rgb(193 120 40 / 0.1) 38%,
    rgb(168 99 34 / 0) 100%
  );

  /* `--tg-glow` #FFFBEA: a warm radial glow from the top, 50% fading to 0. */
  --cozy-glow: radial-gradient(
    ellipse 70% 45% at 50% 0%,
    rgb(255 251 234 / 0.5) 0%,
    rgb(255 251 234 / 0) 100%
  );

  --tg-text-strong: #edab23;
  --tg-text-muted: #d8de62;
  /* Text on cards, tiles and popovers (the dark surfaces). */
  --tg-surface-text: #ffffff;
  --tg-surface-meta: rgba(255, 255, 255, 0.6);
  --harvest-ls1-color: #29342b;
  --harvest-ls2-color: #3c3b2b;
  --harvest-ls3-color: #5b462c;
  --banner-fallback: #29342b;

  --brand-interactive: var(--brand-200);
  --brand-interactive-hover: var(--brand-100);

  /* Keep `--background` in sync with `canvasColor`. */
  --background: #151a17;
  --foreground: var(--tg-text-strong);
  --muted-foreground: var(--tg-text-muted);
  --accent: color-mix(in srgb, var(--tg-text-strong) 12%, transparent);
  --accent-foreground: var(--tg-text-strong);
}

/* Cozy Light: the same scene by day, no light pools, the cabin unlit. */
[data-color-scheme="cozyLight"][data-color-scheme="cozyLight"] {
  /* Page: pale sky into warm cream, top to bottom. The layer is named for
     Harvest's night; it's the only one these themes show. */
  --harvest-sky-night: linear-gradient(
    180deg,
    #bfdceb 0%,
    #ddebe3 12%,
    #f6eedd 26%,
    #f5efe4 100%
  );
  --cozy-amber-pool: none;
  --cozy-amber-lantern: none;
  /* `--tg-glow` #FFFBEA at 60%: a sunlight wash at the top of the page. */
  --cozy-glow: linear-gradient(
    180deg,
    rgb(255 251 234 / 0.6) 0%,
    rgb(255 251 234 / 0) 40%
  );

  --tg-text-strong: #171717;
  --tg-text-muted: rgba(0, 0, 0, 0.6);
  --tg-surface-text: #171717;
  --tg-surface-meta: rgba(0, 0, 0, 0.6);
  --harvest-ls1-color: #a9c4b4;
  --harvest-ls2-color: #8faf83;
  --harvest-ls3-color: #6e8f55;
  --banner-fallback: #fae1d0;

  --brand-interactive: var(--brand-600);
  --brand-interactive-hover: var(--brand-700);

  /* Keep `--background` in sync with `canvasColor`. */
  --background: #f5efe4;
}

/*
 * Fall Light and Fall Dark (the handoff's "Thanksgiving Light" and
 * "Thanksgiving Dark · Espresso Ember"): no scene, just a tiled pattern, a
 * gradient cover and the handoff's `--tg-*` colors mapped onto the app's.
 * Light is force-light and Dark is force-dark, so each block only sets what
 * differs from the app's light or dark tokens.
 */
[data-color-scheme="fallLight"][data-color-scheme="fallLight"],
[data-color-scheme="fallDark"][data-color-scheme="fallDark"] {
  --brand-50: color-mix(in srgb, var(--brand-500) 6%, white);
  --brand-100: color-mix(in srgb, var(--brand-500) 12%, white);
  --brand-200: color-mix(in srgb, var(--brand-500) 24%, white);
  --brand-300: color-mix(in srgb, var(--brand-500) 44%, white);
  --brand-400: color-mix(in srgb, var(--brand-500) 68%, white);
  --brand-600: color-mix(in srgb, var(--brand-500) 88%, black);
  --brand-700: color-mix(in srgb, var(--brand-500) 72%, black);
  --brand-800: color-mix(in srgb, var(--brand-500) 58%, black);
  --brand-900: color-mix(in srgb, var(--brand-500) 44%, black);
  --brand-950: color-mix(in srgb, var(--brand-500) 28%, black);

  --primary: var(--brand-500);
  --primary-foreground: #ffffff;

  --foreground: var(--tg-text-strong);
  --muted-foreground: var(--tg-text-muted);
  --tile: var(--card);
  --card-foreground: var(--tg-text-strong);
  --popover: var(--card);
  --popover-foreground: var(--tg-text-strong);
  --secondary: var(--tg-chip);
  --secondary-foreground: var(--tg-text-strong);
  --accent-foreground: var(--tg-text-strong);
  --border: var(--tg-border);
  --input: var(--tg-border);
}

/* Fall Light: cream page, espresso type, cranberry actions. */
[data-color-scheme="fallLight"][data-color-scheme="fallLight"] {
  --tg-text-strong: #2b1d16;
  --tg-text-muted: #7a6455;
  /* Outline buttons (Edit, Suggestions) are white pills with page text. */
  --tg-surface-text: var(--tg-text-strong);
  --tg-chip: #f2e8dc;
  --tg-border: #eadccb;
  /* The handoff's 10% layer opacity is baked into the tile's alpha. */
  --fall-pattern: url("/themes/thanksgiving/fall-pattern-light.webp");
  --banner-fallback:
    radial-gradient(120% 160% at 85% 10%, #e9a24a 0%, rgb(217 130 43 / 0) 55%),
    linear-gradient(115deg, #5a161b 0%, #8e2a2c 42%, #b5482a 72%, #d9822b 100%);

  --brand-500: #9a2b2e;
  --brand-interactive: var(--brand-500);
  --brand-interactive-hover: var(--brand-600);

  /* Keep `--background` in sync with `canvasColor`. */
  --background: #fbf7f1;
  --card: #ffffff;
  --accent: color-mix(in srgb, var(--tg-text-strong) 5%, transparent);
}

/* Fall Dark: espresso page, cream type, cranberry actions. */
[data-color-scheme="fallDark"][data-color-scheme="fallDark"] {
  --tg-text-strong: #f6ebdd;
  --tg-text-muted: #b9a390;
  --tg-surface-text: var(--tg-text-strong);
  --tg-chip: #352820;
  --tg-border: #45362c;
  /* A lighter tile (pale tan lines), not the light one recolored. */
  --fall-pattern: url("/themes/thanksgiving/fall-pattern-dark.webp");
  --banner-fallback:
    radial-gradient(
      120% 160% at 85% 10%,
      rgb(217 138 62 / 0.75) 0%,
      rgb(176 88 42 / 0) 55%
    ),
    linear-gradient(115deg, #2a0c0f 0%, #4e1418 42%, #7e2a24 72%, #b0582a 100%);

  --brand-500: #c8463a;
  --brand-interactive: var(--brand-300);
  --brand-interactive-hover: var(--brand-200);

  /* Keep `--background` in sync with `canvasColor`. */
  --background: #1e1511;
  --card: #2a1f19;
  --accent: color-mix(in srgb, var(--tg-text-strong) 10%, transparent);
}

/* The pattern fills the window and stays put while the page scrolls. A fixed
   layer rather than `background-attachment: fixed`, which iOS Safari ignores.
   It sits behind the content but above the container's own background, as
   the container is `isolate` on themed pages (`PublicCreatorContainer`). */
[data-color-scheme="fallLight"] #scrollableContainer.isolate::before,
[data-color-scheme="fallDark"] #scrollableContainer.isolate::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--fall-pattern) 0 0 / 564px repeat;
}

/*
 * Motion. Classes keep Tailwind's naming, see seasonal-themes/README.md.
 * With reduced motion Harvest's and Cozy Season's static layout shows (flags,
 * leaves, pumpkin); neither character scene is shown. Both run on a
 * 24 s loop.
 */
@media (prefers-reduced-motion: no-preference) {
  .motion-safe\:animate-harvest-flag {
    animation: harvest-flag-sway 1.5s var(--ease-in-out-sine) infinite alternate;
    animation-delay: calc(var(--i) * 0.2s - 1.5s);
  }

  .motion-safe\:animate-harvest-leaf-fall {
    animation: harvest-leaf-fall 24s linear var(--fall-delay, 0s) infinite;
  }

  .motion-safe\:animate-harvest-leaf-sway {
    animation: harvest-leaf-sway var(--sway-duration, 3s)
      var(--ease-in-out-sine) var(--sway-delay, 0s) infinite alternate;
  }

  .motion-safe\:animate-harvest-peek {
    animation: harvest-peek 24s linear infinite;
  }

  .motion-safe\:animate-harvest-wink {
    animation: harvest-wink 24s linear infinite;
  }

  .motion-safe\:animate-harvest-pumpkin-hop {
    animation: harvest-pumpkin-hop 24s linear infinite;
  }

  .motion-safe\:animate-harvest-wreath-leaf {
    animation: harvest-wreath-pulse 24s linear infinite;
    animation-delay: calc(var(--i) * 45ms);
  }

  .motion-safe\:animate-harvest-keepsake {
    animation: harvest-keepsake-in 0.7s var(--spring-arrive)
      var(--keepsake-delay, 0s) both;
  }

}

/* ---- Harvest ---- */

/* Flags swing from their top edge; --amp is 8, 9.5 or 11 degrees. */
@keyframes harvest-flag-sway {
  from {
    transform: rotate(calc(var(--amp) * -1));
  }
  to {
    transform: rotate(var(--amp));
  }
}

/* Falls the page once per loop; --top is the leaf's resting spot. */
@keyframes harvest-leaf-fall {
  from {
    transform: translateY(calc(-1 * var(--top) - 15vh));
  }
  to {
    transform: translateY(calc(112vh - var(--top)));
  }
}

@keyframes harvest-leaf-sway {
  from {
    transform: translateX(calc(var(--sway) * -1)) rotate(calc(var(--tilt) * -1));
  }
  to {
    transform: translateX(var(--sway)) rotate(var(--tilt));
  }
}

/* Squishy hop at 9.0 s and 17.5 s, pivoting on its base. */
@keyframes harvest-pumpkin-hop {
  0%,
  37.5% {
    transform: translateY(0px) scale(1, 1) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  38.25% {
    transform: translateY(0px) scale(1.12, 0.86) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  38.75% {
    transform: translateY(0px) scale(0.92, 1.1) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  39.417% {
    transform: translateY(-30px) scale(0.92, 1.1) rotate(-5deg);
    animation-timing-function: var(--ease-in-out-sine);
  }
  39.833% {
    transform: translateY(-30px) scale(1, 1) rotate(-5deg);
    animation-timing-function: var(--ease-in-gravity);
  }
  40.583% {
    transform: translateY(0px) scale(0.95, 1.06) rotate(3deg);
    animation-timing-function: var(--ease-out-strong);
  }
  40.917% {
    transform: translateY(0px) scale(1.14, 0.84) rotate(3deg);
    animation-timing-function: var(--ease-out-strong);
  }
  41.333% {
    transform: translateY(-10px) scale(0.97, 1.03) rotate(3deg);
    animation-timing-function: var(--ease-in-gravity);
  }
  41.917% {
    transform: translateY(0px) scale(1.06, 0.94) rotate(3deg);
    animation-timing-function: var(--spring-settle);
  }
  43.333% {
    transform: translateY(0px) scale(1.06, 0.94) rotate(0deg);
    animation-timing-function: var(--spring-settle);
  }
  44.583% {
    transform: translateY(0px) scale(1, 1) rotate(0deg);
  }
  72.917% {
    transform: translateY(0px) scale(1, 1) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  73.667% {
    transform: translateY(0px) scale(1.12, 0.86) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  74.167% {
    transform: translateY(0px) scale(0.92, 1.1) rotate(0deg);
    animation-timing-function: var(--ease-out-strong);
  }
  74.833% {
    transform: translateY(-30px) scale(0.92, 1.1) rotate(-5deg);
    animation-timing-function: var(--ease-in-out-sine);
  }
  75.25% {
    transform: translateY(-30px) scale(1, 1) rotate(-5deg);
    animation-timing-function: var(--ease-in-gravity);
  }
  76% {
    transform: translateY(0px) scale(0.95, 1.06) rotate(3deg);
    animation-timing-function: var(--ease-out-strong);
  }
  76.333% {
    transform: translateY(0px) scale(1.14, 0.84) rotate(3deg);
    animation-timing-function: var(--ease-out-strong);
  }
  76.75% {
    transform: translateY(-10px) scale(0.97, 1.03) rotate(3deg);
    animation-timing-function: var(--ease-in-gravity);
  }
  77.333% {
    transform: translateY(0px) scale(1.06, 0.94) rotate(3deg);
    animation-timing-function: var(--spring-settle);
  }
  78.75% {
    transform: translateY(0px) scale(1.06, 0.94) rotate(0deg);
    animation-timing-function: var(--spring-settle);
  }
  80% {
    transform: translateY(0px) scale(1, 1) rotate(0deg);
  }
  100% {
    transform: translateY(0px) scale(1, 1) rotate(0deg);
  }
}

/* A leaf pulls 16px toward the avatar and springs back, at 11.5 s and 20.0 s. */
@keyframes harvest-wreath-pulse {
  0%,
  47.917%,
  90%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  47.917% {
    transform: translate(0, 0) rotate(0deg);
    animation-timing-function: var(--ease-in-out-strong);
  }
  50.208% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    animation-timing-function: var(--spring-settle);
  }
  54.583% {
    transform: translate(0, 0) rotate(0deg);
  }
  83.333% {
    transform: translate(0, 0) rotate(0deg);
    animation-timing-function: var(--ease-in-out-strong);
  }
  85.625% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    animation-timing-function: var(--spring-settle);
  }
  90% {
    transform: translate(0, 0) rotate(0deg);
  }
}

/* Slides in at 1.5 s, tilts its head at 3.8 s, winks 3.9 to 4.25 s, leaves at 6.4 s.
   Leans 26 degrees to the left at rest; the handoff's rotations are offsets
   from that, counted counterclockwise. */
@keyframes harvest-peek {
  0%,
  6.25% {
    transform: translateX(480px) rotate(-8deg);
    animation-timing-function: var(--spring-arrive);
  }
  10.833% {
    transform: translateX(0) rotate(-23deg);
    animation-timing-function: var(--spring-arrive);
  }
  11.667% {
    transform: translateX(0) rotate(-26deg);
  }
  15.833% {
    transform: translateX(0) rotate(-26deg);
    animation-timing-function: var(--ease-out-strong);
  }
  16.667% {
    transform: translateX(0) rotate(-32deg);
    animation-timing-function: var(--spring-settle);
  }
  19.375% {
    transform: translateX(0) rotate(-26deg);
  }
  26.667% {
    transform: translateX(0) rotate(-26deg);
    animation-timing-function: var(--ease-in-exit);
  }
  28.542% {
    transform: translateX(480px) rotate(-12deg);
  }
  100% {
    transform: translateX(480px) rotate(-12deg);
  }
}

/* Open and wink frames swap with no fade. */
@keyframes harvest-wink {
  0%,
  16.24% {
    opacity: 0;
  }
  16.25% {
    opacity: 1;
    animation-timing-function: steps(1, end);
  }
  17.708%,
  100% {
    opacity: 0;
  }
}

/* A keepsake pops in with a little spring, then stays. */
@keyframes harvest-keepsake-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.6) rotate(var(--rot));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--rot));
  }
}
