/* KI ins eigene Produkt: 3D book object, book landing and flip-book reader.
   Uses the site's tokens from /style.css (ink, paper, accent, fonts). */

.book-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(3rem, 7vw, 6.5rem) 0 clamp(3.5rem, 7vw, 6rem);
  border-bottom: var(--hairline);
  background:
    radial-gradient(60rem 30rem at 18% 30%, rgba(170, 181, 156, 0.13), transparent 70%),
    radial-gradient(40rem 24rem at 85% 90%, rgba(235, 231, 220, 0.06), transparent 70%),
    var(--color-background);
}

.book-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(2rem, 6vw, 5.5rem);
  align-items: center;
}

.book-hero h1 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.9rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.01em;
}

.book-hero__subtitle {
  margin: 0 0 1.6rem;
  color: var(--color-paper);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  font-style: italic;
  line-height: 1.25;
}

.book-hero__lead {
  max-width: 34rem;
  margin: 0 0 1.8rem;
  color: var(--color-muted);
  font-size: 1.05rem;
}

.book-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  margin: 0 0 2rem;
  padding: 0;
  color: var(--color-quiet);
  font-size: 0.82rem;
  list-style: none;
}

.book-facts strong {
  color: var(--color-ink);
  font-weight: 600;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.book-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.9rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  color: var(--color-ink);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}

.book-button:hover,
.book-button:focus-visible {
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

.book-button--primary {
  border-color: var(--color-paper);
  background: var(--color-paper);
  color: var(--color-paper-ink);
}

.book-button--primary:hover,
.book-button--primary:focus-visible {
  border-color: var(--color-accent);
  background: var(--color-accent);
}

/* ---------------------------------------------------------------- 3D book */

.book-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(26rem, 52vw, 38rem);
  perspective: 2200px;
  perspective-origin: 50% 40%;
  touch-action: pan-y;
  user-select: none;
}

.book-stage::after {
  content: "";
  position: absolute;
  bottom: clamp(1rem, 3vw, 2.4rem);
  left: 50%;
  width: min(23rem, 70%);
  height: 2.4rem;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.62), transparent);
  filter: blur(6px);
  transform: translateX(-50%);
  pointer-events: none;
}

.book3d {
  --w: clamp(12.5rem, 25vw, 19rem);
  --h: calc(var(--w) * 210 / 148);
  --d: calc(var(--w) * 14 / 148);
  --rx: 7deg;
  --ry: 30deg;
  position: relative;
  z-index: 1;
  width: var(--w);
  height: var(--h);
  transform-style: preserve-3d;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 1100ms cubic-bezier(0.18, 0.75, 0.2, 1);
  cursor: grab;
  outline: none;
}

.book3d.is-dragging {
  transition: none;
  cursor: grabbing;
}

.book3d:focus-visible {
  filter: drop-shadow(0 0 0.6rem rgba(170, 181, 156, 0.7));
}

.book3d__face {
  position: absolute;
  top: 0;
  left: 0;
  backface-visibility: hidden;
}

.book3d__front,
.book3d__back {
  width: var(--w);
  height: var(--h);
  background-color: #f0f0e7;
  background-position: center;
  background-size: cover;
  border-radius: 2px 5px 5px 2px;
}

.book3d__front {
  background-image: url("/b/1/cover/front.webp");
  transform: translateZ(calc(var(--d) / 2));
  box-shadow: inset 6px 0 10px -6px rgba(0, 0, 0, 0.45);
}

/* Hinge groove and a soft sheen make the cover read as board, not a picture. */
.book3d__front::before,
.book3d__front::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.book3d__front::before {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0, rgba(0, 0, 0, 0.05) 2.2%, rgba(255, 255, 255, 0.18) 3.4%, transparent 5.5%);
}

.book3d__front::after {
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0) 32%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.12) 100%);
  mix-blend-mode: soft-light;
}

.book3d__back {
  background-image: url("/b/1/cover/back.webp");
  border-radius: 5px 2px 2px 5px;
  transform: rotateY(180deg) translateZ(calc(var(--d) / 2));
}

.book3d__spine {
  width: var(--d);
  height: var(--h);
  left: calc(50% - var(--d) / 2);
  background: #143d34 url("/b/1/cover/spine.webp") center / 100% 100% no-repeat;
  transform: rotateY(-90deg) translateZ(calc(var(--w) / 2));
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}

.book3d__edge {
  width: var(--d);
  height: calc(var(--h) - 6px);
  top: 3px;
  left: calc(50% - var(--d) / 2);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.16)),
    repeating-linear-gradient(90deg, #f6f3ea 0 1px, #ddd8ca 1px 2px);
  transform: rotateY(90deg) translateZ(calc(var(--w) / 2 - 3px));
}

