/* Opening cinematic — Skylabs presents WARD ZERO */

.cutscene {
  --cs-bone: #ddd6c6;
  --cs-bone-dim: #9d968a;
  --cs-ash: #5d5953;
  --cs-blood: #9b1512;
  --cs-blood-hi: #d42a1e;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  isolation: isolate;
  background: #000;
  color: var(--cs-bone);
  font-family: "Figtree", "Noto Sans SC", system-ui, sans-serif;
  cursor: none;
  opacity: 1;
  transition: opacity 0.9s ease;
}

.cutscene[hidden] {
  display: none !important;
}

.cutscene.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.cutscene-bg,
.cutscene-dust,
.cutscene-sweep {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* --- atmosphere ------------------------------------------------------- */

.cutscene-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 58% 62% at 50% 45%,
      rgba(0, 0, 0, 0) 20%,
      rgba(0, 0, 0, 0.55) 68%,
      #000 100%
    ),
    linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 28%, transparent 74%, rgba(0, 0, 0, 0.9));
}

.cutscene-glow {
  position: absolute;
  left: 50%;
  top: 44%;
  width: min(150vw, 1500px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(155, 21, 18, 0.28) 0%,
    rgba(117, 14, 12, 0.13) 32%,
    rgba(0, 0, 0, 0) 66%
  );
  opacity: 0.45;
  animation: cutscene-glow 7s ease-in-out 0.4s infinite;
}

.cutscene-grain {
  position: absolute;
  inset: -8%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.055;
  animation: cutscene-grain 1.1s steps(3) infinite;
}

.cutscene-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(221, 214, 198, 0.035) 0,
    rgba(221, 214, 198, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.55;
  mix-blend-mode: screen;
}

.cutscene-sweep {
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(221, 214, 198, 0.03) 44%,
    rgba(221, 214, 198, 0.085) 50%,
    transparent 56%,
    transparent 100%
  );
  opacity: 0.7;
  animation: cutscene-sweep 8.5s linear 1.4s infinite;
  mix-blend-mode: screen;
}

.cutscene-dust {
  overflow: hidden;
}

.cutscene-dust i {
  position: absolute;
  bottom: -3vh;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(221, 214, 198, 0.75);
  filter: blur(0.35px);
  opacity: 0;
  animation-name: cutscene-dust;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.cutscene-dust i.is-ember {
  background: var(--cs-blood-hi);
  box-shadow: 0 0 6px rgba(212, 42, 30, 0.85);
}

/* --- composition ------------------------------------------------------ */

.cutscene-stage {
  position: absolute;
  inset: 0;
  text-align: center;
  transition: transform 1.2s ease, opacity 0.8s ease;
}

.cutscene.is-leaving .cutscene-stage {
  transform: scale(1.015);
  opacity: 0.45;
}

.cutscene-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(46vw, 380px);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition:
    top 1.1s cubic-bezier(0.2, 0.72, 0.2, 1),
    width 1.1s cubic-bezier(0.2, 0.72, 0.2, 1),
    opacity 0.9s ease;
  will-change: top, width, opacity;
}

.cutscene-brand img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 1;
  filter:
    drop-shadow(0 0 18px rgba(221, 214, 198, 0.16))
    drop-shadow(0 0 52px rgba(155, 21, 18, 0.2));
}

.cutscene[data-phase="logo"] .cutscene-brand,
.cutscene[data-phase="presents"] .cutscene-brand,
.cutscene[data-phase="title"] .cutscene-brand,
.cutscene[data-phase="leaving"] .cutscene-brand {
  opacity: 1;
}

