/* Reference-aligned live bookshelf. Artwork contains scenery only; all books,
   labels and controls remain live DOM elements connected to the existing app. */
#app-container { background: #fff0de; align-items: center; }
.shelf-header { width: 100%; max-width: 1440px; min-height: 68px; padding: 10px 1.7%; gap: 12px; background: #dff4ff url('../assets/images/library-scenery.png') center top / 100% auto; border: 0; box-shadow: none; backdrop-filter: none; }
.header-left, .header-right { gap: 10px; }
.header-nav-capsule { padding: 5px 7px; gap: 0; background: #f1fbffdc; border: 1px solid #fff9; box-shadow: 0 3px 5px #6490ba3d; }
.nav-capsule-btn { color: #6933ad; padding: 8px 15px; font-size: 13px; }
.nav-capsule-btn.active { color: #6025ba; background: #e6dfff; box-shadow: none; }
.btn-come-alive-header { background: linear-gradient(#ffe9a3, #ffc85e); border: 1px solid #ffc66b; padding: 8px 18px; box-shadow: 0 2px 3px #ad6b3260, inset 0 1px 2px #fff; }
.come-alive-text { letter-spacing: 0; color: #8d3e0c; }
.header-btn { color: #6d2a9e; background: #fff9ef; width: 42px; height: 42px; box-shadow: 0 3px 4px #6e58622b; }
.user-avatar-badge { width: 42px; height: 42px; background: linear-gradient(#9e82ff, #4534ed); }
.btn-auth-header { color: #205473; background: #f4fbffdb; min-height: 40px; padding: 7px 14px; }
.bookshelf-outer { padding: 0; min-height: 0; height: auto; flex: 1; }
.bookshelf-frame { container-type: inline-size; max-width: 1440px; border-radius: 0; box-shadow: none; overflow: hidden; background: transparent; }
.bookshelf-viewport { padding: 0; flex: 1; min-height: 0; }
.shelf-pillar-left, .shelf-pillar-right, .bookshelf-bottom-spacer { display: none; }
.shelf-unit { --scene-y: 344; --scene-height: 254; --book-w: 11.07cqw; --book-h: 14.7cqw; height: calc(var(--scene-height) * 100cqw / 1156); min-height: 0; margin: 0; background: url('../assets/images/library-scenery.png') center calc(var(--scene-y) * -100cqw / 1156) / 100cqw auto no-repeat; filter: saturate(1.18); }
.shelf-unit[data-shelf-id='continue_reading'] { --scene-y: 68; --scene-height: 276; --book-h: 15.05cqw; }
.shelf-unit[data-shelf-id='classic_tales'] { --scene-y: 344; --scene-height: 254; }
.shelf-unit[data-shelf-id='christmas'] { --scene-y: 598; --scene-height: 249; --book-w: 11.6cqw; --book-h: 15.3cqw; }
.shelf-unit[data-shelf-id='activities'] { --scene-y: 847; --scene-height: 258; --book-h: 15.3cqw; }
.shelf-unit[data-shelf-id='bedtime_magic'] { --scene-y: 1105; --scene-height: 256; }
.shelf-backdrop, .shelf-leaves-top-left, .shelf-moon-left, .shelf-wood-ledge { display: none; }
.shelf-category-plaque { top: 0; height: 4.25cqw; min-height: 0; padding: 0 2.3cqw; gap: 1.45cqw; font-size: 1.8cqw; border: 2px solid #fff7; box-shadow: inset 0 3px 6px #fff8, inset 0 -3px 4px #0002, 0 3px 4px #65301635; letter-spacing: 0; }
.shelf-category-plaque .plaque-icon { font-size: 2.4cqw; }
.shelf-category-plaque .plaque-chevron { display: grid; place-items: center; width: 2.7cqw; height: 2.7cqw; font-size: 2.6cqw; border-radius: 50%; background: #0001; box-shadow: inset 0 1px 3px #0001; }
.shelf-category-plaque:active { transform: translateX(-50%) scale(.97) !important; }
.plaque-continue_reading { background: linear-gradient(#8bcf7b, #2b9968 70%, #3eac7c); top: .7cqw; }
.plaque-classic_tales { background: linear-gradient(#ffb5cf, #ff428b 70%, #f469a1); }
.plaque-christmas { background: linear-gradient(#ffafa4, #f04c50 70%, #d93c3f); }
.plaque-activities { background: linear-gradient(#ffe69b, #ffb821 65%, #f3a51b); }
.plaque-bedtime_magic { background: linear-gradient(#ca99ff, #914bfb 65%, #743cda); }
.shelf-books-row-wrapper { position: absolute; inset: 0; min-height: 0; height: 100%; display: block; border: none !important; outline: none !important; box-shadow: none !important; background: transparent !important; }
.shelf-books-row { position: absolute; left: 8.8%; bottom: 2.8cqw; width: 53%; height: calc(var(--book-h) + 1.5cqw); min-height: 0; gap: 1.4cqw; padding: 1cqw 0 0 .4cqw; scroll-padding-inline: 0; overflow-x: auto; overflow-y: hidden !important; touch-action: pan-x pan-y; border: none !important; outline: none !important; box-shadow: none !important; background: transparent !important; scrollbar-width: none !important; -ms-overflow-style: none !important; }
.shelf-unit[data-shelf-id='continue_reading'] .shelf-books-row { width: 71%; }
.shelf-unit[data-shelf-id='christmas'] .shelf-books-row { left: 12.7%; width: 45%; bottom: 2.6cqw; }
.shelf-unit[data-shelf-id='activities'] .shelf-books-row { bottom: 2.6cqw; }
.shelf-unit[data-shelf-id='bedtime_magic'] .shelf-books-row { left: 8%; width: 84%; height: 17cqw; bottom: 3.9cqw; }
.shelf-book { flex: 0 0 var(--book-w); height: var(--book-h); border-radius: .7cqw; }
.book-spine-cover { border-radius: .6cqw .9cqw .9cqw .6cqw; border: 1px solid #fff9; box-shadow: -2px 1px 2px #4d3d2d66, 0 3px 4px #50331466; background-color: #fff2cd; }
.book-cover-img { object-fit: fill; }
.reference-cover { background-image: url('../assets/images/Shelve Example/Whimsical Pastel Storybook Library.png'); background-repeat: no-repeat; }
.reference-cover .book-cover-img, .reference-cover .book-spine-shine, .reference-cover .book-page-trim-top, .reference-cover .book-page-trim-bottom { opacity: 0; }
.book-spine-shine { width: 1cqw; opacity: .6; }
.book-page-trim-top, .book-page-trim-bottom { height: 2px; }
.book-cast-shadow { opacity: .25; }
.shelf-arrow { width: 4.4cqw; height: 4.4cqw; top: auto; bottom: 7.2cqw; transform: none; color: #92501f; background: #fff7e6; font-size: 3.7cqw; opacity: 1; box-shadow: 0 2px 3px #a4673c5e; }
.shelf-arrow-left { left: 4%; }
.shelf-arrow-right { right: 3.5%; }
.shelf-arrow:hover { transform: scale(1.08); color: #763b14; background: #fffaf1; }
.shelf-add-book-card { align-self: flex-end; flex: 0 0 9.2cqw; height: 12.9cqw; margin: 0 0 1cqw; font-size: 1.15cqw; gap: .5cqw; border: 2px dashed #c0775d66; border-radius: 1.1cqw; background: #fff6; backdrop-filter: none; color: #a54938; box-shadow: none; }
.shelf-add-book-card .plus-icon { font-size: 2.5cqw; color: inherit; }
[data-shelf-id='continue_reading'] .shelf-add-book-card { color: #5c7147; border-color: #7d926b88; }
[data-shelf-id='christmas'] .shelf-add-book-card { color: #303b72; border-color: #d1dcff99; background: #e2e8ff66; }
[data-shelf-id='activities'] .shelf-add-book-card { color: #a96716; border-color: #d59a4f99; }
.shelf-diorama { right: 7%; bottom: 3cqw; height: 14cqw; width: 13cqw; z-index: 6; }
.diorama-art { opacity: 0; width: 100%; height: 100%; max-height: none; }
.shelf-empty-slot { height: 100%; min-height: 0; padding: 0; flex: 0 0 100%; }
.empty-slot-card { width: 19cqw; height: 14.5cqw; padding: .8cqw; gap: .35cqw; border-radius: 1.3cqw; background: #fff0f36b; border: 1px solid #fff3; backdrop-filter: blur(3px); box-shadow: 0 2px 3px #65316a30; animation: none; }
.empty-slot-moon-icon { font-size: 2.8cqw; margin: 0; }
.empty-slot-title { font-size: 1.5cqw; color: #572599; margin: 0; }
.empty-slot-hint { font-size: 1.1cqw; color: #633793; margin: 0; }
.empty-slot-add-btn { padding: .65cqw 2.3cqw; font-size: 1.3cqw; margin-top: .6cqw; color: white; background: linear-gradient(#ba85ff, #8439ed); border: 1px solid #d2afff; box-shadow: 0 2px 3px #6d349655; }
.shelf-unit:last-of-type { margin-bottom: 0; }
.shelf-unit.is-management-mode, .shelf-unit.is-management-mode:first-child { margin-top: 0; }
.shelf-unit.is-management-mode .shelf-books-row { width: 82%; left: 9%; }
.shelf-unit.is-management-mode .shelf-diorama { pointer-events: none; }
.shelf-unit.is-management-mode .diorama-art { pointer-events: none; }
button:focus-visible, .shelf-book:focus-visible { outline: 3px solid #733dea; outline-offset: 3px; }
@media (min-width: 1441px) { .shelf-header { padding-inline: 24px; } }
@media (max-width: 1050px) { .shelf-header { flex-wrap: wrap; justify-content: space-between; } .header-nav-capsule { order: 3; width: 100%; justify-content: center; } }
@media (max-width: 600px) {
  .shelf-header { padding: 8px 12px; gap: 8px; }
  .btn-come-alive-header { padding: 7px 10px; } .come-alive-text { font-size: 11px; }
  .header-right { gap: 6px; } .user-header-group { gap: 5px; }
  .user-avatar-badge { width: 30px; height: 30px; font-size: 11px; }
  .header-btn { width: 32px; height: 32px; font-size: 14px; }
  .btn-auth-header { padding: 6px 8px; font-size: 11px; min-height: 32px; }
  .nav-capsule-btn { padding: 7px 8px; font-size: 11px; gap: 4px; }
  /* Preserve comfortable touch sizes on phones; books scroll in front of scenery. */
  .shelf-unit { height: 255px; --book-w: 112px; --book-h: 155px; background-size: auto 1361px; background-position: right calc(var(--scene-y) * -1px); }
  .shelf-unit[data-shelf-id='continue_reading'] { height: 276px; }
  .shelf-category-plaque { height: 38px; font-size: 17px; padding: 0 16px; gap: 10px; border-width: 1px; top: 3px; }
  .shelf-category-plaque .plaque-icon { font-size: 22px; }
  .shelf-category-plaque .plaque-chevron { width: 25px; height: 25px; font-size: 25px; }
  .shelf-books-row, .shelf-unit[data-shelf-id] .shelf-books-row { left: 14%; width: 72%; bottom: 33px; height: 178px; gap: 14px; padding: 15px 0 0 3px; }
  .shelf-unit[data-shelf-id='bedtime_magic'] .shelf-books-row { width: 84%; left: 8%; height: 175px; }
  .shelf-arrow { width: 42px; height: 42px; bottom: 90px; font-size: 34px; }
  .shelf-arrow-left { left: 2%; } .shelf-arrow-right { right: 2%; }
  .shelf-add-book-card { flex-basis: 94px; height: 140px; font-size: 12px; border-radius: 12px; margin-bottom: 5px; }
  .shelf-add-book-card .plus-icon { font-size: 26px; }
  .empty-slot-card { width: 205px; height: 165px; border-radius: 14px; padding: 12px; gap: 5px; }
  .empty-slot-moon-icon { font-size: 28px; } .empty-slot-title { font-size: 16px; } .empty-slot-hint { font-size: 11px; }
  .empty-slot-add-btn { font-size: 13px; padding: 7px 23px; margin-top: 5px; }
  .shelf-diorama { display: none; }
}
@media (prefers-reduced-motion: reduce) { .shelf-book, .shelf-category-plaque { transition: none; } .empty-slot-card { animation: none; } }

/* Match the reference's softer lettering and line icons. */
.shelf-header, .shelf-header button, .shelf-category-plaque, .shelf-add-book-card,
.empty-slot-title, .empty-slot-add-btn { font-family: 'Nunito', 'Quicksand', sans-serif; font-weight: 900; }
.shelf-category-plaque { font-size: 1.75cqw; gap: 1.3cqw; padding-inline: 2cqw; }
.shelf-header { height: clamp(68px, 5.88235vw, 84.7px); flex-shrink: 0; }
.nav-icon svg { width: 21px; height: 21px; display: block; }
.shelf-category-plaque .plaque-icon { line-height: 1; }
.shelf-category-plaque .plaque-icon svg { width: 2.6cqw; height: 2.6cqw; display: block; }
.shelf-arrow { font-family: 'Nunito', sans-serif; font-weight: 700; }
.shelf-diorama::after { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 50px; color: #ffe78a; text-shadow: 0 0 10px white; pointer-events: none; opacity: 0; }
.shelf-diorama.character-sparkle::after { animation: characterSparkle .7s ease-out; }
@keyframes characterSparkle { 0% { opacity: 0; transform: scale(.3); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-25px) scale(1.5); } }
@media(max-width:1050px) { .shelf-header { height: auto; min-height: 105px; } }
@media(max-width:600px) { .shelf-category-plaque { font-size: 17px; padding-inline: 16px; gap: 10px; } .shelf-category-plaque .plaque-icon svg { width: 25px; height: 25px; } .nav-icon svg { width: 18px; height: 18px; } }
@media(max-width:600px) {
  .shelf-unit[data-shelf-id] { --book-w: 112px; --book-h: 155px; }
  .shelf-header { background-size: auto 1361px; background-position: center top; }
  .user-avatar-badge { display: none; }
  .header-right { gap: 4px; }
  .btn-come-alive-header { padding-inline: 8px; }
  .btn-auth-header { padding-inline: 6px; font-size: 10px; }
  .nav-capsule-btn { padding-inline: 6px; }
}

/* Center the actual chevron artwork, independently of font metrics. */
.shelf-category-plaque .plaque-chevron {
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
}
.shelf-category-plaque .plaque-chevron svg {
  display: block;
  width: 65%;
  height: 65%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Restore the original freestanding bookcase arch on the top shelf only. */
.shelf-unit[data-shelf-id='continue_reading'] { background-image: url('../assets/images/library-scenery-arch.png'); }


/* Give category plaques real clearance from both the rail and shelf contents.
   Scale each scenery slice with its shelf so the wood remains continuous. */
@media (min-width: 601px) {
  .shelf-unit {
    --scene-stretch: 1.11;
    height: calc(var(--scene-height) * 100cqw / 1156 * var(--scene-stretch));
    background-size: 100cqw calc(1361 * 100cqw / 1156 * var(--scene-stretch));
    background-position: center calc(var(--scene-y) * -100cqw / 1156 * var(--scene-stretch));
  }
  .shelf-category-plaque { top: .7cqw; }
  .shelf-unit[data-shelf-id='continue_reading'] { --scene-stretch: 1.03; }
  .shelf-unit[data-shelf-id='continue_reading'] .shelf-books-row { bottom: 2.884cqw; }
  .shelf-unit[data-shelf-id='continue_reading'] .shelf-add-book-card { background: #edf5d7bd; border-color: #81936cab; }
  .shelf-books-row { bottom: 3.108cqw; }
  .shelf-unit[data-shelf-id='christmas'] .shelf-books-row,
  .shelf-unit[data-shelf-id='activities'] .shelf-books-row { bottom: 2.886cqw; }
  .shelf-unit[data-shelf-id='bedtime_magic'] .shelf-books-row { bottom: 4.329cqw; }
  .empty-slot-card { height: 12.5cqw; }
  /* Five covers, five gaps, and the entire add card, plus edge clearance. */
  .shelf-unit[data-shelf-id='continue_reading'] .shelf-books-row { width: 74%; padding-right: 0; }
}
@media (max-width: 600px) {
  .shelf-category-plaque { top: 8px; }
}

/* Empty cards share the plaque's centre, independently of book-row scenery offsets. */
.shelf-unit[data-shelf-id] .shelf-books-row.is-empty {
  left: 0; width: 100%; padding-inline: 0; scroll-padding-inline: 0;
}
.shelf-books-row.is-empty .shelf-empty-slot { flex: 0 0 100%; width: 100%; }
.shelf-books-row.is-empty .empty-slot-card { margin-inline: auto; max-width: calc(100% - 120px); }

.book-edit-btn {
  position: absolute; top: 42px; right: 6px; z-index: 30;
  padding: 5px 9px; border: 1px solid #fff; border-radius: 12px;
  background: linear-gradient(#f2e5ff,#ccabff); color: #512a86;
  font: 800 12px var(--font-display); box-shadow: 0 3px 8px #29134545;
  cursor: pointer; min-height: 30px; touch-action: manipulation;
}
.book-edit-btn:hover { background: #7742c3; color: white; }
.book-edit-btn:focus-visible { outline: 3px solid #ffdf63; outline-offset: 2px; }
