/*
Theme Name: The Other Worlds Library
Description: The bookcase room: oak shelves, tapestry wall, and every book from the Books section.
Requires at least: 6.7
Tested up to: 6.9
Requires PHP: 7.4
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: other-worlds-library
Tags: full-site-editing, block-patterns, accessibility-ready
*/

:root {
  --wall: #2a1e18;
  --wall-2: #33251d;
  --wood: #8a5a36;
  --wood-light: #b07a4c;
  --wood-dark: #5b3920;
  --paper: #f6ecdc;
  --ink: #2b211b;
  --muted: #c9b59a;
  --glow: #f2c46d;
  --ribbon: #b23a3a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --row: 230px;
  --plank: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--paper);
  font-family: var(--serif);
  background-color: #1d3530;
  background-image:
    radial-gradient(ellipse at 50% 30%, transparent 30%, rgba(8, 14, 12, 0.75) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px),
    url("assets/textures/tapestry.svg");
  background-size: auto, auto, auto, 280px 280px;
  background-attachment: fixed, scroll, scroll, scroll;
  min-height: 100vh;
  overflow-x: clip;
}

.masthead { text-align: center; padding: 56px 20px 44px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.8); }
.eyebrow { letter-spacing: 0.25em; text-transform: uppercase; font-size: 0.75rem; color: var(--glow); margin: 0 0 8px; }
h1 { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 400; margin: 0; letter-spacing: 0.02em; }
.stats { color: var(--muted); font-style: italic; margin: 10px 0 0; }

/* The cabinet: a carved wooden frame around a darker back panel of vertical boards */
.case {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 26px 0;
  z-index: 2;
  background: url("assets/textures/wood-post.svg") 0 0 / 60px 900px;
  border-radius: 6px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 220, 170, 0.18),
    inset 0 3px 2px rgba(255, 230, 190, 0.25),
    inset 0 -4px 6px rgba(0, 0, 0, 0.5),
    0 40px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px #2a170b;
}
/* a crown moulding along the top */
.case::before {
  content: ""; position: absolute; left: -14px; right: -14px; top: -22px; height: 26px;
  background: url("assets/textures/wood-plank.svg") 0 0 / 900px 60px;
  border-radius: 4px 4px 2px 2px;
  box-shadow: inset 0 3px 2px rgba(255, 230, 190, 0.3), inset 0 -6px 6px rgba(0, 0, 0, 0.45), 0 8px 14px rgba(0, 0, 0, 0.5);
}
.case-inner {
  padding: 22px 22px 6px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.15) 40%, rgba(0, 0, 0, 0.45)),
    url("assets/textures/wood-back.svg") 0 0 / 140px 900px;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  border-radius: 2px;
}

.shelf-section + .shelf-section { margin-top: 34px; }
h2 { font-weight: 400; font-size: 1.35rem; margin: 0 0 6px 4px; color: var(--glow); }
.hint { font-size: 0.85rem; color: var(--muted); font-style: italic; margin-left: 10px; }

/* Every row of books stands on a wooden plank: rows are a fixed height, and the
   planks are drawn on a layer behind the books that is masked to the bottom of each row. */
.shelf {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  align-content: flex-start;
  padding: 0 8px;
  /* shadow each plank casts on the back panel below it */
  background: repeating-linear-gradient(to bottom,
    rgba(0, 0, 0, 0.55) 0, rgba(0, 0, 0, 0) 22px, transparent var(--row));
}
.shelf::before {
  content: ""; position: absolute; inset: 0 -22px; z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 calc(var(--row) - var(--plank)),
      rgba(255, 228, 185, 0.45) calc(var(--row) - var(--plank)) calc(var(--row) - var(--plank) + 2px),
      transparent calc(var(--row) - var(--plank) + 2px) calc(var(--row) - 4px),
      rgba(0, 0, 0, 0.45) calc(var(--row) - 4px) var(--row)),
    url("assets/textures/wood-plank.svg") 0 0 / 900px 60px;
  -webkit-mask: repeating-linear-gradient(to bottom, transparent 0 calc(var(--row) - var(--plank)), #000 calc(var(--row) - var(--plank)) var(--row));
  mask: repeating-linear-gradient(to bottom, transparent 0 calc(var(--row) - var(--plank)), #000 calc(var(--row) - var(--plank)) var(--row));
}
.shelf > * { position: relative; z-index: 1; }
.shelf > * { height: calc(var(--row) - var(--plank)); margin-bottom: var(--plank); display: flex; align-items: flex-end; }

:where(button.book) { all: unset; }
.book { cursor: pointer; position: relative; display: block; }
.book:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }

