/*
 * Ceritera V8.2 — Phase 2 Newsstand Library
 * Library-only presentation. Reader/import styles remain untouched.
 */

#libraryView { min-width: 0; }
.newsstand-section { margin-top: var(--space-16); }
.newsstand-section:first-of-type { margin-top: var(--space-12); }
.newsstand-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: var(--border-hairline) solid var(--text-primary);
  margin-bottom: var(--space-5);
}
.newsstand-heading {
  margin: 0;
  max-width: 18ch;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.5vw, 3.45rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
.newsstand-section-note {
  max-width: 33rem;
  margin: 0 0 var(--space-1);
  color: var(--text-secondary);
  font-family: var(--font-reading);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.section-kicker {
  margin-bottom: var(--space-2);
  color: var(--action-primary);
  letter-spacing: 0.13em;
}

/* Featured edition */
.featured-edition {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.55fr) 110px;
  min-height: 430px;
  margin: 0 0 var(--space-16);
  overflow: hidden;
  border: var(--border-strong) solid var(--text-primary);
  background: var(--surface-paper);
  box-shadow: 8px 8px 0 color-mix(in srgb, var(--action-primary) 80%, var(--text-primary));
}
.featured-cover {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 430px;
  padding: var(--space-6);
  overflow: hidden;
  border-right: var(--border-strong) solid var(--text-primary);
  color: #191714;
}
.featured-cover::before,
.magazine-cover::before,
.shelf-book-cover::before,
.continue-mini-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(135deg, rgba(255,255,255,.38), transparent 42%),
    radial-gradient(circle at 78% 25%, rgba(255,255,255,.55), transparent 26%),
    repeating-linear-gradient(105deg, transparent 0 16px, rgba(255,255,255,.08) 16px 17px);
}
.featured-cover::after,
.magazine-cover::after,
.shelf-book-cover::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 7%;
  z-index: -1;
  height: 3px;
  background: currentColor;
  opacity: .85;
}
.cover-tone-0 { background: linear-gradient(155deg, #f4d8cc, #d96b46); }
.cover-tone-1 { background: linear-gradient(155deg, #d9e8df, #5f9b82); }
.cover-tone-2 { background: linear-gradient(155deg, #e2dcf2, #8971bd); }
.cover-tone-3 { background: linear-gradient(155deg, #f2e6bf, #c28d34); }
.cover-tone-4 { background: linear-gradient(155deg, #d8e8f1, #4d84aa); }
.cover-tone-5 { background: linear-gradient(155deg, #ecd7df, #a34f72); }
.cover-masthead {
  position: absolute;
  top: var(--space-5);
  left: var(--space-5);
  right: var(--space-5);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid currentColor;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .08em;
  text-align: center;
}
.cover-edition {
  position: absolute;
  top: 4.75rem;
  left: var(--space-5);
  font-family: var(--font-label);
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .14em;
}
.featured-cover-icon {
  align-self: center;
  margin: auto;
  font-size: clamp(5rem, 11vw, 8rem);
  filter: drop-shadow(0 15px 20px rgba(0,0,0,.16));
}
.featured-cover-title {
  display: block;
  margin-top: auto;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 3rem);
  font-weight: 700;
  line-height: .96;
  letter-spacing: -.04em;
  text-wrap: balance;
}
.featured-cover-author {
  margin-top: var(--space-3);
  font-family: var(--font-label);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.featured-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 5vw, 4rem);
  min-width: 0;
}
.featured-eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  color: var(--action-primary);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.featured-eyebrow span { color: var(--text-secondary); }
.featured-copy h2 {
  max-width: 15ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 6vw, 5.25rem);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.05em;
  text-wrap: balance;
}
.featured-byline {
  margin: var(--space-4) 0 0;
  color: var(--text-secondary);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.featured-excerpt {
  max-width: 56ch;
  margin: var(--space-6) 0;
  color: var(--text-secondary);
  font-family: var(--font-reading);
  font-size: var(--text-md);
  line-height: 1.72;
}
.featured-data {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  padding: var(--space-4) 0;
  border-block: var(--border-hairline) solid var(--border-subtle);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.featured-data strong { color: var(--text-primary); font-weight: 700; }
.featured-progress,
.shelf-progress,
.card-progress {
  height: 3px;
  overflow: hidden;
  background: color-mix(in srgb, var(--border-subtle) 75%, transparent);
}
.featured-progress { margin-top: var(--space-5); }
.featured-progress span,
.shelf-progress span,
.card-progress span {
  display: block;
  height: 100%;
  background: var(--action-primary);
}
.featured-actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); }
.featured-actions button {
  min-height: 46px;
  border-radius: var(--radius-xs);
  box-shadow: none;
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.featured-primary { background: var(--text-primary); color: var(--surface-paper); }
.featured-primary:hover { background: var(--action-primary); }
.featured-secondary { border: var(--border-hairline) solid var(--text-primary); background: transparent; }
.featured-folio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-left: var(--border-strong) solid var(--text-primary);
  background: var(--action-primary);
  color: #fff;
  font-family: var(--font-label);
  text-align: center;
}
.featured-folio span { font-size: .6rem; font-weight: 800; letter-spacing: .12em; writing-mode: vertical-rl; }
.featured-folio strong { font-family: var(--font-display); font-size: 3.4rem; line-height: 1; }
.featured-folio small { font-size: .6rem; font-weight: 800; letter-spacing: .14em; }

/* Continue reading */
.continue-shelf {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.continue-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-3);
  border: var(--border-hairline) solid var(--border-subtle);
  background: var(--surface-paper);
  cursor: pointer;
  transition: transform var(--duration-normal) var(--ease-standard), box-shadow var(--duration-normal) var(--ease-standard);
}
.continue-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-raised); }
.continue-card:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.continue-mini-cover {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  aspect-ratio: var(--cover-ratio);
  overflow: hidden;
  color: #191714;
  font-size: 2rem;
  box-shadow: 4px 5px 12px rgba(28,26,22,.16);
}
.mini-masthead {
  position: absolute;
  top: 7px;
  left: 7px;
  right: 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid currentColor;
  font-family: var(--font-display);
  font-size: .46rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
}
.continue-card-copy { min-width: 0; }
.continue-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--action-primary);
  font-family: var(--font-label);
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .11em;
}
.continue-card h3 {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.08rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.continue-card p {
  margin: var(--space-2) 0 var(--space-3);
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--font-reading);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.continue-arrow { font-size: 1.25rem; }

/* Collection shelves */
.collection-head-actions {
  display: flex;
  align-items: end;
  gap: var(--space-4);
}
.shelf-arrows { display: flex; gap: var(--space-2); }
.shelf-arrows button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: var(--border-hairline) solid var(--text-primary);
  border-radius: 50%;
  box-shadow: none;
  background: transparent;
}
.collection-shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 18%);
  gap: var(--space-5);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
  scrollbar-width: thin;
  padding: var(--space-1) var(--space-1) var(--space-5);
}
.shelf-book {
  min-width: 0;
  scroll-snap-align: start;
  cursor: pointer;
}
.shelf-book:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.shelf-book-cover {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: var(--cover-ratio);
  overflow: hidden;
  padding: var(--space-3);
  color: #191714;
  box-shadow: 6px 10px 20px rgba(28,26,22,.16);
  transition: transform var(--duration-normal) var(--ease-standard), box-shadow var(--duration-normal) var(--ease-standard);
}
.shelf-book:hover .shelf-book-cover { transform: translateY(-5px) rotate(-.35deg); box-shadow: var(--shadow-cover); }
.shelf-masthead {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  right: var(--space-3);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid currentColor;
  font-family: var(--font-display);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
}
.shelf-book-icon { align-self: center; margin: auto; font-size: 3.2rem; filter: drop-shadow(0 7px 10px rgba(0,0,0,.16)); }
.shelf-cover-title {
  font-family: var(--font-display);
  font-size: clamp(.85rem, 1.4vw, 1.15rem);
  font-weight: 700;
  line-height: 1;
  text-wrap: balance;
}
.shelf-book h3 {
  margin: var(--space-4) 0 var(--space-1);
  font-family: var(--font-display);
  font-size: .98rem;
  line-height: 1.16;
}
.shelf-book p { margin: 0; color: var(--text-secondary); font-family: var(--font-label); font-size: .68rem; }
.shelf-status {
  display: inline-block;
  margin-top: var(--space-2);
  color: var(--action-primary);
  font-family: var(--font-label);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* New search and filter system */
.library-toolbar {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  border: var(--border-hairline) solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-paper) 90%, transparent);
}
.search-shell { position: relative; display: flex; align-items: center; }
.search-shell .search-icon {
  position: absolute;
  left: var(--space-4);
  z-index: 1;
  color: var(--text-secondary);
  font-size: 1.45rem;
  pointer-events: none;
}
.search-shell input[type="search"] {
  width: 100%;
  min-height: 52px;
  padding: 0 3.25rem 0 3rem;
  border: var(--border-hairline) solid var(--text-primary);
  border-radius: var(--radius-xs);
  outline: none;
  background: var(--surface-paper);
  color: var(--text-primary);
  box-shadow: none;
  font-family: var(--font-ui);
  font-size: var(--text-md);
}
.search-shell input[type="search"]:focus { box-shadow: var(--shadow-focus); }
.search-shell input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: var(--space-3);
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  background: var(--surface-subtle);
}
.filter-chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filter-chip {
  min-height: 34px;
  padding: var(--space-2) var(--space-4);
  border: var(--border-hairline) solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: transparent;
  box-shadow: none;
  font-family: var(--font-label);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.filter-chip.active { border-color: var(--text-primary); background: var(--text-primary); color: var(--surface-paper); }
.filter-chip.active:hover { background: var(--action-primary); color: #fff; }
.toolbar-meta-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.library-result-count {
  color: var(--text-secondary);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.sort-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-family: var(--font-label);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.sort-control select {
  min-height: 38px;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  border: var(--border-hairline) solid var(--border-subtle);
  border-radius: var(--radius-xs);
  box-shadow: none;
  background: var(--surface-paper);
}
.active-filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: calc(var(--space-2) * -1) 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--action-primary-soft);
  color: var(--text-secondary);
  font-family: var(--font-label);
  font-size: var(--text-xs);
}
.active-filter-summary button { padding: 0; border: 0; box-shadow: none; background: transparent; color: var(--action-primary); text-decoration: underline; }

/* Main newsstand grid */
.newsstand-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-8) var(--space-5);
  padding-top: var(--space-2);
}
.newsstand-card {
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.newsstand-card:hover { transform: none; box-shadow: none; }
.newsstand-card .book-card-menu-btn {
  top: var(--space-2);
  right: var(--space-2);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  opacity: 0;
  background: rgba(255,255,255,.9);
  color: #1c1a16;
  box-shadow: var(--shadow-control);
  transition: opacity var(--duration-fast) ease;
}
.newsstand-card:hover .book-card-menu-btn,
.newsstand-card:focus-within .book-card-menu-btn { opacity: 1; }
.newsstand-card .book-card-cover {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: var(--cover-ratio);
  min-height: 0;
  padding: var(--space-4);
  overflow: hidden;
  border: 0;
  color: #191714;
  box-shadow: 7px 12px 23px rgba(28,26,22,.17);
  transition: transform var(--duration-normal) var(--ease-standard), box-shadow var(--duration-normal) var(--ease-standard);
}
.newsstand-card:hover .book-card-cover { transform: translateY(-7px) rotate(-.4deg); box-shadow: var(--shadow-cover); }
.newsstand-card .book-card-cover::before { inset: 0; z-index: -2; font-size: 0; }
.newsstand-card .book-card-cover::after { left: 10%; right: 10%; bottom: 7%; height: 3px; z-index: -1; background: currentColor; }
.newsstand-card .book-card-tagchip {
  top: auto;
  bottom: var(--space-3);
  left: auto;
  right: var(--space-3);
  padding: 3px 6px;
  border: 1px solid currentColor;
  background: rgba(255,255,255,.58);
  color: inherit;
  font-size: .5rem;
}
.magazine-masthead {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid currentColor;
  font-family: var(--font-display);
  font-size: clamp(.82rem, 1.5vw, 1.2rem);
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
}
.newsstand-card .book-card-icon {
  align-self: center;
  margin: auto;
  font-size: clamp(3.3rem, 6vw, 5.1rem);
  filter: drop-shadow(0 9px 12px rgba(0,0,0,.15));
}
.magazine-cover-title {
  max-width: 92%;
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
  font-size: clamp(1rem, 2vw, 1.45rem);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.magazine-cover-line {
  padding-right: 3rem;
  font-family: var(--font-label);
  font-size: .55rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.magazine-issue {
  position: absolute;
  top: 3.3rem;
  right: var(--space-4);
  font-family: var(--font-label);
  font-size: .5rem;
  font-weight: 800;
  letter-spacing: .08em;
}
.newsstand-card .book-card-body { padding: var(--space-4) 0 0; }
.newsstand-card .book-meta { margin-bottom: var(--space-2); }
.newsstand-card .book-title {
  min-height: 2.35em;
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
}
.book-card-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--text-secondary);
  font-family: var(--font-label);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.card-progress { margin-top: var(--space-3); }
.newsstand-empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 290px;
  padding: var(--space-10);
  border: var(--border-hairline) dashed var(--border-subtle);
  text-align: center;
}
.newsstand-empty-state > span { color: var(--action-primary); font-size: 3rem; }
.newsstand-empty-state h3 { margin: var(--space-3) 0 var(--space-2); font-family: var(--font-display); font-size: var(--text-xl); }
.newsstand-empty-state p { margin: 0 0 var(--space-5); color: var(--text-secondary); }
.newsstand-empty-state button { border-radius: var(--radius-xs); background: var(--text-primary); color: var(--surface-paper); box-shadow: none; }
.newsstand-empty { padding: var(--space-10); border: var(--border-hairline) dashed var(--border-subtle); text-align: center; }
.pagination[hidden] { display: none; }

@media (max-width: 980px) {
  .featured-edition { grid-template-columns: minmax(210px, .75fr) minmax(300px, 1.25fr); }
  .featured-folio { display: none; }
  .featured-copy { padding: var(--space-8); }
  .newsstand-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .collection-shelf { grid-auto-columns: minmax(145px, 23%); }
}

@media (max-width: 720px) {
  .newsstand-section { margin-top: var(--space-12); }
  .newsstand-section-head { align-items: start; flex-direction: column; gap: var(--space-3); }
  .newsstand-heading { font-size: clamp(1.7rem, 8vw, 2.7rem); }
  .featured-edition { display: block; box-shadow: 5px 5px 0 color-mix(in srgb, var(--action-primary) 80%, var(--text-primary)); }
  .featured-cover { min-height: 390px; border-right: 0; border-bottom: var(--border-strong) solid var(--text-primary); }
  .featured-copy { padding: var(--space-6); }
  .featured-copy h2 { font-size: clamp(2.25rem, 12vw, 4.3rem); }
  .featured-excerpt { font-size: var(--text-sm); }
  .featured-data { gap: var(--space-2) var(--space-4); }
  .featured-actions { flex-direction: column; }
  .continue-shelf { grid-template-columns: 1fr; }
  .collection-head-actions { width: 100%; align-items: start; justify-content: space-between; }
  .collection-head-actions .newsstand-section-note { max-width: 75%; }
  .collection-shelf { grid-auto-columns: minmax(142px, 42%); gap: var(--space-4); }
  .library-toolbar { padding: var(--space-4); }
  .filter-chip-row { flex-wrap: nowrap; margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-4); overflow-x: auto; scrollbar-width: none; }
  .filter-chip-row::-webkit-scrollbar { display: none; }
  .filter-chip { flex: 0 0 auto; }
  .toolbar-meta-row { align-items: stretch; flex-direction: column; }
  .sort-control { justify-content: space-between; }
  .sort-control select { flex: 1; }
  .newsstand-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8) var(--space-3); }
  .newsstand-card .book-card-menu-btn { opacity: 1; }
}

