/* Title-strip texture for the Books page: its own picture, separately for dark and light mode.
   Tune it in mgb-tune on that page ("Hero dark texture", "Hero light texture"); Publish saves here.
   Starts as a copy of the site default in tokens.css (section 3).
   Picture paths are from assets/css/, not from this folder: browsers read them from styles.css, which uses them. */
:root {
  --tex-hero-dark: url("pages/img/tune/tex-books.webp");
  --tex-hero-dark-strength: 0.15;
  --tex-hero-dark-blend: screen;
  --tex-hero-dark-size: 1400px auto;
  --tex-hero-dark-size-phone: max(100vw, 604px) auto;
  --tex-hero-dark-x: 0px;
  --tex-hero-dark-y: -60px;
  --tex-hero-dark-x-phone: 0vw;
  --tex-hero-dark-y-phone: -4.286vw;
  --tex-hero-dark-size-wide: var(--tex-hero-dark-size);
  --tex-hero-dark-x-wide: calc(0px + max(0px, 50vw - 700px));
  --tex-hero-dark-y-wide: var(--tex-hero-dark-y);
  --tex-hero-dark-repeat-wide: repeat-y;
  --tex-hero-dark-mask-wide: linear-gradient(90deg, transparent max(0px, 50% - 700px), black calc(max(0px, 50% - 700px) + min(280px, max(0px, 100vw - 1400px))), black calc(100% - max(0px, 50% - 700px) - min(280px, max(0px, 100vw - 1400px))), transparent calc(100% - max(0px, 50% - 700px)));
  --tex-hero-dark-keys-wide: "fade";

  --tex-hero-light: url("pages/img/tune/tex-books.webp");
  --tex-hero-light-strength: 0.16;
  --tex-hero-light-blend: darken;
  --tex-hero-light-size: 1400px auto;
  --tex-hero-light-size-phone: max(100vw, 604px) auto;
  --tex-hero-light-x: 0px;
  --tex-hero-light-y: -60px;
  --tex-hero-light-x-phone: 0vw;
  --tex-hero-light-y-phone: -4.286vw;
  --tex-hero-light-size-wide: var(--tex-hero-light-size);
  --tex-hero-light-x-wide: calc(0px + max(0px, 50vw - 700px));
  --tex-hero-light-y-wide: var(--tex-hero-light-y);
  --tex-hero-light-repeat-wide: repeat-y;
  --tex-hero-light-mask-wide: linear-gradient(90deg, transparent max(0px, 50% - 700px), black calc(max(0px, 50% - 700px) + min(280px, max(0px, 100vw - 1400px))), black calc(100% - max(0px, 50% - 700px) - min(280px, max(0px, 100vw - 1400px))), transparent calc(100% - max(0px, 50% - 700px)));
  --tex-hero-light-keys-wide: "fade";
}

/* ---------- What I'm Writing: the novel as a beat-up leather field journal (Nov 2026) ----------
   Picked from mockups (a plain 3D book, cards with pages fanned around them, and this). The cover is drawn in CSS:
   leather from palette colors, /assets/images/leather-wear.webp (scratches, stains, rubbed edges; made by
   design-assets/book-journal/make_leather_wear.py) blended over it, foil and stitching worn away in specks.
   The loose pages are the book's own pictures cut out along their torn edges (*-cut.webp, made by
   design-assets/book-journal/make_page_cutouts.py). Hovering a picture page (tapping on a phone) shows a bigger copy
   beside the book; the script for that is at the bottom of books.html. The stats line is written by
   scripts/build-book.mjs each time the book is published. Paths here are full paths (/assets/...), so they work
   from this folder. */
.bk-row { display: grid; grid-template-columns: auto 1fr; gap: clamp(1.4rem, 4vw, 3rem); align-items: center; }
.bk-info { display: grid; gap: .5rem; color: inherit; text-decoration: none; min-width: 0; }
.bk-info:hover .feature__title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .15em; }
/* the progress line */
.bk-progress { display: grid; gap: .45rem; margin: .5rem 0 .3rem; max-width: 34rem; }
.bk-stats { font: 400 .95rem/1.3 var(--font-accent); letter-spacing: .02em; color: var(--ink); }
.bk-stats b { font-weight: 700; color: var(--title); }
.bk-bar { display: block; height: 10px; background: var(--rule); position: relative; overflow: hidden; }
.bk-bar i { position: absolute; inset: 0 auto 0 0; background: var(--flare); }
.bk-bar::after {   /* quarter marks */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--paper-bg) calc(25% - 1px) 25%);
}
.bk-goal { font-size: .85rem; color: var(--soft); }

