/* Magical animation system for tejbeerbhullar.com */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  background-attachment: scroll;
}

.boot-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(94, 234, 212, 0.1), transparent 24rem),
    #020409;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.boot-mask[hidden] {
  display: none;
}

body.boot-active .boot-mask,
.boot-mask.is-active {
  opacity: 1;
  visibility: visible;
}

.boot-mask.is-released {
  opacity: 0;
  visibility: visible;
  transition: opacity 320ms var(--ease-out);
}

.boot-mask__glyph {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(6rem, 18vw, 14rem);
  aspect-ratio: 1;
  color: #e8ecf2;
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 11vw, 9rem);
  line-height: 1;
  border: 1px solid rgba(232, 236, 242, 0.22);
  background:
    linear-gradient(145deg, rgba(232, 236, 242, 0.13), transparent 45%),
    rgba(5, 7, 13, 0.72);
  box-shadow:
    0 0 0 1px rgba(94, 234, 212, 0.1),
    0 0 60px rgba(94, 234, 212, 0.18),
    inset 0 0 40px rgba(94, 234, 212, 0.08);
  transform: scale(0.74);
  animation: bootGlyph 1.55s var(--ease-out) forwards;
}

.boot-mask__noise {
  position: absolute;
  width: min(54vmin, 32rem);
  aspect-ratio: 1;
  opacity: 0.62;
  mix-blend-mode: screen;
  clip-path: inset(12% 12% 12% 12%);
}

.boot-mask__beam {
  position: absolute;
  width: 42vmin;
  height: 120vh;
  background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.7), rgba(251, 191, 36, 0.54), transparent);
  filter: blur(10px);
  transform: translateX(-60vw) rotate(19deg);
  animation: bootBeam 1.55s var(--ease-out) forwards;
}

.topbar__command {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  min-width: 2.8rem;
  height: 2.2rem;
  padding: 0 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.035);
}

.topbar__command:hover,
.topbar__command:focus-visible {
  color: var(--ink-1);
  border-color: rgba(94, 234, 212, 0.35);
  background: rgba(94, 234, 212, 0.08);
}

.request-spine {
  position: fixed;
  left: clamp(0.55rem, 1.5vw, 1.25rem);
  top: 50%;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transform: translateY(-50%);
  isolation: isolate;
}

.request-spine a {
  position: relative;
  display: block;
  width: 0.72rem;
  height: 0.72rem;
  overflow: hidden;
  color: transparent;
  border: 1px solid rgba(232, 236, 242, 0.2);
  border-radius: 999px;
  background: rgba(232, 236, 242, 0.07);
}

.request-spine a::after {
  position: absolute;
  left: 1.05rem;
  top: 50%;
  content: attr(data-spine-step);
  min-width: max-content;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  transform: translateY(-50%) translateX(-0.4rem);
  opacity: 0;
  transition: opacity var(--d-fast), transform var(--d-fast);
}

.request-spine a:hover::after,
.request-spine a:focus-visible::after,
.request-spine a[aria-current="step"]::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.request-spine a[aria-current="step"] {
  border-color: rgba(94, 234, 212, 0.7);
  background: var(--accent);
  box-shadow: 0 0 18px rgba(94, 234, 212, 0.38);
}

.request-spine__packet {
  position: absolute;
  left: 0.18rem;
  top: 0.18rem;
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 999px;
  background: #fbbf24;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.55);
  transform: translateY(calc(var(--spine-index, 0) * 1.07rem));
  transition: transform 420ms var(--ease-out);
}

.hero {
  position: relative;
  overflow: hidden;
}

.hero-artifact {
  position: absolute;
  right: clamp(1rem, 6vw, 5rem);
  top: clamp(7rem, 14vh, 10rem);
  z-index: -1;
  width: clamp(15rem, 31vw, 31rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  opacity: 0.9;
  perspective: 900px;
}

.hero-artifact__frame {
  position: relative;
  width: 66%;
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transform: rotateX(var(--origin-tilt-x, 0deg)) rotateY(var(--origin-tilt-y, 0deg));
  transition: transform 260ms var(--ease-out);
}

.hero-artifact__core {
  position: absolute;
  inset: 18%;
  border: 1px solid rgba(232, 236, 242, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(232, 236, 242, 0.24), transparent 28%),
    linear-gradient(320deg, rgba(244, 114, 182, 0.18), transparent 48%),
    rgba(2, 4, 9, 0.86);
  box-shadow:
    0 2rem 5rem rgba(0, 0, 0, 0.6),
    inset 0 0 4rem rgba(94, 234, 212, 0.12),
    0 0 5rem rgba(94, 234, 212, 0.15);
  transform: rotate(45deg) translateZ(2rem);
}

.hero-artifact__ring {
  position: absolute;
  inset: 6%;
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 50%;
  transform: rotateX(64deg) rotateZ(12deg);
}

.hero-artifact__ring--two {
  inset: 0;
  border-color: rgba(251, 191, 36, 0.24);
  transform: rotateX(72deg) rotateZ(-36deg);
}

.hero-artifact__packet-path {
  position: absolute;
  inset: 28%;
  border: 1px dashed rgba(94, 234, 212, 0.42);
  border-radius: 50%;
  animation: artifactOrbit 7s linear infinite;
}

.hero-artifact__packet-path::after {
  position: absolute;
  top: -0.18rem;
  left: 50%;
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--accent-3);
  box-shadow: 0 0 1.2rem rgba(251, 191, 36, 0.65);
}