.cutscene[data-phase="logo"] .cutscene-brand img {
  animation: cutscene-brand-in 1.9s cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.cutscene[data-phase="presents"] .cutscene-brand,
.cutscene[data-phase="title"] .cutscene-brand,
.cutscene[data-phase="leaving"] .cutscene-brand {
  top: 28%;
  width: min(21vw, 190px);
}

.cutscene-presents {
  position: absolute;
  left: 50%;
  top: 42%;
  margin: 0;
  transform: translate(-50%, 12px);
  color: var(--cs-bone-dim);
  font-family: "Typewriter", "Noto Sans SC", monospace;
  font-size: clamp(0.82rem, 1.45vw, 1.05rem);
  letter-spacing: 0.72em;
  text-indent: 0.72em;
  opacity: 0;
  transition: opacity 1.1s ease, transform 1.1s ease, color 1.1s ease;
}

.cutscene[data-phase="presents"] .cutscene-presents,
.cutscene[data-phase="title"] .cutscene-presents,
.cutscene[data-phase="leaving"] .cutscene-presents {
  opacity: 0.82;
  transform: translate(-50%, 0);
}

.cutscene[data-phase="title"] .cutscene-presents,
.cutscene[data-phase="leaving"] .cutscene-presents {
  opacity: 0.58;
  color: var(--cs-bone-dim);
}

.cutscene-title {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 100%;
  margin: 0;
  transform: translate(-50%, -50%);
  color: var(--cs-bone);
  font-family: "Fell", "Noto Sans SC", Georgia, serif;
  font-size: clamp(3.05rem, 9.4vw, 7.35rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  opacity: 0;
  transition: opacity 1.4s ease, letter-spacing 2.6s ease;
}

.cutscene[data-phase="title"] .cutscene-title,
.cutscene[data-phase="leaving"] .cutscene-title {
  opacity: 1;
  letter-spacing: 0.17em;
  text-indent: 0.17em;
}

.cutscene-title-text {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  text-shadow:
    3px 0 rgba(212, 42, 30, 0.32),
    -3px 0 rgba(70, 120, 200, 0.22),
    0 0 26px rgba(0, 0, 0, 0.95),
    0 0 90px rgba(155, 21, 18, 0.18);
  animation: cutscene-title-flicker 7s step-end infinite;
}

.cutscene-title-text::before,
.cutscene-title-text::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.cutscene-title-text::before {
  color: var(--cs-blood-hi);
  animation: cutscene-glitch-a 6.4s steps(1) 0.8s infinite;
}

.cutscene-title-text::after {
  color: #4678c8;
  animation: cutscene-glitch-b 6.4s steps(1) 0.8s infinite;
}

.cutscene-rule {
  position: absolute;
  left: 50%;
  top: 61.5%;
  width: 0;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(155, 21, 18, 0.95) 22%,
    rgba(221, 214, 198, 0.72) 50%,
    rgba(155, 21, 18, 0.95) 78%,
    transparent
  );
  box-shadow: 0 0 12px rgba(155, 21, 18, 0.28);
  transition: width 1.9s cubic-bezier(0.2, 0.72, 0.2, 1) 0.15s;
}

.cutscene[data-phase="title"] .cutscene-rule,
.cutscene[data-phase="leaving"] .cutscene-rule {
  width: min(72vw, 580px);
}

.cutscene-sub {
  position: absolute;
  left: 50%;
  top: 64.5%;
  margin: 0;
  transform: translate(-50%, 10px);
  color: var(--cs-bone-dim);
  font-family: "Typewriter", "Noto Sans SC", monospace;
  font-size: clamp(0.6rem, 1.05vw, 0.78rem);
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.2s ease 0.5s, transform 1.2s ease 0.5s;
}

.cutscene[data-phase="title"] .cutscene-sub,
.cutscene[data-phase="leaving"] .cutscene-sub {
  opacity: 0.72;
  transform: translate(-50%, 0);
}

/* --- skip + progress -------------------------------------------------- */

.cutscene-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(clamp(1.15rem, 4vh, 2.4rem) + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  display: flex;
  justify-content: center;
  opacity: 0;
  animation: cutscene-fade-in 0.9s ease 1.35s forwards;
}

.cutscene-skip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: clamp(0.7rem, 2vw, 1.4rem);
  min-height: 44px;
  padding: 0.7rem 1.2rem;
  border: 0;
  background: none;
  color: var(--cs-bone-dim);
  font-family: "Typewriter", "Noto Sans SC", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s ease, letter-spacing 0.35s ease;
}

