/**
 * Power-save CSS — same look when the calendar is on-screen; freeze continuous
 * GPU work when the tab is backgrounded or the device is on low battery /
 * Data Saver / prefers-reduced-motion (via html[data-cal-power]).
 */

/* ------------------------------------------------------------------ */
/* Tab hidden: pause every running animation/transition immediately.  */
/* ------------------------------------------------------------------ */
html[data-cal-power="idle"] *,
html[data-cal-power="idle"] *::before,
html[data-cal-power="idle"] *::after {
  animation-play-state: paused !important;
}

html[data-cal-power="idle"] {
  /* Hint to the UA that we are not interactive — some browsers lower timers. */
}

/* ------------------------------------------------------------------ */
/* Low battery / Data Saver: freeze ambient loops, keep the painted   */
/* frame so the page still looks premium — just not spinning forever. */
/* ------------------------------------------------------------------ */
html[data-cal-power="saver"] .ambient__orb,
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit)::before,
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit)::after,
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit) .cal-page::before,
html[data-cal-power="saver"] .site-brand__rim,
html[data-cal-power="saver"] .gc-day__num::before,
html[data-cal-power="saver"] .gc-day__num::after,
html[data-cal-power="saver"] .gc-day--today .gc-day__num::before,
html[data-cal-power="saver"] .gc-day--today .gc-day__num::after,
html[data-cal-power="saver"] .lgfx-rim::before,
html[data-cal-power="saver"] .lgfx-rim::after,
html[data-cal-power="saver"] .gc-ptr__spinner {
  animation-play-state: paused !important;
  will-change: auto !important;
}

/* Keep aurora readable when frozen (mid-cycle opacity can look washed out). */
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit)::before {
  opacity: 0.92 !important;
}
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit)::after {
  opacity: 0.82 !important;
}
html[data-cal-power="saver"] body.category-page--games:has(.gc-app--mobile-month-fit) .cal-page::before {
  opacity: 0.38 !important;
}

/* Drop permanent will-change layers that pin compositor memory. */
html[data-cal-power="saver"] .ambient__orb,
html[data-cal-power="idle"] .ambient__orb {
  will-change: auto !important;
}

/* ------------------------------------------------------------------ */
/* Layout containment — same pixels, cheaper invalidation / paint.    */
/* ------------------------------------------------------------------ */
/* Year minis are the heavy paint path — skip work for off-screen months. */
.gc-grid--year .gc-year-mini,
.gc-grid--year-mobile-fit .gc-year-mini {
  content-visibility: auto;
  contain-intrinsic-size: auto 9.5rem;
  contain: layout style;
}

/* Soft glass: skip expensive backdrop samples for fully off-screen chrome
   is hard; instead reduce blur cost only under saver (visual near-identical). */
@media (max-width: 900px) {
  html[data-cal-power="saver"] .gc-empty-state.glass,
  html[data-cal-power="saver"] .gc-toolbar .glass,
  html[data-cal-power="saver"] .gc-upcoming.glass {
    backdrop-filter: blur(12px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(140%) !important;
  }
}

/* =========================================================================
   MOBILE UPCOMING — universal horizontal scroll (last in cascade)
   JS owns the gesture (Pointer/Touch → scrollLeft) on every engine.
   touch-action:none avoids browser/JS fighting on iOS + Android + WebViews.
   ========================================================================= */
@media (max-width: 900px) {
  body.category-page--games:has(.gc-app) .gc-upcoming-wrap--mobile,
  body.category-page--games:has(.gc-app) .gc-upcoming-mobile-stack,
  body.category-page--games:has(.gc-app) .gc-upcoming--month-scroll,
  body.category-page--games:has(.gc-app) .gc-upcoming--year-scroll {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  body.category-page--games:has(.gc-app) .gc-upcoming-wrap--mobile {
    overflow: visible !important;
    touch-action: none !important;
  }

  body.category-page--games:has(.gc-app) .gc-upcoming--month-scroll,
  body.category-page--games:has(.gc-app) .gc-upcoming--year-scroll {
    overflow: hidden !important;
    touch-action: none !important;
  }

  body.category-page--games:has(.gc-app) .gc-upcoming--month-scroll .gc-upcoming__track,
  body.category-page--games:has(.gc-app) .gc-upcoming--year-scroll .gc-upcoming__track,
  body.category-page--games:has(.gc-app) .gc-app--mobile-month-fit .gc-upcoming--month-scroll .gc-upcoming__track,
  body.category-page--games:has(.gc-app) .gc-app--mobile-month-fit .gc-upcoming--year-scroll .gc-upcoming__track {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
    touch-action: none !important;
    scroll-snap-type: none !important;
    scroll-behavior: auto !important;
    contain: none !important;
    cursor: grab !important;
  }

  body.category-page--games:has(.gc-app) .gc-upcoming--month-scroll .gc-upcoming-card--stacked,
  body.category-page--games:has(.gc-app) .gc-upcoming--year-scroll .gc-upcoming-card--stacked {
    flex: 0 0 var(--gc-upcoming-card-w, clamp(5.5rem, 36vw, 6.75rem)) !important;
    width: var(--gc-upcoming-card-w, clamp(5.5rem, 36vw, 6.75rem)) !important;
    min-width: var(--gc-upcoming-card-w, clamp(5.5rem, 36vw, 6.75rem)) !important;
    max-width: var(--gc-upcoming-card-w, clamp(5.5rem, 36vw, 6.75rem)) !important;
    touch-action: none !important;
    pointer-events: auto !important;
    -webkit-user-drag: none !important;
    user-select: none !important;
  }
}
