/* ==========================================================================
   Calendoor — Motion System
   One shared vocabulary of durations, easings and keyframes for EVERY
   transition in the app (open / close / day change / platform add-remove /
   list reflow / toasts). Loaded early so the tokens are available to every
   later stylesheet.

   Device tiers are set by motion-init.js on <html data-motion="...">:
     full  — default, full choreography with spring overshoot
     lite  — low-end phones: snappier, no overshoot, no heavy blur animation
     off   — OS Reduce Motion: near-instant, no travel

   Rule of thumb for all motion here: animate only transform + opacity.
   ========================================================================== */

:root {
  /* Durations */
  --mo-dur-xfast: 120ms;
  --mo-dur-fast: 180ms;
  --mo-dur-base: 260ms;
  --mo-dur-slow: 360ms;
  --mo-dur-sheet: 440ms;
  --mo-dur-view: 400ms;

  /* Easings */
  --mo-ease-standard: cubic-bezier(0.22, 1, 0.36, 1);   /* decelerate */
  --mo-ease-emphasized: cubic-bezier(0.2, 0, 0, 1);     /* sheets / big moves */
  --mo-ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);   /* playful overshoot */
  --mo-ease-in: cubic-bezier(0.4, 0, 1, 1);             /* exits */

  /* Travel distances */
  --mo-slide: 14px;
  --mo-sheet-travel: 20px;

  /* Staggered list entrances */
  --mo-stagger-step: 34ms;
}

/* Low-end devices: keep everything crisp, drop overshoot + big travel. */
html[data-motion="lite"] {
  --mo-dur-xfast: 90ms;
  --mo-dur-fast: 130ms;
  --mo-dur-base: 180ms;
  --mo-dur-slow: 240ms;
  --mo-dur-sheet: 300ms;
  --mo-dur-view: 260ms;
  --mo-ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --mo-slide: 10px;
  --mo-sheet-travel: 14px;
  --mo-stagger-step: 22ms;
}

/* OS Reduce Motion: collapse travel + time, keep only opacity crossfades. */
html[data-motion="off"] {
  --mo-dur-xfast: 1ms;
  --mo-dur-fast: 1ms;
  --mo-dur-base: 1ms;
  --mo-dur-slow: 1ms;
  --mo-dur-sheet: 1ms;
  --mo-dur-view: 1ms;
  --mo-slide: 0px;
  --mo-sheet-travel: 0px;
  --mo-stagger-step: 0ms;
}

/* ==========================================================================
   Shared keyframes
   ========================================================================== */
