/* bookshelf: spines on wooden shelves (bookshelf.js). The app positions the shelf's root
   and sets these to fit its look (each has a default):

   on the shelf (.shelf-books, or anything above it):
     --shelf-wood        the shelves' background: wood under each row of spines
     --shelf-row         a row's height: a spine and the shelf under it (238px)
   on each spine (.spine: the app's dress() can set them per book):
     --spine-cover       the spine's own background, under the light and shadow
     --spine-ink         the label and bands
     --spine-ink-shadow  the label's text-shadow
     --spine-font        the label's font
     --spine-focus       the ring around a spine with the keyboard's focus
   A shelf's name (several shelves): .shelf-name, with --shelf-name-ink and --shelf-name-font. */

.shelf-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  justify-content: center;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}
.shelf-books {
  --row: var(--shelf-row, 238px);       /* a spine (220) and the shelf under it (18) */
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-end;
  width: min(100%, 980px);
  min-height: var(--row);
  padding: 0 18px;
  background: var(--shelf-wood,
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--row) - 18px),
      var(--shelf-c1, #6b4526) calc(var(--row) - 18px), var(--shelf-c2, #8a5c34) calc(var(--row) - 16px),
      var(--shelf-c3, #5a3a20) calc(var(--row) - 6px), var(--shelf-c4, #2d1c0f) var(--row)));
  border-radius: 2px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}
.spine {
  position: relative;
  height: calc(var(--row) - 34px);
  margin: 16px 2px 18px 0;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: none;
  border-radius: 4px 4px 2px 2px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(255, 230, 190, 0.1) 30%, rgba(255, 230, 190, 0.06) 55%, rgba(0, 0, 0, 0.5)),
    var(--spine-cover, #5b2c1d);
  box-shadow: 2px 0 3px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 220, 160, 0.06);
  cursor: pointer;
  transition: transform 0.2s;
}
.spine:hover, .spine:focus-visible { transform: translateY(-6px); outline: none; }
.spine:focus-visible { box-shadow: 0 0 0 2px var(--spine-focus, #d8b25a), 2px 0 3px rgba(0, 0, 0, 0.45); }
.spine-band {
  flex: none;
  width: 70%;
  height: 7px;
  border-top: 1.5px solid var(--spine-ink, #d8b25a);
  border-bottom: 1.5px solid var(--spine-ink, #d8b25a);
  opacity: 0.85;
}
.spine-label {
  min-height: 0;
  overflow: hidden;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font: var(--spine-font, 400 19px/1 Georgia, serif);
  font-variant-numeric: lining-nums;
  letter-spacing: 0.12em;
  color: var(--spine-ink, #d8b25a);
  text-shadow: var(--spine-ink-shadow, none);
}

/* Several shelves: each with its name above it. */
.shelf-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: min(100%, 980px);
}
.shelf-group { width: 100%; display: flex; flex-direction: column; align-items: center; }
.shelf-group .shelf-books { width: 100%; }
.shelf-name {
  align-self: flex-start;
  margin: 0 0 4px 18px;
  font: var(--shelf-name-font, 400 20px/1.2 Georgia, serif);
  letter-spacing: 0.04em;
  color: var(--shelf-name-ink, #e9dcc3);
}
.shelf-empty { align-items: center; justify-content: center; }

/* The room (0.2.0): Bookshelf.room(element, { wall, color, shelf }) sets data-bs-wall and
   data-bs-shelf on the element the shelf stands in, and --bs-wall-color. Without them,
   nothing here applies: the app's own background and the default wood (Grimoire's look). */
[data-bs-wall] { background-color: var(--bs-wall-color, #3a2d22); }
[data-bs-wall="plaster"] {
  background-image: radial-gradient(ellipse at 50% 25%, rgba(255, 240, 220, 0.10), transparent 65%),
    radial-gradient(circle at 20% 80%, rgba(0, 0, 0, 0.18), transparent 50%),
    repeating-radial-gradient(circle at 37% 61%, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 5px);
}
[data-bs-wall="wallpaper"] {
  background-image: radial-gradient(ellipse at 50% 20%, rgba(255, 240, 220, 0.10), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 26px, transparent 26px 34px, rgba(0, 0, 0, 0.10) 34px 38px, transparent 38px 64px);
}
[data-bs-wall="brick"] {
  background-image: radial-gradient(ellipse at 50% 20%, rgba(255, 220, 190, 0.10), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='36'%3E%3Cg fill='none' stroke='rgba(0,0,0,0.45)' stroke-width='3'%3E%3Cpath d='M0 1.5H72M0 19.5H72M1.5 0V18M37.5 18V36'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, 72px 36px;
}
[data-bs-wall="paneling"] {
  background-image: radial-gradient(ellipse at 50% 20%, rgba(255, 230, 190, 0.12), transparent 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 2px, rgba(255, 220, 170, 0.05) 2px 4px, transparent 4px 96px),
    repeating-linear-gradient(90deg, rgba(120, 70, 30, 0.25) 0 30px, rgba(90, 50, 20, 0.15) 30px 64px, rgba(130, 80, 40, 0.2) 64px 96px);
}
[data-bs-wall="painted"] {
  background-image: radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.08), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.35), transparent 60%);
}
[data-bs-shelf="oak"] { --shelf-c1: #9a6a39; --shelf-c2: #b9874e; --shelf-c3: #80582d; --shelf-c4: #3f2a14; }
[data-bs-shelf="walnut"] { --shelf-c1: #4d301c; --shelf-c2: #66412a; --shelf-c3: #3b2415; --shelf-c4: #1a0f08; }
[data-bs-shelf="white"] { --shelf-c1: #e4ded2; --shelf-c2: #f6f2ea; --shelf-c3: #cdc5b6; --shelf-c4: #7c7468; }
[data-bs-shelf="metal"] { --shelf-c1: #34343a; --shelf-c2: #5a5a62; --shelf-c3: #26262b; --shelf-c4: #0d0d0f; }
[data-bs-shelf="glass"] { --shelf-c1: rgba(190, 225, 235, 0.35); --shelf-c2: rgba(255, 255, 255, 0.6);
  --shelf-c3: rgba(150, 195, 210, 0.3); --shelf-c4: rgba(0, 0, 0, 0.45); }
.shelf-empty-note { margin: 0 0 30px; color: var(--shelf-name-ink, #e9dcc3); opacity: 0.7; font-style: italic; }
