/* Reference-led Books to Read Next layout. Data and actions remain React-owned. */
.app-shell.home-app-mode .online-recommendations-panel {
  --read-next-panel: linear-gradient(145deg, #fffaf1 0%, #f5ead7 100%);
  --read-next-card: rgba(255, 253, 247, 0.82);
  --read-next-text: #3f2b1d;
  --read-next-muted: #735f4e;
  --read-next-gold: #a86717;
  --read-next-border: rgba(157, 105, 36, 0.28);
  padding: clamp(22px, 3vw, 38px) !important;
  color: var(--read-next-text) !important;
  background: var(--read-next-panel) !important;
  border: 1px solid var(--read-next-border) !important;
  border-radius: 24px !important;
  box-shadow: 0 22px 60px rgba(70, 42, 15, 0.14), inset 0 1px rgba(255, 255, 255, 0.7) !important;
  container-type: inline-size;
}

/* Place online suggestions directly below the owned-shelf suggestions and
   let both sections use the full dashboard-main width. */
.app-shell.home-app-mode .home-dashboard-lists {
  grid-template-areas:
    "series"
    "recommended" !important;
  grid-template-columns: minmax(0, 1fr) !important;
}

.app-shell.home-app-mode .home-dashboard-grid {
  grid-template-areas:
    "main aside"
    "read-next read-next";
}
.app-shell.home-app-mode .home-dashboard-main { grid-area: main; }
.app-shell.home-app-mode .home-dashboard-aside { grid-area: aside; }
.app-shell.home-app-mode .home-dashboard-read-next-wide {
  grid-area: read-next;
  width: 100%;
  min-width: 0;
}
.app-shell.home-app-mode .home-dashboard-read-next-wide .online-recommendations-panel {
  width: 100%;
  box-sizing: border-box;
}

/* Give the owned-shelf recommendations the same clear section hierarchy as
   the other homepage cards without changing its controls or copy. */
.app-shell.home-app-mode .recommended-panel .home-recommendation-group-title {
  margin-bottom: 24px;
  padding: 4px 0 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--gold) 48%, transparent);
}

.app-shell.home-app-mode .recommended-panel .home-recommendation-group-title strong {
  color: var(--gold) !important;
  font-family: var(--display-font);
  font-size: clamp(1.75rem, 2.4vw, 2.35rem) !important;
  line-height: 1.08;
}

.app-shell.home-app-mode .read-next-wishlist-note {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 112px;
  margin-top: clamp(20px, 2vw, 28px);
  padding: 20px clamp(150px, 18vw, 280px) 20px 24px;
  overflow: hidden;
  color: var(--read-next-text);
  background: color-mix(in srgb, var(--read-next-card) 92%, transparent);
  border: 1px solid var(--read-next-border);
  border-radius: 18px;
  box-sizing: border-box;
}
.app-shell.home-app-mode .read-next-wishlist-note::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 24px;
  bottom: 8px;
  width: clamp(120px, 15vw, 230px);
  background: url("./stats/reading-books-plant-gold.png") center / contain no-repeat;
  opacity: .72;
  pointer-events: none;
}
.app-shell.home-app-mode .read-next-wishlist-note-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--read-next-gold);
  border: 2px solid currentColor;
  border-radius: 50%;
  font: 700 1.25rem/1 Georgia, serif;
}
.app-shell.home-app-mode .read-next-wishlist-note-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.app-shell.home-app-mode .read-next-wishlist-note-copy strong {
  color: var(--read-next-gold);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
}
.app-shell.home-app-mode .read-next-wishlist-note-copy > span {
  color: var(--read-next-muted);
  font-size: clamp(.85rem, 1vw, 1rem);
}

.app-shell.home-app-mode:not([data-theme="light"]):not(.shelf-visual-light) .online-recommendations-panel {
  --read-next-panel: radial-gradient(circle at 82% 18%, rgba(194, 132, 40, 0.08), transparent 32%), linear-gradient(145deg, #0b0e10 0%, #10110f 100%);
  --read-next-card: linear-gradient(110deg, rgba(27, 27, 23, 0.96), rgba(17, 18, 17, 0.97));
  --read-next-text: #f5eee1;
  --read-next-muted: #bdb6ad;
  --read-next-gold: #e2aa4f;
  --read-next-border: rgba(212, 156, 65, 0.24);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.4), inset 0 1px rgba(255, 255, 255, 0.035) !important;
}

