/* Motion-logo background for the home hero (see hero-motion.js).
   The hero is always dark so the dark motion clips blend in, whatever the site theme. */
.hero.hero--motion {
  --paper: #0c0d10;
  --paper-2: #151821;
  --paper-3: #1a1e29;
  --ink: #eef0f3;
  --ink-2: #c3c8d2;
  --muted: #9198a6;
  --line: #2a3040;
  --lapis: #8fa5ff;
  --on-ink: #0c0d10;
  --gold: #d6a84b;
  background:
    radial-gradient(ellipse 60% 80% at 15% 40%, #1a1f2e 0%, transparent 70%),
    #0c0d10;
  color: var(--ink);
  color-scheme: dark;
  isolation: isolate;
  overflow: hidden;
  position: relative;
}

.hero--motion .hero__inner {
  position: relative;
  z-index: 1;
}

/* The motion layer takes over the visual role of the featured plate and background calligraphy */
.hero--motion .hero__plate,
.hero--motion .hero__callig {
  display: none;
}

.hero__motion {
  background: transparent;
  /* logical insets: the motion sits on the side opposite the text (right in LTR, left in RTL) */
  inset-block: 0;
  inset-inline: auto 0;
  pointer-events: none;
  position: absolute;
  width: 60%;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to right, transparent 0, transparent 14%, #000 42%, #000 100%);
  mask-image: linear-gradient(to right, transparent 0, transparent 14%, #000 42%, #000 100%);
}

[dir="rtl"] .hero__motion {
  -webkit-mask-image: linear-gradient(to left, transparent 0, transparent 14%, #000 42%, #000 100%);
  mask-image: linear-gradient(to left, transparent 0, transparent 14%, #000 42%, #000 100%);
}

.hero__motion-video {
  height: 100%;
  inset: 0;
  object-fit: cover;
  /* nudge the centred logo away from the faded edge */
  object-position: 30% 50%;
  opacity: 0;
  position: absolute;
  transition: opacity 900ms var(--ease, ease);
  width: 100%;
}

[dir="rtl"] .hero__motion-video {
  object-position: 70% 50%;
}

.hero__motion-video.is-active {
  opacity: 1;
}

/* Wide compositions are shown whole, inside the opaque part of the layer */
.hero__motion-video.is-contained {
  aspect-ratio: 16 / 9;
  height: auto;
  inset-block: 50% auto;
  inset-inline: auto 0;
  object-fit: contain;
  translate: 0 -50%;
  width: 62%;
  /* soften the video's own frame edge so it melts into the hero */
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent 0, #000 18%, #000 82%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
  mask-composite: intersect;
}

/* ---------- SVG scenes (intro + client logos) share placement and crossfade ---------- */
.hero-scene {
  align-content: center;
  display: grid;
  inset-block: 0;
  inset-inline: 38% 0;
  justify-items: center;
  opacity: 0;
  position: absolute;
  text-align: center;
  transition: opacity 900ms var(--ease, ease);
}

.hero-scene.is-active {
  opacity: 1;
}

.hero-scene.is-paused,
.hero-scene.is-paused * {
  animation-play-state: paused !important;
}

/* ---------- Client logo scenes ---------- */
.hero-logo__art {
  aspect-ratio: var(--ratio, 1);
  /* --size lets tall, slim logos (e.g. Lisan al Arab) be shown a little larger */
  height: calc(clamp(190px, 34vh, 300px) * var(--size, 1));
  max-width: 82%;
  position: relative;
}

.hero-logo__svg {
  display: block;
  height: 100%;
  overflow: visible;
  position: relative;
  width: 100%;
}

.hero-logo__glow {
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 30%, transparent) 0%, color-mix(in srgb, var(--accent) 8%, transparent) 42%, transparent 70%);
  aspect-ratio: 1;
  border-radius: 50%;
  height: 170%;
  left: 50%;
  opacity: 0.55;
  position: absolute;
  top: 50%;
  translate: -50% -50%;
}

.hero-logo__shine {
  background: linear-gradient(105deg, transparent 38%, #ffffffb0 50%, transparent 62%) no-repeat;
  background-size: 260% 100%;
  background-position: 120% 0;
  inset: 0;
  -webkit-mask: var(--mask) center / contain no-repeat;
  mask: var(--mask) center / contain no-repeat;
  mix-blend-mode: overlay;
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.hero-logo__edge {
  background: linear-gradient(to bottom, transparent, var(--accent) 20%, #fff 50%, var(--accent) 80%, transparent);
  box-shadow: 0 0 18px 4px color-mix(in srgb, var(--accent) 60%, transparent);
  inset-block: -6%;
  inset-inline-start: 100%;
  opacity: 0;
  position: absolute;
  width: 2px;
}

.hero-logo__name {
  color: #c3c8d2;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  margin-top: clamp(18px, 2.4vw, 28px);
  text-transform: uppercase;
}

/* finished state (also what reduced-motion visitors see) */
.hero-logo__shape {
  stroke: var(--accent);
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  stroke-opacity: 0;
  stroke-width: 1.2px;
  vector-effect: non-scaling-stroke;
}

/* draw: outlines are written stroke by stroke, then filled */
.hero-logo--draw.is-playing .hero-logo__shape {
  animation:
    hero-intro-draw 1.6s cubic-bezier(0.6, 0, 0.3, 1) calc(var(--i) * var(--step)) both,
    hero-intro-fill 0.9s ease calc(1.4s + var(--i) * var(--step) * 0.6) both;
}

/* the ink glows in the logo's accent while it is being written, then cools down */
.hero-logo--draw.is-playing .hero-logo__svg {
  animation:
    hero-logo-settle 3s cubic-bezier(0.2, 0.7, 0.2, 1) both,
    hero-logo-ink 3.4s ease both;
}

/* slow push-in for a cinematic feel */
.hero-logo--draw.is-playing .hero-logo__art {
  animation: hero-logo-drift 7.5s linear both;
}

.hero-logo__rule {
  background: linear-gradient(to right, transparent, var(--accent), transparent);
  height: 1px;
  margin-top: 14px;
  opacity: 0.8;
  width: 64px;
}

.hero-logo.is-playing .hero-logo__rule {
  animation: hero-logo-rule 1s cubic-bezier(0.2, 0.7, 0.2, 1) 3s both;
}

@keyframes hero-logo-ink {
  0% { filter: drop-shadow(0 0 0 transparent); }
  35% { filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 85%, transparent)); }
  70% { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 45%, transparent)); }
  100% { filter: drop-shadow(0 6px 18px #00000080); }
}

@keyframes hero-logo-drift {
  from { transform: scale(0.97); }
  to { transform: scale(1.04); }
}

@keyframes hero-logo-rule {
  from { opacity: 0; width: 0; }
  to { opacity: 0.8; width: 64px; }
}

/* wipe: revealed right-to-left, the direction Arabic is written, behind a glowing edge */
.hero-logo--wipe.is-playing .hero-logo__svg {
  animation: hero-logo-wipe 2.2s cubic-bezier(0.55, 0, 0.25, 1) 0.2s both;
}

.hero-logo--wipe.is-playing .hero-logo__edge {
  animation: hero-logo-edge 2.2s cubic-bezier(0.55, 0, 0.25, 1) 0.2s both;
}

/* rise: letters and ornaments float up one after another */
.hero-logo--rise.is-playing .hero-logo__shape {
  animation: hero-logo-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) calc(var(--i) * var(--step)) both;
  transform-box: fill-box;
  transform-origin: center;
}

/* shared finale: glow swells, light sweeps across, the name appears */
.hero-logo.is-playing .hero-logo__glow {
  animation: hero-intro-glow 3.6s ease 1.4s both;
}

.hero-logo.is-playing .hero-logo__shine {
  animation: hero-logo-shine 1.6s ease-in-out 2.7s both;
}

.hero-logo.is-playing .hero-logo__name {
  animation: hero-intro-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 2.6s both;
}

@keyframes hero-logo-settle {
  from { transform: scale(0.94); }
  to { transform: none; }
}

@keyframes hero-logo-wipe {
  from { clip-path: inset(-10% -10% -10% 100%); }
  to { clip-path: inset(-10% -10% -10% -10%); }
}

@keyframes hero-logo-edge {
  0% { inset-inline-start: 100%; opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { inset-inline-start: -2%; opacity: 0; }
}

[dir="rtl"] .hero-logo--wipe.is-playing .hero-logo__edge {
  animation-name: hero-logo-edge-rtl;
}

@keyframes hero-logo-edge-rtl {
  0% { inset-inline-start: -2%; opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { inset-inline-start: 100%; opacity: 0; }
}

@keyframes hero-logo-rise {
  from { opacity: 0; transform: translateY(18%) scale(0.92); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes hero-logo-shine {
  0% { opacity: 1; background-position: 120% 0; }
  100% { opacity: 1; background-position: -20% 0; }
}

/* ---------- Animated fachri.graphy intro ---------- */

.hero-intro__stage {
  display: grid;
  place-items: center;
  position: relative;
  width: clamp(150px, 16vw, 220px);
}

.hero-intro__glow {
  aspect-ratio: 1;
  background: radial-gradient(circle, #d6a84b40 0%, #d6a84b14 40%, transparent 70%);
  border-radius: 50%;
  position: absolute;
  width: 190%;
}

.hero-intro__mark {
  display: block;
  overflow: visible;
  width: 100%;
}

.hero-intro__petal {
  fill: #f4efe4;
  stroke: #d6a84b;
  stroke-dasharray: 1;
  stroke-linejoin: round;
  stroke-width: 0.9;
}

.hero-intro__dot {
  fill: #d6a84b;
  transform-box: fill-box;
  transform-origin: center;
}

.hero-intro__word {
  color: #f4efe4;
  font-family: var(--font-display, inherit);
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: clamp(18px, 2.4vw, 30px);
}

.hero-intro__word span {
  color: #d6a84b;
}

.hero-intro__tag {
  color: #9198a6;
  font-size: clamp(0.72rem, 0.9vw, 0.85rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  margin-top: 10px;
  text-transform: uppercase;
}

/* Arabic letters must stay joined: no tracking or caps on the tagline */
[dir="rtl"] .hero-intro__tag {
  font-size: clamp(0.85rem, 1vw, 1rem);
  letter-spacing: 0;
}

[dir="rtl"] .hero.hero--motion {
  background:
    radial-gradient(ellipse 60% 80% at 85% 40%, #1a1f2e 0%, transparent 70%),
    #0c0d10;
}

/* Static (reduced motion / paused before start): show the finished logo */
.hero-intro__petal { stroke-dashoffset: 0; fill-opacity: 1; stroke-opacity: 0; }

.hero-intro.is-playing .hero-intro__mark {
  animation: hero-intro-mark 2.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hero-intro.is-playing .hero-intro__petal {
  animation:
    hero-intro-draw 1.5s cubic-bezier(0.6, 0, 0.3, 1) calc(var(--i) * 0.16s) both,
    hero-intro-fill 0.9s ease calc(1.3s + var(--i) * 0.12s) both;
}

.hero-intro.is-playing .hero-intro__dot {
  animation: hero-intro-pop 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) calc(1.9s + var(--i) * 0.1s) both;
}

.hero-intro.is-playing .hero-intro__glow {
  animation: hero-intro-glow 3.4s ease 1.6s both;
}

.hero-intro.is-playing .hero-intro__word {
  animation: hero-intro-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 2.5s both;
}

.hero-intro.is-playing .hero-intro__tag {
  animation: hero-intro-fade 0.9s ease 3.1s both;
}

@keyframes hero-intro-mark {
  from { transform: rotate(-35deg) scale(0.86); }
  to { transform: none; }
}

@keyframes hero-intro-draw {
  from { stroke-dashoffset: 1; stroke-opacity: 1; fill-opacity: 0; }
  to { stroke-dashoffset: 0; stroke-opacity: 1; fill-opacity: 0; }
}

@keyframes hero-intro-fill {
  from { fill-opacity: 0; stroke-opacity: 1; }
  to { fill-opacity: 1; stroke-opacity: 0; }
}

@keyframes hero-intro-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes hero-intro-glow {
  0% { opacity: 0; transform: scale(0.6); }
  40% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0.55; transform: scale(1); }
}

@keyframes hero-intro-rise {
  from { opacity: 0; transform: translateY(14px); letter-spacing: 0.08em; }
  to { opacity: 1; transform: none; letter-spacing: -0.02em; }
}

@keyframes hero-intro-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Controls ---------- */
.hero__motion-controls {
  align-items: center;
  background: #0c0d10b8;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid #ffffff1f;
  border-radius: 999px;
  bottom: clamp(16px, 3vw, 28px);
  color: #c3c8d2;
  display: flex;
  font-size: 0.8rem;
  gap: 12px;
  inset-inline-end: var(--gutter, 24px);
  padding: 6px 6px 6px 14px;
  position: absolute;
  z-index: 2;
}

.hero__motion-caption {
  font-weight: 600;
  white-space: nowrap;
}

.hero__motion-dots {
  display: flex;
  gap: 2px;
}

.hero__motion-dot,
.hero__motion-toggle {
  background: none;
  border: 0;
  border-radius: 999px;
  color: inherit;
  cursor: pointer;
  display: grid;
  height: 28px;
  padding: 0;
  place-items: center;
  width: 24px;
}

.hero__motion-dot::before {
  background: currentColor;
  border-radius: 999px;
  content: "";
  height: 6px;
  opacity: 0.35;
  transition: opacity 200ms ease, width 300ms var(--ease, ease);
  width: 6px;
}

.hero__motion-dot[aria-current="true"]::before {
  background: #d6a84b;
  opacity: 1;
  width: 16px;
}

.hero__motion-toggle {
  background: #eef0f3;
  color: #0c0d10;
  width: 28px;
}

.hero__motion-toggle::before {
  border-inline: 2px solid currentColor;
  content: "";
  height: 10px;
  width: 4px;
}

.hero__motion-toggle[data-state="paused"]::before {
  border-block: 5px solid transparent;
  border-inline-end: 0;
  border-inline-start: 8px solid currentColor;
  height: 0;
  margin-inline-start: 2px;
  width: 0;
}

.hero__motion-dot:focus-visible,
.hero__motion-toggle:focus-visible {
  outline: 2px solid #d6a84b;
  outline-offset: 2px;
}

/* ---------- Phones: motion sits below the text ---------- */
@media (width <= 820px) {
  .hero.hero--motion {
    padding-bottom: calc(min(68vw, 440px) + 24px);
  }

  .hero__motion,
  [dir="rtl"] .hero__motion {
    height: min(68vw, 440px);
    inset: auto 0 0 0;
    width: 100%;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 100%);
  }

  .hero__motion-video,
  [dir="rtl"] .hero__motion-video {
    object-position: center;
  }

  .hero__motion-video.is-contained {
    inset-inline: 0;
    width: 100%;
  }

  .hero-scene {
    inset: 8% 0 0 0;
  }

  .hero-logo__art {
    height: calc(min(42vw, 260px) * var(--size, 1));
  }

  .hero-logo__name {
    margin-top: 12px;
  }

  .hero-intro__stage {
    width: clamp(110px, 30vw, 170px);
  }

  .hero__motion-controls {
    bottom: 12px;
    inset-inline-end: 12px;
  }
}

@media (width <= 420px) {
  .hero__motion-caption {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero__motion-video,
  .hero-scene {
    transition-duration: 0.01ms;
  }
}
