:root {
  --hero-bg: #81d0fb;
  --ink: #080808;
  --speech: #fff35f;
  --speech-shadow: #ef245c;
  --blue-shadow: #18d8ff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--hero-bg);
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
}

button {
  font: inherit;
}

.hero {
  position: relative;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.36), transparent 22rem),
    linear-gradient(180deg, #81d0fb 0%, #81d0fb 100%);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -12%;
  z-index: 0;
  background:
    linear-gradient(rgba(0, 67, 170, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 67, 170, 0.18) 1px, transparent 1px);
  background-size: clamp(34px, 5vw, 84px) clamp(34px, 5vw, 84px);
  transform: perspective(620px) rotateX(58deg) translateY(13vh) scale(1.2);
  transform-origin: center bottom;
  opacity: 0.55;
}

.character-stage {
  position: relative;
  align-self: end;
  justify-self: center;
  z-index: 2;
  width: min(96vw, 665px);
  height: min(88svh, 760px);
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: default;
  filter: drop-shadow(14px 18px 0 rgba(0, 0, 0, 0.14));
  animation: float 5.2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

.character-stage.is-armed {
  cursor: pointer;
}

.character-stage:focus-visible {
  outline: none;
  filter:
    drop-shadow(14px 18px 0 rgba(0, 0, 0, 0.14))
    drop-shadow(0 0 18px rgba(255, 243, 95, 0.42));
}

.character {
  position: absolute;
  inset: auto 50% 0 auto;
  width: min(85vw, 600px);
  max-width: none;
  height: auto;
  translate: 38% 0;
  transform: translateZ(0);
  backface-visibility: hidden;
  user-select: none;
  pointer-events: none;
  will-change: opacity, filter;
  transition: filter 180ms ease;
}

.character-open {
  opacity: 0;
}

.character-stage.is-speaking .character-closed {
  opacity: 0;
}

.character-stage.is-speaking .character-open {
  opacity: 1;
  filter:
    drop-shadow(3px 0 0 rgba(239, 36, 92, 0.55))
    drop-shadow(-3px 0 0 rgba(24, 216, 255, 0.5));
}

.speech-bubble {
  position: absolute;
  top: clamp(11rem, 31svh, 18rem);
  left: calc(50% + min(16vw, 220px));
  z-index: 4;
  width: min(34vw, 390px);
  min-width: 280px;
  padding: clamp(0.75rem, 1.8vw, 1rem) clamp(0.9rem, 2.4vw, 1.35rem);
  border: 5px solid var(--ink);
  border-radius: 8px;
  background: var(--speech);
  color: var(--ink);
  font-size: clamp(1.35rem, 2.8vw, 2.65rem);
  line-height: 0.92;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    3px 0 0 var(--speech-shadow),
    -3px 0 0 var(--blue-shadow);
  box-shadow: 10px 10px 0 var(--ink);
  opacity: 0;
  transform: translate(0, -8px) rotate(-1deg) scale(0.96);
  transition: opacity 160ms ease, transform 180ms cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: -25px;
  top: 54%;
  width: 34px;
  height: 34px;
  background: var(--speech);
  border-left: 5px solid var(--ink);
  border-bottom: 5px solid var(--ink);
  transform: rotate(45deg);
}

.character-stage.is-speaking .speech-bubble {
  opacity: 1;
  transform: translate(0, 0) rotate(-1deg) scale(1);
  animation: bubble-glitch 4.8s steps(1, end) infinite;
}

.crt-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.11) 0,
      rgba(255, 255, 255, 0.11) 1px,
      rgba(0, 0, 0, 0.04) 1px,
      rgba(0, 0, 0, 0.04) 3px,
      transparent 3px,
      transparent 6px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.13) 0,
      rgba(0, 0, 0, 0.13) 1px,
      transparent 1px,
      transparent 4px
    ),
    radial-gradient(circle at center, transparent 46%, rgba(0, 0, 0, 0.12) 100%);
  mix-blend-mode: multiply;
  opacity: 0.58;
}

.next-fold {
  position: relative;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  background: #ffffff;
}

.coffin-button {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: block;
  width: min(62vw, 850px);
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.coffin-button:focus-visible {
  outline: 4px solid #111111;
  outline-offset: -4px;
}

.coffin-image {
  display: block;
  width: min(62vw, 850px);
  height: auto;
  user-select: none;
}

.latin-text {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: start;
  width: min(48vw, 680px);
  margin: 0;
  padding: clamp(3rem, 7vw, 6rem);
  color: #111111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.15vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: 0;
}

@keyframes float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(-0.3deg);
  }

  50% {
    transform: translate3d(0, -12px, 0) rotate(0.4deg);
  }
}

@keyframes bubble-glitch {
  0%,
  88%,
  100% {
    text-shadow:
      3px 0 0 var(--speech-shadow),
      -3px 0 0 var(--blue-shadow);
  }

  90% {
    text-shadow:
      7px 0 0 var(--speech-shadow),
      -6px 0 0 var(--blue-shadow);
  }

  92% {
    text-shadow:
      -5px 0 0 var(--speech-shadow),
      5px 0 0 var(--blue-shadow);
  }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .speech-bubble {
    top: clamp(10rem, 29svh, 16rem);
    left: calc(50% + min(19vw, 185px));
    width: min(27vw, 300px);
    min-width: 250px;
    font-size: clamp(1.25rem, 2.7vw, 2rem);
  }
}

@media (max-width: 720px) {
  .hero {
    min-height: 112svh;
  }

  .character-stage {
    width: 96vw;
    height: 92svh;
    margin-bottom: calc(20svh + clamp(0.25rem, 1.5svh, 1rem));
    justify-self: center;
  }

  .character {
    bottom: clamp(0.25rem, 1.5svh, 1rem);
    width: 92vw;
    translate: 46% 0;
  }

  .speech-bubble {
    top: calc(max(0.5rem, env(safe-area-inset-top)) + 20svh);
    left: 49%;
    width: min(74vw, 340px);
    min-width: 0;
    border-width: 4px;
    box-shadow: 7px 7px 0 var(--ink);
    font-size: clamp(1.15rem, 6.4vw, 1.9rem);
    transform: translate(-50%, -8px) rotate(-1deg) scale(0.96);
  }

  .speech-bubble::after {
    left: 58%;
    top: auto;
    bottom: -23px;
    width: 30px;
    height: 30px;
    border-width: 4px;
    border-left: 0;
    border-top: 0;
    border-right: 4px solid var(--ink);
    border-bottom: 4px solid var(--ink);
  }

  .character-stage.is-speaking .speech-bubble {
    transform: translate(-50%, 0) rotate(-1deg) scale(1);
  }

  .next-fold {
    display: flex;
    flex-direction: column;
    min-height: auto;
    align-items: stretch;
  }

  .latin-text {
    align-self: start;
    width: auto;
    max-width: 100%;
    justify-self: stretch;
    padding: calc(20svh + clamp(0.85rem, 4vw, 1.5rem)) clamp(1.25rem, 6vw, 2rem) clamp(2rem, 8vw, 3rem);
    font-size: clamp(1.15rem, 6vw, 1.75rem);
    line-height: 1.08;
  }

  .coffin-button {
    position: relative;
    right: auto;
    bottom: auto;
    order: 2;
    align-self: flex-end;
    width: 108vw;
    margin-top: clamp(3rem, 12svh, 5rem);
  }

  .coffin-image {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