.app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 24px;
  align-items: center;
  margin-bottom: clamp(22px, 2.5vw, 32px);
}

.app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title strong {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--read-next-text) !important;
  font-family: var(--display-font);
  font-size: clamp(1.55rem, 2.3vw, 2.35rem) !important;
  line-height: 1.1;
}

.app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title strong::before {
  content: "";
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1'/%3E%3Ccircle cx='19' cy='20' r='1'/%3E%3Cpath d='M3 4h2l2.7 11.4a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L21 8H6'/%3E%3C/svg%3E") center / contain no-repeat;
  color: var(--read-next-gold);
}

.app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title::after {
  content: "Suggested books you might enjoy. Not in your library yet.";
  grid-column: 1;
  color: var(--read-next-muted);
  font-size: clamp(0.88rem, 1.25vw, 1.05rem);
  line-height: 1.45;
}

.app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 48px !important;
  padding: 0 24px !important;
  color: var(--read-next-gold) !important;
  background: transparent !important;
  border: 1px solid var(--read-next-border) !important;
  border-radius: 999px !important;
  font-size: 0.95rem !important;
}

.app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger::before {
  content: "↻";
  margin-right: 9px;
  font-size: 1.35em;
  font-weight: 500;
}

.app-shell.home-app-mode .online-read-next-list {
  gap: clamp(14px, 1.6vw, 20px) !important;
  margin-top: 0 !important;
}

.app-shell.home-app-mode .online-read-next-card {
  grid-template-columns: clamp(108px, 11vw, 150px) minmax(210px, 1fr) auto !important;
  gap: clamp(22px, 3vw, 44px) !important;
  min-height: clamp(210px, 19vw, 270px);
  padding: clamp(18px, 2vw, 28px) clamp(60px, 5vw, 78px) clamp(18px, 2vw, 28px) clamp(18px, 2vw, 28px) !important;
  background: var(--read-next-card) !important;
  border: 1px solid var(--read-next-border) !important;
  border-radius: 22px !important;
  box-shadow: 0 12px 28px rgba(20, 14, 8, 0.1);
}

.app-shell.home-app-mode .online-read-next-cover .book-cover-card {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 0.68;
  border-radius: 12px !important;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.3) !important;
}

.app-shell.home-app-mode .online-read-next-copy { gap: 10px !important; }
.app-shell.home-app-mode .online-read-next-copy strong {
  color: var(--read-next-text) !important;
  font-family: var(--display-font);
  font-size: clamp(1.35rem, 2vw, 2rem) !important;
  white-space: normal !important;
}
.app-shell.home-app-mode .online-read-next-copy small {
  color: var(--read-next-muted) !important;
  font-size: clamp(0.92rem, 1.2vw, 1.08rem) !important;
  white-space: normal !important;
}
.app-shell.home-app-mode .online-read-next-copy::after {
  content: "▣  Not in library";
  margin-top: 8px;
  color: var(--read-next-gold);
  font-size: 0.98rem;
  font-weight: 750;
}

