/*
 * Orbiteer web motion: the boot screen, element reveals, title words, the
 * orbit loader and skeleton shimmer. Driven by src/components/web/motion.ts.
 * Colours follow src/components/ui/colors.js.
 */

:root {
  --ob-night: #0E0F12;
  --ob-card: #16181C;
  --ob-raised: #1D1F24;
  --ob-line: #24262B;
  --ob-bone: #F2F2F0;
  --ob-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Boot: shown from the first frame until the app has mounted. ---------- */
/* #279 (Hugo TG 431): the face-only mark in the centre. Its entry is variant A (class va: the outline draws round,
   the eyes open and blink) or B (class vb: it rises in, blinks, and a blue ring waves out), set on #boot in
   index.html. It holds there until the app has drawn (motion.tsx hideBoot, never before data-intro-ms), and if
   the app is still loading after the entry, a faint arc turns slowly round it: the only thing that spins. */

@property --boot-sweep { syntax: '<angle>'; inherits: false; initial-value: 360deg; }

#boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 700px at 50% 42%, #15171c 0%, var(--ob-night) 62%);
  transition: opacity 0.5s var(--ob-ease), visibility 0s linear 0.5s;
}
#boot.out { opacity: 0; visibility: hidden; }

.boot-face { position: relative; width: clamp(96px, 16vmin, 140px); aspect-ratio: 1; }
.boot-face svg { position: relative; display: block; width: 100%; height: 100%; overflow: visible; }
.boot-face .eye { transform-box: fill-box; transform-origin: center; }
.boot-wait {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(242, 242, 240, 0.5) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  opacity: 0;
  animation: boot-show 0.4s ease 1.2s forwards, spin 2.4s linear 1.2s infinite;
}
.boot-hi {
  position: absolute;
  inset: -7%;
  border-radius: 50%;
  border: 1.5px solid rgba(93, 204, 255, 0.9);
  box-shadow: 0 0 24px rgba(0, 175, 255, 0.5), inset 0 0 24px rgba(0, 175, 255, 0.35);
  opacity: 0;
}

/* A, "draws and wakes": the outline sweeps round clockwise (0 to 0.5 s), the eyes open (0.5 to 0.68 s) and blink
   once (0.8 to 0.92 s). */
#boot.va .o {
  -webkit-mask: conic-gradient(from -90deg, #000 var(--boot-sweep), transparent 0);
  mask: conic-gradient(from -90deg, #000 var(--boot-sweep), transparent 0);
  animation: boot-sweep 0.5s cubic-bezier(0.65, 0, 0.35, 1) both;
}
#boot.va .eye { animation: boot-open 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) 0.5s both, boot-blink 0.12s ease-in-out 0.8s; }

/* B, "arrives and says hi": the face rises in (0 to 0.35 s), blinks (0.42 to 0.54 s), and an Orbiteer-blue ring
   waves out from it (0.55 to 1 s). */
#boot.vb .boot-face { animation: boot-arrive 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#boot.vb .eye { animation: boot-blink 0.12s ease-in-out 0.42s; }
#boot.vb .boot-hi { animation: boot-wave 0.45s cubic-bezier(0.3, 0.6, 0.2, 1) 0.55s forwards; }

/* ---------- Reveals: elements rise into place as they come into view. ---------- */

html.rv [data-reveal]:not([data-shown]),
html.rv [data-reveal-kid]:not([data-shown]) {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  filter: blur(6px);
}
html.rv [data-shown='in'] {
  transition:
    opacity 0.7s var(--ob-ease),
    transform 0.9s var(--ob-ease),
    filter 0.7s var(--ob-ease);
  transition-delay: var(--rv-delay, 0ms);
}

/* Title words rise one after another, once the boot screen has gone. */
html.rv [data-word] { display: inline-block; opacity: 0; }
html.rv.go [data-word] {
  animation: word 0.9s var(--ob-ease) both;
  animation-delay: calc(var(--i, 0) * 55ms + 40ms);
}

/* ---------- Orbit loader: a satellite on its ring. ---------- */

.ob-loader {
  position: relative;
  width: var(--s, 28px);
  height: var(--s, 28px);
  flex: none;
}
.ob-loader::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--c, var(--ob-bone)) 16%, transparent);
}
.ob-loader .ob-trail {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 66%, color-mix(in srgb, var(--c, var(--ob-bone)) 60%, transparent) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  animation: spin 1.1s linear infinite;
}
.ob-loader .ob-sat { position: absolute; inset: 0; animation: spin 1.1s linear infinite; }
.ob-loader .ob-sat::after {
  content: '';
  position: absolute;
  top: calc(var(--d, 5px) / -2 + 0.5px);
  left: 50%;
  width: var(--d, 5px);
  height: var(--d, 5px);
  margin-left: calc(var(--d, 5px) / -2);
  border-radius: 50%;
  background: var(--c, var(--ob-bone));
  box-shadow: 0 0 8px 1px color-mix(in srgb, var(--c, var(--ob-bone)) 50%, transparent);
}
.ob-loader .ob-core {
  position: absolute;
  inset: 40%;
  border-radius: 50%;
  background: var(--c, var(--ob-bone));
  opacity: 0.85;
  animation: breathe 2.2s ease-in-out infinite;
}
.ob-loader-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: fade 0.4s var(--ob-ease) 0.15s both;
}
.ob-loader-label {
  font-family: HostGrotesk_500Medium, system-ui, sans-serif;
  font-size: 12px;
  color: #8E9099;
}

