*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --text: #ffffff;
  --bronze: #b5935a;
  --bronze-dim: rgba(181,147,90,0.12);
  --bronze-border: rgba(181,147,90,0.22);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Animated grid ── */
.grid-bg {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 64px 64px;
  animation: drift 40s linear infinite;
  pointer-events: none; z-index: 0;
}
@keyframes drift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 64px 64px, 64px 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .grid-bg { animation: none; }
}

/* radial vignette */
.vignette {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 35%, rgba(10,10,10,0.88) 100%);
  pointer-events: none; z-index: 1;
}

/* ── Shell ── */
.shell {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center;
  height: 100vh;
  height: 100dvh;   /* mobile browsers: track the real visible viewport */
  padding: 22px 28px 18px;
}

/* ── Header ── */
header {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0;
}
.h-name {
  font-size: 13px; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--bronze);
  white-space: nowrap;
}
.h-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(181,147,90,0.35); flex-shrink: 0;
}
.h-role {
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  white-space: nowrap;
}

/* ── Flipbook stage ── */
.stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 0;
  position: relative;
}

#bookwrap {
  position: relative;
  transform-origin: center center;
  will-change: transform;
}

/* ── Loading ── */
#loading {
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
}
.ld-label {
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--bronze);
}
.progress-track {
  width: 180px; height: 1px;
  background: rgba(255,255,255,0.07);
  overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--bronze);
  transition: width 0.15s ease;
}
.ld-sub {
  font-size: 10px; font-weight: 200;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.18);
}

#flipbook { display: none; }

/* ── Navigation ── */
nav {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 0 2px;
  visibility: hidden;
}
.nav-btn {
  background: none;
  border: 1px solid var(--bronze-border);
  color: var(--bronze);
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
  flex-shrink: 0;
}
.nav-btn:hover:not(:disabled) {
  background: var(--bronze-dim);
  border-color: var(--bronze);
  transform: scale(1.07);
}
.nav-btn:disabled { opacity: 0.18; cursor: default; transform: none; }
.nav-btn svg { display: block; }
.nav-btn.active {
  background: var(--bronze-dim);
  border-color: var(--bronze);
}

.counter {
  font-size: 11px; font-weight: 300;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
  min-width: 72px; text-align: center;
}
.counter em { font-style: normal; color: var(--bronze); font-weight: 400; }

.nav-sep {
  width: 1px; height: 18px;
  background: rgba(255,255,255,0.08);
}

/* hint */
.hint {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.1);
  pointer-events: none; z-index: 3;
  transition: opacity 0.5s;
  white-space: nowrap;
}
.hint.hidden { opacity: 0; }

/* ── StPageFlip page content ── */
.stf__item {
  background: #111;
  /* outer-edge lift: book sits slightly off the surface */
  box-shadow: 0 10px 28px -12px rgba(0, 0, 0, 0.55);
  transition: box-shadow 0.35s ease;
}
/* a turning page catches less light — whole book deepens slightly mid-flip */
#bookwrap.flipping .stf__item {
  box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.62);
}
/* spine crease: barely-there hint at the gutter, two-page spreads only.
   Tight and soft — must not cut through artwork spanning both pages. */
.spread-mode .stf__block::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 14;
  background: linear-gradient(to right,
    transparent 48%,
    rgba(0, 0, 0, 0.06) 49.5%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.06) 50.5%,
    transparent 52%);
}
.page { background: #111; overflow: hidden; }
.page img {
  width: 100%; height: 100%;
  object-fit: contain;   /* never squash a page, whatever the container does */
  display: block;
  user-select: none; -webkit-user-drag: none;
}

/* ── Edge flip strips (invisible, expand grab zone) ── */
.flipstrip {
  position: absolute;
  z-index: 25;
  cursor: pointer;
  touch-action: none;
}

/* ── Zoom mode ── */
#panLayer {
  position: fixed;
  z-index: 34;
  cursor: grab;
  touch-action: none;
  display: none;
}
#panLayer.on { display: block; }
#panLayer.dragging { cursor: grabbing; }

.z-pill {
  position: fixed;
  bottom: 72px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: rgba(20,20,20,0.92);
  border: 1px solid var(--bronze-border);
  border-radius: 22px;
  padding: 9px 18px;
  z-index: 36;
}
.z-pill[hidden] { display: none; }
#zlevel {
  font-size: 11px; font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--bronze);
  min-width: 40px; text-align: center;
}
.z-pill button {
  background: none; border: none;
  color: rgba(255,255,255,0.55);
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer;
  padding: 5px 6px;
}
.z-pill button:hover { color: var(--bronze); }

/* visible keyboard focus */
button:focus-visible {
  outline: 1px solid var(--bronze);
  outline-offset: 2px;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .shell { padding: 14px 14px 10px; }
  .h-name { font-size: 12px; }
  .h-role { font-size: 9px; letter-spacing: 0.18em; }
  nav { gap: 16px; padding: 12px 0 2px; }
  .nav-btn { width: 46px; height: 46px; }   /* ≥44px touch target */
  .counter { min-width: 60px; font-size: 10px; }
  .z-pill { bottom: 80px; padding: 10px 16px; }
  .z-pill button { padding: 8px 8px; }
  .hint { bottom: 8px; font-size: 8px; max-width: 94vw; }
}
