/* =========================================================
   Lor Criber — page-level layouts (home + book detail)
   ========================================================= */

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
  padding-block: clamp(3rem, 8vw, 6.5rem) clamp(3rem, 7vw, 5.5rem);
}

.hero::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  z-index: -1;
  width: 60vw;
  height: 60vw;
  max-width: 780px;
  max-height: 780px;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--accent) 16%, transparent),
    transparent 62%
  );
  filter: blur(20px);
  animation: drift 22s var(--ease-out) infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  to {
    transform: translate3d(-6%, 5%, 0) scale(1.12);
  }
}

.hero__title {
  margin-bottom: 1.25rem;
}

/* Word-by-word entrance, staggered from JS */
.hero__title .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em);
  animation: word-up 0.85s var(--ease-out) forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes word-up {
  to {
    opacity: 1;
    transform: none;
  }
}

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

.hero__title em {
  font-style: italic;
  color: var(--accent);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2rem;
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.stat__num {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat__label {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Fanned stack of covers — each layer parallaxes at its own rate */
.hero__stack {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(320px, 46vw, 520px);
  perspective: 1400px;
}

.hero__stack .cover {
  container-type: inline-size;
  position: absolute;
  width: clamp(130px, 19vw, 200px);
  transform: translate3d(var(--x, 0), var(--y, 0), 0) rotate(var(--r, 0deg));
  transition: transform var(--dur-slow) var(--ease-out);
}

.hero__stack .cover:nth-child(1) {
  --x: -80%;
  --y: 2%;
  --r: -12deg;
  z-index: 1;
  filter: brightness(0.88);
}

.hero__stack .cover:nth-child(2) {
  --x: 0%;
  --y: -12%;
  --r: 1deg;
  z-index: 3;
}

.hero__stack .cover:nth-child(3) {
  --x: 78%;
  --y: 6%;
  --r: 13deg;
  z-index: 2;
  filter: brightness(0.92);
}

/* Exactly two covers: the three-cover offsets above would hang the pair off to
   the left, so they get their own balanced spread. The published title leads. */
.hero__stack .cover:first-child:nth-last-child(2) {
  --x: -42%;
  --y: -4%;
  --r: -8deg;
  z-index: 3;
  filter: none;
}

.hero__stack .cover:first-child:nth-last-child(2) ~ .cover {
  --x: 42%;
  --y: 4%;
  --r: 9deg;
  z-index: 2;
  filter: brightness(0.92);
}

/* A lone cover sits centred and upright — the fan needs siblings to read.
   Declared after the nth-child rules so it wins on source order. */
.hero__stack .cover:only-child {
  --x: 0%;
  --y: 0%;
  --r: 0deg;
  width: clamp(180px, 26vw, 300px);
  filter: none;
}

.hero__stack .cover:hover {
  z-index: 4;
  transform: translate3d(var(--x, 0), calc(var(--y, 0%) - 14px), 0) rotate(0deg)
    scale(1.05);
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero__stack {
    order: -1;
    min-height: 300px;
  }
}

/* ---------------- Marquee strip ---------------- */

.marquee {
  padding-block: 1rem;
  border-block: 1px solid var(--line);
  background: var(--bg-sunken);
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.marquee__track {
  display: inline-flex;
  gap: 3rem;
  animation: marquee 38s linear infinite;
}

.marquee:hover .marquee__track {
  animation-play-state: paused;
}

.marquee span {
  font-family: var(--font-display);
  font-size: var(--step-0);
  font-style: italic;
  color: var(--ink-muted);
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

/* ---------------- Author section ---------------- */

.author {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
  padding: clamp(2rem, 5vw, 3.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

.author__portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: linear-gradient(155deg, var(--accent-2), var(--accent));
  display: grid;
  place-items: center;
  overflow: hidden;
}

.author__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author__portrait span {
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6rem);
  color: rgb(255 255 255 / 92%);
  letter-spacing: -0.04em;
}

.author__portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -40deg,
    rgb(255 255 255 / 6%) 0 3px,
    transparent 3px 8px
  );
}

.author__portrait:has(img)::after {
  content: none;
}

.author__socials {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.75rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  transition: transform var(--dur) var(--ease-spring), color var(--dur-fast),
    border-color var(--dur-fast);
}

.icon-btn:hover {
  transform: translateY(-4px);
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 820px) {
  .author {
    grid-template-columns: 1fr;
  }

  .author__portrait {
    max-width: 260px;
  }
}

/* ---------------- Newsletter ---------------- */

.newsletter {
  padding: clamp(2rem, 5vw, 3.5rem);
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: var(--bg);
  text-align: center;
}

.newsletter h2 {
  margin-bottom: 0.75rem;
}

.newsletter p {
  max-width: 48ch;
  margin-inline: auto;
  color: color-mix(in srgb, var(--bg) 72%, transparent);
}

.newsletter__form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  max-width: 460px;
  margin: 2rem auto 0;
}

.newsletter__form input {
  flex: 1 1 220px;
  padding: 0.9rem 1.25rem;
  border: 1px solid color-mix(in srgb, var(--bg) 24%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg) 8%, transparent);
  color: var(--bg);
}

.newsletter__form input::placeholder {
  color: color-mix(in srgb, var(--bg) 50%, transparent);
}

.newsletter__form input:focus {
  outline: none;
  border-color: var(--accent);
}

/* =========================================================
   Book detail page
   ========================================================= */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  height: 3px;
  width: 100%;
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: transform 90ms linear;
}

