/* Wishlist & Favourites (wishlist.js, WishlistController): the heart and bookmark on
   book covers (_ShelfBook), the book page buttons (_SaveBook), My Wishlist and a
   shared Wishlist (Views/Wishlist), and the message at the bottom of the screen.
   Night mode overrides are at the end. */

:root {
  --wl-sage: #718a56;
  --wl-sage-deep: #4e6338;
  --wl-sage-soft: #eef3e8;
  --wl-heart: #d6336c;
  --wl-heart-soft: #fdf0f4;
  --wl-blue: #1d4ed8;
  --wl-ink: #1f2a1b;
  --wl-muted: #66705f;
  --wl-line: #e2e6dc;
  --wl-panel: #fff;
}

/* ---- On covers ---- */
.hb-save {
  position: absolute;
  z-index: 3;
  bottom: 12px;
  right: max(3px, calc(50% - 48px + 3px));
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.25s ease;
}

.hb-book:hover .hb-save,
.hb-book:focus-within .hb-save,
.hb-save:has([aria-pressed="true"]) { opacity: 1; }

.hb-book:hover .hb-save { transform: translateY(-6px); }

/* Phones, tablets and any touch-first screen: always shown. */
@media (hover: none), (pointer: coarse) {
  .hb-save { opacity: 1; }
}

/* Bare icons, no circle: a white outline with a dark shadow reads on any cover; saved
   ones are filled. */
.hb-save-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.hb-save-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.75));
}

.hb-save-btn.is-fav[aria-pressed="true"] svg { fill: #e0335f; }
.hb-save-btn.is-wish[aria-pressed="true"] svg { fill: #4f9a46; }
.hb-save-btn:focus-visible { outline: 3px solid var(--wl-blue); outline-offset: 1px; }

/* ---- On the book page ---- */
.wl-bookbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  margin: 0 0 1rem;
}

.wl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--wl-line);
  border-radius: 999px;
  background: var(--wl-panel);
  color: var(--wl-ink);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.wl-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.wl-btn:hover { border-color: #c9d3bd; }
.wl-btn.is-wish[aria-pressed="true"] { border-color: var(--wl-sage); background: var(--wl-sage-soft); color: var(--wl-sage-deep); }
.wl-btn.is-wish[aria-pressed="true"] svg { fill: var(--wl-sage); stroke: var(--wl-sage); }
.wl-btn.is-fav[aria-pressed="true"] { border-color: var(--wl-heart); background: var(--wl-heart-soft); color: var(--wl-heart); }
.wl-btn.is-fav[aria-pressed="true"] svg { fill: var(--wl-heart); }
.wl-btn:focus-visible { outline: 3px solid var(--wl-blue); outline-offset: 2px; }

.wl-proof { display: inline-flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; font-size: 0.85rem; color: var(--wl-muted); }
.wl-proof strong { color: var(--wl-ink); }
.wl-proof.is-drop { color: #1f7a46; font-weight: 600; }

/* ---- The message ---- */
.wl-toast {
  position: fixed;
  z-index: 1080;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  max-width: min(92vw, 30rem);
  padding: 0.65rem 1rem;
  border-radius: 0.75rem;
  background: #1f2a1b;
  color: #fff;
  font-size: 0.92rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 150%);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}

.wl-toast.is-shown { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.wl-toast a { color: #c9e0ad; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .wl-toast, .hb-save { transition: none; }
}

/* ---- My Wishlist and shared Wishlists ---- */
.wl-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.25rem 2rem;
  align-items: center;
  margin: 1.5rem 0 1rem;
  padding: 1.75rem 2rem;
  border-radius: 1.25rem;
  color: #fff;
  background:
    radial-gradient(circle at 90% 15%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(135deg, #4e6338, #718a56 50%, #1d4ed8);
}

.wl-hero h1 { margin: 0.35rem 0 0.4rem; color: #fff; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); font-weight: 900; }
.wl-hero p { margin: 0; color: rgba(255, 255, 255, 0.92); }

.wl-eyebrow {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wl-hero-note {
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.92rem;
}

.wl-ico { font-style: normal; }

.wl-done {
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid #d3dec6;
  border-radius: 0.75rem;
  background: var(--wl-sage-soft);
  color: var(--wl-ink);
}

.wl-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--wl-line); }

.wl-tab {
  padding: 0.55rem 1rem;
  border-bottom: 3px solid transparent;
  color: var(--wl-muted);
  font-weight: 600;
  text-decoration: none;
}

.wl-tab span { margin-left: 0.3rem; padding: 0 0.45rem; border-radius: 999px; background: #eef1ea; font-size: 0.78rem; }
.wl-tab.is-on { border-bottom-color: var(--wl-sage); color: var(--wl-ink); }

.wl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1.5rem; align-items: start; margin-bottom: 2rem; }
.wl-main { display: grid; gap: 0.9rem; min-width: 0; }
.wl-side { display: grid; gap: 1rem; }

.wl-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.wl-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.wl-chip {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--wl-line);
  border-radius: 999px;
  background: var(--wl-panel);
  color: var(--wl-ink);
  font-size: 0.86rem;
  text-decoration: none;
}

.wl-chip.is-on { border-color: #b9cbf6; background: #eaf0fd; color: var(--wl-blue); }
.wl-sort { display: flex; gap: 0.4rem; align-items: center; font-size: 0.86rem; color: var(--wl-muted); }
.wl-sort .form-select { width: auto; }

.wl-cartbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border: 1px solid #d3dec6;
  border-radius: 0.75rem;
  background: var(--wl-sage-soft);
}

.wl-rows { display: grid; border: 1px solid var(--wl-line); border-radius: 0.9rem; background: var(--wl-panel); }

.wl-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--wl-line);
}

