/* =============================================================
   Hero animation
   On page load: fragments of chaotic documentation animate into
   a single organized datasheet over 2.2s.
   CSS-only. Respects prefers-reduced-motion via main stylesheet.
   ============================================================= */

.hero {
  position: relative;
  padding: 2rem 0 4rem;
  min-height: 32rem;
  text-align: center;
}

/* Center hero text content, override the lede max-width centering */
.hero .eyebrow {
  justify-content: center;
}
.hero h1 {
  margin-left: auto;
  margin-right: auto;
}
.hero p.lede,
.hero p.lede--wide {
  margin-left: auto;
  margin-right: auto;
}

/* CTAs need to be centered within the hero too */
.hero .cta-row {
  justify-content: center;
  margin-top: 3rem;
}

.hero__stage {
  position: relative;
  height: 24rem;
  margin: 4rem auto 3rem;
  max-width: 56rem;
  text-align: left;
}

/* All fragments share this base */
.frag {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 0.9rem 1.1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  will-change: transform, opacity;
  transform-origin: center;
  animation: frag-enter 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.frag__type {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 0.35rem;
  display: block;
}
.frag__body {
  color: var(--ink-muted);
}
.frag__body strong { color: var(--ink); }

/* Each fragment has a start position (chaotic) and a final position
   (neatly on a grid). We animate from start to final. */

/* Fragment 1 - Slack message */
.frag--1 {
  --start-x: 4%;
  --start-y: 8%;
  --start-rot: -4deg;
  --end-x: 0%;
  --end-y: 0%;
  --end-rot: 0deg;
  width: 22rem;
  animation-delay: 0s;
}

/* Fragment 2 - Wiki page title */
.frag--2 {
  --start-x: 48%;
  --start-y: 18%;
  --start-rot: 2deg;
  --end-x: 38%;
  --end-y: 0%;
  --end-rot: 0deg;
  width: 18rem;
  animation-delay: 0.08s;
}

/* Fragment 3 - Email subject */
.frag--3 {
  --start-x: 28%;
  --start-y: 58%;
  --start-rot: 5deg;
  --end-x: 0%;
  --end-y: 32%;
  --end-rot: 0deg;
  width: 24rem;
  animation-delay: 0.16s;
}

/* Fragment 4 - Stale PDF filename */
.frag--4 {
  --start-x: 62%;
  --start-y: 52%;
  --start-rot: -6deg;
  --end-x: 38%;
  --end-y: 32%;
  --end-rot: 0deg;
  width: 20rem;
  animation-delay: 0.24s;
}

/* Fragment 5 - Sticky note */
.frag--5 {
  --start-x: 8%;
  --start-y: 78%;
  --start-rot: 8deg;
  --end-x: 0%;
  --end-y: 64%;
  --end-rot: 0deg;
  width: 16rem;
  animation-delay: 0.32s;
  background: #f7ec9e;
  border-color: #e0d678;
}

/* Fragment 6 - README excerpt */
.frag--6 {
  --start-x: 52%;
  --start-y: 84%;
  --start-rot: -3deg;
  --end-x: 38%;
  --end-y: 64%;
  --end-rot: 0deg;
  width: 22rem;
  animation-delay: 0.40s;
}

/* Final assembled datasheet card appears over the grid.
   Centered inside the stage so it's visually balanced. */
.frag--final {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scale(0.98);
  width: 100%;
  max-width: 42rem;
  height: 100%;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 2px;
  padding: 2rem;
  opacity: 0;
  animation: final-enter 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 1.6s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 2;
}

.frag:not(.frag--final) {
  z-index: 1;
}

.frag--final::before {
  content: "DATASHEET";
  position: absolute;
  top: -0.6rem;
  left: 1.5rem;
  background: var(--paper);
  padding: 0 0.6rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--rust);
}

.frag--final h3 {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin: 0 0 0.25rem;
  font-variation-settings: "opsz" 72, "SOFT" 50;
}
.frag--final .meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}
.frag--final .fields {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.6rem 1rem;
  font-size: 0.88rem;
}
.frag--final .fields dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faded);
  padding-top: 0.1rem;
}
.frag--final .fields dd {
  margin: 0;
  color: var(--ink);
}
.frag--final .fields dd.stable { color: var(--blue); font-weight: 600; }

@keyframes frag-enter {
  0% {
    left: var(--start-x);
    top: var(--start-y);
    transform: rotate(var(--start-rot));
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  70% {
    left: var(--end-x);
    top: var(--end-y);
    transform: rotate(var(--end-rot));
    opacity: 1;
  }
  100% {
    left: var(--end-x);
    top: var(--end-y);
    transform: rotate(var(--end-rot));
    opacity: 0;
  }
}

@keyframes final-enter {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

/* Scroll-triggered reveals for other sections */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: reveal 800ms cubic-bezier(0.3, 0, 0.2, 1) forwards;
  animation-delay: 0.3s;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive: on small screens, skip the scattered animation.
   Just show the final card directly. */
@media (max-width: 800px) {
  .hero__stage { height: auto; min-height: 18rem; }
  .frag:not(.frag--final) { display: none; }
  .frag--final {
    position: relative;
    opacity: 1;
    transform: none;
    animation: none;
  }
}