/* Spines */
.spine {
  margin: 0 1px;
  border-radius: 2px 2px 0 0;
  box-shadow: inset -3px 0 6px rgba(0, 0, 0, 0.35), inset 2px 0 3px rgba(255, 255, 255, 0.15);
  transition: transform 0.25s ease;
  transform-origin: bottom left;
  overflow: visible;
}
.spine::before, .spine::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(242, 196, 109, 0.55);
}
.spine::before { top: 14px; }
.spine::after { bottom: 14px; }
.spine-title {
  position: absolute; inset: 24px 0 26px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 11px; line-height: 1.1; text-align: center;
  overflow: hidden; color: rgba(255, 248, 235, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.spine:hover, .spine:focus-visible { transform: translateY(-6px) rotate(-5deg); z-index: 5; }
/* A spine's cover, popped out above the book you are pointing at. It is drawn in
   a fixed overlay (see library.js) so no shelf, wrapper or stacking order can
   clip it or hide it behind the books beside it. */
#owl-peek {
  position: fixed; left: 0; top: 0; width: 110px; height: 165px;
  object-fit: cover; border-radius: 2px; z-index: 2147483000;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -100%) scale(0.85);
  transform-origin: 50% 100%;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#owl-peek.is-on { opacity: 1; transform: translate(-50%, -100%) scale(1); }
/* Near the top of the window there is no room above, so it pops out below instead */
#owl-peek.is-below { transform: translate(-50%, 0) scale(0.85); transform-origin: 50% 0; }
#owl-peek.is-below.is-on { transform: translate(-50%, 0) scale(1); }

/* Face-out covers */
.face { margin: 0 8px; transition: transform 0.25s ease; }
.face:hover, .face:focus-visible { transform: translateY(-6px); }
.cover {
  display: block; width: 118px; height: 178px; object-fit: cover; border-radius: 2px 4px 4px 2px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55), inset 4px 0 6px rgba(0, 0, 0, 0.3);
}
.drawn-cover {
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  padding: 14px 10px; text-align: center; color: var(--paper); font-size: 13px;
  border: 1px solid rgba(242, 196, 109, 0.5); outline: 3px double rgba(242, 196, 109, 0.4); outline-offset: -8px;
}
.drawn-cover small { font-style: italic; opacity: 0.85; }

/* Currently reading: bigger, with a ribbon bookmark */
.current { --row: 300px; }
.current .shelf { justify-content: center; gap: 30px; }
.current .cover { width: 170px; height: 255px; }
.current .face::before {
  content: ""; position: absolute; top: -12px; right: 26px; width: 14px; height: 70px; z-index: 2;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Want to read: piles of books lying flat */
.want { --row: 210px; }
.piles { gap: 0 26px; }
.pile { display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; }
.pile > * { height: auto; }
.flat {
  height: 22px; margin-top: 1px; border-radius: 2px;
  box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.35), inset 0 2px 2px rgba(255, 255, 255, 0.15);
  font-size: 10.5px; line-height: 22px; padding: 0 8px; color: rgba(255, 248, 235, 0.92);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  transition: transform 0.2s ease;
}
.flat:hover, .flat:focus-visible { transform: translateX(14px); }

