/*
 * InfoAina Motion Switch - styles.
 * Built from the theme's own tokens (--panel, --border, --glow, --mono ...), so it
 * follows the dark/light toggle. Every class and id starts with "ia-motion".
 */

/* ---------- What the switch does to the page ---------- */

/* OFF: tiles stay still, in the same calm look the theme already uses for "reduce motion". */
body[data-infoaina-motion="off"] .tile {
  animation: none;
  --k: 0.14;
}

/* ON means ON, even if the device asks for reduced motion (the visitor chose it).
   Same animation as .tile in style.css. */
@media (prefers-reduced-motion: reduce) {
  body[data-infoaina-motion="on"] .tile {
    --k: 0.05;
    animation: tile-wave 6.4s ease-in-out infinite;
    animation-delay: var(--delay, 0s);
  }
}

/* ---------- The switch ---------- */
.ia-motion {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  min-height: 40px;
  padding: 0 12px 0 16px;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: rgba(var(--panel-rgb), 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 28px -12px rgba(0, 0, 0, var(--shadow-alpha));
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color 0.2s ease;
}
.ia-motion[hidden] { display: none; }
.ia-motion--right { right: max(16px, env(safe-area-inset-right)); }
.ia-motion--left { left: max(16px, env(safe-area-inset-left)); }
.ia-motion:hover { border-color: var(--glow); }

.ia-motion__label { color: var(--text-soft); }
.ia-motion__state {
  min-width: 3ch; /* "On" and "Off" take the same room, so the pill never resizes */
  color: var(--text);
}

/* Same size and shape as the theme's light/dark toggle. */
.ia-motion__track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  transition: border-color 0.2s ease;
}
.ia-motion__dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-soft);
  transition: transform 0.25s ease, background 0.25s ease;
}
.ia-motion[aria-checked="true"] .ia-motion__track { border-color: var(--glow-soft); }
.ia-motion[aria-checked="true"] .ia-motion__dot { transform: translateX(16px); background: var(--glow); }

/* On screens narrow enough for the switch to meet the footer, leave room under it. */
@media (max-width: 1460px) {
  body.ia-motion-active .site-footer { padding-bottom: 88px; }
}

/* ---------- Small screens, touch, motion, print ---------- */
@media (max-width: 520px) {
  .ia-motion__state { display: none; }
  .ia-motion { padding-left: 14px; }
}
@media (pointer: coarse) {
  .ia-motion { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .ia-motion, .ia-motion__track, .ia-motion__dot { transition: none; }
}
@media print {
  .ia-motion { display: none; }
}
