:root {
  color-scheme: light;
  --cream: #fff8dc;
  --ink: #293b54;
  --rose: #e999ad;
  --gold: #f2c66f;
  --sky: #9fd9f6;
  --violet: #9885d8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--sky);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

.experience,
.intro,
.hatchery {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100svh;
  overflow: hidden;
}

.intro {
  z-index: 2;
  background: #8bcdf4;
  transition: opacity 900ms ease, visibility 900ms ease;
}

.intro.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.world {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.world img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 220svh;
  object-fit: cover;
  object-position: center;
  transform: translate3d(0, 0, 0) scale(1.03);
  animation: descend 6.4s cubic-bezier(.55, .02, .25, 1) 350ms forwards;
  will-change: transform;
}

@keyframes descend {
  0% { transform: translate3d(0, 0, 0) scale(1.03); }
  16% { transform: translate3d(0, -5svh, 0) scale(1.03); }
  100% { transform: translate3d(0, -120svh, 0) scale(1); }
}

.sun-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 250, 218, .6), transparent 27%),
    linear-gradient(180deg, rgba(115, 184, 231, .08) 0%, transparent 48%, rgba(35, 64, 69, .23) 100%);
  pointer-events: none;
}

.intro-copy {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: clamp(3.2rem, 8svh, 6.5rem);
  width: min(92vw, 46rem);
  padding: 1.5rem;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 1rem);
  animation: reveal-title 1.1s ease 5.55s forwards;
  text-shadow: 0 2px 14px rgba(255, 255, 255, .96), 0 1px 3px rgba(31, 65, 75, .42);
}

@keyframes reveal-title {
  to { opacity: 1; transform: translate(-50%, 0); }
}

.eyebrow {
  margin: 0 0 .65rem;
  font-family: ui-rounded, "Avenir Next", Avenir, sans-serif;
  font-size: clamp(.78rem, 1.6vw, .95rem);
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #fffdf1;
  font-size: clamp(3.1rem, 8.8vw, 7.8rem);
  font-weight: 700;
  line-height: .79;
  letter-spacing: -.055em;
  text-transform: uppercase;
  -webkit-text-stroke: 1px rgba(87, 77, 122, .38);
}

.intro-line {
  margin: 1.2rem 0 1.3rem;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-style: italic;
  font-weight: 700;
}

.storybook-button {
  position: relative;
  min-width: 10.5rem;
  min-height: 3.25rem;
  padding: .8rem 1.7rem;
  border: 2px solid rgba(255, 250, 215, .92);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 251, 228, .97), rgba(247, 215, 158, .96));
  color: #594668;
  box-shadow:
    0 7px 0 rgba(148, 103, 107, .55),
    0 12px 30px rgba(41, 60, 77, .27),
    inset 0 1px 0 #fff;
  cursor: pointer;
  font-family: ui-rounded, "Avenir Next", Avenir, sans-serif;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.storybook-button::before {
  content: "✦";
  margin-right: .65rem;
  color: #d991a7;
}

.storybook-button:hover {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 9px 0 rgba(148, 103, 107, .52), 0 16px 32px rgba(41, 60, 77, .28), inset 0 1px 0 #fff;
}

.storybook-button:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 rgba(148, 103, 107, .55), 0 7px 18px rgba(41, 60, 77, .2), inset 0 1px 0 #fff;
}

.storybook-button:focus-visible {
  outline: 4px solid rgba(97, 76, 157, .65);
  outline-offset: 5px;
}

.storybook-button:disabled {
  cursor: wait;
  filter: saturate(.72);
}

.descent-status {
  position: absolute;
  z-index: 2;
  bottom: 1.25rem;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .88);
  font-family: ui-rounded, "Avenir Next", Avenir, sans-serif;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  animation: status-away .8s ease 5.2s forwards;
}

@keyframes status-away {
  to { opacity: 0; transform: translate(-50%, .5rem); }
}

.hatchery {
  z-index: 1;
  display: grid;
  place-items: center;
  align-items: safe center;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 900ms ease, visibility 900ms ease;
}

.hatchery.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.farm-backdrop {
  position: fixed;
  inset: 0;
  background: url("./assets/farm-panorama.png") center bottom / cover no-repeat;
  filter: saturate(.92) brightness(.77);
}

.hatchery-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 246, 205, .32), rgba(41, 54, 82, .17) 42%, rgba(27, 39, 65, .55) 100%),
    linear-gradient(180deg, rgba(69, 121, 154, .14), rgba(44, 43, 76, .22));
  backdrop-filter: blur(2px);
}

.small-brand {
  position: absolute;
  z-index: 3;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fffceb;
  font-family: ui-rounded, "Avenir Next", Avenir, sans-serif;
  font-size: .86rem;
  font-weight: 900;
  letter-spacing: .15em;
  text-align: center;
  text-shadow: 0 2px 12px rgba(28, 42, 62, .6);
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-gem {
  margin-right: .5rem;
  color: #ffe797;
}

.hatch-panel {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(94vw, 52rem);
  padding: clamp(1rem, 3vw, 2rem);
  text-align: center;
  margin-block: 3rem 1.2rem;
}

.egg-control {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.egg-control:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 5px;
}

.egg-control:disabled {
  cursor: wait;
}

.magic-stage.is-revealed .egg-control {
  display: none;
}

.magic-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: min(78vw, 34rem);
  height: min(57svh, 35rem);
  min-height: 20rem;
  isolation: isolate;
}

.egg,
.unicorn {
  position: relative;
  z-index: 3;
  display: block;
  width: min(69vw, 25rem);
  max-height: 51svh;
  object-fit: contain;
  filter: drop-shadow(0 22px 23px rgba(37, 45, 55, .34));
}