.book3d__top,
.book3d__bottom {
  width: calc(var(--w) - 6px);
  height: var(--d);
  left: 3px;
  top: calc(50% - var(--d) / 2);
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.16), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.14)),
    repeating-linear-gradient(0deg, #f6f3ea 0 1px, #ddd8ca 1px 2px);
}

.book3d__top {
  transform: rotateX(90deg) translateZ(calc(var(--h) / 2 - 3px));
}

.book3d__bottom {
  transform: rotateX(-90deg) translateZ(calc(var(--h) / 2 - 3px));
}

.book-stage__hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  color: var(--color-quiet);
  font-size: 0.75rem;
  text-align: center;
}

.book-stage__controls {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 0.4rem;
}

.book-stage__controls button {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: rgba(23, 24, 20, 0.6);
  color: var(--color-muted);
  font-size: 0.75rem;
}

.book-stage__controls button:hover,
.book-stage__controls button:focus-visible {
  border-color: var(--color-accent);
  color: var(--color-ink);
}

/* ---------------------------------------------------------- book sections */

.book-section {
  padding: var(--section-space) 0;
  border-bottom: var(--hairline);
}

.book-section--paper {
  background: var(--color-paper);
  color: var(--color-paper-ink);
}

.book-section--paper .eyebrow {
  color: var(--color-accent-deep);
}

.book-section h2 {
  margin: 0 0 1.4rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 400;
  line-height: 1.05;
}

.book-split {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2rem, 6vw, 5rem);
}

.book-quote {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.2;
}

.book-quote footer {
  margin-top: 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}

.book-prose p {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
}

.book-questions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 2.5rem;
  border: var(--hairline-dark);
  background: var(--color-line-dark);
}

.book-question {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.2rem;
  min-height: 9rem;
  padding: 1.5rem;
  background: var(--color-paper);
  transition: background var(--ease);
}

.book-question:hover,
.book-question:focus-visible {
  background: #f3f0e7;
}

.book-question span:first-child {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.25;
}

.book-question span:last-child {
  color: var(--color-paper-muted);
  font-size: 0.82rem;
}

.book-toc {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--hairline);
}

.book-toc li {
  border-bottom: var(--hairline);
}

.book-toc a {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: baseline;
  padding: 1.1rem 0;
  transition: color var(--ease), padding var(--ease);
}

.book-toc a:hover,
.book-toc a:focus-visible {
  padding-left: 0.4rem;
  color: var(--color-accent);
}

.book-toc__no {
  color: var(--color-quiet);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.book-toc__title {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  line-height: 1.2;
}

.book-toc__title small {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-muted);
  font-family: var(--font-body);
  font-size: 0.86rem;
}

.book-toc__page {
  color: var(--color-quiet);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.book-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.6rem;
  border: var(--hairline);
  border-radius: var(--corner);
  background: var(--color-surface);
}

.book-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
}

.book-card p {
  margin: 0;
  color: var(--color-muted);
}

.book-card .text-link {
  margin-top: auto;
}

.book-downloads {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  border: var(--hairline);
  background: var(--color-line);
  list-style: none;
}

.book-downloads li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1.2rem 1.4rem;
  background: var(--color-background);
}

.book-downloads strong {
  display: block;
  font-weight: 600;
}

.book-downloads code {
  color: var(--color-quiet);
  font-size: 0.7rem;
  word-break: break-all;
}

.book-note {
  margin: 1.4rem 0 0;
  color: var(--color-quiet);
  font-size: 0.85rem;
}

.books-shelf {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  padding: 2rem 0;
  border-top: var(--hairline);
  border-bottom: var(--hairline);
}

.books-shelf img {
  width: 100%;
  height: auto;
  border-radius: 2px 6px 6px 2px;
  box-shadow: 0 24px 50px -18px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  transform: rotate(-2deg);
  transition: transform 400ms ease;
}

.books-shelf a:hover img,
.books-shelf a:focus-visible img {
  transform: rotate(0deg) translateY(-4px);
}

.books-shelf h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
}

/* ------------------------------------------------------------ flip-book */

.reader {
  --page-h: min(calc(100vh - 12.5rem), 62rem, calc((100vw - 12rem) / 2 * 210 / 148));
  --page-w: calc(var(--page-h) * 148 / 210);
  padding: clamp(1.2rem, 3vw, 2rem) 0 3rem;
  background:
    radial-gradient(50rem 26rem at 50% 45%, rgba(235, 231, 220, 0.07), transparent 70%),
    var(--color-background);
}