.stack-stepper {
  display: none;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 1rem;
}

.stack-stepper__btn {
  width: 2.4rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.stack-stepper__panel {
  flex: 1;
  min-height: 7rem;
  padding: 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(5, 7, 13, 0.78);
}

.command-shell[hidden],
.motion-lab[hidden],
.portal-drawer[hidden] {
  display: none;
}

.command-shell {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: start center;
  padding: clamp(5rem, 12vh, 8rem) var(--content-pad) var(--content-pad);
}

.command-shell__scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 9, 0.72);
  backdrop-filter: blur(18px);
}

.command-palette {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.7fr);
  gap: 0;
  width: min(56rem, 100%);
  max-height: min(38rem, 78vh);
  overflow: hidden;
  border: 1px solid rgba(232, 236, 242, 0.14);
  border-radius: 8px;
  background: rgba(5, 7, 13, 0.93);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.55);
}

.command-palette__input {
  grid-column: 1 / -1;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.035);
  outline: none;
  font-family: var(--font-mono);
}

.command-palette__results,
.command-palette__preview {
  min-height: 18rem;
  padding: 0.8rem;
}

.command-palette__preview {
  border-left: 1px solid var(--rule);
  color: var(--ink-2);
  background:
    linear-gradient(145deg, rgba(94, 234, 212, 0.05), transparent 40%),
    rgba(255, 255, 255, 0.018);
}

.command-palette__result {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-1);
  background: transparent;
  text-align: left;
}

.command-palette__result:hover,
.command-palette__result:focus-visible,
.command-palette__result.is-active {
  border-color: rgba(94, 234, 212, 0.28);
  background: rgba(94, 234, 212, 0.08);
}

.command-palette__result-label {
  font-family: var(--font-mono);
}

.command-palette__result-summary {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
}

.terminal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.terminal__chip {
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.035);
}

.terminal__chip:hover,
.terminal__chip:focus-visible {
  color: var(--ink-1);
  border-color: rgba(94, 234, 212, 0.35);
}

.portal-rail {
  align-items: stretch;
}

.portal-card {
  position: relative;
  overflow: hidden;
}

.portal-card::before {
  position: absolute;
  inset: 0;
  content: "";
  border-radius: inherit;
  opacity: 0;
  background:
    linear-gradient(120deg, rgba(94, 234, 212, 0.1), transparent 38%),
    linear-gradient(260deg, rgba(251, 191, 36, 0.08), transparent 45%);
  transition: opacity var(--d-med);
  pointer-events: none;
}

.portal-card:hover::before,
.portal-card:focus-visible::before,
.portal-card.is-highlighted::before {
  opacity: 1;
}

.portal-drawer,
.motion-lab {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  top: max(5rem, env(safe-area-inset-top));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 9400;
  width: min(29rem, calc(100vw - 2rem));
  overflow: auto;
  border: 1px solid rgba(232, 236, 242, 0.14);
  border-radius: 8px;
  background: rgba(5, 7, 13, 0.94);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
}

.portal-drawer__head,
.motion-lab__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--rule);
  background: rgba(5, 7, 13, 0.96);
}

.portal-drawer__head h3,
.motion-lab__head h2 {
  font-size: var(--t-lg);
}

.portal-drawer__close,
.motion-lab [data-motion-lab-close] {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.portal-drawer__body,
.motion-lab__body {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.receipt-row,
.motion-demo {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.receipt-row dt,
.motion-demo__label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  text-transform: uppercase;
}

.receipt-row dd {
  margin: 0;
  color: var(--ink-2);
}

.motion-demo__stage {
  position: relative;
  height: 4rem;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(94, 234, 212, 0.08), transparent 38%),
    rgba(2, 4, 9, 0.56);
}

.motion-demo__dot {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: var(--accent-3);
  box-shadow: 0 0 1rem rgba(251, 191, 36, 0.6);
  transform: translateY(-50%);
  animation: demoTravel 2.8s var(--ease-in-out) infinite;
}

.motion-demo__trail,
.motion-demo__packet {
  position: absolute;
  pointer-events: none;
}

.motion-demo__trail {
  left: 0.8rem;
  right: 0.8rem;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(94, 234, 212, 0.42), transparent);
  transform: translateY(-50%);
}

.motion-demo__packet {
  inset: 0.7rem;
  border: 1px solid rgba(94, 234, 212, 0.25);
  border-radius: 5px;
  opacity: 0;
}

.motion-demo[data-motion-demo="boot-sequence"] .motion-demo__dot {
  left: 50%;
  background: var(--accent);
  box-shadow: 0 0 1.6rem rgba(94, 234, 212, 0.7);
  animation: demoBootPulse 2.4s var(--ease-out) infinite;
}