.egg {
  animation: egg-breathe 2.8s ease-in-out infinite;
}

@keyframes egg-breathe {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 22px 23px rgba(37, 45, 55, .34)) brightness(1); }
  50% { transform: translateY(-8px) scale(1.018); filter: drop-shadow(0 28px 28px rgba(255, 222, 135, .42)) brightness(1.05); }
}

.magic-stage.is-hatching .egg {
  animation: hatch-shake 1.65s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes hatch-shake {
  0%, 100% { transform: translate(0, 0) rotate(0) scale(1); }
  10% { transform: translate(-7px, -2px) rotate(-2deg) scale(1.01); }
  20% { transform: translate(8px, -6px) rotate(2deg) scale(1.02); }
  30% { transform: translate(-11px, -3px) rotate(-3deg) scale(1.025); }
  43% { transform: translate(11px, -10px) rotate(3deg) scale(1.035); }
  56% { transform: translate(-13px, -6px) rotate(-3deg) scale(1.04); }
  70% { transform: translate(12px, -13px) rotate(3deg) scale(1.055); filter: brightness(1.28) drop-shadow(0 0 42px #fff0a4); }
  84% { transform: translate(-7px, -9px) rotate(-2deg) scale(1.07); filter: brightness(1.65) drop-shadow(0 0 58px #fff); }
}

.unicorn {
  display: none;
  opacity: 0;
  transform: scale(.78) translateY(1.5rem);
}

.magic-stage.is-revealed .egg {
  display: none;
}

.magic-stage.is-revealed .unicorn {
  display: block;
  animation: unicorn-arrives 850ms cubic-bezier(.18, .85, .25, 1.22) forwards;
}

@keyframes unicorn-arrives {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.magic-ring {
  position: absolute;
  z-index: 1;
  width: 72%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 243, 178, .7);
  border-radius: 50%;
  box-shadow: 0 0 38px rgba(255, 228, 155, .38), inset 0 0 35px rgba(242, 172, 218, .22);
  animation: orbit 9s linear infinite;
}

.magic-ring::before,
.magic-ring::after {
  content: "✦";
  position: absolute;
  top: 50%;
  color: #fff0a1;
  font-size: 1.25rem;
  text-shadow: 0 0 12px #fff;
}

.magic-ring::before { left: -9px; }
.magic-ring::after { right: -9px; }

.magic-ring--two {
  width: 56%;
  border-color: rgba(196, 185, 255, .72);
  animation-direction: reverse;
  animation-duration: 6.5s;
  transform: rotateX(65deg);
}

@keyframes orbit {
  to { rotate: 1turn; }
}

.hatch-flash {
  position: absolute;
  z-index: 5;
  width: 26rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 8%, rgba(255, 248, 194, .95) 17%, rgba(255, 207, 238, .44) 39%, transparent 69%);
  opacity: 0;
  pointer-events: none;
}

.magic-stage.is-hatching .hatch-flash {
  animation: hatch-flash 1.25s ease 1.15s both;
}

@keyframes hatch-flash {
  0% { opacity: 0; transform: scale(.15); }
  43% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1.8); }
}

.hatch-copy {
  position: relative;
  z-index: 6;
  margin-top: clamp(-1.2rem, -2svh, -.3rem);
  padding: .75rem 1.35rem;
  color: #fffdf1;
  text-shadow: 0 2px 10px rgba(28, 42, 62, .7);
}

.hatch-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
  letter-spacing: -.035em;
}

.hatch-copy p:last-child {
  margin: .75rem 0 0;
  font-family: ui-rounded, "Avenir Next", Avenir, sans-serif;
  font-size: clamp(.95rem, 2vw, 1.08rem);
  font-weight: 650;
}

.storybook-button--hatch {
  z-index: 7;
  margin-top: .35rem;
  min-width: min(20rem, 88vw);
}

.particle-field,
.sparkles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  left: var(--x);
  top: var(--y);
  border-radius: 50%;
  background: #fff7bc;
  box-shadow: 0 0 12px #fff, 0 0 22px rgba(246, 191, 232, .8);
  opacity: .35;
  animation: drift var(--speed) ease-in-out var(--delay) infinite alternate;
}

@keyframes drift {
  to { transform: translate3d(var(--dx), -2.5rem, 0) scale(1.5); opacity: .95; }
}

@media (max-width: 700px) {
  .world img {
    height: 235svh;
    animation-name: descend-mobile;
  }

  @keyframes descend-mobile {
    0% { transform: translate3d(0, 0, 0) scale(1.03); }
    100% { transform: translate3d(0, -135svh, 0) scale(1); }
  }

  .intro-copy {
    bottom: 3.4rem;
  }

  .magic-stage {
    width: 92vw;
    height: 53svh;
  }

  .egg,
  .unicorn {
    width: min(84vw, 24rem);
    max-height: 48svh;
  }

  .hatch-panel {
    padding: .55rem;
  }

  .hatch-copy {
    padding-inline: .75rem;
  }
}

@media (max-height: 650px) {
  .magic-stage {
    height: 38svh;
    min-height: 0;
  }

  .egg,
  .unicorn {
    width: auto;
    max-width: 80vw;
    max-height: 36svh;
  }

  .magic-ring {
    width: auto;
    height: 94%;
  }

  .magic-ring--two {
    height: 74%;
  }

  .hatch-copy {
    margin-top: 0;
    padding-block: .5rem;
  }

  .hatch-copy h2 {
    font-size: 2rem;
  }

  .hatch-copy p:last-child {
    margin-top: .5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .world img {
    animation-duration: .01ms;
  }

  .intro-copy {
    animation-delay: .15s;
  }

  .descent-status {
    display: none;
  }

  .egg,
  .magic-ring,
  .particle {
    animation-duration: .01ms !important;
  }
}