.wl-row:last-child { border-bottom: 0; }
.wl-row.has-new { background: #f7faf3; }
.wl-row.is-bought { opacity: 0.75; }

.wl-cover img,
.wl-cover-blank {
  display: block;
  width: 56px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 2px 5px 5px 2px;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, 0.16), 0 3px 8px -4px rgba(20, 30, 50, 0.5);
}

.wl-cover-blank { display: grid; place-items: center; background: var(--wl-sage-soft); color: var(--wl-sage); font-size: 1.3rem; }

.wl-info { display: grid; gap: 0.2rem; min-width: 0; }
.wl-info h2 { margin: 0; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.wl-info h2 a { color: inherit; text-decoration: none; }
.wl-info h2 a:hover { text-decoration: underline; }
.wl-meta, .wl-when { color: var(--wl-muted); font-size: 0.85rem; }
.wl-when { font-size: 0.78rem; }

.wl-pills { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.wl-pill { padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600; background: #f4f4f2; color: var(--wl-muted); }
.wl-pill.is-drop { background: #e8f5ec; color: #1f7a46; }
.wl-pill.is-up { background: #f6eee2; color: #94742f; }
.wl-pill.is-in { background: #eaf0fd; color: var(--wl-blue); }
.wl-pill.is-gone { background: #fbeaea; color: #b42318; }
.wl-pill.is-wait { background: var(--wl-sage-soft); color: var(--wl-sage-deep); }
.wl-pill.is-new { background: var(--wl-sage); color: #fff; }
.wl-pill.is-fav { background: var(--wl-heart-soft); color: var(--wl-heart); }
.wl-pill.is-gift { background: #fff4d6; color: #8a5a00; }

.wl-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: flex-end; }
.wl-price { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 0.25rem; }
.wl-muted, .btn-link.wl-muted { color: var(--wl-muted); }
.wl-none, .wl-count { margin: 0; color: var(--wl-muted); font-size: 0.86rem; }

.wl-box {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  border: 1px solid var(--wl-line);
  border-radius: 0.9rem;
  background: var(--wl-panel);
  font-size: 0.92rem;
}

.wl-box h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.wl-box small { font-size: 0.78rem; }
.wl-box .btn { justify-self: start; }

.wl-switch, .wl-radio { display: flex; gap: 0.55rem; align-items: flex-start; cursor: pointer; }
.wl-switch input, .wl-radio input { margin-top: 0.25rem; accent-color: var(--wl-sage); }
.wl-switch small, .wl-radio small { display: block; color: var(--wl-muted); }

.wl-share { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.wl-share .form-control { flex: 1 1 100%; font-size: 0.8rem; }

.wl-empty { display: grid; justify-items: center; gap: 0.4rem; padding: 2.5rem 1rem; text-align: center; border: 1px dashed var(--wl-line); border-radius: 1rem; background: var(--wl-panel); }
.wl-empty > span { font-size: 2rem; color: var(--wl-sage); }
.wl-empty h2 { margin: 0; font-size: 1.2rem; }
.wl-empty p { margin: 0 0 0.5rem; color: var(--wl-muted); max-width: 32rem; }

@media (max-width: 900px) {
  .wl-layout { grid-template-columns: 1fr; }
  .wl-hero { grid-template-columns: 1fr; padding: 1.4rem 1.25rem; }
}

@media (max-width: 560px) {
  .wl-row { grid-template-columns: 46px minmax(0, 1fr); }
  .wl-cover img, .wl-cover-blank { width: 46px; }
  .wl-actions { grid-column: 2; justify-content: flex-start; }
}

/* ---- Night mode ---- */
[data-blog-theme="dark"] {
  --wl-ink: #e6eadf;
  --wl-muted: #adb7a4;
  --wl-line: #2f3628;
  --wl-panel: #1a1e15;
  --wl-sage-soft: #24301b;
  --wl-heart-soft: #3a1c27;
}

[data-blog-theme="dark"] .wl-row.has-new { background: #1f2918; }
[data-blog-theme="dark"] .wl-tab span,
[data-blog-theme="dark"] .wl-pill { background: #262c20; }
[data-blog-theme="dark"] .wl-chip.is-on,
[data-blog-theme="dark"] .wl-pill.is-in { background: #1c2742; color: #a9c1ff; border-color: #2c3f6e; }
[data-blog-theme="dark"] .wl-pill.is-drop { background: #173322; color: #8fd6a6; }
[data-blog-theme="dark"] .wl-pill.is-new { background: var(--wl-sage); color: #fff; }
[data-blog-theme="dark"] .wl-pill.is-fav { color: #f39bbb; }
[data-blog-theme="dark"] .wl-pill.is-gone { background: #3a1d1d; color: #f2a5a5; }
[data-blog-theme="dark"] .wl-cartbar,
[data-blog-theme="dark"] .wl-done { border-color: #34422a; }
[data-blog-theme="dark"] .wl-proof.is-drop { color: #8fd6a6; }
