/* ═══════════════════════════════════════════════════════════════
   G&Y Company · catalogue reader
   A book on a wood table, rather than a PDF in a viewer.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --wood-1: #2e2118;
  --wood-2: #43301f;
  --wood-3: #1d150f;
  --bar: #1a120c;
  --line: rgba(255, 236, 210, 0.14);
  --text: #f2e8db;
  --soft: rgba(242, 232, 219, 0.55);
  --gold: #c9a227;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Jost', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  color: var(--text);
  overflow: hidden;
  /* a walnut surface: broad grain, fine grain, warm base */
  background:
    repeating-linear-gradient(92deg,
      rgba(255, 255, 255, 0.020) 0 2px,
      transparent 2px 9px,
      rgba(0, 0, 0, 0.055) 9px 11px,
      transparent 11px 22px),
    repeating-linear-gradient(88deg,
      rgba(255, 255, 255, 0.012) 0 1px,
      transparent 1px 14px),
    linear-gradient(160deg, var(--wood-2) 0%, var(--wood-1) 45%, var(--wood-3) 100%);
}

a { color: inherit; text-decoration: none; }

.bk { display: flex; flex-direction: column; height: 100%; }

/* ── Toolbar ───────────────────────────────────────────────────── */
.bk-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
  padding: 0 16px;
  background: rgba(26, 18, 12, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.bk-icon {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: 0.22s var(--ease);
}
.bk-icon svg { width: 17px; height: 17px; }
.bk-icon:hover { border-color: var(--gold); color: var(--gold); }

.bk-title { min-width: 0; flex: 1; }
.bk-title strong {
  display: block;
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-title span {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  margin-top: 3px;
}

.bk-tools { display: flex; align-items: center; gap: 10px; flex: none; }

.bk-pager {
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}
.bk-pager button {
  font-family: inherit; font-size: 15px; line-height: 1;
  background: none; border: 0; color: var(--text);
  padding: 10px 14px; cursor: pointer;
  transition: 0.2s var(--ease);
}
.bk-pager button:hover { background: rgba(255,255,255,0.08); color: var(--gold); }

#pageNum {
  width: 46px; text-align: center;
  font-family: inherit; font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.06);
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  color: var(--text);
  padding: 10px 4px;
}
#pageNum:focus { outline: none; background: rgba(255,255,255,0.12); }

#pageCount {
  font-size: 12px; color: var(--soft);
  padding: 0 12px 0 8px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ── The book ──────────────────────────────────────────────────── */
.bk-stage {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: 26px 16px;
  overflow: hidden;
}

.bk-book {
  position: relative;
  display: flex;
  align-items: stretch;
  opacity: 0;
  transition: opacity 0.45s var(--ease);
  /* the whole volume sits on the table */
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, 0.62));
}
.bk-book.ready { opacity: 1; }

.bk-page {
  position: relative;
  background: #fdfcfa;
  line-height: 0;
}
.bk-page canvas { display: block; }
.bk-page.blank { display: none; }

/* page block: a hint of thickness at the outer edges */
.bk-page:first-child::before,
.bk-page:last-child::after {
  content: '';
  position: absolute;
  top: 3px; bottom: 3px;
  width: 5px;
  background: linear-gradient(90deg, rgba(0,0,0,0.16), rgba(0,0,0,0));
}
.bk-page:first-child::before { left: -5px; transform: scaleX(-1); }
.bk-page:last-child::after { right: -5px; }

/* the fold down the middle */
.bk-gutter {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 46px;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.10) 34%,
    rgba(0,0,0,0.30) 49%,
    rgba(0,0,0,0.30) 51%,
    rgba(0,0,0,0.10) 66%,
    rgba(0,0,0,0) 100%);
}
.bk-book.single .bk-gutter { display: none; }
.bk-book.single .bk-page:first-child::before { display: none; }

/* ── Page-turn zones ───────────────────────────────────────────── */
.bk-edge {
  position: absolute;
  top: 0; bottom: 0;
  width: clamp(60px, 12vw, 150px);
  border: 0;
  background: none;
  cursor: pointer;
  z-index: 3;
  transition: background 0.3s var(--ease);
}
.bk-edge-l { left: 0; }
.bk-edge-r { right: 0; }
.bk-edge-l:hover { background: linear-gradient(90deg, rgba(255,255,255,0.05), transparent); }
.bk-edge-r:hover { background: linear-gradient(270deg, rgba(255,255,255,0.05), transparent); }

/* ── Loading ───────────────────────────────────────────────────── */
.bk-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  z-index: 4;
  transition: opacity 0.45s var(--ease), visibility 0.45s var(--ease);
}
.bk-loading.done { opacity: 0; visibility: hidden; }

.bk-spin {
  width: 34px; height: 34px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: bk-rot 0.9s linear infinite;
}
@keyframes bk-rot { to { transform: rotate(360deg); } }

.bk-loading span {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}
/* Indeterminate: with streaming off there is no total to report, and a bar
   frozen at zero reads as a broken page rather than a loading one. */
.bk-progress { width: 190px; height: 2px; background: var(--line); overflow: hidden; }
.bk-progress i {
  display: block; height: 100%; width: 38%;
  background: var(--gold);
  animation: bk-sweep 1.5s var(--ease) infinite;
}
@keyframes bk-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(263%); }
}

/* ── Small screens ─────────────────────────────────────────────── */
@media (max-width: 980px) {
  .bk-toggle { display: none; }
  .bk-stage { padding: 14px 8px; }
  .bk-edge { width: 22%; }
}

@media (max-width: 720px) {
  .bk-bar { height: auto; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .bk-title { order: 3; flex-basis: 100%; }
  .bk-tools { order: 2; margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