/* ---------- D: a beat-up leather field journal, a stack of loose pages sliding out of it ---------- */
.fj {
  --leather: color-mix(in oklab, color-mix(in oklab, var(--book-soft) 68%, var(--accent-800)) 62%, var(--color-deep));
  --leather-lite: color-mix(in oklab, var(--leather) 70%, var(--book-paper-edge));
  --leather-dark: color-mix(in oklab, var(--leather) 55%, var(--color-deep));
  --foil: var(--book-rule);
  --speckle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 2.6 0 0 0 -.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  position: relative; width: clamp(160px, 22vw, 220px); aspect-ratio: 2 / 3; margin: 20px 150px 40px 10px;
  transform: perspective(900px) rotateY(-13deg) rotateZ(-1.5deg); transform-origin: left center; transition: transform .4s ease;
}
.fj:hover, .fj:focus-within { transform: perspective(900px) rotateY(-5deg) rotateZ(-.8deg) translateY(-3px); }
.fj::after {   /* the page block, old paper seen from the side */
  content: ""; position: absolute; top: 2%; bottom: 2.5%; right: -11px; width: 12px; z-index: 12;
  background: repeating-linear-gradient(180deg, var(--book-paper) 0 2px, var(--book-paper-edge) 2px 3px);
  transform: skewY(-6deg); transform-origin: left; border-radius: 0 3px 3px 0; filter: sepia(.25) brightness(.92);
}
/* the cover */
.fj-cover {
  position: absolute; inset: 0; z-index: 20; display: grid; grid-template-rows: auto auto 1fr auto; justify-items: center; align-items: center;
  padding: 16% 12% 13% 15%; overflow: hidden; text-decoration: none;
  border-radius: 3px 11px 8px 2px / 2px 9px 13px 4px;   /* uneven, like a cover that has been bent */
  background: radial-gradient(ellipse 80% 60% at 55% 40%, var(--leather), var(--leather-dark) 100%);
  box-shadow: inset 0 0 0 1px var(--leather-dark), inset 0 0 24px 8px color-mix(in oklab, var(--color-deep) 55%, transparent),
              12px 16px 26px color-mix(in oklab, var(--color-deep) 60%, transparent);
}
.fj-wear {   /* scratches, a water ring, creases, rubbed edges (leather-wear.webp, gray = no change) */
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: url("/assets/images/leather-wear.webp") center / 100% 100%; mix-blend-mode: overlay; opacity: .95;
}
.fj-cover::before {   /* fine pebbled grain */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 -.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
.fj-cover::after {    /* the spine fold, scuffed */
  content: ""; position: absolute; inset: 0 auto 0 0; width: 11%; pointer-events: none; z-index: 1;
  background: linear-gradient(90deg, var(--leather-dark), color-mix(in oklab, var(--leather-lite) 45%, transparent) 60%, transparent);
}
.fj-stitch { position: absolute; inset: 5% 5% 5% 13%; z-index: 1; border: 1px dashed color-mix(in oklab, color-mix(in oklab, var(--foil) 35%, var(--leather-dark)) 70%, transparent);
  border-radius: 2px 8px 6px 2px; pointer-events: none;
  -webkit-mask-image: var(--speckle); mask-image: var(--speckle); }   /* some stitches worn away */
.fj-series, .fj-no, .fj-by, .fj-title { position: relative; z-index: 2; }
.fj-series, .fj-no, .fj-by { color: var(--foil);
  text-shadow: 0 1px 0 color-mix(in oklab, var(--color-deep) 60%, transparent), 0 -1px 0 color-mix(in oklab, var(--book-paper) 15%, transparent);
  -webkit-mask-image: var(--speckle); mask-image: var(--speckle); }   /* the foil half rubbed off */
.fj-series { font: 700 clamp(.74rem, 2.1vw, .92rem)/1 var(--font-heading); letter-spacing: .28em; padding-left: .28em; }
.fj-no { margin-top: .5em; font: 400 .6rem/1 var(--font-accent); letter-spacing: .3em; opacity: .8; }
.fj-by { font: 700 .82rem/1 var(--font-heading); letter-spacing: .28em; padding-left: .28em; }
.fj-by::before { content: ""; display: block; height: 2px; width: 120%; margin: 0 0 .7rem -10%; background: var(--flare); opacity: .8; }
.fj-title { width: 116%; max-width: none; height: auto; mix-blend-mode: screen; opacity: .92;   /* black drops out: splintered wood on leather */
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, black 60%, transparent 100%);
          mask-image: radial-gradient(ellipse 60% 55% at 50% 50%, black 60%, transparent 100%); }

