/**
 * HHText: Typography motion effects stylesheet
 *
 * Supports: chars, lines, scrub, weight, mask effects
 * Respects prefers-reduced-motion
 */

/* ==========================================================================
   CHARACTER-LEVEL ANIMATION
   ========================================================================== */

.hh-char {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  will-change: transform, opacity;
  /* The splitter emits the space between words as its own .hh-char. As an
     inline-block under the default white-space:normal that space collapses to
     zero width, and every heading renders as one run-on word
     ("EveryChaldeanorphanshould..."). pre keeps the space its real width. */
  white-space: pre;
}

/* overflow:hidden on a 1em box clips descenders (g, y, p) and any accents.
   Give the glyph room and pull it back so the line box is unchanged. */
.hh-char {
  height: auto;
  padding-bottom: 0.18em;
  margin-bottom: -0.18em;
}

/* Holds one word's worth of .hh-char boxes. Without this the browser treats
   every character as its own break opportunity and headlines wrap mid-word. */
.hh-word {
  display: inline-block;
  white-space: nowrap;
}

/* Reduced motion: disable animations */
@media (prefers-reduced-motion: reduce) {
  .hh-char,
  .hh-word,
  .hh-line,
  .hh-unit {
    transform: none !important;
    opacity: 1 !important;
    animation: none !important;
  }
}

/* ==========================================================================
   WORD-LEVEL ANIMATION (for RTL/Syriac content)
   ========================================================================== */

.hh-word {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  will-change: transform, opacity;
}

/* ==========================================================================
   LINE-LEVEL ANIMATION
   ========================================================================== */

.hh-line {
  display: block;
  overflow: hidden;
  height: 1.3em;
  will-change: transform, opacity;
}

.hh-line > span {
  display: inline-block;
  position: relative;
  will-change: transform, opacity;
}

/* ==========================================================================
   SCRUB/SCROLL-DRIVEN EFFECT
   ========================================================================== */

.hh-unit {
  display: inline-block;
  position: relative;
  transition: opacity 150ms ease-out, color 150ms ease-out;
  will-change: opacity, color;
}

/* Dim state (inactive) */
.hh-unit {
  opacity: 0.3;
  color: var(--muted, #59636F);
}

/* Lit state (active) — set by JS */
.hh-unit.active {
  opacity: 1;
  color: inherit;
}

/* ==========================================================================
   WEIGHT EFFECT (Variable font animation)
   ========================================================================== */

[data-hhtext="weight"] {
  font-family: 'Bricolage Grotesque', var(--display);
  font-variation-settings: 'wght' 200;
  will-change: font-variation-settings;
}

/* ==========================================================================
   MASK EFFECT (Clip-path wipe)
   ========================================================================== */

[data-hhtext="mask"] {
  will-change: clip-path;
}

/* ==========================================================================
   GLOBAL SETTINGS
   ========================================================================== */

/* Ensure smooth rendering of split text */
[data-hhtext] {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Preserve text selection across split elements */
[data-hhtext] ::selection {
  background: var(--gold);
  color: var(--lapis-ink);
}

/* High DPI support */
@media (min-resolution: 2dppx) {
  .hh-char,
  .hh-word,
  .hh-line,
  .hh-unit {
    /* Slight backface visibility optimization */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

/* Hide the generated span tree from screen readers */
[aria-hidden="true"] {
  /* Visual text remains, but not announced */
}

/* Ensure original text is available via aria-label */
[aria-label] {
  /* aria-label provides fallback for screen readers */
}

/* For RTL/Syriac fallback content */
[lang="syr"] {
  font-family: 'Noto Sans Syriac Eastern', var(--syriac);
  direction: rtl;
  unicode-bidi: isolate;
}