/* Book card */
dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border: none; border-radius: 6px; padding: 0;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(20, 12, 8, 0.7); backdrop-filter: blur(3px); }
.card-body { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 30px; }
.card-cover .cover { width: 220px; height: 330px; }
.card-series { margin: 0; font-style: italic; color: #8a6b4f; font-size: 0.9rem; }
dialog h3 { font-size: 1.8rem; font-weight: 400; margin: 2px 0 4px; line-height: 1.15; }
.card-author { margin: 0 0 12px; font-size: 1.05rem; }
.card-meta { margin: 0 0 16px; color: #6c5440; font-size: 0.95rem; }
.stars { color: #c08a2a; letter-spacing: 2px; font-size: 1.1rem; }
.card-desc { font-size: 0.98rem; line-height: 1.55; max-height: 260px; overflow: auto; white-space: pre-line; }
.card-desc.empty { font-style: italic; color: #8a6b4f; }
.card-link { display: inline-block; margin-top: 18px; color: var(--ribbon); font-weight: 600; text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.close {
  position: absolute; top: 8px; right: 12px; border: none; background: none;
  font-size: 2rem; line-height: 1; cursor: pointer; color: #6c5440;
}



@media (max-width: 640px) {
  :root { --row: 190px; }
  .case { padding: 12px; }
  .case-inner { padding: 14px 6px 4px; }
  .case::before { left: -6px; right: -6px; }
  .current { --row: 250px; }
  .current .cover { width: 130px; height: 195px; }
  .cover { width: 92px; height: 138px; }
  .face { margin: 0 4px; }
  .hint { display: block; margin: 2px 0 0; }
  .card-body { grid-template-columns: 1fr; padding: 22px; gap: 16px; }
  .card-cover { display: flex; justify-content: center; }
  .card-cover .cover { width: 150px; height: 225px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Five-star reads that stay spine-out get a small gold star near the top */
.spine.fav .spine-title { top: 34px; }
.spine.fav > .star {
  position: absolute; top: 18px; left: 0; right: 0; text-align: center;
  color: var(--glow); font-size: 11px; line-height: 1;
}
.spine.fav::before { top: 8px; }

.tagline { font-style: italic; font-size: clamp(1rem, 2.2vw, 1.2rem); color: var(--glow); margin: 12px 0 0; }

/* Decorations among the to-read piles */
.decor img { display: block; height: auto; max-height: calc(var(--row) - var(--plank) - 4px); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.55)); }
.decor.glow-candle img { filter: drop-shadow(0 0 14px rgba(255, 190, 90, 0.55)) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.5)); }
.decor.glow-fire img { filter: drop-shadow(0 0 12px rgba(255, 120, 40, 0.45)) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.5)); }
@media (max-width: 640px) { .decor img { transform: scale(0.85); transform-origin: bottom center; } }


/* The cabinet stands on a plinth with little feet */
.case-inner { margin-bottom: 0; }
.case > .plinth { display: none; }
.case::after {
  content: ""; position: absolute; left: -10px; right: -10px; bottom: -34px; height: 34px;
  background:
    linear-gradient(rgba(255, 230, 190, 0.25), transparent 4px, transparent 26px, rgba(0, 0, 0, 0.5)),
    url("assets/textures/wood-plank.svg") 0 0 / 900px 60px;
  border-radius: 2px;
  clip-path: polygon(0 0, 100% 0, 100% 70%, calc(100% - 26px) 70%, calc(100% - 26px) 100%, calc(100% - 60px) 100%, calc(100% - 60px) 70%, 60px 70%, 60px 100%, 26px 100%, 26px 70%, 0 70%);
}

/* The room: skirting board where the wall meets the floor, then oak floorboards in perspective */
.room-floor {
  position: relative; z-index: 1;
  margin-top: -60px;
  height: 320px;
  overflow: hidden;
  background: #2c1a0e;
}
.skirting {
  position: absolute; left: 0; right: 0; top: 0; height: 30px; z-index: 2;
  background:
    linear-gradient(rgba(255, 236, 200, 0.35), transparent 3px, transparent 8px, rgba(255, 236, 200, 0.15) 9px, transparent 11px, transparent 26px, rgba(0, 0, 0, 0.55)),
    url("assets/textures/wood-plank.svg") 0 -20px / 900px 60px;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.5);
}
/* the wrapper flattens the tilted floor so the rug can sit on top of it */
.floor-wrap { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.floor {
  position: absolute; top: 30px; left: -60%; right: -60%; height: 900px;
  z-index: 0;
  background: url("assets/textures/floor.svg") 0 0 / 360px 120px;
  transform: perspective(500px) rotateX(62deg);
  transform-origin: top center;
}
/* soft light pooling in front of the bookcase, and darkness towards the viewer's edges */
.floor::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 200, 130, 0.18), transparent 45%);
}
.room-floor::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    radial-gradient(ellipse 60% 40px at 50% 30px, rgba(0, 0, 0, 0.7), transparent),
    linear-gradient(90deg, rgba(0, 0, 0, 0.55), transparent 25%, transparent 75%, rgba(0, 0, 0, 0.55)),
    linear-gradient(transparent 60%, rgba(10, 5, 2, 0.6));
}
/* a big fluffy rectangular rug lying on the floor, so it takes the floor's perspective */
.rug {
  position: absolute; left: 50%; top: 16px; width: calc(min(1240px, 100vw) + 180px); height: 250px;
  transform: translateX(-50%);
  background: url("assets/textures/rug.svg") center / 100% 100% no-repeat;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.45));
}
.foot {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 18px;
  text-align: center; color: var(--paper); text-shadow: 0 1px 8px #000;
  font-size: 0.85rem; font-style: italic;
}
.foot p { margin: 0; }
/* The credit line, kept quiet enough to belong on the floor of the room */
.foot .credit {
  margin-top: 5px; font-size: 0.76rem; font-style: normal;
  letter-spacing: 0.05em; color: rgba(246, 236, 220, 0.6);
}
.foot .credit a {
  color: rgba(242, 196, 109, 0.9); text-decoration: none;
  border-bottom: 1px solid rgba(242, 196, 109, 0.35);
}
.foot .credit a:hover, .foot .credit a:focus-visible {
  color: #fff6e2; border-bottom-color: rgba(242, 196, 109, 0.85);
}
@media (max-width: 640px) {
  .room-floor { height: 240px; margin-top: -40px; }
  .rug { width: calc(100vw + 80px); height: 300px; top: 12px; }
  .case::after { left: -4px; right: -4px; }
}