/* the loose sheets: a staggered stack sliding out of the open side, each a little lower and further out */
.fj-sheet {
  position: absolute; z-index: 0; display: block; width: 84%; aspect-ratio: 16 / 9;
  top: calc(7% + var(--i) * 9.6% + var(--dy, 0px)); left: calc(30% + var(--i) * 5.2% + var(--dx, 0px));
  transform: rotate(var(--r)); transform-origin: left center;
  filter: drop-shadow(0 2px 3px color-mix(in oklab, var(--color-deep) 45%, transparent));
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.fj-paper { display: block; width: 100%; height: 100%; }
.fj-paper--pic img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: left center; filter: sepia(.12); }   /* their own torn edges */
.fj-paper--blank {   /* plain old paper with a soft, uneven edge (a wavy mask, not a cut) */
  background: repeating-linear-gradient(180deg, transparent 0 15px, color-mix(in oklab, var(--book-soft) 18%, transparent) 15px 16px),
              var(--book-paper) var(--tex-oldpaper) center / 300px auto;
  background-blend-mode: normal, multiply; filter: sepia(.3) brightness(.95);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 56' preserveAspectRatio='none'%3E%3Cpath d='M0 1 C25 0 50 2 75 .6 S96 1.4 97.5 .8 C98.6 8 96.8 15 98.2 22 S99.3 34 97.6 41 S98.8 52 97.9 55.2 C70 56 40 55 0 55.6Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 56' preserveAspectRatio='none'%3E%3Cpath d='M0 1 C25 0 50 2 75 .6 S96 1.4 97.5 .8 C98.6 8 96.8 15 98.2 22 S99.3 34 97.6 41 S98.8 52 97.9 55.2 C70 56 40 55 0 55.6Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.fj-sheet:nth-child(4n+3) .fj-paper--blank {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 56' preserveAspectRatio='none'%3E%3Cpath d='M0 .4 C30 1.4 60 0 98.4 1.2 C97.2 10 99 18 97.8 27 S98.4 40 99 46 S97.4 53 98.6 55.4 C60 55 30 56 0 55Z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 56' preserveAspectRatio='none'%3E%3Cpath d='M0 .4 C30 1.4 60 0 98.4 1.2 C97.2 10 99 18 97.8 27 S98.4 40 99 46 S97.4 53 98.6 55.4 C60 55 30 56 0 55Z'/%3E%3C/svg%3E");
}
/* on hover the stack loosens: the sheets slide a little further out */
.fj:hover .fj-sheet, .fj:focus-within .fj-sheet { transform: translateX(calc(8px + var(--i) * 5px)) rotate(var(--r)); }
a.fj-sheet { z-index: 6; }   /* the picture pages lie on top; the plain sheets show as paper edges between them */
a.fj-sheet:hover, a.fj-sheet:focus-visible { transform: translateX(calc(22px + var(--i) * 5px)) rotate(calc(var(--r) * .3)); }

/* the preview: a bigger copy of the page beside the book (about a quarter of the screen) */
.fj-peek {
  position: fixed; z-index: 70; width: clamp(280px, 34vw, 600px); pointer-events: auto; cursor: zoom-in;
  filter: drop-shadow(0 18px 30px color-mix(in oklab, var(--color-deep) 60%, transparent));
  transform: rotate(-1deg) scale(.88); opacity: 0; transition: opacity .18s, transform .22s cubic-bezier(.2, .8, .2, 1);
}
.fj-peek.is-open { opacity: 1; transform: rotate(-1deg) scale(1); }
.fj-peek img { display: block; width: 100%; height: auto; }
.fj-peek[hidden] { display: block; visibility: hidden; }

@media (max-width: 640px) {
  .bk-row { grid-template-columns: 1fr; justify-items: center; }
  .fj { width: 150px; margin: 10px 120px 40px 0; }
  .fj-peek { width: 88vw; }
  .fj-series { font-size: .66rem; letter-spacing: .2em; padding-left: .2em; }
  .fj-by { font-size: .74rem; letter-spacing: .22em; }
}