.reader__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.reader__head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 400;
}

.reader__head p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.reader__stage {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(0.4rem, 1.5vw, 1rem);
  align-items: center;
}

.reader__arrow {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  background: transparent;
  color: var(--color-ink);
  font-size: 1.3rem;
  transition: border-color var(--ease), background var(--ease);
}

.reader__arrow:hover:not(:disabled),
.reader__arrow:focus-visible {
  border-color: var(--color-accent);
  background: rgba(170, 181, 156, 0.1);
}

.reader__arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.flipbook {
  position: relative;
  display: flex;
  justify-content: center;
  perspective: 2600px;
  touch-action: pan-y;
}

.flipbook__spread {
  position: relative;
  display: grid;
  grid-template-columns: var(--page-w) var(--page-w);
  height: var(--page-h);
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.55));
}

.flipbook.is-single .flipbook__spread {
  grid-template-columns: var(--page-w);
}

.flipbook__page,
.flipbook__leaf-face {
  position: relative;
  overflow: hidden;
  background: #fbfaf6 linear-gradient(110deg, #fbfaf6 40%, #f1eee6 50%, #fbfaf6 60%) 0 0 / 300% 100%;
}

.flipbook__page img,
.flipbook__leaf-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.flipbook__page--left {
  border-radius: 4px 0 0 4px;
}

.flipbook__page--right {
  border-radius: 0 4px 4px 0;
}

.flipbook__page.is-empty {
  background: transparent;
}

/* Gutter shading: the inner margins of an open book curve away from the light. */
.flipbook__page--left::after,
.flipbook__page--right::after,
.flipbook__leaf-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flipbook__page--left::after {
  background: linear-gradient(90deg, transparent 82%, rgba(0, 0, 0, 0.14) 96%, rgba(0, 0, 0, 0.24));
}

.flipbook__page--right::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.24), rgba(0, 0, 0, 0.12) 4%, transparent 18%);
}

.flipbook.is-single .flipbook__page--right::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.14), transparent 6%);
}

.flipbook__page.is-empty::after {
  display: none;
}

.flipbook__leaf {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--page-w);
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 760ms cubic-bezier(0.3, 0.05, 0.25, 1);
  z-index: 3;
  pointer-events: none;
}

.flipbook__leaf[hidden] {
  display: none;
}

.flipbook__leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.flipbook__leaf-face--back {
  transform: rotateY(180deg);
}

.flipbook__leaf-face--front::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 12%, transparent 70%, rgba(0, 0, 0, var(--shade, 0)));
}

.flipbook__leaf-face--back::after {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.18), transparent 12%, transparent 70%, rgba(0, 0, 0, var(--shade, 0)));
}

.flipbook__hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22%;
  border: 0;
  background: transparent;
  z-index: 4;
}

.flipbook__hit--prev {
  left: 0;
  cursor: w-resize;
}

.flipbook__hit--next {
  right: 0;
  cursor: e-resize;
}

.reader__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.6rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.reader__tools input[type="range"] {
  width: min(26rem, 80vw);
  accent-color: var(--color-accent);
}

.reader__tools input[type="number"],
.reader__tools select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-line);
  border-radius: var(--corner);
  background: var(--color-surface);
  color: var(--color-ink);
}

.reader__tools input[type="number"] {
  width: 4.6rem;
}

.reader__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: center;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.reader__links a {
  color: var(--color-accent);
}

.reader__links a:hover,
.reader__links a:focus-visible {
  color: var(--color-ink);
}

.reader__noscript {
  max-width: 40rem;
  margin: 2rem auto;
  color: var(--color-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .book-hero__inner,
  .book-split,
  .books-shelf {
    grid-template-columns: 1fr;
  }

  .book-hero__inner .book-stage {
    order: -1;
  }

  .book-cards {
    grid-template-columns: 1fr;
  }

  .book-questions {
    grid-template-columns: 1fr;
  }

  .books-shelf img {
    max-width: 13rem;
  }

  .reader {
    --page-h: min(calc(100vh - 14rem), calc((100vw - 2.5rem) * 210 / 148));
  }

  .reader__stage {
    grid-template-columns: 1fr;
  }

  .reader__arrow {
    display: none;
  }
}

@media (max-width: 560px) {
  .book-toc a {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .book-toc__no {
    grid-column: 1 / -1;
  }

  .book-downloads li {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book3d,
  .flipbook__leaf {
    transition: none;
  }
}
