/* 5.1 Hero container */
.hero {
  position: relative;
  direction: ltr;
  height: calc(100vh + var(--hero-pt, 0rem) + var(--hero-pb, 0rem));
  overflow: hidden;
  background: linear-gradient(var(--void) 0%, var(--void) 62%, var(--navy) 100%);
}

/* Layer 1: Statue media wrapper (left-framed) */
.hero-media {
  position: absolute;
  top: auto;
  bottom: var(--hero-pb, 0rem);
  left: -2vw;
  right: auto;
  width: 62vw;
  max-width: none;
  height: 92vh;
  mix-blend-mode: screen;
  filter: contrast(1.06) brightness(0.98);
  pointer-events: none;
  z-index: 1;
}

.hero-poster-img,
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 10% bottom;
  display: block;
  pointer-events: none;
}

.hero-video {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hero-video.is-playing {
  opacity: 1;
}

/* Layer 2: Directional readability & bottom crimson fade */
.hero-fade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      270deg,
      var(--void) 0%,
      var(--void) 39%,
      rgba(168, 22, 19, 0.72) 45%,
      transparent 54%
    ),
    linear-gradient(transparent 62%, var(--navy) 100%);
  pointer-events: none;
  z-index: 2;
}

/* Layer 3: Copy column (right) */
.hero-copy {
  position: absolute;
  left: auto;
  right: 3.8rem;
  top: calc(21vh + var(--hero-pt, 0rem));
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.4rem;
  direction: rtl;
  text-align: right;
}

.hero-eyebrow {
  font-family: "IBM Plex Sans Arabic", "IBM Plex Sans Arabic Fallback", sans-serif;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--mute);
  letter-spacing: 0;
  min-height: 1.4em;
}

.hero-headline {
  position: relative;
  margin-top: 1.2rem;
  font-family: "Readex Pro", "Readex Pro Fallback", sans-serif;
  font-weight: 600;
  font-size: 3.8rem;
  color: var(--paper);
  line-height: 1.28;
  min-height: calc(2 * 1.28em);
  letter-spacing: 0;
  max-width: 8.79em;
  overflow: visible;
  text-rendering: geometricPrecision;
}

.hero-headline-ghost {
  display: block;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.hero-headline-live {
  position: absolute;
  inset: 0;
}

/* "رقمية" unbroken RTL character selection overlay */
.sel {
  position: relative;
  display: inline-block;
  color: var(--paper);
}

.sel.is-empty {
  display: none;
}

.sel-ghost {
  display: inline;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.sel-base {
  position: absolute;
  top: 0;
  right: 0;
  white-space: nowrap;
}

.sel-highlight {
  position: absolute;
  inset: 0;
  white-space: nowrap;
  background-color: var(--paper);
  color: var(--ink);
  clip-path: inset(0 0 0 calc((1 - var(--sel-frac, 0)) * 100%));
  pointer-events: none;
}

/* Transform-positioned blinking block caret (zero layout shift) */
.caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.55em;
  height: 0.92em;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
}

.caret::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.85);
  animation: caretBlink 0.53s steps(1) infinite;
}

.caret.is-typing::after {
  animation: none;
  opacity: 1;
}

.caret.is-static::after {
  animation: none;
  opacity: 1;
}

.caret.is-done::after {
  animation: none;
}

.caret.is-hidden {
  visibility: hidden !important;
}

@keyframes caretBlink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.hero-paragraph-wrap {
  position: relative;
  margin-top: 1.6rem;
  max-width: 31rem;
  width: 100%;
  min-height: calc(3 * 1.7 * 1.15rem);
  opacity: 0;
  visibility: hidden;
  overflow: visible;
}

.hero-paragraph {
  font-family: "IBM Plex Sans Arabic", "IBM Plex Sans Arabic Fallback", sans-serif;
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--mute);
  line-height: 1.7;
  margin: 0;
}

/* Actions row */
.hero-actions {
  margin-top: 2.2rem;
  display: flex;
  align-items: center;
  gap: 2.4rem;
}

