/* Fairy Realms Archivum stability skin.
   Materials add surface detail, but colour, seal visibility and manuscript readability win. */

/* ---------- Archivum cabinet: dark walnut, never gold ---------- */
body .fr-archive-cabinet {
  background-image:
    linear-gradient(rgba(24, 12, 7, .82), rgba(24, 12, 7, .82)),
    var(--fr-archive-walnut) !important;
  background-size: 100% 100%, 720px 720px !important;
  background-blend-mode: multiply, normal !important;
  border-color: rgba(104, 67, 38, .72) !important;
  box-shadow:
    0 46px 105px rgba(0,0,0,.74),
    inset 0 0 0 8px rgba(42,22,12,.60),
    inset 0 0 92px rgba(0,0,0,.70) !important;
}

body .fr-archive-cabinet::before,
body .fr-archive-cabinet::after,
body .fr-archive-crown::before,
body .fr-archive-cabinet-base,
body .fr-archive-shelf-board,
body .fr-archive-shelf-edge {
  background-image:
    linear-gradient(rgba(28, 14, 8, .76), rgba(28, 14, 8, .76)),
    var(--fr-archive-walnut) !important;
  background-blend-mode: multiply, normal !important;
}

body .fr-archive-cabinet-inner,
body .fr-archive-cavity {
  background-image:
    linear-gradient(rgba(8, 5, 3, .72), rgba(8, 5, 3,.72)),
    var(--fr-archive-dark-wood) !important;
  background-blend-mode: multiply, normal !important;
}

/* Master Seal stays fully visible. Gilt is an accent ring, not the material body. */
body .fr-archive-master-medallion {
  width: 82px !important;
  height: 82px !important;
  background: radial-gradient(circle, #25160f 0 58%, #120a06 72%, #080503 100%) !important;
  border: 1px solid rgba(210, 166, 74, .58) !important;
  box-shadow:
    0 0 0 3px rgba(48, 27, 14, .82),
    0 8px 22px rgba(0,0,0,.58),
    inset 0 0 0 1px rgba(235, 194, 103, .12) !important;
}

body .fr-archive-master-mask {
  width: 72px !important;
  height: 72px !important;
  overflow: visible !important;
  background: transparent !important;
  box-shadow: none !important;
}
body .fr-archive-master-mask img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border-radius: 50% !important;
  filter: drop-shadow(0 3px 7px rgba(0,0,0,.50));
}

/* ---------- Shelf volumes ---------- */
body .fr-archive-volume.is-held {
  filter: brightness(.60) saturate(.68) drop-shadow(8px 12px 9px rgba(0,0,0,.78)) !important;
}

