/* cheapgc loaders (loader.js has the API): skeletons with a slow violet-tinted sweep, the brand loader (the four-point
   star breathing inside a violet orbit), and a small spinner for buttons. Every loader fades in only after
   --cg-ld-delay (160 ms), so a fast load never shows one. Under reduced motion they hold still, with a slow opacity
   pulse at most. No dependencies: the colours fall back to cheapgc's own when the app's tokens are absent. */

:root { --cg-ld-delay: 160ms; }

@keyframes cg-ld-in { from { opacity: 0; } }
@keyframes cg-ld-sweep { from { translate: -100% 0; } to { translate: 100% 0; } }
@keyframes cg-ld-breathe { 0%, 100% { scale: 0.84; opacity: 0.82; } 50% { scale: 1; opacity: 1; } }
@keyframes cg-ld-turn { to { rotate: 360deg; } }
@keyframes cg-ld-pulse { 50% { opacity: 0.55; } }
@keyframes cg-ld-hush { to { color: transparent; } }

/* ---------- Skeletons ---------- */

.cg-skel {
  position: relative; overflow: hidden; isolation: isolate;
  background: oklch(95.4% 0.012 292);
  animation: cg-ld-in 320ms cubic-bezier(0.2, 0, 0, 1) calc(var(--cg-ld-delay) + var(--i, 0) * 70ms) both;
}
/* the sweep: a soft diagonal band of light with a faint violet edge, slow, a little later on each card of a row */
.cg-skel::after {
  content: ""; position: absolute; inset: 0 -60%; z-index: 1; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, oklch(97.5% 0.03 300 / 0.55) 42%, oklch(100% 0 0 / 0.9) 50%, oklch(96% 0.04 285 / 0.5) 58%, transparent 68%);
  animation: cg-ld-sweep 2200ms cubic-bezier(0.45, 0, 0.25, 1) calc(var(--i, 0) * 120ms) infinite;
}
/* a template card (the home's C-cover cards: 9:16 or 16:9, 15 px corners), with a faint title bar at its foot */
.cg-skel-card { aspect-ratio: 9 / 16; border-radius: 15px; }
.cg-skel-card[data-format="h"] { aspect-ratio: 16 / 9; }
.cg-skel-card::before {
  content: ""; position: absolute; left: 10%; bottom: 7%; width: 56%; height: 9px; border-radius: 5px; background: oklch(91.5% 0.016 290);
}
/* a line of text: a row's title, a heading */
.cg-skel-line { display: inline-block; width: var(--w, 8em); height: 0.8em; border-radius: 6px; vertical-align: middle; }
/* any block (a hero's video area, a picture): give it a size and a radius */
.cg-skel-block { border-radius: var(--r, 18px); }
.row.is-skel .row-head { min-height: 29px; }
.row.is-skel .track { overflow: hidden; }

/* ---------- The brand loader: the star breathing in a violet orbit ---------- */

.cg-loader {
  --cg-ld-size: 44px; --cg-ld-ink: var(--violet, oklch(54% 0.24 286)); --cg-ld-star: var(--violet-mark, oklch(60% 0.22 287));
  position: relative; display: inline-grid; place-items: center; width: var(--cg-ld-size); height: var(--cg-ld-size); flex: none;
  animation: cg-ld-in 280ms cubic-bezier(0.2, 0, 0, 1) var(--cg-ld-delay) both;
}
.cg-loader svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; color: var(--cg-ld-ink); }
.cg-loader .cg-ld-star { color: var(--cg-ld-star); transform-origin: 50% 50%; transform-box: fill-box; animation: cg-ld-breathe 1600ms cubic-bezier(0.45, 0, 0.55, 1) infinite; }
.cg-loader .cg-ld-track { fill: none; stroke: var(--cg-ld-ink); stroke-opacity: 0.12; stroke-width: 1.4; }
.cg-loader .cg-ld-arc { fill: none; stroke-width: 1.8; stroke-linecap: round; transform-origin: 50% 50%; animation: cg-ld-turn 1300ms linear infinite; }
.cg-loader .cg-ld-spark { fill: #fff; filter: drop-shadow(0 0 2px var(--cg-ld-ink)); }
/* over video or a dark picture: a light star and orbit on a soft dark glass disc */
.cg-loader.is-light { --cg-ld-ink: oklch(100% 0 0); --cg-ld-star: oklch(100% 0 0); }
.cg-loader.is-light::before {
  content: ""; position: absolute; inset: -38%; border-radius: 50%; background: oklch(18% 0.03 280 / 0.42);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
/* centred over a host (a card, a player, the hero): the host gets .cg-ld-host */
.cg-ld-host { position: relative; }
.cg-ld-over { position: absolute; inset: 0; margin: auto; z-index: 5; pointer-events: none; }

/* ---------- Small spinner, inline and in buttons ---------- */

.cg-spin {
  display: inline-block; width: 1.15em; height: 1.15em; border-radius: 50%; flex: none; vertical-align: -0.2em; color: var(--cg-spin-color, currentColor);
  background: conic-gradient(from 90deg, transparent 0 12%, currentColor 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 1.8px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.2px), #000 calc(100% - 1.8px));
  animation: cg-ld-in 200ms ease var(--cg-ld-delay) both, cg-ld-turn 760ms linear infinite;
}
/* a busy button keeps its size: its label goes quiet as the spinner appears in its middle */
.cg-busy { position: relative; pointer-events: none; animation: cg-ld-hush 1ms linear var(--cg-ld-delay) forwards; }
.cg-busy > .cg-busy-spin { position: absolute; inset: 0; margin: auto; }

/* ---------- Leaving: loaders and skeletons fade as their content comes in (loader.js reveal) ---------- */

.cg-ld-out { animation: none !important; opacity: 0; transition: opacity 260ms cubic-bezier(0.4, 0, 0.2, 1); }

@media (prefers-reduced-motion: reduce) {
  .cg-skel::after, .cg-loader .cg-ld-arc { display: none; }
  .cg-loader .cg-ld-track { stroke-opacity: 0.3; }
  .cg-skel, .cg-loader, .cg-spin { animation: cg-ld-in 1ms var(--cg-ld-delay) both, cg-ld-pulse 1800ms ease-in-out var(--cg-ld-delay) infinite; }
  .cg-loader .cg-ld-star { animation: none; }
  .cg-spin { background: conic-gradient(currentColor 0 70%, transparent 70%); }
}
