/* =========================================================
   RedemptionArc — motion layer stylesheet

   Loaded only when the master animation switch in the admin panel is on
   (see includes/motion.php). Every selector below is either .ra-fx-* or a
   data-ra-* attribute that assets/js/motion.js adds at runtime, so nothing
   in style.css / theme.css / platform.css / content.css / admin.css is
   touched, overridden or depended upon beyond its design tokens.

   The one thing worth explaining is [data-ra-fx]:

     .hero already has position:relative, but neither .hero nor .page-header
     nor .footer is a stacking context. A canvas at z-index:-1 inside a
     non-stacking-context parent escapes all the way behind that parent's own
     background and disappears. Adding z-index:0 alongside position:relative
     creates the context, which is the whole trick that lets the backdrop sit
     behind the text with zero edits to the existing rules. It changes no
     layout: no offsets are set, and nothing is clipped.
   ========================================================= */

/* ---------------------------------------------------------
   Canvas backdrops
   --------------------------------------------------------- */

[data-ra-fx] {
  position: relative;
  z-index: 0;
}

/* The element selector is here on purpose: .hero > * in style.css sets
   position:relative and z-index:1 on every hero child, and canvas.ra-fx-canvas
   (0,1,1) outranks it (0,1,0) without needing !important. */
canvas.ra-fx-canvas {
  position: absolute;
  inset: 0;
  /* width/height are NOT redundant with inset:0. A canvas is a replaced element
     with an intrinsic size, so with width:auto the intrinsic size wins and the
     offsets become over-constrained (one of left/right is dropped). Without
     these two lines the canvas lays out at its attribute size instead of the
     host's, and because motion.js sizes the buffer from clientWidth * dpr, each
     resize ratchets it larger: 300 -> 600 -> 1200. */
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
  pointer-events: none;
}

/* Inner pages: .page-header is a third the height of the home hero, so the
   same effect needs to be quieter there to keep the heading crisp. */
canvas.ra-fx-canvas.is-band { opacity: 0.7; }

/* A drifting band across the top of the footer. Sits inside the footer's own
   3rem of top padding, so it costs no layout at all. */
canvas.ra-fx-canvas.is-strip {
  inset: 0 0 auto 0;
  width: 100%;
  height: 46px;
  opacity: 0.75;
}

/* ---------------------------------------------------------
   Directional scroll reveal

   content.js owns .reveal; this is a separate namespace for the elements it
   does not cover, and motion.js refuses to mark anything that already has
   .reveal so the two can never both animate one element.
   --------------------------------------------------------- */

[data-ra-reveal] { opacity: 0; }
[data-ra-reveal="up"]    { transform: translateY(22px); }
[data-ra-reveal="right"] { transform: translateX(26px); }
[data-ra-reveal="left"]  { transform: translateX(-26px); }
[data-ra-reveal="zoom"]  { transform: scale(0.94); }

[data-ra-reveal].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.55s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------------------------------------------------------
   Light sweep across buttons

   Driven by background-position rather than a translated overlay so no
   overflow:hidden is needed. That matters: .btn is inline-flex, and clipping
   an inline-level box moves its baseline to the bottom margin edge, which
   would nudge every button that sits in a baseline-aligned row.
   --------------------------------------------------------- */

.btn[data-ra-sheen] { position: relative; }

.btn[data-ra-sheen]::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg,
    transparent 32%,
    rgba(255, 255, 255, 0.16) 46%,
    transparent 62%);
  background-size: 250% 100%;
  background-position: 110% 0;
}

.btn[data-ra-sheen]:hover::after,
.btn[data-ra-sheen]:focus-visible::after {
  animation: ra-fx-sheen 0.72s ease-out;
}

@keyframes ra-fx-sheen {
  from { opacity: 1; background-position: 110% 0; }
  to   { opacity: 1; background-position: -55% 0; }
}

/* ---------------------------------------------------------
   Underline draw on section titles
   --------------------------------------------------------- */

.section-head h2[data-ra-underline] { position: relative; }

.section-head h2[data-ra-underline]::after {
  content: '';
  position: absolute;
  right: 0;
  left: 0;
  bottom: -9px;
  height: 2px;
  border-radius: 2px;
  background: var(--gradient-signal);
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.section-head h2[data-ra-underline].is-drawn::after { transform: scaleX(1); }

/* ---------------------------------------------------------
   Slow shimmer over the telegram banner
   --------------------------------------------------------- */

.telegram-banner[data-ra-shimmer] { position: relative; }

.telegram-banner[data-ra-shimmer]::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 36%,
    rgba(45, 212, 255, 0.10) 47%,
    rgba(57, 255, 136, 0.09) 53%,
    transparent 64%);
  background-size: 300% 100%;
  animation: ra-fx-shimmer 7s linear infinite;
}

@keyframes ra-fx-shimmer {
  from { background-position: 135% 0; }
  to   { background-position: -65% 0; }
}