.cutscene-skip::before,
.cutscene-skip::after {
  content: "";
  width: clamp(24px, 6vw, 58px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(221, 214, 198, 0.38));
  transition: background 0.25s ease, width 0.35s ease;
}

.cutscene-skip::after {
  background: linear-gradient(90deg, rgba(221, 214, 198, 0.38), transparent);
}

.cutscene-skip:hover,
.cutscene-skip:focus-visible {
  color: var(--cs-bone);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  outline: none;
}

.cutscene-skip:hover::before,
.cutscene-skip:focus-visible::before {
  width: clamp(34px, 8vw, 76px);
  background: linear-gradient(90deg, transparent, var(--cs-blood-hi));
}

.cutscene-skip:hover::after,
.cutscene-skip:focus-visible::after {
  width: clamp(34px, 8vw, 76px);
  background: linear-gradient(90deg, var(--cs-blood-hi), transparent);
}

.cutscene-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(221, 214, 198, 0.06);
}

.cutscene-progress i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--cs-blood) 35%, var(--cs-blood-hi));
  transform: scaleX(0);
  transform-origin: left center;
  animation: cutscene-progress 8.7s linear 0.25s forwards;
  opacity: 0.55;
}

/* --- keyframes -------------------------------------------------------- */

@keyframes cutscene-brand-in {
  0% {
    opacity: 0;
    transform: scale(1.06);
    filter: blur(14px) brightness(2.2);
  }
  8% {
    opacity: 0.18;
  }
  10% {
    opacity: 0;
  }
  16% {
    opacity: 0.55;
    filter: blur(7px) brightness(1.8);
  }
  18% {
    opacity: 0.08;
  }
  24% {
    opacity: 0.9;
    filter: blur(3px) brightness(1.25);
  }
  26% {
    opacity: 0.32;
  }
  30% {
    opacity: 1;
    filter: blur(1.3px) brightness(1.1);
  }
  36% {
    opacity: 0.7;
  }
  38% {
    opacity: 1;
    filter: blur(0) brightness(1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter:
      blur(0) brightness(1) drop-shadow(0 0 18px rgba(221, 214, 198, 0.16))
      drop-shadow(0 0 52px rgba(155, 21, 18, 0.2));
  }
}

@keyframes cutscene-title-flicker {
  0%,
  7%,
  9%,
  59%,
  62%,
  100% {
    opacity: 1;
  }
  8% {
    opacity: 0.35;
  }
  60% {
    opacity: 0.55;
  }
  78% {
    opacity: 0.88;
  }
  79% {
    opacity: 1;
  }
}

@keyframes cutscene-glitch-a {
  0%,
  91%,
  94%,
  100% {
    opacity: 0;
    transform: translate(0);
    clip-path: inset(0 0 0 0);
  }
  91.4% {
    opacity: 0.62;
    transform: translate(-4px, 1px);
    clip-path: inset(10% 0 64% 0);
  }
  92% {
    opacity: 0.4;
    transform: translate(5px, -1px);
    clip-path: inset(56% 0 18% 0);
  }
  92.6% {
    opacity: 0;
  }
}

@keyframes cutscene-glitch-b {
  0%,
  91.2%,
  93.4%,
  100% {
    opacity: 0;
    transform: translate(0);
    clip-path: inset(0 0 0 0);
  }
  91.6% {
    opacity: 0.38;
    transform: translate(4px, 2px);
    clip-path: inset(62% 0 9% 0);
  }
  92.2% {
    opacity: 0.28;
    transform: translate(-5px, -2px);
    clip-path: inset(22% 0 52% 0);
  }
  92.8% {
    opacity: 0;
  }
}

@keyframes cutscene-glow {
  0%,
  100% {
    opacity: 0.36;
    transform: translate(-50%, -50%) scale(1);
  }
  48% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1.08);
  }
  52% {
    opacity: 0.52;
    transform: translate(-50%, -50%) scale(1.09);
  }
}