.motion-demo[data-motion-demo="request-spine"] .motion-demo__dot {
  animation: demoTravel 2.8s steps(5, end) infinite;
}

.motion-demo[data-motion-demo="command-constellation"] .motion-demo__dot {
  top: 1rem;
  left: 50%;
  background: #a78bfa;
  box-shadow: 0 0 1.2rem rgba(167, 139, 250, 0.7);
  animation: demoCommandSnap 2.6s var(--ease-out) infinite;
}

.motion-demo[data-motion-demo="stack-packets"] .motion-demo__dot {
  background: var(--accent-3);
  animation: demoPacketHop 3.1s var(--ease-in-out) infinite;
}

.motion-demo[data-motion-demo="portal-receipts"] .motion-demo__packet {
  opacity: 1;
  animation: demoPortalReveal 3s var(--ease-out) infinite;
}

.craft-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: var(--s-6);
}

.craft-index a,
.craft-index button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.035);
}

.craft-index a:hover,
.craft-index button:hover,
.craft-index a:focus-visible,
.craft-index button:focus-visible {
  color: var(--ink-1);
  border-color: rgba(94, 234, 212, 0.35);
}

@keyframes bootGlyph {
  0% { opacity: 0; transform: scale(0.72); filter: blur(14px); }
  28% { opacity: 1; transform: scale(0.86); filter: blur(0); }
  70% { transform: scale(1); }
  100% { opacity: 0; transform: scale(5.8); filter: blur(18px); }
}

@keyframes bootBeam {
  0%, 48% { opacity: 0; transform: translateX(-60vw) rotate(19deg); }
  60% { opacity: 1; }
  100% { opacity: 0; transform: translateX(60vw) rotate(19deg); }
}

@keyframes artifactOrbit {
  to { transform: rotate(360deg); }
}

@keyframes demoTravel {
  0%, 100% { left: 0.8rem; }
  48% { left: calc(100% - 1.5rem); }
}

@keyframes demoBootPulse {
  0%, 100% { opacity: 0.35; transform: translate(-50%, -50%) scale(0.72); filter: blur(0); }
  38% { opacity: 1; transform: translate(-50%, -50%) scale(1.8); filter: blur(2px); }
  58% { opacity: 0.72; transform: translate(-50%, -50%) scale(0.95); filter: blur(0); }
}

@keyframes demoCommandSnap {
  0%, 100% { transform: translate(-50%, 0) scale(0.82); }
  28% { transform: translate(-2.2rem, 1.25rem) scale(1); }
  56% { transform: translate(2.2rem, 1.25rem) scale(1); }
  76% { transform: translate(-50%, 0) scale(1.18); }
}

@keyframes demoPacketHop {
  0%, 100% { left: 0.8rem; top: 50%; }
  32% { left: 42%; top: 28%; }
  64% { left: calc(100% - 1.5rem); top: 62%; }
}

@keyframes demoPortalReveal {
  0%, 100% { opacity: 0.2; transform: translateY(0.9rem) scale(0.92); }
  42%, 72% { opacity: 1; transform: translateY(0) scale(1); box-shadow: inset 0 0 1.4rem rgba(94, 234, 212, 0.12); }
}

@media (max-width: 960px) {
  .request-spine {
    left: 50%;
    right: auto;
    top: auto;
    bottom: 0.75rem;
    flex-direction: row;
    padding: 0.45rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: rgba(5, 7, 13, 0.86);
    transform: translateX(-50%);
    backdrop-filter: blur(14px);
  }

  .request-spine a::after {
    display: none;
  }

  .request-spine__packet {
    transform: translateX(calc(var(--spine-index, 0) * 1.07rem));
  }

  .hero-artifact {
    right: -4rem;
    top: 7rem;
    width: min(22rem, 72vw);
    opacity: 0.52;
  }

  .stack__svg {
    max-height: 25rem;
  }

  .stack-stepper {
    display: flex;
  }

  .stack__card {
    display: none !important;
  }

  .command-palette {
    grid-template-columns: 1fr;
  }

  .command-palette__preview {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 640px) {
  .topbar__command {
    height: 2rem;
    min-width: 2.35rem;
    padding: 0 0.55rem;
  }

  .hero-artifact {
    top: 6.5rem;
    right: -6rem;
  }

  .portal-drawer,
  .motion-lab {
    left: 0.75rem;
    right: 0.75rem;
    top: 4.5rem;
    bottom: 0.75rem;
    width: auto;
  }
}

body[data-motion="reduced"] .boot-mask,
body[data-motion="reduced"] .boot-mask__glyph,
body[data-motion="reduced"] .boot-mask__beam,
body[data-motion="reduced"] .hero-artifact__packet-path,
body[data-motion="reduced"] .motion-demo__dot,
body[data-motion="reduced"] .motion-demo__packet {
  animation: none !important;
}

body[data-motion="reduced"] .request-spine__packet,
body[data-motion="reduced"] .hero-artifact__frame,
body[data-motion="reduced"] .portal-card::before {
  transition: none !important;
}