/* Book I is controlled brown leather. The real texture is only a faint grain layer. */
body .fr-archive-volume.is-available .fr-archive-spine {
  background: linear-gradient(90deg, #150805 0%, #3d1b10 18%, #5b2d1c 46%, #35170f 73%, #120704 100%) !important;
  border: 1px solid rgba(112, 67, 35, .46) !important;
  box-shadow:
    inset 18px 0 24px rgba(0,0,0,.48),
    inset -16px 0 22px rgba(0,0,0,.46),
    inset 0 3px 4px rgba(255,232,190,.06),
    inset 0 -5px 7px rgba(0,0,0,.44) !important;
}
body .fr-archive-volume.is-available .fr-archive-spine-light {
  background-image: var(--fr-book-texture) !important;
  background-size: 280px 280px !important;
  background-position: center !important;
  opacity: .16 !important;
  mix-blend-mode: soft-light !important;
}
body .fr-archive-volume.is-available .fr-archive-band {
  background: linear-gradient(180deg, rgba(132,76,44,.74), rgba(44,19,11,.96) 62%, rgba(18,7,4,.98)) !important;
  border-top-color: rgba(216,174,105,.16) !important;
}

/* Page blocks sit inside the binding instead of wrapping the books in a white outline. */
body .fr-archive-page-block {
  right: -5px !important;
  top: 15px !important;
  bottom: 13px !important;
  width: 8px !important;
  border-radius: 0 3px 3px 0 !important;
  background: repeating-linear-gradient(0deg, #9d825d 0 2px, #765d3d 2px 3px) !important;
  box-shadow: 3px 2px 5px rgba(0,0,0,.44), inset -1px 0 1px rgba(67,42,22,.22) !important;
  opacity: .72 !important;
}
/* The old top-page strip is intentionally suppressed. The page block belongs inside the boards. */
body .fr-archive-top-pages {
  display: none !important;
}
/* A fine leather board edge beyond the fore-edge makes the pages read as inset. */
body .fr-archive-volume::after {
  content: "";
  position: absolute;
  z-index: 4;
  top: 6px;
  right: -8px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #241109;
  box-shadow: 1px 0 2px rgba(0,0,0,.48);
  pointer-events: none;
}
body .fr-archive-volume.is-available .fr-archive-page-block {
  background: repeating-linear-gradient(0deg, #a38860 0 2px, #765c3e 2px 3px) !important;
}
/* Once Book I leaves the shelf, every physical edge leaves with it. */
body .fr-archive-volume.is-removed::after,
body .fr-archive-volume.is-removed .fr-archive-page-block,
body .fr-archive-volume.is-removed .fr-archive-book-shadow {
  opacity: 0 !important;
  box-shadow: none !important;
}
/* Keep keyboard focus visible on the physical book, never around the empty shelf slot. */
body .fr-archive-slot-active:focus,
body .fr-archive-slot-active:focus-visible {
  outline: none !important;
}
body .fr-archive-slot-active:focus-visible .fr-archive-volume:not(.is-removed) {
  filter:
    brightness(1.10)
    saturate(1.02)
    drop-shadow(12px 18px 11px rgba(0,0,0,.72))
    drop-shadow(0 0 8px rgba(221,177,81,.62)) !important;
}

/* Book I seal sits above the leather ridges rather than underneath them. */
body .fr-archive-sigil-mask {
  z-index: 7 !important;
  width: 76px !important;
  height: 76px !important;
  overflow: visible !important;
  border: 0 !important;
  background: radial-gradient(circle, rgba(25,12,7,.94) 0 65%, rgba(25,12,7,0) 72%) !important;
  box-shadow: none !important;
}
body .fr-archive-sigil-mask img {
  position: relative;
  z-index: 2;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  border-radius: 50% !important;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.56));
}
body .fr-archive-roman,
body .fr-archive-title,
body .fr-archive-gilt-rule {
  z-index: 7 !important;
}
body .fr-archive-roman,
body .fr-archive-title {
  color: #d8ba76 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.96) !important;
}
body .fr-archive-gilt-rule {
  background: linear-gradient(90deg, transparent, #89682e 18%, #b79752 50%, #89682e 82%, transparent) !important;
  box-shadow: none !important;
}

/* ---------- Book I reader: aged tea-stained parchment ---------- */
body .fr-reader-page,
body .fr-reader-left-page,
body .fr-reader-right-page {
  color: #2c2117 !important;
  background-color: #d8b67d !important;
  background-image:
    radial-gradient(ellipse at 8% 8%, rgba(112,67,25,.24), transparent 26%),
    radial-gradient(ellipse at 94% 92%, rgba(103,58,21,.20), transparent 31%),
    radial-gradient(circle at 68% 24%, rgba(255,238,192,.16), transparent 35%),
    repeating-linear-gradient(0deg, rgba(85,51,24,.018) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #dfc48f 0%, #d8b77d 48%, #d2ac72 100%) !important;
  background-size: 100% 100% !important;
  background-blend-mode: multiply, multiply, screen, normal, normal !important;
  border-color: rgba(83,52,25,.38) !important;
  box-shadow:
    inset 0 0 76px rgba(91,54,21,.20),
    inset 0 0 0 1px rgba(255,239,197,.10) !important;
}
body .fr-reader-left-page {
  background-image:
    linear-gradient(270deg, rgba(55,33,13,.24), transparent 11%),
    radial-gradient(ellipse at 7% 10%, rgba(112,67,25,.22), transparent 26%),
    radial-gradient(ellipse at 90% 91%, rgba(96,55,22,.15), transparent 30%),
    repeating-linear-gradient(0deg, rgba(85,51,24,.018) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #dfc48f 0%, #d8b77d 48%, #d2ac72 100%) !important;
}
body .fr-reader-right-page {
  background-image:
    linear-gradient(90deg, rgba(55,33,13,.25), transparent 11%),
    radial-gradient(ellipse at 93% 9%, rgba(112,67,25,.20), transparent 27%),
    radial-gradient(ellipse at 9% 90%, rgba(96,55,22,.14), transparent 31%),
    repeating-linear-gradient(0deg, rgba(85,51,24,.018) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #dfc48f 0%, #d8b77d 48%, #d2ac72 100%) !important;
}
body .fr-reader-left-page::after {
  background: linear-gradient(90deg, transparent, rgba(42,27,11,.30)) !important;
}
body .fr-reader-right-page::before {
  background: linear-gradient(90deg, rgba(42,27,11,.31), transparent) !important;
}

/* Force manuscript contrast regardless of paper ageing. */
body .fr-reader-copy,
body .fr-reader-title,
body .fr-reader-art,
body .fr-reader-paragraphs,
body .fr-reader-paragraphs p,
body .fr-reader-emphasis,
body .fr-reader-chapter h2,
body .fr-reader-chapter > div {
  color: #2b2116 !important;
  text-shadow: none !important;
}
body .fr-reader-paragraphs {
  font-weight: 400 !important;
}
body .fr-reader-chapter > div,
body .fr-reader-page-number,
body .fr-reader-kicker,
body .fr-reader-book-number {
  color: #72562f !important;
}
body .fr-reader-title p,
body .fr-reader-art figcaption {
  color: #60492d !important;
}

/* Closed/opening Book I is unambiguously brown leather, never green. */
body .fr-reader-back-cover {
  border: 1px solid rgba(121,74,39,.58) !important;
  background: linear-gradient(135deg, #4f2718 0%, #30150e 53%, #170906 100%) !important;
  box-shadow:
    0 38px 54px rgba(0,0,0,.66),
    inset 0 0 0 1px rgba(204,157,78,.16),
    inset 0 0 46px rgba(0,0,0,.38) !important;
}
body .fr-reader-back-cover::after {
  content: "";
  position: absolute;
  top: 11px;
  right: -6px;
  bottom: 11px;
  width: 7px;
  border-radius: 0 4px 4px 0;
  background: repeating-linear-gradient(0deg, #a48a62 0 2px, #795f40 2px 3px) !important;
  box-shadow: 2px 0 4px rgba(0,0,0,.35);
  pointer-events: none;
}
body .fr-reader-cover-face {
  border: 1px solid rgba(178,119,49,.50) !important;
  background-image:
    repeating-linear-gradient(107deg, rgba(255,255,255,.018) 0 1px, transparent 1px 6px),
    radial-gradient(circle at 22% 15%, rgba(176,115,66,.14), transparent 34%),
    linear-gradient(135deg, #572b1a 0%, #36180f 53%, #180a06 100%) !important;
  background-blend-mode: soft-light, normal, normal !important;
  box-shadow:
    inset 18px 0 30px rgba(0,0,0,.46),
    inset 0 0 0 1px rgba(225,181,91,.19),
    inset 0 0 52px rgba(0,0,0,.44) !important;
}
body .fr-reader-cover-rule {
  border-color: rgba(206,158,65,.60) !important;
}
body .fr-reader-cover-rule.outer {
  border-width: 2px !important;
}
body .fr-reader-cover-rule.inner {
  border-color: rgba(206,158,65,.30) !important;
}
body .fr-reader-cover-sigil {
  overflow: visible !important;
  border: 1px solid rgba(211,164,70,.55) !important;
  background: #24120c !important;
  box-shadow:
    0 0 0 4px rgba(57,31,17,.46),
    0 7px 18px rgba(0,0,0,.36) !important;
}
body .fr-reader-cover-sigil img,
body .fr-reader-round-sigil img,
body .fr-reader-chapter span img {
  object-fit: contain !important;
}
body .fr-reader-cover-kicker,
body .fr-reader-cover-title {
  color: #e4c474 !important;
  text-shadow: 0 1px 2px rgba(20,8,4,.96) !important;
}
body .fr-reader-cover-number,
body .fr-reader-cover-subtitle {
  color: #b99553 !important;
}

/* ---------- Physical front-cover opening ----------
   Closed: one centred book. Open: the cover is hinged on the spread's centre spine. */
body .fr-reader-volume:not(.is-open) {
  transform: translateX(-25%) translateY(-18px) scale(.82) !important;
}
body .fr-reader-volume.is-open {
  transform: translateX(0) translateY(0) scale(1) !important;
}
body .fr-reader-front-cover {
  left: 50% !important;
  width: 50% !important;
  transform-origin: left center !important;
  backface-visibility: hidden !important;
  filter: drop-shadow(11px 18px 18px rgba(0,0,0,.54)) !important;
}
/* Before the hinge opens, the rear board occupies the same centred closed-book footprint. */
body .fr-reader-volume:not(.is-open) .fr-reader-back-cover {
  left: 50% !important;
  right: auto !important;
  width: 50% !important;
}
body .fr-reader-volume.is-open .fr-reader-back-cover {
  left: -14px !important;
  right: -14px !important;
  width: auto !important;
}
/* Give the turning cover a subdued inside face instead of exposing a flat colour slab. */
body .fr-reader-front-cover::after {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border-radius: 13px;
  background: linear-gradient(135deg, #6d5037 0%, #967b57 48%, #695039 100%);
  box-shadow: inset 12px 0 22px rgba(37,21,11,.30), inset 0 0 0 1px rgba(80,54,28,.25);
  transform: rotateY(180deg);
  backface-visibility: hidden;
}

body .fr-reader-art img {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  mix-blend-mode: multiply !important;
  filter: contrast(.99) saturate(.90) sepia(.06) !important;
}

@media (max-width: 767px) {
  body .fr-archive-master-medallion { width: 66px !important; height: 66px !important; }
  body .fr-archive-master-mask { width: 58px !important; height: 58px !important; }
  body .fr-archive-sigil-mask { width: 43px !important; height: 43px !important; }
  body .fr-archive-page-block { right: -3px !important; width: 6px !important; top: 11px !important; bottom: 10px !important; }
  body .fr-archive-volume::after { right: -5px; width: 2px; }
  body .fr-reader-back-cover::after { right: -4px; width: 6px; }

  /* Mobile is a one-page reader, so keep the cover full-page rather than half a desktop spread. */
  body .fr-reader-volume:not(.is-open) { transform: translateX(0) translateY(-18px) scale(.82) !important; }
  body .fr-reader-front-cover { left: 0 !important; width: 100% !important; transform-origin: left center !important; }
  body .fr-reader-volume:not(.is-open) .fr-reader-back-cover { left: 0 !important; width: 100% !important; }
  body .fr-reader-volume.is-open .fr-reader-back-cover { left: -8px !important; right: -8px !important; width: auto !important; }
}

@media (prefers-reduced-motion: reduce) {
  body .fr-reader-front-cover,
  body .fr-reader-spread,
  body .fr-reader-volume,
  body .fr-archive-volume {
    animation: none !important;
    transition: none !important;
  }
}
