/* =========================================================================
   SERIES — a box set on the shelf, a page of its own
   ========================================================================= */

/* the stack: up to three books, the next one to read in front */
.bset {
  position: relative; display: block; flex: none;
  width: calc(var(--bw) + 30px); height: var(--bh);
  transform-style: preserve-3d; touch-action: manipulation;
}
.bset .b3d { position: absolute; bottom: 0; left: calc(var(--k, 0) * 15px); pointer-events: none; }
.bset .b3d:not(:last-of-type) .b3d-obj { filter: brightness(calc(1 - var(--k) * .12)); }
.bset .b3d:last-of-type { z-index: 3; }
.bset .b3d:nth-of-type(2):not(:last-of-type) { z-index: 2; }
.bset:hover .b3d:last-of-type .b3d-obj, .bset:focus-visible .b3d:last-of-type .b3d-obj { transform: translateZ(calc(var(--t) / -2)) translateY(-6px) rotateY(14deg); }
.bset:active .b3d:last-of-type .b3d-obj { transform: translateZ(calc(var(--t) / -2)) translateY(-10px) rotateY(6deg); }
.bset-count {
  position: absolute; z-index: 5; top: -10px; right: -4px; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 999px; display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: #d9a52a; color: #2b2410; box-shadow: 0 0 0 3px var(--desk), 0 6px 14px -6px rgba(var(--shadow), .6);
}

/* ---- the series page ---- */
.series-view .sv-panel { position: relative; height: 100%; overflow-y: auto; padding: calc(var(--safe-t) + 16px) clamp(16px, 4.5vw, 60px) 60px; }
.sv-head { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 3; padding: 4px 0 14px; background: var(--desk); }
.sv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sv-title input {
  font: 500 clamp(26px, 3.6vw, 38px) var(--display); color: var(--ink); background: none; border: 0; outline: 0;
  padding: 2px 8px; margin-left: -8px; border-radius: 10px; min-width: 0; letter-spacing: -.01em;
}
.sv-title input:focus { background: var(--card); }
.sv-title small { color: var(--ink-3); font-weight: 700; font-size: 13.5px; }
.sv-kente { position: relative; height: 6px; border-radius: 4px; margin: 0 0 22px; }
.sv-next {
  display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
  padding: 24px 30px; border-radius: 26px; background: var(--card); margin-bottom: 26px;
  box-shadow: 0 2px 0 rgba(var(--shadow), .1), 0 24px 50px -36px rgba(var(--shadow), .7);
  perspective: 1200px; position: relative; overflow: hidden;
}
.sv-next:empty { display: none; }
.sv-next .b3d { cursor: pointer; }
.sv-next .b3d-obj { transform: translateZ(calc(var(--t) / -2)) rotateY(18deg); }
.sv-next .eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.sv-next h3 { font: 500 clamp(22px, 2.8vw, 30px) var(--display); margin: 6px 0 14px; line-height: 1.1; }
.sv-next .meter { max-width: 340px; height: 6px; margin-bottom: 18px; }
.sv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sv-book {
  display: grid; grid-template-columns: 34px auto 1fr auto; gap: 18px; align-items: center;
  padding: 14px 18px; border-radius: 20px; background: color-mix(in srgb, var(--card) 65%, transparent);
  perspective: 900px; cursor: pointer; transition: background-color .2s, transform .25s var(--spring);
  animation: rise .45s var(--ease-paper) both;
}
.sv-book:active { transform: scale(.985); }
.sv-book.is-next { background: var(--card); box-shadow: inset 4px 0 0 #d9a52a; }
.sv-num { font: 500 24px var(--display); color: var(--ink-3); text-align: center; }
.sv-book .b3d { pointer-events: none; }
.sv-book .b3d-obj { transform: translateZ(calc(var(--t) / -2)) rotateY(22deg); }
.sv-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sv-text b { font: 500 18px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-text small { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.sv-tools { display: flex; gap: 6px; }
.sv-tools button { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--btn); box-shadow: 0 4px 10px -6px rgba(var(--shadow), .5); }
.sv-tools button:disabled { opacity: .3; }
.series-view.editing .sv-book { cursor: default; }
@media (max-width: 640px) {
  .sv-next { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .sv-book { grid-template-columns: 26px auto 1fr; }
  .sv-tools { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---- "put it in a series" sheet ---- */
.ser-sheet { z-index: 58; }
#serScrim { z-index: 57; }
.ser-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ser-chips:empty { display: none; }
.ser-chips button { height: 38px; padding: 0 16px; border-radius: 999px; background: var(--chip); font-weight: 700; font-size: 14px; color: var(--ink-2); }
.ser-chips button.on { background: var(--accent); color: var(--accent-ink); }
.ser-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ser-field span { font-size: 13px; font-weight: 800; color: var(--ink-3); }
.ser-field input { height: 50px; padding: 0 18px; border-radius: 16px; border: 0; outline: 0; background: var(--chip); font: 600 16px var(--ui); color: var(--ink); }
.ser-field input:focus { box-shadow: 0 0 0 2px var(--accent); }
.ser-field.small input { width: 140px; }
.ser-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---- "next in series" card in the reader ---- */
.next-up {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 24px); z-index: 34; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; border-radius: 22px;
  width: min(520px, calc(100% - 28px)); background: var(--card); color: var(--ink);
  box-shadow: 0 2px 0 rgba(var(--shadow), .1), 0 24px 50px -18px rgba(var(--shadow), .7), 0 0 0 1px var(--rule);
  animation: nextIn .5s var(--spring) both;
}
@keyframes nextIn { from { opacity: 0; transform: translate(-50%, 30px); } }
.nu-cover { flex: none; width: 44px; height: 64px; border-radius: 2px 6px 6px 2px; background: var(--chip) center / cover no-repeat; box-shadow: 0 6px 12px -6px rgba(var(--shadow), .6); }
.nu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nu-text small { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.nu-text b { font: 500 17px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-up .btn-ink { height: 42px; padding: 0 18px; }