/* A card for a book with no real cover: text only */
.card-body.no-cover { grid-template-columns: 1fr; }

/* forces the next books onto a new shelf (used to keep a series together) */
.shelf > .row-break { flex-basis: 100%; height: 0; margin: 0; }

/* items set onto shelves that had room: a little breathing space either side */
.shelf > .gap-decor { margin: 0 8px var(--plank); }

/* Shelf headings (Currently reading, Read, Want to read) as engraved brass plaques */
.shelf-section h2 {
  position: relative;
  display: inline-block;
  margin: 0 0 14px 4px;
  padding: 7px 22px 6px;
  font-size: 0.95rem; font-weight: 400; line-height: 1.2;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: #3b2a10;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
  background: linear-gradient(160deg, #f3d78f 0%, #c99a3e 35%, #e9c776 55%, #a97a28 80%, #d8b15e 100%);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 245, 210, 0.6), inset 0 0 0 3px rgba(120, 80, 20, 0.35),
    0 3px 6px rgba(0, 0, 0, 0.6);
}
/* little brass screws */
.shelf-section h2::before, .shelf-section h2::after {
  content: ""; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3cf, #8a6220);
}
.shelf-section h2::before { left: 7px; }
.shelf-section h2::after { right: 7px; }

/* =====================================================================
   WordPress housekeeping
   ===================================================================== */

/* The template's top-level sections carry a block gap; the room owns its own
   rhythm, so zero it. */
.wp-site-blocks > * + * { margin-block-start: 0; }
.wp-site-blocks { overflow-x: clip; }
.alignfull { max-width: none; }

/* Books are links; they must not look like links. */
a.book { text-decoration: none; color: inherit; }
a.book:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
.book.spine { display: block; }

.masthead h1 { font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: 0.02em; line-height: 1.05; font-weight: 400; margin: 0; }

/* A book with no cover keeps a plain spine: the title, and the author under it. */
.spine:has(.spine-author) .spine-title { inset: 20px 0 44%; }
.spine:has(.spine-author) .spine-author {
  position: absolute; inset: 58% 0 24px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 9.5px; line-height: 1.15; font-style: italic; text-align: center;
  color: rgba(255, 248, 235, 0.75); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.spine:has(.spine-author)::after { bottom: 6px; }
.spine:has(.spine-author).fav .spine-title { inset: 34px 0 44%; }

/* The book card --------------------------------------------------------- */
#card-title { font-size: 1.8rem; font-weight: 400; margin: 2px 0 4px; line-height: 1.15; letter-spacing: 0; }
.card-extra { display: block; margin-top: 3px; }
.card-desc { white-space: normal; }
.card-desc p { margin: 0 0 0.8em; }
.card-desc p:last-child { margin-bottom: 0; }
.card-desc img { max-width: 100%; height: auto; }
dialog { max-height: calc(100dvh - 40px); }
dialog .card-body { max-height: calc(100dvh - 100px); }
dialog .card-body { overflow: auto; }

/* =====================================================================
   One book's own page: the same paper card, standing in the room
   ===================================================================== */
.owl-single {
  min-height: 100dvh;
  padding: 44px 20px 80px;
  display: flex; justify-content: center; align-items: flex-start;
  box-sizing: border-box;
}
.owl-single-inner { width: min(760px, 100%); }
.owl-back {
  display: inline-block; margin: 0 0 16px 2px;
  color: var(--glow); font-style: italic; font-size: 0.9rem; text-decoration: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}
.owl-back:hover, .owl-back:focus-visible { text-decoration: underline; }
.book-sheet {
  display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 30px;
  background: var(--paper); color: var(--ink); border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.book-sheet.no-cover { grid-template-columns: 1fr; }
.book-sheet .card-cover .cover {
  display: block; width: 220px; height: 330px; object-fit: cover;
  border-radius: 2px 4px 4px 2px; box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
}
.book-sheet h1 { font-size: 1.9rem; font-weight: 400; margin: 2px 0 4px; line-height: 1.15; letter-spacing: 0; }
.book-sheet .card-desc { max-height: none; overflow: visible; }
.book-sheet .card-desc em { color: #8a6b4f; }

@media (max-width: 640px) {
  .owl-single { padding: 28px 12px 56px; }
  .book-sheet { grid-template-columns: 1fr; gap: 18px; padding: 22px; }
  .book-sheet .card-cover { display: flex; justify-content: center; }
  .book-sheet .card-cover .cover { width: 170px; height: 255px; }
  .book-sheet h1 { font-size: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
