/* Library: a tabbed folder (reading tracker / articles / favorites) with a sidebar,
   over a desk scene with a quote, description, and floating light specks. */

body.library-page {
  background: #fff url("../images/library.png") no-repeat center center;
  background-size: cover;
  font-family: system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.top-bar {
  padding: 20px 0;
}
.top-bar a {
  color: #fff;
}

/* ---- Desk scene decorations ---- */

.quote-cursor {
  animation: blink 1s step-end infinite;
}

.library-quote {
  position: absolute;
  top: 50px;
  left: 85%;
  width: 200px;
  font-family: "Special Elite", "Courier New", monospace;
  color: #fff;
  text-shadow:
    0 0 8px #000,
    0 0 8px #000,
    0 0 14px #000;
  text-align: right;
  z-index: 1;
}
.library-quote p {
  font-size: 14px;
  line-height: 1.3;
}
.library-quote span {
  font-size: 13px;
  line-height: 1.3;
}

.paperscrap-wrap {
  position: absolute;
  bottom: -20px;
  left: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}
.paperscrap-img {
  display: block;
  width: 100%;
}
.library-description {
  position: absolute;
  left: 2%;
  top: 20%;
  width: 15%;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 18px;
  line-height: 1.4;
  text-align: right;
  z-index: 2;
}

.book-stack-img,
.coffee-img {
  position: absolute;
  pointer-events: none;
  filter: drop-shadow(4px 4px 10px rgba(0, 0, 0, 0.35));
  z-index: 1;
}
.book-stack-img {
  top: 50%;
  right: 20px;
  width: 500px;
}
.coffee-img {
  top: 30%;
  right: 120px;
  width: 300px;
}

/* Glowing specks drifting up the page; created in library.js */
.light-specs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.spec {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: #fff9d6;
  box-shadow:
    0 0 6px 2px rgba(255, 246, 200, 0.9),
    0 0 12px 4px rgba(255, 230, 150, 0.5);
  opacity: 0;
  animation: spec-float linear infinite;
}
@keyframes spec-float {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  80% {
    opacity: 0.7;
  }
  100% {
    transform: translate(var(--drift, 20px), -110vh) scale(1);
    opacity: 0;
  }
}

/* ---- Folder, tabs, and board layout ---- */

.library-folder {
  width: calc(100% - 40px);
  max-width: 1020px;
  margin: 0 auto 20px;
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-row {
  display: flex;
  align-items: flex-end;
}
.folder-tab {
  display: inline-block;
  background: #eee;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 8px 28px;
  border-radius: 4px 4px 0 0;
  margin-left: 8px;
  border: 1px solid #333;
  border-bottom: 1px solid #eee;
  position: relative;
  bottom: -1px;
  z-index: 0;
  cursor: pointer;
  color: #666;
}
.folder-tab.active {
  border-bottom: 1px solid transparent;
  z-index: 2;
  color: #000;
}

/* The active tab and the board share one continuous grid-paper background */
.folder-tab.active,
.library-board {
  background: #fff url("../images/grid.png") repeat;
  background-size: 300px auto;
  background-attachment: fixed;
}
/* ...except the articles tab, which is plain white */
.folder-tab.active[data-tab="articles"],
#tab-articles {
  background: #fff;
}

.board-with-sidebar {
  display: flex;
  align-items: stretch;
  gap: 16px;
  position: relative;
  flex: 1;
  min-height: 0;
}
.library-board {
  overflow-y: auto;
  padding: 20px;
  border: 1px solid #333;
  border-radius: 0 6px 6px 6px;
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* ---- Reading tracker tab ---- */

.shelf-section {
  width: 100%;
}
.shelf-year {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #999;
  text-transform: uppercase;
  margin-top: 36px;
  margin-bottom: 12px;
}
.shelf-year:first-child {
  margin-top: 0;
}
.book-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.book-card {
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
.book-card img {
  width: 130px;
  height: 195px;
  object-fit: cover;
  display: block;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}
.book-card:hover img {
  transform: scale(1.05);
  box-shadow: 5px 5px 14px rgba(0, 0, 0, 0.35);
}
/* Card details are only shown in the modal and the favorites list */
.book-info,
.book-notes-source {
  display: none;
}

/* Heart added to favorite cards by library.js */
.book-card .favorite-star {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 28px;
  line-height: 1;
  pointer-events: none;
  transition: transform 0.3s ease;
}
.book-card:hover .favorite-star {
  animation: star-spin 0.4s ease forwards;
  transform: scale(1.3);
}
@keyframes star-spin {
  0%   { transform: scale(1)   rotate(0deg); }
  50%  { transform: scale(1.3) rotate(20deg); }
  100% { transform: scale(1.3) rotate(0deg); }
}

/* ---- Genre tags ---- */

.book-tag {
  border-radius: 999px;
  padding: 4px 16px;
  font-size: 14px;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15);
}

/* Every genre tag used in content/books needs a color here (the build script checks) */
.tag-classic            { background: #e8dcc8; }
.tag-climate            { background: #b0d4c8; }
.tag-coming-of-age      { background: #f7c5a8; }
.tag-cyberpunk          { background: #7fd4e8; }
.tag-dystopian          { background: #b0c4d8; }
.tag-essay              { background: #c8d4c0; }
.tag-fantasy            { background: #c9b1e8; }
.tag-fiction            { background: #aed6f1; }
.tag-gothic             { background: #9e8fb0; }
.tag-historical-fiction { background: #c4a882; }
.tag-history            { background: #d5dbdb; }
.tag-horror             { background: #f1948a; }
.tag-lgbtq              { background: #f9c9f0; }
.tag-literary           { background: #f0b27a; }
.tag-magical-realism    { background: #b8c4e8; }
.tag-memoir             { background: #d4b896; }
.tag-mystery            { background: #a2d9ce; }
.tag-mythology          { background: #e8c8a0; }
.tag-nature             { background: #c4d9b0; }
.tag-nonfiction         { background: #f9e79f; }
.tag-philosophy         { background: #b0bcd0; }
.tag-politics           { background: #b8c8d8; }
.tag-romance            { background: #f9b7c8; }
.tag-satire             { background: #e8d4a0; }
.tag-science            { background: #b8cce8; }
.tag-scifi              { background: #a9dfbf; }
.tag-short-stories      { background: #b8d4b8; }
.tag-speculative        { background: #a8d0d8; }
.tag-thriller           { background: #c4a8a8; }
.tag-translation        { background: #d9c2d9; }

/* ---- Articles tab ---- */

#tab-articles {
  margin: -20px;
  padding: 20px;
  min-height: calc(100% + 40px);
  box-sizing: border-box;
}
.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.article-item {
  padding: 6px 0;
  border-bottom: 1px dotted #ccc;
  font-size: 13px;
}
.article-header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  cursor: pointer;
}
.article-title {
  flex: 1;
}
.article-byline {
  color: #999;
  white-space: nowrap;
}
.article-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
  color: #999;
}
.article-item.expanded .article-arrow {
  transform: rotate(90deg);
}
.article-details {
  display: none;
  padding: 8px 0 4px;
  color: #555;
  font-style: italic;
}
.article-item.expanded .article-details {
  display: block;
}

/* ---- Favorites tab (list built from data-favorite cards by library.js) ---- */

#tab-favorites {
  padding: 20px;
}
.favorites-intro {
  font-size: 13px;
  font-style: italic;
  color: #555;
  margin-bottom: 16px;
}
.favorites-list {
  display: flex;
  flex-direction: column;
}
.favorites-list .book-card {
  padding: 10px 0;
  border-bottom: 1px dotted #ccc;
}
.favorites-list .book-card:last-child {
  border-bottom: none;
}
.favorites-list .fav-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.favorites-list .fav-row.has-notes {
  cursor: pointer;
}
.favorites-list .book-card img {
  width: 60px;
  height: 90px;
  flex-shrink: 0;
}
.favorites-list .book-info {
  display: block;
  flex: 1;
}
.favorites-list .book-title {
  font-weight: bold;
  font-size: 14px;
}
.favorites-list .book-author {
  font-size: 13px;
  color: #666;
  margin-top: 2px;
}
.favorites-list .book-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.favorites-list .book-tag {
  font-size: 11px;
  padding: 2px 10px;
}
.favorites-list .book-date {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}
.favorites-list .favorite-star {
  display: none;
}
.favorites-list .fav-arrow {
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  color: #999;
}
.favorites-list .book-card.expanded .fav-arrow {
  transform: rotate(-90deg);
}
.favorites-list .book-notes {
  display: none;
  padding: 8px 0 4px 74px;
  color: #555;
  font-style: italic;
  font-size: 13px;
}
.favorites-list .book-card.expanded .book-notes {
  display: block;
}
.favorites-list .book-notes p {
  margin: 0;
}
.favorites-list .book-notes p + p,
.favorites-list .book-notes blockquote {
  margin: 1em 0 0;
}
/* Highlighted quotes: a "> " blockquote in the book's Markdown */
.favorites-list .book-notes blockquote {
  border-left: 3px solid #ccc;
  padding-left: 12px;
}
.favorites-list .book-notes blockquote:first-child {
  margin-top: 0;
}

/* ---- Sidebar ---- */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: flex-start;
  position: relative;
  z-index: 1;
}
.sidebar-box {
  background: #fff;
  padding: 14px 16px;
  box-shadow: 2px 2px 0px #000, 4px 4px 0px #000, 6px 6px 0px #000;
  border: 1px solid #333;
  border-radius: 8px;
}
.sidebar-box h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #555;
  padding-bottom: 8px;
}

.cr-entry {
  margin-bottom: 14px;
}
.cr-title {
  font-style: italic;
  font-size: 13px;
}
.cr-author {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

.jump-section-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 0;
}
.jump-section a {
  display: block;
  font-size: 13px;
  color: #000;
  text-decoration: none;
  padding: 2px 0;
}
.jump-section a:hover {
  color: red;
  text-decoration: underline;
}

/* Height is capped to the board's bottom edge by library.js */
.filter-section {
  overflow-y: auto;
  box-sizing: border-box;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pill {
  padding: 3px 12px;
  font-size: 12px;
}
.filter-pill.active {
  outline-offset: 1px;
}

/* ---- Book detail modal ---- */

#book-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#book-modal.open {
  display: flex;
}
#book-modal-inner {
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  gap: 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
#book-modal-inner img {
  height: 260px;
  width: auto;
  flex-shrink: 0;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
}
#book-modal-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#book-modal-title {
  font-weight: bold;
  font-size: 24px;
}
#book-modal-author {
  font-size: 17px;
  color: #333;
}
#book-modal-date {
  font-size: 13px;
  color: #888;
  font-style: italic;
}
#book-modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- Small screens ---- */

@media (max-width: 600px) {
  .library-folder {
    width: calc(100% - 20px);
    box-sizing: border-box;
  }
  #tab-books {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
  }
  .book-card img {
    width: 100px;
  }
  #book-modal-inner {
    flex-direction: column;
    padding: 20px;
    gap: 16px;
  }
  #book-modal-inner img {
    height: auto;
    width: 100%;
    max-width: 180px;
  }
}
