/* ============================================================================
   refine.css — 21 September 2026

   Refinements layered over style.css. Loaded after it, so every rule here is
   an override rather than a replacement. No markup was changed to make these
   work: each effect is built from the elements the pages already render
   (.book / .bk-face / .bk-top / .bk-edge, .gfig / .gfig-frame, .step-face),
   which is why all 176 book spines and all 51 teacher figures pick it up
   without touching a single page of content.

   Three things it does:
     1. Binds every book as an ancient manuscript — leather boards, palm-leaf
        head and tail, two cords drawn round and tied.
     2. Makes the golu padi grander, with a carved symbol frieze on each riser.
     3. Styles the download gate that states a file's true size before it
        starts transferring.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. THE BOOKS — bound as the tradition binds them
   --------------------------------------------------------------------------- */

/* The spine becomes tooled leather rather than flat cloth. The two gradients
   sit *under* the existing sheen from style.css: a fine 74° grain, and a
   broad darkening toward the fore-edge so the spine reads as curved. 74° is
   deliberate — at 88° the grain beat against the pixel grid and produced a
   visible plaid. */
.bk-face {
  background-image:
    repeating-linear-gradient(74deg,
      rgba(255, 248, 234, 0.035) 0 2px,
      rgba(0, 0, 0, 0.055) 2px 5px),
    linear-gradient(100deg,
      rgba(255, 255, 255, 0.24) 0%,
      rgba(255, 255, 255, 0.05) 26%,
      rgba(0, 0, 0, 0.34) 72%,
      rgba(0, 0, 0, 0.5) 100%);
  /* Room at head and tail for the leaf blocks and the cords. Tightened from
     an earlier 46/52: at that figure five of the 176 spines clipped their
     titles by 6-15px, the worst being Aparokṣānubhūti. */
  padding: 40px 3px 44px;
  gap: 0.45rem;
}