.book-hero {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  padding-block: clamp(2rem, 5vw, 4rem);
}

.book-hero__media {
  container-type: inline-size;
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  align-self: start;
  perspective: 1200px;
}

.book-hero__media .cover {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform var(--dur) var(--ease-out);
  will-change: transform;
}

.book-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}

.book-hero__meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.book-hero__meta svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.75;
}

.book-hero h1 {
  font-size: var(--step-3);
  margin-bottom: 0.5rem;
}

.book-hero__tagline {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
}

/* Purchase panel */
.buy-panel {
  display: grid;
  gap: 0.9rem;
  margin-top: 2rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.buy-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.buy-panel__label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.buy-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.buy-option__info strong {
  display: block;
  font-size: var(--step-0);
}

.buy-option__info small {
  color: var(--ink-muted);
}

.buy-panel__note {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-align: center;
}

@media (max-width: 820px) {
  .book-hero {
    grid-template-columns: 1fr;
  }

  .book-hero__media {
    position: static;
    max-width: 240px;
  }
}

/* Synopsis */
.prose p + p {
  margin-top: 1.15em;
}

.prose {
  max-width: var(--measure);
  color: var(--ink-soft);
  font-size: var(--step-0);
  line-height: 1.75;
}

.prose--dropcap > p:first-of-type::first-letter {
  float: left;
  margin: 0.05em 0.12em 0 0;
  font-family: var(--font-display);
  font-size: 3.2em;
  line-height: 0.82;
  color: var(--accent);
}

.excerpt {
  position: relative;
  max-width: var(--measure);
  margin-top: 2.5rem;
  padding: 2rem 2rem 2rem 3.5rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-sunken);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-style: italic;
  line-height: 1.5;
  white-space: pre-line;
}

.excerpt::before {
  content: '\201C';
  position: absolute;
  top: 0.1em;
  left: 0.35rem;
  font-family: var(--font-display);
  font-size: 4rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.35;
}

/* Details table */
.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.details div {
  padding: 1.15rem 1.25rem;
  background: var(--bg-elevated);
  transition: background-color var(--dur-fast);
}

.details div:hover {
  background: var(--bg-sunken);
}

.details dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.details dd {
  margin: 0.35rem 0 0;
  font-weight: 500;
}

/* Reviews layout */
.reviews {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}

.reviews__summary {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  text-align: center;
}

.reviews__score {
  font-family: var(--font-display);
  font-size: var(--step-4);
  line-height: 1;
  letter-spacing: -0.04em;
}

.reviews__bars {
  display: grid;
  gap: 0.4rem;
  margin-top: 1.5rem;
  text-align: left;
}

.bar-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr 2rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--gold);
  transition: width 900ms var(--ease-out);
}

.reviews__list {
  display: grid;
  gap: 1rem;
}

.review-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.75rem;
  padding: 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.review-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 820px) {
  .reviews {
    grid-template-columns: 1fr;
  }

  .reviews__summary {
    position: static;
  }

  .review-form__row {
    grid-template-columns: 1fr;
  }
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-muted);
  transition: color var(--dur-fast);
}

.back-link svg {
  width: 15px;
  height: 15px;
  transition: transform var(--dur) var(--ease-spring);
}

.back-link:hover {
  color: var(--accent);
}

.back-link:hover svg {
  transform: translateX(-4px);
}

/* Not-found state */
.not-found {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  min-height: 60svh;
  text-align: center;
}

/* Empty catalogue state */
.empty-state {
  grid-column: 1 / -1;
  padding: 4rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}
