@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=Caveat:wght@400;600&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&display=swap');

/*
  bookshelf.css
  ─────────────────────────────────────────────
  All selectors are prefixed with .bs- to avoid
  colliding with your existing site styles.
*/

/* ── PAGE WRAPPER ── */

.bs-page {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 24px 20px 40px;
}


/* ── LAYOUT ── */

.bs-wrap {
  display: flex;
  align-items: flex-start; /* required for sticky sidebar */
  width: 100%;
  max-height: 88vh;
  overflow: hidden;        /* clip so inner cols scroll */

  /* sit above the CRT scanline overlay (body::before z-index:9999) */
  position: relative;
  z-index: 10000;
}

/* ── SHELF COLUMN ── */

.bs-shelves-col {
  flex: 1;
  min-width: 0;
  padding-top: 10px;
  overflow-y: auto;
  max-height: 88vh;        /* must match .bs-wrap so overflow-y activates */

  /* pale wood background with subtle grain lines */
  background-color: #d4b896;
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.03) 0px, transparent 1px,
      transparent 18px, rgba(0,0,0,0.02) 18px,
      transparent 19px, transparent 38px
    ),
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.06) 0px, transparent 1px,
      transparent 12px, rgba(0,0,0,0.02) 12px,
      transparent 13px
    );
}

/* ── SHELF INTRO TEXT ── */

.bs-header-intro {
  font-family: 'Caveat', cursive;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.3px;
}

.bs-header-intro em {
  font-style: normal;
  color: rgba(255, 255, 255, 0.65);
}

/* ── HEADER SHELF (full-width title ledge) ── */

.bs-header-shelf {
  width: 100%;
  background: #7a4e28;
  border-top: 3px solid #a06830;
  border-bottom: 4px solid #5a3410;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.bs-header-shelf::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
}

/* ── GENRE LEDGE (sits below each row of books) ── */

.bs-ledge {
  width: 100%;
  background: #7a4e28;
  border-top: 3px solid #a06830;
  border-bottom: 4px solid #5a3410;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.bs-ledge::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.bs-ledge-count {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.3);
}

/* ── APOTHECARY DRAWER LABEL ── */

.bs-drawer-label {
  background: #f5f0e8;
  border: 2px solid #c8a030;
  outline: 1px solid #8a1010;
  outline-offset: -3px;
  padding: 2px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #111;
  white-space: nowrap;
  text-transform: uppercase;
}

.bs-drawer-label--title {
  font-size: 13px;
  padding: 3px 16px;
}

/* ── BOOK ROW ── */

.bs-shelf-books {
  display: flex;
  align-items: flex-end;
  padding: 8px 12px 0;
  gap: 4px;
  /* no overflow — books are pre-packed to fit */
}

/* ── INDIVIDUAL BOOK SPINE ── */

.bs-book {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 3px 3px 1px 1px;
  overflow: hidden;
  padding: 5px 0;
  transform: rotate(var(--tilt, 0deg));
  transform-origin: bottom center;
  transition: transform 0.13s ease;
}

.bs-book:hover {
  transform: rotate(var(--tilt, 0deg)) translateY(-9px);
}

.bs-book.is-selected {
  transform: rotate(var(--tilt, 0deg)) translateY(-13px);
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: -1px;
}

/* ── FLAT STACK ── */

.bs-stack {
  display: flex;
  flex-direction: column;
  align-self: flex-end;
  flex-shrink: 0;
  gap: 1px;
  cursor: pointer;
}

.bs-stack-book {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
  border-radius: 2px;
  transition: opacity 0.12s ease;
}

.bs-stack-book:hover {
  opacity: 0.78;
}

.bs-stack-book.is-selected {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: -1px;
}

.bs-stack-book__band {
  width: 4px;
  flex-shrink: 0;
  opacity: 0.85;
}

.bs-stack-book__label {
  font-family: 'Inter', sans-serif;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 0 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  opacity: 0.85;
}

.bs-book__band {
  width: 100%;
  flex-shrink: 0;
}

.bs-book__title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 3px 0;
  text-align: center;
  line-height: 1.15;
  flex: 1;
}

/* ── SIDEBAR ── */

.bs-sidebar {
  width: 45%;
  flex-shrink: 0;

  /* sticky: stays in view while shelves scroll */
  position: sticky;
  top: 0;
  align-self: flex-start;

  /* explicit height so both book states always fill the panel */
  height: 88vh;
  max-height: 88vh;
}

/* ── CLOSED BOOK (default / no selection) ── */

.bs-closed-book {
  display: flex;
  height: 100%;
  box-shadow: -6px 0 18px rgba(0, 0, 0, 0.45);
}

.bs-closed-book__spine {
  width: 26px;
  flex-shrink: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent        0px,
      transparent        34px,
      rgba(255,255,255,0.07) 34px,
      rgba(255,255,255,0.07) 36px
    ),
    linear-gradient(
      to right,
      #0c0702 0%,
      #221208 45%,
      #2e1a0a 60%,
      #180c04 100%
    );
}

.bs-closed-book__cover {
  flex: 1;
  background-color: #1c1005;
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px,
      transparent 1px, transparent 4px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px,
      transparent 1px, transparent 4px
    );
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  position: relative;
}

/* double decorative frame — classic hardcover embossing */
.bs-closed-book__cover::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(200, 155, 70, 0.18);
  pointer-events: none;
}

