/* Red Ink Creative — white label hero animation
   Plays once. No JavaScript required.
   Add .riha--observe + JS toggle of .is-playing only if you want a scroll trigger. */

.riha {
  width: 500px;
  max-width: 100%;
  min-width: 0;
  font-family: "Nunito", sans-serif;
}

@media (max-width: 850px) {
  .riha {
    display: none;
  }
}

.riha__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 500 / 340;
  border-radius: 20px 0 20px 0;
  overflow: hidden;
  background: #0a0a0a;
  box-shadow: 2px 2px 5px 0 rgb(230, 230, 230);
  animation: riha-frame-in 0.45s ease both;
}

/* ---------- Scene 1 — code editor ---------- */

.riha__scene--code {
  position: absolute;
  inset: 0;
  animation: riha-layer-out 0.5s ease 2.45s both;
}

.riha__chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  background: #111;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.riha__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3a3a;
}

.riha__dot--live {
  background: #cc0000;
}

.riha__filename {
  margin-left: 8px;
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  color: #6f6f6f;
  letter-spacing: 0.04em;
}

.riha__scan {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 46px;
  background: linear-gradient(180deg, rgba(51, 176, 221, 0.18), transparent);
  animation: riha-scan 2.2s linear 0.2s 1 both;
  pointer-events: none;
}

.riha__code {
  padding: 14px 16px;
  font-family: "Courier Prime", monospace;
  font-size: 11.5px;
  line-height: 1.85;
  white-space: nowrap;
}

.riha__line {
  display: flex;
  gap: 12px;
  animation: riha-code-in 0.4s ease both;
}

.riha__line:nth-child(1) {
  animation-delay: 0.25s;
}
.riha__line:nth-child(2) {
  animation-delay: 0.43s;
}
.riha__line:nth-child(3) {
  animation-delay: 0.61s;
}
.riha__line:nth-child(4) {
  animation-delay: 0.79s;
}
.riha__line:nth-child(5) {
  animation-delay: 0.97s;
}
.riha__line:nth-child(6) {
  animation-delay: 1.15s;
}
.riha__line:nth-child(7) {
  animation-delay: 1.33s;
}
.riha__line:nth-child(8) {
  animation-delay: 1.51s;
}
.riha__line:nth-child(9) {
  animation-delay: 1.69s;
}

.riha__num {
  width: 10px;
  text-align: right;
  color: #3a3a3a;
}

/* syntax colours */
.riha-c-punct {
  color: #5c5c5c;
}
.riha-c-fn {
  color: #ff79c6;
}
.riha-c-tag {
  color: #8be9fd;
}
.riha-c-attr {
  color: #ffca3a;
}
.riha-c-str {
  color: #7ee787;
}
.riha-c-text {
  color: #e6e6e6;
}
.riha-c-note {
  color: #5c5c5c;
}

.riha__caret {
  display: inline-block;
  width: 7px;
  height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
  background: #cc0000;
  animation: riha-caret 0.7s steps(1) 1.8s infinite;
}

/* ---------- Diagonal overlay captions ---------- */

.riha__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.riha__overlay-inner {
  transform: rotate(-13deg);
  width: 150%;
  text-align: center;
}

.riha__caption {
  display: block;
  font-family: "Anton", sans-serif;
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.85);
}

.riha__caption--work {
  font-size: 76px;
  animation: riha-wipe-out 2.35s ease 0.45s both;
}

.riha__caption--client {
  font-size: 68px;
  animation: riha-wipe-hold 0.75s ease 3.3s both;
}

/* ---------- Scene 2 — finished client site ---------- */

.riha__scene--site {
  position: absolute;
  inset: 0;
  background: #2b1636;
  opacity: 0;
  animation:
    riha-layer-in 0.5s ease 2.6s both,
    riha-fade-out 0.45s ease 5s forwards;
}

.riha__shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: riha-shot-in 1.1s cubic-bezier(0.2, 0.7, 0.3, 1) 2.6s both;
}

.riha__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
}

/* ---------- Scene 3 — sign off ---------- */

.riha__scene--signoff {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: #fff;
  opacity: 0;
  animation: riha-layer-in 0.5s ease 5.15s both;
}

.riha__logo {
  width: 250px;
  max-width: 70%;
  height: auto;
  animation: riha-logo-in 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) 5.3s both;
}

.riha__signoff-text {
  font-family: "Anton", sans-serif;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #000;
  text-align: center;
  animation: riha-rise-in 0.5s ease 5.7s both;
}

/* ---------- Keyframes ---------- */

@keyframes riha-frame-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes riha-code-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes riha-caret {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes riha-layer-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.04);
  }
}

@keyframes riha-layer-in {
  from {
    opacity: 0;
    transform: scale(0.99);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes riha-logo-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes riha-rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes riha-scan {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(420%);
  }
}

@keyframes riha-shot-in {
  from {
    opacity: 0;
    transform: scale(1.12);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes riha-fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes riha-wipe-hold {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
  }
  to {
    clip-path: inset(0 -10% 0 0);
    opacity: 1;
  }
}

@keyframes riha-wipe-out {
  0% {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
  }
  18% {
    clip-path: inset(0 -10% 0 0);
    opacity: 1;
  }
  80% {
    clip-path: inset(0 -10% 0 0);
    opacity: 1;
  }
  100% {
    clip-path: inset(0 -10% 0 0);
    opacity: 0;
  }
}

/* ---------- Optional scroll trigger ----------
   Add class riha--observe to .riha and the animation waits for .is-playing. */

.riha--observe .riha__stage,
.riha--observe .riha__stage * {
  animation-play-state: paused;
}

.riha--observe.is-playing .riha__stage,
.riha--observe.is-playing .riha__stage * {
  animation-play-state: running;
}

/* ---------- Reduced motion — show the sign-off frame only ---------- */

@media (prefers-reduced-motion: reduce) {
  .riha__stage,
  .riha__stage * {
    animation: none !important;
  }

  .riha__scene--code,
  .riha__scene--site {
    display: none;
  }

  .riha__scene--signoff {
    opacity: 1;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 420px) {
  .riha__caption--work {
    font-size: 54px;
  }
  .riha__caption--client {
    font-size: 48px;
  }
  .riha__signoff-text {
    font-size: 24px;
  }
  .riha__code {
    font-size: 10px;
    padding: 10px 12px;
  }
}