/* Larger, and with enough shadow to hold against a pale plaque. */
.bk-face b {
  font-size: 1.24rem;
  line-height: 1.08;
  letter-spacing: 0.005em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 1px rgba(0, 0, 0, 0.6);
}
.bk-face em {
  font-size: 0.95rem;
  line-height: 1.08;
  color: rgba(255, 248, 234, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* The head and tail leaf blocks. style.css used these two pseudo-elements as
   thin gilt rules; here they become stacked palm-leaf edges capped top and
   bottom by a gilt line — the same striping style.css already uses on the
   .bk-top and .bk-edge faces, so the three agree. */
.bk-face::before,
.bk-face::after {
  left: 5%;
  right: 5%;
  height: 16px;
  background:
    repeating-linear-gradient(90deg,
      #f0e4ca 0 2px,
      #cdbb96 2px 4px);
  border-top: 1px solid rgba(240, 205, 138, 0.9);
  border-bottom: 1px solid rgba(240, 205, 138, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  border-radius: 1px;
}
.bk-face::before { top: 7px; }
.bk-face::after  { bottom: 7px; }

/* The two cords, drawn round the bundle and tied. Each pseudo-element is a
   30px band carrying two backgrounds: a 12px leather cord repeated across,
   and the photographed knot centred on it. The knot is a real photograph
   rather than a drawn shape, which is what stops this reading as clip-art. */
.book::before,
.book::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  height: 30px;
  z-index: 4;
  pointer-events: none;
  transform: translateZ(1px);
  background-image:
    url("../img/wood/cord-knot.webp"),
    linear-gradient(180deg,
      #3f2712 0%,
      #8a5a2c 26%,
      #c08b48 50%,
      #7a4e26 74%,
      #2e1c0d 100%);
  background-size: auto 32px, 100% 11px;
  background-position: center center, center center;
  background-repeat: no-repeat, repeat-x;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}
.book::before { top: 21px; }
.book::after  { bottom: 25px; }

/* A shelf holding only three or four volumes left a wide empty run of teak.
   Centring the row reads as a shelf that is deliberately not crowded, rather
   than one that is missing its books. Shelves that already fill are unaffected. */
.shelf-books { justify-content: center; }

/* With the row centred, style.css's 12px bookend sliver no longer sits against
   the last volume — it floated detached in the middle of the shelf. */
.shelf-books::after { display: none; }

/* Set by bookfit.js on any spine whose title would otherwise clip. The custom
   property carries the fitted size, so the cascade stays in one place. */
.bk-face b[style*="--fit"] { font-size: var(--fit); }

/* ---------------------------------------------------------------------------
   2. THE GOLU PADI — grander, and carrying the tradition's own symbols
   --------------------------------------------------------------------------- */

/* Each riser gains a carved symbol frieze. The strip is cropped to 4.48:1 so
   its figures stay legible when it repeats; the earlier full-height frieze
   tiled six times and turned to mush at this scale. */
.step-face::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  height: clamp(16px, 2.1vw, 26px);
  background: url("../img/wood/symbol-strip.webp") center/auto 100% repeat-x;
  opacity: 0.62;
  mix-blend-mode: soft-light;
  pointer-events: none;
  border-radius: 2px;
}

/* A deeper, warmer step face, so the padi reads as draped rather than boxed. */
.step-face {
  box-shadow:
    inset 0 1px 0 rgba(246, 236, 216, 0.16),
    inset 0 -10px 18px rgba(0, 0, 0, 0.38),
    0 10px 22px rgba(0, 0, 0, 0.34);
}

/* The carved frame gains an inner gilt containment line, so each figure sits
   in a niche rather than floating in a rectangle. */
.gfig-frame::after {
  content: "";
  position: absolute;
  inset: 11.5%;
  border: 1px solid rgba(240, 205, 138, 0.42);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}

/* Names and dates grow slightly, and stop orphaning "CE" onto its own line. */
.gfig b {
  font-size: 1.24rem;
  text-wrap: balance;
}
.gfig i {
  font-size: 0.9rem;
  text-wrap: balance;
}

/* Rows of figures match plate heights so a step reads as one shelf. */
.step-figs { align-items: stretch; }

/* ---------------------------------------------------------------------------
   3. THE DOWNLOAD GATE — the size, stated before the transfer starts
   --------------------------------------------------------------------------- */

.dlgate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
}
.dlgate[aria-hidden="false"] { opacity: 1; pointer-events: auto; }

.dlgate__scrim {
  position: absolute;
  inset: 0;
  background: var(--veil, rgba(10, 13, 24, 0.72));
  backdrop-filter: blur(5px);
}

.dlgate__panel {
  position: relative;
  z-index: 1;
  width: min(30rem, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--space-6);
  border: 1px solid rgba(229, 181, 92, 0.42);
  border-radius: 14px;
  background-image:
    linear-gradient(180deg, rgba(229, 181, 92, 0.12), rgba(10, 13, 24, 0.72)),
    var(--teak-img);
  background-size: auto, cover;
  background-position: center;
  background-blend-mode: normal, multiply;
  box-shadow: var(--shadow-lg, 0 24px 64px rgba(0, 0, 0, 0.55));
}

.dlgate__kicker {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
}
.dlgate__panel h2 {
  margin: 0.3rem 0 0.2rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--cream);
}
.dlgate__pub {
  margin: 0 0 var(--space-5);
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.dlgate__facts {
  margin: 0 0 var(--space-5);
  border-top: 1px solid rgba(229, 181, 92, 0.22);
}
.dlgate__fact {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(229, 181, 92, 0.14);
}
.dlgate__fact dt {
  font-size: 0.88rem;
  color: var(--color-text-muted);
}
.dlgate__fact dd {
  margin: 0;
  text-align: right;
  font-size: 0.95rem;
  color: var(--cream);
}
.dlgate__fact dd small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.dlgate__note {
  margin: 0 0 var(--space-5);
  padding: var(--space-4);
  border: 1px solid rgba(229, 181, 92, 0.26);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  font-size: 0.88rem;
  line-height: 1.6;
  color: #e2d0ad;
}

.dlgate__acts { display: grid; gap: 0.6rem; }
.dlgate__go,
.dlgate__no {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.98rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 180ms var(--ease-out);
}
.dlgate__go {
  border: 1px solid transparent;
  background: linear-gradient(180deg, #f4d693, #d2a349);
  color: #2a1708;
  font-weight: 600;
}
.dlgate__go:hover { background: linear-gradient(180deg, #ffe4ab, #dfb257); }
.dlgate__no {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
}
.dlgate__no:hover { border-color: var(--brass); color: var(--cream); }

/* The size, shown on the trigger itself so it is known before the click. */
.dl-size {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid rgba(229, 181, 92, 0.45);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--brass);
  white-space: nowrap;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
   4. SMALL SCREENS
   --------------------------------------------------------------------------- */

@media (max-width: 640px) {
  /* Spines are narrower on a phone, so the binding scales with them. */
  .bk-face { padding: 38px 2px 42px; }
  .bk-face b { font-size: 1.1rem; }
  .bk-face em { font-size: 0.86rem; }
  .bk-face::before, .bk-face::after { height: 13px; }
  .book::before { top: 20px; }
  .book::after { bottom: 24px; }
  .book::before, .book::after {
    height: 24px;
    background-size: auto 21px, 100% 9px;
  }
  .gfig b { font-size: 1.1rem; }
  .dlgate__panel { padding: var(--space-5); }
}

@media (prefers-reduced-motion: reduce) {
  .dlgate { transition: none; }
}
