/* Each book on its own mat (the founder, 2026-11-12, round 8: "the book is the star, and it looks like a real book";
   "the mat is a surface, not a scene"). One standard for the homepage's two cards and the `?cover=1` views: this file
   draws them in the page (the homepage, the table book's still cover), and book-mats.mjs paints the same mats, in the
   same colours, as the 3D views' textures (book-mats.test.mjs holds the two to one palette).

   `.book-mat[data-mat]`: a quiet tactile surface in the book's palette, lit from top left, with the one grain tile
   (mats/grain.webp, scripts/books/render-mat-grain.mjs) laid on by soft-light and an inset shade at its edges. At most
   one small motif each: Lantern Night's navy felt has a gold stitched border and a warm glow behind the book, as if from
   its lantern; Understanding Energy's oxblood leather a gold tooled edge; Pip's Ribbon Route's navy felt one gold
   ribbon laid across a corner.

   `.real-book`: the cover image, unchanged, made a hardback: a spine and its hinge on the left, a page block of cream
   edges and hairline page lines on the right and bottom, a slight turn (rotateY -8deg, in perspective, so the page
   block faces the reader), a contact shadow, a long soft shadow to the right and a faint gloss. It lifts a little on
   hover; under reduced motion nothing moves. */

.book-mat {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 14px;
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  background-size: 100% 100%, 100% 100%, 128px 128px, 100% 100%;
  background-blend-mode: normal, normal, soft-light, normal;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .07),
    inset 0 0 0 1px rgb(0 0 0 / .25),
    inset 0 0 70px rgb(0 0 0 / .38),
    0 26px 46px -30px rgb(18 22 34 / .75);
}
.book-mat::after { content: ""; position: absolute; z-index: 0; pointer-events: none; }

/* Lantern Night: navy felt, a gold stitched border, a warm glow behind the book. */
.book-mat[data-mat="lantern-felt"] {
  background-color: #121b35;
  background-image:
    radial-gradient(ellipse 42% 58% at 50% 50%, rgb(255 190 105 / .3), transparent 100%),
    radial-gradient(ellipse 95% 85% at 16% 8%, rgb(150 175 230 / .2), transparent 100%),
    url("/primer/showcase/mats/grain.webp"),
    linear-gradient(160deg, #22325a, #121b35);
}
.book-mat[data-mat="lantern-felt"]::after {
  inset: 13px;
  border: 2px dashed #caa45e;
  border-radius: 9px;
  opacity: .72;
  filter: drop-shadow(0 1px 0 rgb(0 0 0 / .5));
}

/* Understanding Energy: oxblood leather, a gold tooled edge (a pressed rule and a finer one inside it). */
.book-mat[data-mat="energy-leather"] {
  background-color: #3f1510;
  background-image:
    radial-gradient(ellipse 46% 40% at 50% 104%, rgb(0 0 0 / .26), transparent 100%),
    radial-gradient(ellipse 95% 85% at 16% 8%, rgb(255 214 170 / .2), transparent 100%),
    url("/primer/showcase/mats/grain.webp"),
    linear-gradient(160deg, #6f2a22, #3f1510);
}
.book-mat[data-mat="energy-leather"]::after {
  inset: 12px;
  border: 1.5px solid #d2ad66;
  border-radius: 8px;
  outline: 1px solid rgb(210 173 102 / .5);
  outline-offset: -6px;
  opacity: .8;
  box-shadow: 0 1px 0 rgb(0 0 0 / .45), inset 0 1px 0 rgb(0 0 0 / .45);
}

/* Pip's Ribbon Route: navy felt, one gold satin ribbon laid across the top left corner (the older book lies right of
   the middle of its pad, so that corner stays clear). */
.book-mat[data-mat="ribbon-felt"] {
  background-color: #121b35;
  background-image:
    radial-gradient(ellipse 46% 40% at 50% 104%, rgb(0 0 0 / .22), transparent 100%),
    radial-gradient(ellipse 95% 85% at 16% 8%, rgb(150 175 230 / .2), transparent 100%),
    url("/primer/showcase/mats/grain.webp"),
    linear-gradient(160deg, #22325a, #121b35);
}
.book-mat[data-mat="ribbon-felt"]::after {
  top: 13%;
  left: -16%;
  width: 52%;
  height: 4.2%;
  min-height: 11px;
  transform: rotate(-38deg);
  background: linear-gradient(180deg, #e9c877, #c99b45 46%, #a87a2e 56%, #d9b462);
  box-shadow: 0 1px 0 rgb(255 240 200 / .35) inset, 0 7px 10px -5px rgb(0 0 0 / .6);
}

/* The hardback. The element holds the cover image; ::before is the spine and the gloss over it. Its turn and shadow are
   custom properties, so a page whose own rules on the same element are stronger can keep them (home.css). */
.real-book {
  --book-turn: perspective(1400px) rotateY(-8deg);
  --book-pages: 1px 1px 0 #efe6d2, 2px 2px 0 #cdbf9f, 3px 3px 0 #f3ebd8, 4px 3px 0 #d6c9ab, 5px 4px 0 #f1e8d4, 6px 5px 0 #b9a985;
  --book-shadow: var(--book-pages), 5px 9px 6px -1px rgb(0 0 0 / .42), 30px 34px 46px -14px rgb(0 0 0 / .52);
  position: relative;
  display: block;
  border-radius: 2px 6px 6px 2px;
  transform: var(--book-turn);
  transform-origin: 40% 50%;
  transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s cubic-bezier(.2, .7, .2, 1);
  box-shadow: var(--book-shadow);
}
.real-book img { display: block; border-radius: inherit; }
.real-book::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgb(0 0 0 / .4) 0, rgb(255 255 255 / .2) 1.4%, rgb(0 0 0 / .16) 3%, rgb(255 255 255 / .08) 4.6%, transparent 6.5%, rgb(0 0 0 / .2) 7.6%, rgb(255 255 255 / .12) 8.6%, transparent 10.5%),
    linear-gradient(118deg, rgb(255 255 255 / .17), rgb(255 255 255 / .05) 30%, transparent 46%, transparent 74%, rgb(255 255 255 / .06));
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .real-book:hover {
    --book-turn: perspective(1400px) rotateY(-6deg) translateY(-6px);
    --book-shadow: var(--book-pages), 6px 14px 10px -2px rgb(0 0 0 / .32), 36px 44px 54px -14px rgb(0 0 0 / .5);
  }
}
@media (prefers-reduced-motion: reduce) { .real-book { transition: none; } }
