:root {
  --bg: #b0b0b0;
  /* Accents de cada sitio GDP (el papel de los 3 es #fcfcfc). */
  --bg-ornella: #dac660;
  --bg-amanda: #da9ba7;
  --bg-marcelo: #9dc3c9;
  --ink: #0a0a0a;
  --gap: clamp(4.5rem, 11vw, 10rem);
  --page-pad-x: clamp(1.25rem, 4vw, 3rem);
  --title-max: min(28rem, 68vw);
  --book-max: 17rem;
  --noise-image: url("./assets/noise.png");
  --noise-amount: 0.24;
  --noise-density: 256px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, serif;
  transition: background-color 480ms ease;
}

/* Gradient default con los 3 accents; se desvanece en hover de un libro. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 90% 70% at 12% 18%,
      var(--bg-ornella) 0%,
      transparent 58%
    ),
    radial-gradient(
      ellipse 85% 65% at 88% 22%,
      var(--bg-amanda) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse 95% 75% at 50% 92%,
      var(--bg-marcelo) 0%,
      transparent 60%
    ),
    linear-gradient(
      125deg,
      color-mix(in srgb, var(--bg-ornella) 55%, #c8c4bc) 0%,
      color-mix(in srgb, var(--bg-amanda) 50%, #c8c4bc) 48%,
      color-mix(in srgb, var(--bg-marcelo) 55%, #c8c4bc) 100%
    );
  opacity: 1;
  transition: opacity 480ms ease;
}

body:has(.book[data-site="ornella"]:hover),
body:has(.book[data-site="ornella"]:focus-visible) {
  background-color: var(--bg-ornella);
}

body:has(.book[data-site="amanda"]:hover),
body:has(.book[data-site="amanda"]:focus-visible) {
  background-color: var(--bg-amanda);
}

body:has(.book[data-site="marcelo"]:hover),
body:has(.book[data-site="marcelo"]:focus-visible) {
  background-color: var(--bg-marcelo);
}

body:has(.book:hover)::before,
body:has(.book:focus-visible)::before {
  opacity: 0;
}

/* Grain vivo (mismo asset/animación que los sitios artbook GDP). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background-image: var(--noise-image), var(--noise-image), var(--noise-image);
  background-repeat: repeat;
  background-size: var(--noise-density);
  background-position: 0 0, 0 0, 0 0;
  opacity: var(--noise-amount);
  animation: noise-flicker 0.4s steps(1) infinite;
}

@keyframes noise-flicker {
  0% {
    background-position: 0 0, 0 0, 0 0;
  }
  20% {
    background-position: -48px 24px, 32px -16px, 12px 40px;
  }
  40% {
    background-position: 28px -52px, -20px 36px, -40px -12px;
  }
  60% {
    background-position: -16px 8px, 44px 20px, 24px -36px;
  }
  80% {
    background-position: 36px 44px, -36px -28px, -8px 16px;
  }
  100% {
    background-position: 0 0, 0 0, 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  body::before {
    transition: none;
  }

  body::after {
    animation: none;
  }
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

.cursor-trail {
  position: fixed;
  inset: 0;
  z-index: 85;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
}

.page {
  position: relative;
  z-index: 1;
  width: min(80rem, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vh, 1.25rem) var(--page-pad-x)
    clamp(1.25rem, 3vh, 2rem);
}

.brand {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  margin: 0;
  width: 100%;
}

.brand__title {
  margin: 0;
  width: var(--title-max);
}

.brand__logo {
  width: 100%;
  height: auto;
  margin-inline: auto;
}

/* Mobile: flujo normal debajo del título (evita cortar el primer libro). */
.books {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(2.75rem, 8vh, 4rem);
  width: 100%;
  margin-top: clamp(1.75rem, 5vh, 2.75rem);
  padding: 0 0 clamp(2rem, 6vh, 3.5rem);
  pointer-events: none;
}

.book {
  display: block;
  width: min(100%, var(--book-max));
  pointer-events: auto;
  opacity: 0;
  transform: translateY(3.5rem);
  animation: book-enter 720ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.book:nth-child(1) {
  animation-delay: 120ms;
}

.book:nth-child(2) {
  animation-delay: 280ms;
}

.book:nth-child(3) {
  animation-delay: 440ms;
}

@keyframes book-enter {
  from {
    opacity: 0;
    transform: translateY(3.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes book-levitate {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-14px);
  }
}

.book:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.book__cover {
  width: 100%;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.28));
  transition: filter 280ms ease, transform 280ms ease;
  transform: translateY(0);
  will-change: transform;
}

.book:hover .book__cover,
.book:focus-visible .book__cover {
  filter: drop-shadow(0 32px 40px rgba(0, 0, 0, 0.4));
  animation: book-levitate 2.4s ease-in-out infinite;
}

@media (min-width: 768px) {
  /* Desktop: logo arriba, libros centrados en el viewport. */
  .books {
    position: absolute;
    inset: 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: var(--gap);
    margin-top: 0;
    padding: clamp(5.5rem, 14vh, 7rem) var(--page-pad-x)
      clamp(1.25rem, 3vh, 2rem);
  }

  .book {
    width: min(100%, calc((100% - 2 * var(--gap)) / 3));
    max-width: var(--book-max);
  }
}

@media (prefers-reduced-motion: reduce) {
  .book {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .book__cover {
    transition: none;
  }

  .book:hover .book__cover,
  .book:focus-visible .book__cover {
    animation: none;
    transform: translateY(-12px);
  }
}