@keyframes cutscene-grain {
  0% {
    transform: translate3d(0, 0, 0);
  }
  33% {
    transform: translate3d(-2%, 1.5%, 0);
  }
  66% {
    transform: translate3d(1.5%, -2%, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes cutscene-sweep {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes cutscene-dust {
  0% {
    transform: translate3d(0, 8vh, 0);
    opacity: 0;
  }
  12% {
    opacity: var(--o, 0.3);
  }
  82% {
    opacity: var(--o, 0.3);
  }
  100% {
    transform: translate3d(var(--dx, 24px), -104vh, 0);
    opacity: 0;
  }
}

@keyframes cutscene-fade-in {
  to {
    opacity: 1;
  }
}

@keyframes cutscene-progress {
  to {
    transform: scaleX(1);
  }
}

/* --- smaller screens -------------------------------------------------- */

@media (max-width: 640px) {
  .cutscene-brand {
    width: min(66vw, 300px);
  }

  .cutscene[data-phase="presents"] .cutscene-brand,
  .cutscene[data-phase="title"] .cutscene-brand,
  .cutscene[data-phase="leaving"] .cutscene-brand {
    top: 27%;
    width: min(42vw, 172px);
  }

  .cutscene-presents {
    top: 40%;
  }

  .cutscene-title {
    top: 52%;
    font-size: clamp(2.15rem, 11vw, 4.5rem);
    letter-spacing: 0.08em;
    text-indent: 0.08em;
  }

  .cutscene[data-phase="title"] .cutscene-title,
  .cutscene[data-phase="leaving"] .cutscene-title {
    letter-spacing: 0.12em;
    text-indent: 0.12em;
  }

  .cutscene-rule {
    top: 60.5%;
  }

  .cutscene-sub {
    top: 63.5%;
    font-size: 0.64rem;
    letter-spacing: 0.18em;
    text-indent: 0.18em;
  }

  .cutscene-skip {
    font-size: 0.7rem;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
  }
}

@media (max-height: 560px) {
  .cutscene-brand {
    width: min(30vw, 260px);
  }

  .cutscene[data-phase="presents"] .cutscene-brand,
  .cutscene[data-phase="title"] .cutscene-brand,
  .cutscene[data-phase="leaving"] .cutscene-brand {
    top: 24%;
    width: min(15vw, 130px);
  }

  .cutscene-presents {
    top: 38%;
  }

  .cutscene-title {
    top: 53%;
  }

  .cutscene-rule {
    top: 64%;
  }

  .cutscene-sub {
    top: 68%;
  }
}

/* --- calmer mode ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .cutscene-grain,
  .cutscene-sweep,
  .cutscene-dust,
  .cutscene-title-text::before,
  .cutscene-title-text::after {
    display: none;
  }

  .cutscene-brand img,
  .cutscene-title-text,
  .cutscene-glow,
  .cutscene-progress i {
    animation: none !important;
  }

  .cutscene,
  .cutscene.is-leaving {
    transition-duration: 0.3s;
  }

  .cutscene-brand {
    transition-duration: 0.5s;
  }

  .cutscene-title {
    transition-duration: 0.6s;
  }

  .cutscene-rule {
    transition-duration: 0.6s;
  }
}

body.reduced-motion .cutscene-grain,
body.reduced-motion .cutscene-sweep,
body.reduced-motion .cutscene-dust,
body.reduced-motion .cutscene-title-text::before,
body.reduced-motion .cutscene-title-text::after {
  display: none;
}

body.reduced-motion .cutscene-brand img,
body.reduced-motion .cutscene-title-text,
body.reduced-motion .cutscene-glow,
body.reduced-motion .cutscene-progress i {
  animation: none !important;
}

body.reduced-motion .cutscene,
body.reduced-motion .cutscene.is-leaving {
  transition-duration: 0.3s;
}

body.reduced-motion .cutscene-brand {
  transition-duration: 0.5s;
}

body.reduced-motion .cutscene-title,
body.reduced-motion .cutscene-rule {
  transition-duration: 0.6s;
}