/* ---------- Skeletons: one light sweeps across every block at once. ---------- */

.sk-list { display: flex; flex-direction: column; gap: 12px; }
.sk-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1024px) { .sk-grid { grid-template-columns: 1fr 1fr; } }
.sk-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--ob-line);
  background: var(--ob-card);
  animation: rise 0.6s var(--ob-ease) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}
.sk-card.tile { padding: 0; overflow: hidden; gap: 0; }
.sk-card.tile .sk-body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 20px; }
.sk-row { display: flex; align-items: center; gap: 14px; }
.sk-col { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.sk {
  border-radius: 999px;
  background: linear-gradient(100deg, var(--ob-raised) 35%, #2a2c32 50%, var(--ob-raised) 65%) fixed;
  background-size: 200vw 100%;
  animation: shimmer 1.8s linear infinite;
}
.sk.img { border-radius: 0; height: 150px; }
.sk.round { border-radius: 50%; flex: none; }

/* ---------- Keyframes ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(0.92); opacity: 0.75; } 50% { transform: scale(1); opacity: 1; } }
@keyframes bar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes boot-sweep { from { --boot-sweep: 0deg; } to { --boot-sweep: 360deg; } }
@keyframes boot-open { from { transform: scaleY(0); } }
@keyframes boot-blink { 0%, 100% { transform: none; } 50% { transform: scaleY(0.12); } }
@keyframes boot-arrive { from { opacity: 0; transform: translateY(10px) scale(0.86); } }
@keyframes boot-wave { 0% { opacity: 0; transform: scale(0.7); } 20% { opacity: 1; } 100% { opacity: 0; transform: scale(5); } }
@keyframes boot-show { to { opacity: 1; } }
@keyframes word { from { opacity: 0; transform: translateY(0.45em); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes shimmer { from { background-position: 100vw 0; } to { background-position: -100vw 0; } }

/* Less motion asked for: content shows at once and loaders hold still. */
@media (prefers-reduced-motion: reduce) {
  html.rv [data-reveal]:not([data-shown]),
  html.rv [data-reveal-kid]:not([data-shown]) { opacity: 1; transform: none; filter: none; }
  html.rv [data-word], html.rv.go [data-word] { opacity: 1; animation: none; }
  /* The boot face shows still, with no arc turning. */
  #boot .boot-face, #boot .boot-face *, #boot .o { animation: none !important; -webkit-mask: none; mask: none; }
  .ob-loader .ob-trail, .ob-loader .ob-sat, .ob-loader .ob-core,
  .sk, .sk-card { animation: none; }
}
