/* "Read your own guide" button: a small book that OPENS, gives a little KNOCK upward, then a PAGE FLIPS (owner 2026-10-29).
   Same approach as the footer YouTube launch (fsoc): transform + opacity only, gentle ease-out curves, one long cycle with a calm rest.
   Names: docs/WEBSITE_NAMES.md section 28 (prefix gbook). Script: assets/js/guide-book.js (plays only while the button is on screen).
   Without the script, or with reduced motion, the book is simply open and still. */
.btn--gbook { gap: 10px; }
.gbook {
  --gbook-ink: var(--on-gold);
  --gbook-page: #fff6dc;
  --gbook-line: rgb(122 90 51 / 0.6);
  --gbook-cycle: 6.4s;
  flex: none; width: 30px; height: 22.5px; overflow: visible;
  transition: transform 0.2s ease-out;
}
.btn--gbook:hover .gbook, .btn--gbook:focus-visible .gbook { transform: translateY(-1px) scale(1.08); transition-duration: 0.12s; }
[dir="rtl"] .gbook { scale: -1 1; } /* the book opens toward the reading side: the right in English, the left in Arabic */
.gbook * { transform-box: view-box; transform-origin: 16px 12px; }
.gbook__page { fill: var(--gbook-page); stroke: var(--gbook-ink); stroke-width: 1.5; stroke-linejoin: round; }
.gbook__ln { fill: none; stroke: var(--gbook-line); stroke-width: 1.1; stroke-linecap: round; }
.gbook__spine { fill: none; stroke: var(--gbook-ink); stroke-width: 1.7; stroke-linecap: round; }
.gbook__flip { opacity: 0; }

/* the cycle: closed 0-6%, OPEN 6-20%, KNOCK 26-37%, PAGE FLIP 46-60%, rest, close 92-99% */
.gbook-on .gbook__slide { animation: gbook-slide var(--gbook-cycle) infinite both; }
.gbook-on .gbook__knock { animation: gbook-knock var(--gbook-cycle) infinite both; }
.gbook-on .gbook__left { animation: gbook-open var(--gbook-cycle) infinite both; }
.gbook-on .gbook__flip { animation: gbook-flip var(--gbook-cycle) infinite both; }

@keyframes gbook-slide { /* the closed book sits centred; opening slides it so the spine is centred */
  0%, 6% { transform: translateX(-6px); animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
  20%, 92% { transform: translateX(0); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  99%, 100% { transform: translateX(-6px); }
}
@keyframes gbook-open { /* the left cover and page swing open about the spine */
  0%, 6% { transform: scaleX(0); animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
  20%, 92% { transform: scaleX(1); animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1); }
  99%, 100% { transform: scaleX(0); }
}
@keyframes gbook-knock { /* a small bump upward and a settle */
  0%, 25% { transform: translateY(0) rotate(0); animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
  30% { transform: translateY(-3.4px) rotate(-3deg); animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.4); }
  34% { transform: translateY(0.7px) rotate(0.8deg); animation-timing-function: ease-out; }
  37%, 100% { transform: translateY(0) rotate(0); }
}
@keyframes gbook-flip { /* a right page turns over onto the left, and goes with the cover when the book closes */
  0%, 45.9% { opacity: 0; transform: scaleX(1) skewY(0); }
  46% { opacity: 1; transform: scaleX(1) skewY(0); animation-timing-function: cubic-bezier(0.45, 0.05, 0.3, 1); }
  53% { transform: scaleX(0.05) skewY(-7deg); animation-timing-function: cubic-bezier(0.3, 0.1, 0.4, 1); }
  60%, 92% { opacity: 1; transform: scaleX(-1) skewY(0); }
  99% { opacity: 1; transform: scaleX(0) skewY(0); }
  99.5%, 100% { opacity: 0; transform: scaleX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .gbook__slide, .gbook__knock, .gbook__left, .gbook__flip { animation: none !important; }
  .gbook { transition: none; }
}