@keyframes mo-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes mo-pop-in {
  from { opacity: 0; transform: translate3d(0, var(--mo-sheet-travel), 0) scale(0.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes mo-sheet-up-in {
  from { opacity: 0; transform: translate3d(0, calc(var(--mo-sheet-travel) + 6px), 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes mo-slide-in-next {
  from { opacity: 0; transform: translate3d(var(--mo-slide), 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes mo-slide-in-prev {
  from { opacity: 0; transform: translate3d(calc(var(--mo-slide) * -1), 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes mo-item-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes mo-chip-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

/* Staggered entrance for a freshly rendered list. Each direct child animates
   in with an index-based delay. Children past the cap share the last delay so
   long lists never feel laggy. */
.mo-stagger > * {
  animation: mo-item-in var(--mo-dur-base) var(--mo-ease-standard) both;
}
.mo-stagger > *:nth-child(1) { animation-delay: calc(var(--mo-stagger-step) * 0); }
.mo-stagger > *:nth-child(2) { animation-delay: calc(var(--mo-stagger-step) * 1); }
.mo-stagger > *:nth-child(3) { animation-delay: calc(var(--mo-stagger-step) * 2); }
.mo-stagger > *:nth-child(4) { animation-delay: calc(var(--mo-stagger-step) * 3); }
.mo-stagger > *:nth-child(5) { animation-delay: calc(var(--mo-stagger-step) * 4); }
.mo-stagger > *:nth-child(6) { animation-delay: calc(var(--mo-stagger-step) * 5); }
.mo-stagger > *:nth-child(7) { animation-delay: calc(var(--mo-stagger-step) * 6); }
.mo-stagger > *:nth-child(n + 8) { animation-delay: calc(var(--mo-stagger-step) * 7); }

/* FLIP: motion-init.js adds .mo-flipping while it animates the inverse
   transform back to identity, so the browser interpolates the layout change. */
.mo-flipping {
  transition: transform var(--mo-dur-base) var(--mo-ease-standard) !important;
  will-change: transform;
}

/* Upcoming strip — stay mounted across Day/Week; collapse without teardown. */
.gc-upcoming-wrap {
  overflow: hidden;
  max-height: 22rem;
  opacity: 1;
  transition:
    max-height var(--mo-dur-view) var(--mo-ease-standard),
    opacity var(--mo-dur-fast) var(--mo-ease-standard),
    margin var(--mo-dur-view) var(--mo-ease-standard),
    padding var(--mo-dur-view) var(--mo-ease-standard);
}

.gc-upcoming-wrap--collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border: 0 !important;
  pointer-events: none !important;
}

html[data-motion="off"] .gc-upcoming-wrap {
  transition: none !important;
}

.mo-chip-animate {
  animation: mo-chip-pop var(--mo-dur-fast) var(--mo-ease-spring) both;
}

/* ==========================================================================
   Low-end tier: kill the expensive continuous effects (per-frame blur loops,
   ambient parallax) that cause jank on weak GPUs. Discrete transitions stay.
   ========================================================================== */
html[data-motion="lite"] .ambient,
html[data-motion="lite"] .ambient__orb,
html[data-motion="lite"] [class*="aurora"],
html[data-motion="lite"] [class*="-stars"] {
  animation: none !important;
}

html[data-motion="lite"] .nav-drawer__backdrop,
html[data-motion="lite"] .gc-settings-backdrop,
html[data-motion="lite"] .gc-profile-backdrop {
  transition-property: opacity, visibility !important;
}

/* Reduce Motion: no travel, no stagger, no decorative keyframes. */
html[data-motion="off"] .mo-stagger > *,
html[data-motion="off"] .mo-chip-animate {
  animation: none !important;
}

/* ==========================================================================
   Theme / Locale switches — soft, cheap (opacity + color only)
   View Transitions when available; class fallback otherwise.
   ========================================================================== */
html.theme-switching,
html.locale-switching {
  transition:
    color var(--mo-dur-base) var(--mo-ease-standard),
    background-color var(--mo-dur-base) var(--mo-ease-standard),
    border-color var(--mo-dur-base) var(--mo-ease-standard) !important;
}

html.theme-switching body,
html.theme-switching .nav-drawer,
html.theme-switching .gc-settings,
html.theme-switching .gc-profile-sheet,
html.theme-switching .site-header,
html.theme-switching .gc-chrome,
html.theme-switching .glass,
html.locale-switching body,
html.locale-switching .nav-drawer,
html.locale-switching .gc-settings,
html.locale-switching .gc-profile-sheet {
  transition:
    color var(--mo-dur-base) var(--mo-ease-standard),
    background-color var(--mo-dur-base) var(--mo-ease-standard),
    background var(--mo-dur-base) var(--mo-ease-standard),
    border-color var(--mo-dur-base) var(--mo-ease-standard),
    box-shadow var(--mo-dur-base) var(--mo-ease-standard),
    opacity var(--mo-dur-fast) var(--mo-ease-standard) !important;
}

html.locale-switching body {
  animation: mo-locale-soft var(--mo-dur-base) var(--mo-ease-standard) both;
}

@keyframes mo-locale-soft {
  0% { opacity: 0.72; }
  100% { opacity: 1; }
}

/* Segment pills (theme / EN-ES) — smooth active chip */
.nav-drawer__segment button,
.nav-drawer .theme-toggle-row button,
.nav-drawer .locale-toggle button,
.gc-settings-v3 .gc-set-segment__btn,
.gc-settings-v3 .theme-toggle-row button {
  transition:
    background var(--mo-dur-fast) var(--mo-ease-standard),
    color var(--mo-dur-fast) var(--mo-ease-standard),
    box-shadow var(--mo-dur-fast) var(--mo-ease-standard),
    transform var(--mo-dur-xfast) var(--mo-ease-standard) !important;
}

@supports (view-transition-name: none) {
  html[data-vt="theme"]::view-transition-old(root),
  html[data-vt="theme"]::view-transition-new(root) {
    animation-duration: var(--mo-dur-slow);
    animation-timing-function: var(--mo-ease-standard);
    mix-blend-mode: normal;
  }

  html[data-vt="theme"]::view-transition-old(root) {
    animation-name: mo-theme-out;
  }

  html[data-vt="theme"]::view-transition-new(root) {
    animation-name: mo-theme-in;
  }

  html[data-vt="locale"]::view-transition-old(root),
  html[data-vt="locale"]::view-transition-new(root) {
    animation-duration: var(--mo-dur-base);
    animation-timing-function: var(--mo-ease-standard);
  }

  html[data-vt="locale"]::view-transition-old(root) {
    animation-name: mo-theme-out;
  }

  html[data-vt="locale"]::view-transition-new(root) {
    animation-name: mo-theme-in;
  }

  @keyframes mo-theme-out {
    to { opacity: 0; }
  }

  @keyframes mo-theme-in {
    from { opacity: 0; }
  }
}

html[data-motion="off"].theme-switching,
html[data-motion="off"].locale-switching,
html[data-motion="off"][data-vt] {
  transition: none !important;
}

html[data-motion="off"].locale-switching body {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-switching,
  html.locale-switching,
  html.theme-switching body,
  html.locale-switching body,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
    transition: none !important;
  }
}
