/* CtrlCopy motion kit.
   Everything animates transform or opacity, so effects stay smooth on cheap phones.
   All of it switches off under prefers-reduced-motion at the end of this file.
   Expects these colour tokens from the site: --fg --bg --accent --line */

/* Light-up button. Recipe taken from AuthKit: the fill lightens in 150ms. The glow is ours. */
.cc-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 6px 6px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s cubic-bezier(.4, 0, .2, 1), box-shadow .2s cubic-bezier(.4, 0, .2, 1);
}
.cc-btn:hover {
  background: color-mix(in srgb, var(--fg) 80%, var(--accent));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent), 0 8px 28px color-mix(in srgb, var(--accent) 40%, transparent);
}
.cc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cc-btn > i {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--fg);
  font-style: normal;
  transition: transform .2s cubic-bezier(.4, 0, .2, 1);
}
.cc-btn:hover > i { transform: translateX(2px); }

/* Theme button: shows the mode a click switches to. Handled here rather than in motion.js so the icon is right on first paint. */
.cc-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cc-sun { display: block; }
  :root:not([data-theme="light"]) .cc-moon { display: none; }
}
:root[data-theme="dark"] .cc-sun { display: block; }
:root[data-theme="dark"] .cc-moon { display: none; }

/* Click-to-reveal options: a panel's own display rule would otherwise override `hidden` and show every panel at once. */
[role="tabpanel"][hidden] { display: none; }

/* Ambient background. AuthKit's faint grid, a slow breathing light, and a few pulsing points. */
.cc-ambient { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cc-ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 88px 88px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 72% 60% at 50% 0, #000 15%, transparent 78%);
  mask-image: radial-gradient(ellipse 72% 60% at 50% 0, #000 15%, transparent 78%);
}
.cc-ambient::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -420px;
  width: min(1000px, 130%);
  aspect-ratio: 1;
  margin-left: calc(min(1000px, 130%) / -2);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 24%, transparent), transparent 72%);
  animation: cc-breathe 7s ease-in-out infinite;
}
.cc-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  margin: -2px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px var(--accent);
  animation: cc-blink 5s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}
@keyframes cc-breathe { 50% { opacity: .55; transform: scale(1.06); } }
@keyframes cc-blink { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }

/* Objects that drift, and follow the cursor a little (Acctual's desk, Shopify's image shift). */
.cc-depth { transform: translate3d(var(--px, 0), var(--py, 0), 0); transition: transform .3s ease-out; }
.cc-float { animation: cc-float 9s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes cc-float { 50% { transform: translateY(-9px); } }

/* Text that stays with you while photos scroll past (Icebug's Shoe Finder). */
.cc-sticky { position: sticky; top: var(--cc-sticky-top, 104px); align-self: start; }

/* Scroll-linked pieces. motion.js sets --p from 0 to 1. Without it they rest in the final position. */
.cc-rise { transform: translate(calc(var(--p, 1) * var(--shift, 0px)), calc((1 - var(--p, 1)) * var(--rise, 200px))) rotate(calc(var(--p, 1) * var(--tilt, 0deg))); }

/* A receipt printing line by line, then the stamp landing. */
.cc-print { animation: cc-print .45s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 80ms + 200ms); }
.cc-stamp { animation: cc-stamp .4s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--stamp-delay, 1.5s); }
@keyframes cc-print { from { opacity: 0; transform: translateY(-8px); } }
@keyframes cc-stamp { from { opacity: 0; transform: scale(1.6) rotate(var(--stamp-tilt, -10deg)); } }

@media (prefers-reduced-motion: reduce) {
  .cc-ambient::after, .cc-spark, .cc-float, .cc-print, .cc-stamp { animation: none; }
  .cc-btn, .cc-btn > i, .cc-depth { transition: none; }
}