/* ---------------------------------------------------------
   Scroll progress on pages that are not a single article

   Deliberately the same geometry and z-index as .ra-progress in content.css:
   only one of the two ever exists on a page, and they should look identical
   when the reader moves between an article and an archive.
   --------------------------------------------------------- */

.ra-fx-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  z-index: 200;
  background: transparent;
  pointer-events: none;
}

.ra-fx-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gradient-signal);
  box-shadow: 0 0 12px rgba(57, 255, 136, 0.5);
}

/* ---------------------------------------------------------
   Back to top

   Bottom-left, which is the trailing corner in an RTL layout. Kept clear of
   .ra-toast and .ra-bright-toast, both of which are bottom-centre.
   --------------------------------------------------------- */

.ra-fx-top {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 250;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-line);
  border-radius: 50%;
  background: var(--bg-panel-glass);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.92);
  transition:
    opacity 0.25s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.25s,
    color 0.18s,
    border-color 0.18s;
}

.ra-fx-top.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.ra-fx-top:hover,
.ra-fx-top:focus-visible {
  color: var(--accent-green);
  border-color: rgba(57, 255, 136, 0.45);
}

.ra-fx-top .ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);   /* progress starts at twelve o'clock */
}

.ra-fx-top .ring circle {
  fill: none;
  stroke-width: 2;
}

.ra-fx-top .ring .track { stroke: rgba(255, 255, 255, 0.07); }
.ra-fx-top .ring .bar   { stroke: var(--accent-green); }

.ra-fx-top .ico {
  position: relative;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ---------------------------------------------------------
   Phones: same effects, less of them

   Aligned with the existing breakpoints in style.css (760 / 560) rather than
   inventing new ones, so nothing shifts at a width the rest of the site does
   not already treat as a boundary.
   --------------------------------------------------------- */

@media (max-width: 760px) {
  canvas.ra-fx-canvas { opacity: 0.55; }
  canvas.ra-fx-canvas.is-band  { opacity: 0.45; }
  canvas.ra-fx-canvas.is-strip { height: 34px; opacity: 0.5; }
  .telegram-banner[data-ra-shimmer]::before { animation-duration: 10s; }
  [data-ra-reveal="right"] { transform: translateX(16px); }
  [data-ra-reveal="left"]  { transform: translateX(-16px); }
}

@media (max-width: 560px) {
  canvas.ra-fx-canvas { opacity: 0.4; }
  .ra-fx-top {
    width: 40px;
    height: 40px;
    bottom: 14px;
    left: 14px;
  }
  .ra-fx-top .ico { width: 18px; height: 18px; }
}

/* ---------------------------------------------------------
   Reduced motion — nothing moves, nothing is hidden

   motion.js already refuses to start any of this when the preference is set;
   this block is here for the case where it is switched on after the page has
   loaded, and so the stylesheet is honest on its own.
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  canvas.ra-fx-canvas { display: none; }

  [data-ra-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .btn[data-ra-sheen]::after,
  .telegram-banner[data-ra-shimmer]::before { animation: none; content: none; }

  .section-head h2[data-ra-underline]::after {
    transform: scaleX(1);
    transition: none;
  }

  .ra-fx-progress { display: none; }

  .ra-fx-top { transition: none; }
}

/* Nothing decorative belongs on paper. */
@media print {
  canvas.ra-fx-canvas,
  .ra-fx-progress,
  .ra-fx-top { display: none !important; }
  [data-ra-reveal] { opacity: 1 !important; transform: none !important; }
}

/* =========================================================
   v2 extras — typed-caret, card glow
   Same rules as the rest of this file: attribute-scoped, no
   existing stylesheet touched, nothing decorative in print.
   ========================================================= */

/* Blinking block caret while the hero eyebrow is typing. The class is
   added/removed by motion.js around the tween. */
.hero-eyebrow.is-typing::after {
  content: '\258C';
  margin-inline-start: 3px;
  color: var(--accent-green);
  animation: ra-caret 0.9s steps(1) infinite;
}

@keyframes ra-caret {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0; }
}

/* Shop cards: gentle lift + green rim glow on hover. The attribute is
   stamped by motion.js so this never applies when JS is off. */
[data-ra-cardglow] {
  transition: transform 0.28s ease-out, box-shadow 0.28s ease-out, border-color 0.28s ease-out;
}
[data-ra-cardglow]:hover {
  transform: translateY(-5px);
  border-color: rgba(57, 255, 136, 0.38);
  box-shadow:
    0 16px 40px -16px rgba(57, 255, 136, 0.30),
    0 6px 18px rgba(0, 0, 0, 0.35);
}

/* Reduced motion: the card may not fly, and the caret has nothing to do
   (the typewriter itself is already disabled under prefers-reduced-motion). */
@media (prefers-reduced-motion: reduce) {
  [data-ra-cardglow],
  [data-ra-cardglow]:hover { transform: none; transition: none; }
  .hero-eyebrow.is-typing::after { animation: none; }
}