*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5vh;
  background: url('background.jpg') center / cover no-repeat;
}

.scene {
  display: flex;
  align-items: center;
  gap: 4vw;
}

/* ——— Notebook wrap: stacking context above phone ——— */
.notebook-wrap {
  position: relative;
  width: 18vw;
  flex-shrink: 0;
  z-index: 2;
}

/* Notebook cover sits on top of pages */
.notebook {
  position: relative;
  width: 100%;
  height: auto;
  z-index: 4;
}

/* ——— Pages ——— */
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  transform: translateX(0);
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Front page (closest to cover) slides out least */
.page-1 { z-index: 3; }
/* Middle */
.page-2 { z-index: 2; transition-delay: 0.05s; }
/* Back page slides out furthest */
.page-3 { z-index: 1; transition-delay: 0.1s; }

.notebook-wrap:hover .page-1,
.notebook-wrap.fanned .page-1 { transform: translateX(78%) translateY(-20px) rotate(-4deg); }

.notebook-wrap:hover .page-2,
.notebook-wrap.fanned .page-2 { transform: translateX(99%) rotate(2deg); }

.notebook-wrap:hover .page-3,
.notebook-wrap.fanned .page-3 { transform: translateX(145%) rotate(-1deg); }

/* Return: no delay so they snap back cleanly */
.notebook-wrap:not(:hover):not(.fanned) .page-1,
.notebook-wrap:not(:hover):not(.fanned) .page-2,
.notebook-wrap:not(:hover):not(.fanned) .page-3 {
  transition-delay: 0s;
}

/* ——— Phone ——— */
.phone-wrap {
  position: relative;
  width: 19vw;
  flex-shrink: 0;
  z-index: 1;
  cursor: pointer;
  filter: drop-shadow(0 10px 50px rgba(0, 0, 0, 0.25));
  transition: transform 0.2s ease;
}

.phone-wrap:hover {
  transform: scale(1.02);
}


.phone {
  width: 100%;
  height: auto;
  display: block;
}

/* App screen: sits beneath, slides up into place */
.phone.app {
  position: relative;
  transform: translateY(6%);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.45s ease;
}

/* Splash: on top, slides up and out on activate */
.phone.splash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s ease;
}

/* Click: splash slides up and out, app slides in */
.phone-wrap.active .phone.splash {
  transform: translateY(-100%);
  opacity: 0;
}

.phone-wrap.active .phone.app {
  transform: translateY(0);
  opacity: 1;
}

/* Instant return to splash on mouse off */
.phone-wrap.returning .phone.splash,
.phone-wrap.returning .phone.app {
  transition: none;
}

/* Pulse on "tap to continue" hint — draws attention before first tap */
@keyframes pulse-phone {
  0%, 100% { filter: drop-shadow(0 10px 50px rgba(0, 0, 0, 0.25)); }
  50%       { filter: drop-shadow(0 10px 60px rgba(0, 0, 0, 0.38)) drop-shadow(0 0 20px rgba(121, 216, 240, 0.4)); }
}

.phone-wrap:not(.active) {
  animation: pulse-phone 2.5s ease-in-out infinite;
}

.bottom-lockup {
  width: 20vw;
  height: auto;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.bottom-lockup:hover {
  opacity: 1;
}

/* ——— Modal ——— */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  max-width: 600px;
  width: 100%;
  position: relative;
}

.modal-body {
  background: white;
  border: 5px solid #40c8ef;
  padding: 40px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: -26px;
  right: -26px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: white;
  border: 5px solid #40c8ef;
  font-size: 22px;
  color: #231f20;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}

.modal-close:hover {
  background: #f0f0f0;
}

.modal-body p {
  font-family: 'Inconsolata', monospace;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.7;
  color: #231f20;
  margin-bottom: 20px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.highlight {
  color: #40c8ef;
  font-weight: 700;
}

a.highlight {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (hover: none) {
  /* Disable fan on touch — pages stay stacked */
  .notebook-wrap:hover .page-1,
  .notebook-wrap:hover .page-2,
  .notebook-wrap:hover .page-3 {
    transform: none;
  }

  .page.page-top {
    z-index: 5;
    animation: shuffle-in 0.18s ease;
  }

  @keyframes shuffle-in {
    from { transform: scale(0.95); opacity: 0.6; }
    to   { transform: scale(1);    opacity: 1; }
  }
}

@media (max-width: 700px) {
  .modal-body p {
    font-size: 12px;
  }

  .modal-body {
    padding: 24px;
  }
  body {
    gap: 6vw;
    padding: 10vw 0;
  }

  .scene {
    flex-direction: column;
    align-items: center;
    gap: 10vw;
  }

  .notebook-wrap {
    width: 58vw;
  }

  .phone-wrap {
    width: 58vw;
  }

  .bottom-lockup {
    width: 72vw;
  }

  /* Disable hover scale on touch */
  .phone-wrap:hover {
    transform: none;
  }
}
