/* Final public Archivum corrections.
   Loaded after library-ornate.css so physical binding/readability rules win. */

body .fr-reader-volume {
  --fr-book-page-edge: url("/Books/Texture%20(7).webp");
}

/* The Library title uses the same Fairy Realms display face as the main identity. */
body:has(.fr-archive-cabinet) h1 {
  font-family: "Cinzel Decorative", ui-serif, Georgia, serif !important;
  letter-spacing: .02em !important;
  font-weight: 700 !important;
}

/* Remove the artificial top paper strip completely. */
body .fr-archive-top-pages {
  display: none !important;
}

/* Shelf fore-edges are compressed old paper, not ruled notebook lines. */
body .fr-archive-page-block {
  right: -3px !important;
  top: 16px !important;
  bottom: 14px !important;
  width: 4px !important;
  border-radius: 0 3px 3px 0 !important;
  background-color: #806b4d !important;
  background-image:
    linear-gradient(90deg, rgba(59,39,23,.70), rgba(176,150,106,.24) 48%, rgba(65,43,25,.72)),
    var(--fr-book-page-edge) !important;
  background-size: 100% 100%, cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-blend-mode: multiply, normal !important;
  box-shadow:
    1px 1px 2px rgba(0,0,0,.46),
    inset -1px 0 1px rgba(45,29,16,.36) !important;
  opacity: .68 !important;
}

/* The leather board projects beyond the inset page block. */
body .fr-archive-volume::after {
  right: -6px !important;
  width: 2px !important;
  top: 7px !important;
  bottom: 7px !important;
  background-image:
    linear-gradient(rgba(20,8,5,.64), rgba(20,8,5,.64)),
    var(--fr-book-texture) !important;
  box-shadow: 1px 0 2px rgba(0,0,0,.48) !important;
}

/* Book I gets a warmer inset fore-edge without becoming a bright paper stripe. */
body .fr-archive-volume.is-available .fr-archive-page-block {
  background-color: #8b7351 !important;
  background-image:
    linear-gradient(90deg, rgba(67,43,25,.68), rgba(192,163,114,.28) 48%, rgba(70,45,27,.68)),
    var(--fr-book-page-edge) !important;
  opacity: .73 !important;
}

/* Book I has only head and tail raised bands; the centre is reserved for its seal. */
body .fr-archive-volume.is-available .fr-archive-band-b {
  display: none !important;
}

/* Give the shelf copy more physical curvature and a clearer leather shoulder. */
body .fr-archive-volume.is-available .fr-archive-spine {
  border-radius: 13px 5px 5px 13px !important;
  box-shadow:
    inset 18px 0 24px rgba(0,0,0,.52),
    inset -14px 0 20px rgba(0,0,0,.46),
    inset 8px 0 9px rgba(197,126,74,.10),
    inset 0 3px 4px rgba(255,232,190,.07),
    inset 0 -5px 7px rgba(0,0,0,.46),
    3px 3px 7px rgba(0,0,0,.34) !important;
}

/* The Book I seal is the visual centre of the spine and must remain completely legible. */
body .fr-archive-volume.is-available .fr-archive-sigil-mask {
  z-index: 9 !important;
  width: 80px !important;
  height: 80px !important;
  border-radius: 50% !important;
  background: radial-gradient(circle, rgba(22,10,6,.98) 0 58%, rgba(34,16,8,.82) 66%, transparent 74%) !important;
  filter: none !important;
}
body .fr-archive-volume.is-available .fr-archive-sigil-mask img {
  z-index: 10 !important;
  object-fit: contain !important;
  filter:
    brightness(1.08)
    saturate(1.04)
    drop-shadow(0 4px 7px rgba(0,0,0,.68)) !important;
}
body .fr-archive-volume.is-available .fr-archive-roman,
body .fr-archive-volume.is-available .fr-archive-title {
  text-shadow: 0 1px 3px rgba(0,0,0,.98) !important;
}

/* The final reading papers are quiet handmade sheets. */
body .fr-reader-left-page {
  background-color: #d7bb88 !important;
  background-image:
    linear-gradient(270deg, rgba(53,31,12,.23), transparent 11%),
    radial-gradient(ellipse at center, transparent 58%, rgba(105,61,22,.11) 100%),
    url("/Books/Page%201.webp") !important;
  background-size: 100% 100%, 100% 100%, cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-blend-mode: multiply, multiply, normal !important;
  box-shadow:
    inset 0 0 62px rgba(91,54,21,.14),
    inset 0 0 0 1px rgba(255,239,197,.08) !important;
}

body .fr-reader-right-page,
body .fr-reader-mobile-page {
  background-color: #d9bd8c !important;
  background-image:
    linear-gradient(90deg, rgba(53,31,12,.24), transparent 11%),
    radial-gradient(ellipse at center, transparent 59%, rgba(105,61,22,.10) 100%),
    url("/Books/Page%202.webp") !important;
  background-size: 100% 100%, 100% 100%, cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-blend-mode: multiply, multiply, normal !important;
  box-shadow:
    inset 0 0 62px rgba(91,54,21,.13),
    inset 0 0 0 1px rgba(255,239,197,.08) !important;
}