@media (max-width: 430px) {
  .featured-cover { min-height: 340px; }
  .featured-cover-icon { font-size: 5.5rem; }
  .continue-card { grid-template-columns: 70px minmax(0,1fr) auto; gap: var(--space-3); }
  .collection-shelf { grid-auto-columns: minmax(132px, 48%); }
  .newsstand-grid { gap: var(--space-6) var(--space-3); }
  .newsstand-card .book-card-cover { padding: var(--space-3); }
  .magazine-masthead { top: var(--space-3); left: var(--space-3); right: var(--space-3); }
  .magazine-cover-title { font-size: .96rem; }
  .magazine-cover-line { display: none; }
  .magazine-issue { top: 2.85rem; right: var(--space-3); }
  .newsstand-card .book-card-tagchip { display: none; }
  .newsstand-card .book-card-menu-btn { width: 26px; height: 26px; }
  .newsstand-card .book-title { min-height: 2.5em; font-size: .98rem; }
  .book-card-status-row { font-size: .55rem; }
}

@media (prefers-reduced-motion: reduce) {
  .featured-edition,
  .newsstand-card .book-card-cover,
  .shelf-book-cover,
  .continue-card { transition: none; }
  .newsstand-card:hover .book-card-cover,
  .shelf-book:hover .shelf-book-cover,
  .continue-card:hover { transform: none; }
}
