/*
  grid-motion.css — GRID v1.1 motion layer
  Two voices: machine content arrives composed; hand content draws after.
  All hide-states are scoped under .st-motion-ready so no-JS = full visibility.
  prefers-reduced-motion: reduce disables everything; final states only.
*/

/* ── 1. Machine arrival ───────────────────────────────────────────── */
/* Default (no JS): visible */
.st-reveal { }

/* JS active: hide until observer fires */
.st-motion-ready .st-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 380ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.st-motion-ready .st-reveal.st-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger siblings via data-reveal-order */
.st-motion-ready .st-reveal[data-reveal-order="2"] { transition-delay: 60ms; }
.st-motion-ready .st-reveal[data-reveal-order="3"] { transition-delay: 120ms; }
.st-motion-ready .st-reveal[data-reveal-order="4"] { transition-delay: 180ms; }
.st-motion-ready .st-reveal[data-reveal-order="5"] { transition-delay: 240ms; }


/* ── 2. Hand elements — base visual state ────────────────────────── */

/* Highlight sweep: a translucent background drawn left-to-right */
.st-sweep {
  position: relative;
  display: inline;
  background-image: linear-gradient(var(--sweep-color, rgba(245,51,63,0.18)), var(--sweep-color, rgba(245,51,63,0.18)));
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 100% 55%;
  border-radius: 2px;
  padding-bottom: 1px;
}
.st-motion-ready .st-sweep {
  background-size: 0% 55%;
  transition: background-size 520ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: background-size;
}
.st-motion-ready .st-sweep.st-drawn {
  background-size: 100% 55%;
}

/* Cobalt theme sweep */
.theme-cobalt .st-sweep    { --sweep-color: rgba(61,90,255,0.18); }
/* Teal theme sweep */
.theme-teal .st-sweep      { --sweep-color: rgba(18,166,181,0.18); }
/* Violet theme sweep */
.theme-violet .st-sweep    { --sweep-color: rgba(124,92,255,0.18); }
/* Amber theme sweep */
.theme-amber .st-sweep     { --sweep-color: rgba(238,138,30,0.18); }
/* Green theme sweep */
.theme-green .st-sweep     { --sweep-color: rgba(34,176,98,0.18); }

/* Dark mode tint boost */
body.dark .st-sweep        { --sweep-color: rgba(245,51,63,0.25); }
body.dark.theme-cobalt .st-sweep  { --sweep-color: rgba(61,90,255,0.28); }
body.dark.theme-teal .st-sweep    { --sweep-color: rgba(18,166,181,0.28); }


/* Ring / circle: SVG drawn via stroke-dashoffset */
.st-ring-wrap {
  position: relative;
  display: inline-block;
}
.st-ring-wrap svg.st-ring-svg {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 28px);
  height: calc(100% + 24px);
}
.st-ring-svg path {
  fill: none;
  stroke: var(--acc);
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 320;
  stroke-dashoffset: 0;
}
.st-motion-ready .st-ring-svg path {
  stroke-dashoffset: 320;
  transition: stroke-dashoffset 600ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: stroke-dashoffset;
}
.st-motion-ready .st-ring-svg.st-drawn path {
  stroke-dashoffset: 0;
}


/* Margin note: tilted Kalam annotation */
.st-note-ann {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  color: var(--acc);
  display: block;
  margin-top: 8px;
}
.st-note-ann[data-tilt="-3"] { transform: rotate(-3deg); }
.st-note-ann[data-tilt="2"]  { transform: rotate(2deg); }
.st-note-ann[data-tilt="-2"] { transform: rotate(-2deg); }
.st-note-ann[data-tilt="3"]  { transform: rotate(3deg); }

.st-motion-ready .st-note-ann {
  opacity: 0;
  transition: opacity 250ms ease 200ms;
  will-change: opacity;
}
.st-motion-ready .st-note-ann.st-drawn {
  opacity: 1;
}


/* ── 3. Margin note block (sidebar annotation) ───────────────────── */
.st-margin-note {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  color: var(--acc);
  border-left: 2px solid var(--acc);
  padding-left: 10px;
  margin: 12px 0 0;
  display: block;
  opacity: 0.85;
}
.st-margin-note[data-tilt="-2"] { transform: rotate(-2deg); }
.st-margin-note[data-tilt="2"]  { transform: rotate(2deg); }
.st-motion-ready .st-margin-note {
  opacity: 0;
  transition: opacity 250ms ease 280ms;
  will-change: opacity;
}
.st-motion-ready .st-margin-note.st-drawn {
  opacity: 0.85;
}


/* ── 4. Cursor (desktop fine-pointer only) ───────────────────────── */
#st-cursor-dot {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acc);
  pointer-events: none;
  z-index: 9999;
  opacity: 0.65;
  transform: translate(-50%, -50%);
  will-change: transform;
  transition: opacity 0.2s;
}
.st-motion-ready #st-cursor-dot {
  display: block;
}

/* Hover ring on interactive elements */
.st-hover-ring {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  border: 1.5px solid var(--acc);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.8);
  width: 40px;
  height: 40px;
  transition: opacity 0.18s, transform 0.18s;
  will-change: opacity, transform;
}
.st-motion-ready .st-hover-ring.st-ring-active {
  opacity: 0.5;
  transform: scale(1);
}


/* ── 4b. Ink ripple on click (all pointer types) ─────────────────── */
/* A freehand ring of ink expanding from the tap point: the pen tapping
   the page. Slightly irregular radius + a few degrees of rotation keep
   it hand-drawn rather than mechanical. Transform + opacity only. */
.st-ink-ripple {
  position: fixed;
  top: 0; left: 0;
  width: 16px;
  height: 16px;
  border: 2px solid var(--acc);
  border-radius: 47% 53% 50% 49% / 51% 48% 52% 50%;
  pointer-events: none;
  z-index: 9997;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
  will-change: transform, opacity;
}
.st-motion-ready .st-ink-ripple.st-rippling {
  animation: st-ink-ripple 0.55s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}
@keyframes st-ink-ripple {
  0%   { opacity: 0.55; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  100% { opacity: 0;    transform: translate(-50%, -50%) scale(3.6) rotate(6deg); }
}

/* ── 5. Reduced motion override ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .st-motion-ready .st-reveal,
  .st-motion-ready .st-reveal.st-visible {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .st-motion-ready .st-sweep {
    background-size: 100% 55% !important;
    transition: none !important;
  }
  .st-motion-ready .st-ring-svg path {
    stroke-dashoffset: 0 !important;
    transition: none !important;
  }
  .st-motion-ready .st-note-ann,
  .st-motion-ready .st-margin-note {
    opacity: 0.85 !important;
    transition: none !important;
  }
  #st-cursor-dot,
  .st-hover-ring,
  .st-ink-ripple {
    display: none !important;
  }
}
