/*
 * Lightframe — book.css
 * ─────────────────────
 * Coffee-table book view for an album (?album=…&view=book).
 * One screen at a time, left to right, one or two prints per screen.
 * Desktop: the caption list sits to the right of the prints, aligned to their
 * foot. Phones: it sits underneath. Uses the tokens from the active
 * stylesheet (style-print-light.css).
 */

body.book-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.book-page .site-header { margin-bottom: 0; }

.book {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  --label: 22px;   /* space under each print for its number */
}

/* ── Bar: title, counter, controls ── */
.book-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px 40px 14px;
}

.book-title { min-width: 0; }

.book-title h1 {
  font-family: var(--font-disp);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.book-title p {
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.book-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.book-count {
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .06em;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.book-count b { color: var(--text); font-weight: 500; }

.book-btn {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 999px;
  color: var(--text);
  font: 500 .78rem/1 var(--font-body);
  padding: 9px 15px;
  cursor: pointer;
  transition: border-color .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.book-btn:hover { border-color: var(--text); }
.book-btn:disabled { opacity: .35; cursor: default; }
.book-btn:disabled:hover { border-color: var(--edge); }
.book-btn.icon { width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 1.15rem; }
.book-btn[aria-expanded="true"] { border-color: var(--text); background: var(--text); color: #fff; }

/* ── Layout tuning panel (shown with &tune) ── */
.book-panel {
  position: absolute;
  right: 40px;
  top: 150px;
  z-index: 50;
  width: min(330px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-up);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 14px;
  font-size: .85rem;
}

.book-panel h2 {
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.book-panel .row { display: grid; gap: 8px; }
.book-panel label { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.book-panel input[type=range] { width: 110px; accent-color: var(--text); }
.book-panel select { font: inherit; border: 1px solid var(--edge); border-radius: 6px; padding: 4px 8px; background: var(--surface); color: var(--text); }
.book-panel .w { color: var(--muted); width: 1.5em; text-align: right; font-variant-numeric: tabular-nums; }
.book-panel code { display: block; font-size: .72rem; background: var(--surface2); padding: 8px 10px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; color: var(--text-soft); user-select: all; }
.book-panel p { font-size: .75rem; color: var(--muted); line-height: 1.5; }

/* ── Carousel ── */
.book-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  min-height: 0;
  scrollbar-width: none;
}

.book-track::-webkit-scrollbar { display: none; }
.book-track:focus-visible { outline: none; }

.book-card {
  flex: 0 0 100%;
  min-width: 0;
  height: 100%;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(15rem, 22vw, 21rem);
  grid-template-rows: minmax(0, 1fr);
  gap: 0 44px;
  padding: 8px 40px 10px;
}

.book-plates {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--gap);
}

.book-row {
  display: flex;
  justify-content: center;
  gap: var(--gap);
  padding-bottom: var(--label);
}

/* each photo as a print */
.book-plate {
  position: relative;
  margin: 0;
  background: var(--surface);
  padding: var(--mat);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: transform .25s, box-shadow .25s;
}

.book-plate:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
.book-plate:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.book-plate img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface2);
  opacity: 0;
  transition: opacity .5s;
}

.book-plate img.in { opacity: 1; }

/* number written under the print's bottom-right corner */
.book-num {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  line-height: 1;
  color: var(--text);
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

/* caption list: right of the prints, level with their foot */
.book-text {
  align-self: end;
  margin-bottom: var(--label);
  min-width: 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.book-text:has(.book-caps:empty) { border-top-color: transparent; }

.book-caps { list-style: none; display: grid; gap: 14px; }
.book-caps li { display: grid; grid-template-columns: 1.6em 1fr; gap: 6px; font-size: .9rem; line-height: 1.45; }
.book-caps b { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.book-caps small { display: block; color: var(--muted); font-size: .74rem; }

.book-status {
  font-size: .72rem;
  color: var(--muted);
  padding: 6px 40px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.book-loading { display: grid; place-items: center; width: 100%; color: var(--muted); font-size: .85rem; letter-spacing: .06em; }

/* ── Book lightbox ── */
.book-lb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(250,250,248,.97);
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  padding: 64px 72px 20px;
}

.book-lb-stage { position: relative; min-height: 0; }

.book-lb-stage img {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-out;
  background: #fff;
  padding: clamp(10px, 1.6vw, 22px);
  border: 1px solid var(--edge);
  box-shadow: 0 2px 6px rgba(20,20,20,.08), 0 20px 50px rgba(20,20,20,.14);
}

.book-lb-cap { display: flex; gap: 12px; align-items: baseline; justify-content: center; flex-wrap: wrap; font-size: .85rem; text-align: center; }
.book-lb-cap b { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.book-lb-cap small { color: var(--muted); font-size: .76rem; }
.book-lb .book-btn { background: rgba(255,255,255,.92); }
.book-lb-close { position: absolute; top: 16px; right: 18px; }
.book-lb-prev, .book-lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.book-lb-prev { left: 16px; }
.book-lb-next { right: 16px; }

@media (prefers-reduced-motion: reduce) {
  .book-track { scroll-behavior: auto; }
  .book-plate, .book-plate:hover { transition: none; transform: none; }
}

@media (max-width: 800px) {
  .book { --label: 18px; }
  .book-bar { padding: 14px 16px 10px; }
  .book-card { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 6px 16px 4px; }
  .book-status { padding: 4px 16px 10px; }
  .book-text { align-self: start; margin-bottom: 0; padding-top: 10px; }
  .book-caps { gap: 6px; }
  .book-caps li { font-size: .84rem; }
  .book-panel { right: 16px; top: 190px; }
  .book-lb { padding: 64px 8px 16px; }
  .book-lb-prev, .book-lb-next { top: auto; bottom: 64px; transform: none; }
}