.hero-cta {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: box-shadow 0.08s ease, background-color 0.15s ease;
}

@media (max-width: 991px) {
  .hero-headline {
    font-size: 3.4rem;
  }
}

@media (max-width: 600px) {
  .hero {
    height: calc(100svh + var(--hero-pt, 0rem) + var(--hero-pb, 0rem));
  }
  .hero-copy {
    left: 1.5rem;
    right: 1.5rem;
    top: calc(12svh + var(--hero-pt, 0rem));
    gap: 0.85rem;
  }
  .hero-headline {
    margin-top: 0.5rem;
    font-size: 2.6rem;
  }
  .hero-paragraph-wrap {
    margin-top: 0.75rem;
    max-width: 100%;
    min-height: calc(3 * 1.55 * 0.9rem);
  }
  .hero-paragraph {
    font-size: 0.9rem;
    line-height: 1.55;
  }
  .hero-actions {
    margin-top: 1rem;
    gap: 1.2rem;
    flex-wrap: nowrap;
  }
  .hero-media {
    width: 120vw;
    max-width: none;
    height: 54svh;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: auto;
    bottom: var(--hero-pb, 0rem);
  }
  .hero-poster-img,
  .hero-video {
    object-fit: cover;
    object-position: 24% bottom;
  }
  .hero-fade {
    background: linear-gradient(
      to bottom,
      var(--void) 0%,
      var(--void) 45%,
      rgba(168, 22, 19, 0) 58%,
      transparent 72%,
      var(--navy) 100%
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-headline-ghost {
    visibility: visible !important;
  }
  .hero-headline-live {
    display: none !important;
  }
  .hero-paragraph-wrap,
  .hero-actions,
  .hero-cta {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
  }
}

@media (max-width: 768px) {
  .hero {
    height: auto;
    min-height: auto;
    padding: 1.25rem 1.5rem 1.5rem;
    margin-block: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-copy > *:first-child {
    margin-top: 0;
  }

  .hero-copy > *:last-child {
    margin-bottom: 0;
  }

  .hero .hero-copy {
    order: -1;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    margin-top: 4.5rem;
    gap: 0;
  }

  .hero .hero-headline {
    font-size: clamp(1.75rem, 7.5vw, 2.25rem);
    line-height: 1.3;
    min-height: calc(2 * 1.3em);
    margin: 0 0 0.75rem;
    max-width: 100%;
    overflow: visible;
  }

  .hero .hero-paragraph-wrap {
    margin: 0 0 1.25rem;
    max-width: 100%;
    min-height: calc(3 * 1.7 * 0.9rem);
  }

  .hero .hero-paragraph {
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0;
  }

  .hero .hero-actions {
    margin: 0;
  }

  .hero .hero-actions .keycap-btn {
    min-height: max(44px, 2.75rem);
    height: auto;
    width: auto;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
  }

  .hero .hero-media {
    order: 1;
    position: relative;
    top: auto;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 120vw;
    max-width: none;
    height: clamp(19rem, 44svh, 25rem);
    margin-top: 1rem;
    margin-bottom: 0;
  }
  .hero .hero-poster-img,
  .hero .hero-video {
    object-fit: cover;
    object-position: 24% bottom;
  }

  .hero .hero-fade {
    background: linear-gradient(
      to bottom,
      var(--void) 0%,
      var(--void) 38%,
      rgba(168, 22, 19, 0) 52%,
      transparent 74%,
      var(--navy) 100%
    );
  }
}

@media (max-width: 600px) {
  .hero {
    padding-bottom: 0;
  }

  .hero .hero-media {
    height: calc(clamp(19rem, 44svh, 25rem) + 1.5rem);
    bottom: 0;
  }

  .hero .hero-poster-img,
  .hero .hero-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 24% bottom;
  }

  .hero .hero-fade {
    background: linear-gradient(
      to bottom,
      var(--void) 0%,
      var(--void) 38%,
      rgba(168, 22, 19, 0) 52%,
      rgba(168, 22, 19, 0) calc(100% - 2.5rem),
      var(--navy) 100%
    );
  }
}

