/* Aamin AI (HAFR workspace): lib/transitions.css, the styles of lib/transitions.js (home-transitions,
   2026-11-28). Read lib/transitions.js for what moves and how a page opts in or out.

   Nothing here hides content: a page without JavaScript, or with reduced motion, reads as written.
   Only transform and opacity ever animate. The values follow lib/story.css (chapter top padding 128 px,
   88 px below 1,024 px; row padding 112 px, 72 px below 1,024 px), so a seam or a thread always stays
   inside a band's top padding, above the first line of text. */

:root {
  --hf-tr-loaded: 1;            /* lib/transitions.js checks this before it adds anything */
  --hf-tr-seam: 96px;           /* the soft seam at the top of a band whose ground differs */
  --hf-tr-thread-h: 84px;       /* the dotted thread above a chapter's eyebrow */
  --hf-tr-thread-gap: 16px;
}
@media (max-width: 63.99rem) {
  :root { --hf-tr-seam: 56px; --hf-tr-thread-h: 52px; --hf-tr-thread-gap: 14px; }
}

/* ---- Grounds: the seam and the take-over veil (one layer per band, under the band's content) ---- */
/* The bands skip rendering off-screen (content-visibility, lib/app.js): their paint is clipped to the box,
   and two neighbours can leave one row of pixels between them, where the page ground shows as a hairline.
   The ground reaches 2 px above the band and the band may paint 2 px past its edge, so the seam closes it. */
.hf-tr-band { isolation: isolate; overflow-clip-margin: 2px; }
.hf-tr-ground {
  position: absolute; inset: -2px 0 0 0; z-index: -1;
  overflow: hidden; pointer-events: none; contain: strict;
}
/* the ground above, eased out over the band's top padding (no hard edge) */
.hf-tr-ground__seam {
  position: absolute; inset-inline: 0; inset-block-start: 0; block-size: var(--hf-tr-seam);
  /* a smoothstep in nine stops: no visible band where the gradient starts or ends */
  background: linear-gradient(180deg,
    rgb(var(--hf-tr-from)) 0%,
    rgb(var(--hf-tr-from) / 0.97) 10%,
    rgb(var(--hf-tr-from) / 0.85) 24%,
    rgb(var(--hf-tr-from) / 0.66) 38%,
    rgb(var(--hf-tr-from) / 0.5) 48%,
    rgb(var(--hf-tr-from) / 0.33) 59%,
    rgb(var(--hf-tr-from) / 0.15) 74%,
    rgb(var(--hf-tr-from) / 0.03) 90%,
    rgb(var(--hf-tr-from) / 0) 100%);
}
/* the band's own plain ground at its foot, where the next band's seam begins */
.hf-tr-ground__foot {
  position: absolute; inset-inline: 0; inset-block-end: 0; block-size: var(--hf-tr-seam);
  background: linear-gradient(0deg,
    rgb(var(--hf-tr-own)) 0%,
    rgb(var(--hf-tr-own) / 0.85) 24%,
    rgb(var(--hf-tr-own) / 0.5) 48%,
    rgb(var(--hf-tr-own) / 0.15) 74%,
    rgb(var(--hf-tr-own) / 0) 100%);
}
/* the ground above, laid over the band until it takes over the view; then it slides up and away
   (a soft lower edge, so the band's own ground rises in from below). Off by default. */
.hf-tr-ground__veil {
  position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 140%;
  opacity: var(--hf-tr-k, 1);
  background: linear-gradient(180deg,
    rgb(var(--hf-tr-from)) 0%,
    rgb(var(--hf-tr-from)) 66%,
    rgb(var(--hf-tr-from) / 0.5) 84%,
    rgb(var(--hf-tr-from) / 0) 100%);
  transform: translateY(-101%);
}

/* ---- The dotted thread: from the band's edge down into the chapter, ending above its eyebrow ---- */
.hf-chapter.hf-tr-has-thread { position: relative; }
.hf-tr-thread {
  /* the chapter's first child: its static position is the top of the chapter's content box (where the
     eyebrow starts); the negative margin lifts it into the padding above */
  display: block; position: absolute; left: 50%;
  inline-size: 4px; block-size: var(--hf-tr-thread-h);
  margin: calc(-1 * (var(--hf-tr-thread-h) + var(--hf-tr-thread-gap))) 0 0 -2px;
  overflow: hidden; pointer-events: none;
  color: var(--hf-color-text-3, #5E666F);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
}
.hf-tr-thread__dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, currentColor 0 1.1px, transparent 1.6px);
  background-size: 4px 9px; background-position: 50% 100%; background-repeat: repeat-y;
  opacity: 0.55;
}
.hf-ground--night .hf-tr-thread { color: #A9B0B8; }

/* ---- Title lines rising out of their masks (SplitText adds .hf-tr-line and .hf-tr-line-mask while a
   title plays): the mask reaches past the line box so descenders and Arabic marks are never cut ---- */
.hf-tr-split { display: flex; flex-direction: column; }
.hf-tr-line-mask { padding-block: 0.2em; margin-block: -0.2em; }
:lang(ar) .hf-tr-line-mask { padding-block: 0.28em; margin-block: -0.28em; }

/* ---- Devices: a soft contact shadow that settles as the device lands --------------------------- */
.hf-dev--phone .hf-dev__frame::after,
.hf-dev[data-device-mode="phone"] .hf-dev__frame::after,
.hf-dev--laptop:not([data-device-mode="phone"]) .hf-dev__base::after {
  content: ""; position: absolute; inset-inline: 9%; inset-block-start: calc(100% + 3px); block-size: 14px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(24 32 44 / 0.15), rgb(24 32 44 / 0));
  pointer-events: none;
  transition: opacity 1.1s cubic-bezier(0.16, 1, 0.3, 1), transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}
.hf-ground--night .hf-dev--phone .hf-dev__frame::after,
.hf-ground--night .hf-dev[data-device-mode="phone"] .hf-dev__frame::after,
.hf-ground--night .hf-dev--laptop:not([data-device-mode="phone"]) .hf-dev__base::after {
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.5), rgb(0 0 0 / 0));
}
/* lifted: the shadow is wide, low and faint; it settles to the rule above as the device lands */
.hf-dev[data-tr-shadow="lift"].hf-dev--phone .hf-dev__frame::after,
.hf-dev[data-tr-shadow="lift"][data-device-mode="phone"] .hf-dev__frame::after,
.hf-dev[data-tr-shadow="lift"].hf-dev--laptop:not([data-device-mode="phone"]) .hf-dev__base::after {
  opacity: 0; transform: translateY(18px) scale(1.5, 2.2); transition: none;
}

/* ---- Reduced motion and print: still and complete ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hf-dev .hf-dev__frame::after, .hf-dev .hf-dev__base::after { transition: none; }
  .hf-tr-ground__veil { display: none; }
}
html[data-reduced] .hf-tr-ground__veil { display: none; }
@media print {
  .hf-tr-pending { opacity: 1 !important; transform: none !important; }
  .hf-tr-ground__veil { display: none; }
}