/* Manuscript plates are the illustrated leaf itself, not a picture pasted onto it. */
body .fr-reader-art {
  padding: .5% .55% 3.1% !important;
}
body .fr-reader-art img {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  mix-blend-mode: multiply !important;
  filter: contrast(1.015) saturate(.82) sepia(.05) !important;
  -webkit-mask-image: radial-gradient(ellipse 101% 99% at 50% 48%, #000 0 56%, rgba(0,0,0,.98) 64%, rgba(0,0,0,.78) 76%, rgba(0,0,0,.42) 87%, rgba(0,0,0,.12) 95%, transparent 100%) !important;
  mask-image: radial-gradient(ellipse 101% 99% at 50% 48%, #000 0 56%, rgba(0,0,0,.98) 64%, rgba(0,0,0,.78) 76%, rgba(0,0,0,.42) 87%, rgba(0,0,0,.12) 95%, transparent 100%) !important;
}
body .fr-reader-art figcaption {
  background: transparent !important;
  border: 0 !important;
  padding-top: 2px !important;
}

/* The closed book is one coherent object. Its page block is plain aged paper. */
body .fr-reader-back-cover::after {
  background:
    linear-gradient(90deg, rgba(69,45,26,.68), rgba(185,156,108,.70) 46%, rgba(75,49,28,.70)),
    var(--fr-book-page-edge) !important;
  background-size: 100% 100%, cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-blend-mode: multiply, normal !important;
}

/* Opening sequence: never expand the back cover into a second red spread.
   It stays behind the closed book, fades as the leather front cover swings away,
   and the already-built paper spread is what is revealed. */
body .fr-reader-volume.is-open .fr-reader-back-cover {
  left: 50% !important;
  right: auto !important;
  width: 50% !important;
  opacity: 0 !important;
  border-color: rgba(82,48,27,.68) !important;
  box-shadow: none !important;
  transition: opacity .12s linear .10s !important;
}
body .fr-reader-volume.is-open .fr-reader-back-cover::after {
  opacity: 0 !important;
  box-shadow: none !important;
}

/* Keep the opening cover itself leather and clear; no residual gilt panel remains. */
body .fr-reader-front-cover,
body .fr-reader-cover-face {
  backface-visibility: hidden !important;
}
body .fr-reader-volume.is-open .fr-reader-front-cover {
  pointer-events: none !important;
}

/* Dynamic viewport units stop mobile browser chrome from eating the physical book or controls. */
body .fr-reader-volume {
  height: min(89vh, 960px) !important;
  height: min(89dvh, 960px) !important;
}
body .fr-reader-controls {
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 8px)) !important;
}
body .fr-reader-contents {
  top: max(12px, calc(env(safe-area-inset-top) + 8px)) !important;
  max-height: calc(100vh - 92px) !important;
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px) !important;
}

@media (max-width: 767px) {
  body .fr-reader-volume {
    width: min(92vw, calc(100vw - 20px)) !important;
    height: 82vh !important;
    height: min(82dvh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 54px)) !important;
  }

  body .fr-reader-volume.is-open .fr-reader-back-cover {
    left: 0 !important;
    right: auto !important;
    width: 100% !important;
  }

  body .fr-reader-art {
    padding: .8% .8% 4.2% !important;
  }

  body .fr-reader-controls {
    bottom: max(10px, calc(env(safe-area-inset-bottom) + 8px)) !important;
  }

  body .fr-reader-contents {
    left: 50% !important;
    right: auto !important;
    width: min(92vw, 420px) !important;
    transform: translateX(-50%) !important;
  }
}

@media (max-width: 640px) {
  /* Five physical volumes must stay inside the cabinet even on a 320-360px phone. */
  body .fr-archive-books {
    gap: 2px !important;
  }
  body .fr-archive-slot {
    width: 18.35% !important;
  }

  body .fr-archive-page-block {
    right: -2px !important;
    width: 3px !important;
    top: 12px !important;
    bottom: 10px !important;
  }

  body .fr-archive-volume::after {
    right: -4px !important;
    width: 2px !important;
  }

  /* Keep the seal inside the physically narrower phone-sized spine. */
  body .fr-archive-volume.is-available .fr-archive-sigil-mask {
    width: 39px !important;
    height: 39px !important;
  }
}

@media (max-height: 520px) and (max-width: 960px) {
  body .fr-reader-volume {
    height: 76vh !important;
    height: min(76dvh, calc(100dvh - 58px)) !important;
  }

  body .fr-reader-controls button {
    min-width: 38px !important;
    height: 38px !important;
  }
}