.app-shell.home-app-mode .online-read-next-actions {
  display: flex !important;
  gap: 14px !important;
  align-items: center;
}
.app-shell.home-app-mode .online-read-next-card :is(.home-secondary-button, .home-primary-button) {
  min-height: 52px !important;
  padding: 0 22px !important;
  border-radius: 12px !important;
  font-size: 0.94rem !important;
}
.app-shell.home-app-mode .online-read-next-card .home-secondary-button {
  color: #261805 !important;
  background: linear-gradient(180deg, #f1c36f, #d99a35) !important;
  border-color: #f0c36d !important;
}
.app-shell.home-app-mode .online-read-next-card .home-secondary-button::before { content: "◎"; margin-right: 9px; font-size: 1.3em; }
.app-shell.home-app-mode .online-read-next-card .home-primary-button {
  color: var(--read-next-gold) !important;
  background: transparent !important;
  border: 1px solid var(--read-next-border) !important;
}
.app-shell.home-app-mode .online-read-next-card .home-primary-button::before { content: "♡"; margin-right: 9px; font-size: 1.4em; }
.app-shell.home-app-mode .online-read-next-dismiss {
  top: 20px !important;
  right: 20px !important;
  width: 38px !important;
  height: 38px !important;
  color: var(--read-next-gold) !important;
  background: transparent !important;
  border: 1px solid var(--read-next-border) !important;
}

@media (max-width: 900px) {
  .app-shell.home-app-mode .online-read-next-card {
    grid-template-columns: 105px minmax(0, 1fr) !important;
    min-height: 0;
  }
  .app-shell.home-app-mode .online-read-next-actions {
    grid-column: 2;
    flex-wrap: wrap;
  }
}

/* The desktop homepage places this panel in a narrow grid column. Size the
   contents from the panel itself, rather than from the browser width. */
@container (max-width: 650px) {
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    margin-bottom: 20px;
  }
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title strong {
    gap: 9px;
    font-size: clamp(1.2rem, 7cqw, 1.55rem) !important;
  }
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title::after {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.82rem;
  }
  .app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger {
    grid-row: 1;
    min-height: 40px !important;
    padding: 0 13px !important;
    font-size: 0.78rem !important;
  }
  .app-shell.home-app-mode .online-read-next-card {
    grid-template-columns: clamp(76px, 23cqw, 104px) minmax(0, 1fr) !important;
    gap: 14px 18px !important;
    min-height: 0;
    padding: 16px !important;
    border-radius: 16px !important;
  }
  .app-shell.home-app-mode .online-read-next-copy {
    gap: 6px !important;
    padding-right: 26px;
  }
  .app-shell.home-app-mode .online-read-next-copy strong {
    font-size: clamp(1.05rem, 5.5cqw, 1.35rem) !important;
  }
  .app-shell.home-app-mode .online-read-next-copy small,
  .app-shell.home-app-mode .online-read-next-copy::after {
    font-size: 0.82rem !important;
  }
  .app-shell.home-app-mode .online-read-next-actions {
    grid-column: 1 / -1;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px !important;
    width: 100%;
    min-width: 0;
  }
  .app-shell.home-app-mode .online-read-next-card :is(.home-secondary-button, .home-primary-button) {
    width: 100%;
    min-width: 0;
    min-height: 44px !important;
    padding: 0 8px !important;
    font-size: 0.76rem !important;
  }
  .app-shell.home-app-mode .online-read-next-dismiss {
    top: 11px !important;
    right: 11px !important;
    width: 30px !important;
    height: 30px !important;
  }
}

/* On the wide homepage row, show all four suggestions sideways instead of
   stacking four oversized rows down the page. */