.bs-closed-book__cover::after {
  content: '';
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(200, 155, 70, 0.09);
  pointer-events: none;
}

.bs-closed-book__cover-inner {
  position: relative;
  z-index: 1;
  text-align: center;
}

.bs-closed-book__ornament {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 28px;
  color: rgba(200, 155, 70, 0.2);
  line-height: 1;
  margin-bottom: 14px;
}

.bs-closed-book__prompt {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 12px;
  color: rgba(200, 155, 70, 0.22);
  line-height: 2;
  letter-spacing: 0.3px;
}

.bs-closed-book__pages {
  width: 14px;
  flex-shrink: 0;
  /* dense alternating lines = stacked page edges */
  background: repeating-linear-gradient(
    0deg,
    #eae2c8 0px, #eae2c8 1px,
    #c8bea0 1px, #c8bea0 2px
  );
  box-shadow: inset -4px 0 8px rgba(0, 0, 0, 0.28);
}

/* ── OPEN / CLOSED VISIBILITY TOGGLE ── */

/* Default: closed visible, open hidden */
.bs-sidebar .bs-closed-book { display: flex; }
.bs-sidebar .bs-open-book   { display: none; }

/* When a book is selected */
.bs-sidebar.is-open .bs-closed-book { display: none; }
.bs-sidebar.is-open .bs-open-book   { display: flex; }

/* Open book wrapper */
.bs-open-book {
  height: 100%;
  overflow: hidden;
  box-shadow: -6px 0 18px rgba(0, 0, 0, 0.45);
}

/* ── PAGES ── */

.bs-open-book__page {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 22px 16px 28px;
  /* fill full height of the open book */
  align-self: stretch;
}

.bs-open-book__page--left {
  background-color: #f0e8d2;
  /* SVG fractalNoise grain tiled over the page */
  background-image:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='250' height='250'><filter id='pl'><feTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='250' height='250' filter='url(%23pl)' opacity='0.1'/></svg>");
  background-size: 250px 250px;
  /* faint shadow curving into the gutter */
  box-shadow: inset -12px 0 20px rgba(0, 0, 0, 0.07);
}

.bs-open-book__page--right {
  background-color: #f5eedc;
  background-image:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='250' height='250'><filter id='pr'><feTurbulence type='fractalNoise' baseFrequency='0.68' numOctaves='4' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='250' height='250' filter='url(%23pr)' opacity='0.09'/></svg>");
  background-size: 250px 250px;
  box-shadow: inset 12px 0 20px rgba(0, 0, 0, 0.05);
}

/* ── SPINE GUTTER ── */

.bs-open-book__gutter {
  width: 2px;
  flex-shrink: 0;
  align-self: stretch;
  background: linear-gradient(
    to right,
    #a08050 0%,
    #c8a870 25%,
    #e0c898 50%,
    #c8a870 75%,
    #a08050 100%
  );
  box-shadow:
    inset -3px 0 8px rgba(0, 0, 0, 0.18),
    inset  3px 0 8px rgba(0, 0, 0, 0.18);
}

/* ── EMPTY STATE ── */

.bs-left-ornament {
  text-align: center;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 32px;
  color: rgba(80, 50, 20, 0.18);
  padding-top: 40px;
  line-height: 1;
}

.bs-left-ornament--empty {
  color: rgba(80, 50, 20, 0.14);
}

.bs-empty-text {
  font-family: 'Caveat', cursive;
  font-size: 13px;
  color: rgba(60, 40, 15, 0.28);
  line-height: 1.9;
  text-align: center;
  padding-top: 30px;
}

/* ── LEFT PAGE: TITLE AREA ── */

.bs-left-ornament {
  text-align: center;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 28px;
  color: rgba(80, 50, 20, 0.35);
  margin-bottom: 18px;
  line-height: 1;
}

.bs-left__rule {
  border: none;
  border-top: 1px solid rgba(80, 50, 20, 0.18);
  margin: 0 20px 14px;
}

.bs-left__title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: var(--text-xl);
  font-style: italic;
  color: #2a1808;
  line-height: 1.35;
  text-align: center;
  margin-bottom: 6px;
}

.bs-left__author {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-lg);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #7a5a30;
  text-align: center;
  margin-bottom: 18px;
}

.bs-left__swatch {
  width: 32px;
  height: 3px;
  border-radius: 2px;
  margin: 0 auto 14px;
}

.bs-left__genre {
  display: block;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid;
  width: fit-content;
  margin: 0 auto;
  border-radius: 1px;
}

/* ── RIGHT PAGE: REVIEW & DATES ── */

.bs-review__body {
  font-family: 'Caveat', cursive;
  font-size: var(--text-base);
  color: #3a2510;
  line-height: 1.85;
  margin-bottom: 14px;
}

.bs-review__body em {
  font-style: italic;
  color: #2a4a1a;
}

.bs-review__divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 10px 0;
}

/* ── DATE FIELDS ── */

.bs-dates {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bs-date-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bs-date-label {
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(50, 30, 10, 0.4);
}

.bs-date-value {
  font-family: 'Caveat', cursive;
  font-size: 15px;
  color: #3a2510;
  letter-spacing: 0.5px;
}

.bs-date-value--unread {
  font-size: 13px;
  color: rgba(50, 30, 10, 0.3);
  font-style: italic;
}