@container (min-width: 651px) {
  .app-shell.home-app-mode .recommended-panel .recommended-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-card {
    justify-items: center;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-cover {
    width: min(100%, 205px);
  }
  .app-shell.home-app-mode .recommended-panel .recommended-cover .book-cover-card {
    width: 100% !important;
    max-width: 205px !important;
    height: auto !important;
    aspect-ratio: 0.68 !important;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-card :is(h3, p, em) {
    width: min(100%, 205px);
    text-align: left;
  }
  .app-shell.home-app-mode .online-read-next-list {
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
    align-items: stretch;
  }
  .app-shell.home-app-mode .online-read-next-card {
    grid-template-columns: clamp(72px, 7cqw, 96px) minmax(0, 1fr) !important;
    grid-template-rows: 1fr auto;
    gap: 14px !important;
    min-height: 220px;
    padding: 18px 14px 14px !important;
    align-items: center;
  }
  .app-shell.home-app-mode .online-read-next-cover .book-cover-card {
    width: 100% !important;
    max-width: 96px;
  }
  .app-shell.home-app-mode .online-read-next-copy { gap: 6px !important; padding-right: 20px; }
  .app-shell.home-app-mode .online-read-next-copy strong { font-size: clamp(1rem, 1.35vw, 1.3rem) !important; }
  .app-shell.home-app-mode .online-read-next-copy small,
  .app-shell.home-app-mode .online-read-next-copy::after { font-size: 0.76rem !important; }
  .app-shell.home-app-mode .online-read-next-actions {
    grid-column: 1 / -1;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
    width: 100%;
  }
  .app-shell.home-app-mode .online-read-next-card :is(.home-secondary-button, .home-primary-button) {
    min-width: 0;
    min-height: 42px !important;
    padding: 0 7px !important;
    font-size: 0.7rem !important;
  }
  .app-shell.home-app-mode .online-read-next-dismiss {
    top: 10px !important;
    right: 10px !important;
    width: 30px !important;
    height: 30px !important;
  }
}

@media (max-width: 1280px) {
  .app-shell.home-app-mode .home-dashboard-grid {
    grid-template-areas:
      "main"
      "read-next"
      "aside";
  }
}

@media (max-width: 620px) {
  .app-shell.home-app-mode .online-recommendations-panel { padding: 18px 14px !important; border-radius: 18px !important; }
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title strong { font-size: 1.35rem !important; }
  .app-shell.home-app-mode .online-recommendations-panel .home-recommendation-group-title::after { grid-column: 1 / -1; grid-row: 2; }
  .app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger { grid-row: 1; min-height: 42px !important; padding: 0 14px !important; }
  .app-shell.home-app-mode .online-read-next-card {
    grid-template-columns: 88px minmax(0, 1fr) !important;
    gap: 16px !important;
    padding: 16px !important;
    border-radius: 16px !important;
  }
  .app-shell.home-app-mode .online-read-next-copy { padding-right: 28px; }
  .app-shell.home-app-mode .online-read-next-copy strong { font-size: 1.15rem !important; }
  .app-shell.home-app-mode .online-read-next-actions { grid-column: 1 / -1; display: grid !important; grid-template-columns: 1fr 1fr; width: 100%; }
  .app-shell.home-app-mode .online-read-next-card :is(.home-secondary-button, .home-primary-button) { min-height: 48px !important; padding: 0 10px !important; font-size: 0.8rem !important; }
  .app-shell.home-app-mode .online-read-next-dismiss { top: 12px !important; right: 12px !important; width: 32px !important; height: 32px !important; }
  .app-shell.home-app-mode .read-next-wishlist-note {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    padding: 16px;
  }
  .app-shell.home-app-mode .read-next-wishlist-note::after { display: none; }
  .app-shell.home-app-mode .read-next-wishlist-note-icon { width: 32px; height: 32px; font-size: 1rem; }
}

@media (max-width: 480px) {
  .app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger { font-size: 0 !important; width: 44px; padding: 0 !important; }
  .app-shell.home-app-mode .online-recommendations-panel .online-read-next-trigger::before { margin: 0; font-size: 22px; }
  .app-shell.home-app-mode .online-read-next-actions { grid-template-columns: 1fr; }
}

/* Owned-shelf cards are a sibling of the online recommendation container, so
   their desktop sizing must use the viewport breakpoint rather than the
   online panel's container query. */
@media (min-width: 651px) {
  .app-shell.home-app-mode .recommended-panel .recommended-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-card {
    justify-items: center;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-cover {
    width: min(100%, 205px) !important;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-cover .book-cover-card {
    width: 100% !important;
    max-width: 205px !important;
    height: auto !important;
    aspect-ratio: 0.68 !important;
  }
  .app-shell.home-app-mode .recommended-panel .recommended-card :is(h3, p, em) {
    width: min(100%, 205px);
    text-align: left;
  }
}

/* Balance the owned-shelf section with the other homepage headings while
   keeping all three full covers visible at a quieter supporting size. */
.app-shell.home-app-mode .recommended-panel .home-panel-head h2 {
  font-size: clamp(2.5rem, 3.2vw, 3.4rem) !important;
  line-height: 1;
}

@media (min-width: 651px) {
  .app-shell.home-app-mode .recommended-panel .recommended-cover,
  .app-shell.home-app-mode .recommended-panel .recommended-card :is(h3, p, em) {
    width: min(100%, 170px) !important;
  }

  .app-shell.home-app-mode .recommended-panel .recommended-cover .book-cover-card {
    max-width: 170px !important;
  }
}

@media (max-width: 620px) {
  .app-shell.home-app-mode .recommended-panel .home-panel-head h2 {
    font-size: clamp(1.75rem, 8vw, 2.2rem) !important;
  }
}
