/* PRESS 3 - flipbook.css
 *
 * Chrome for the WebGL page-curl flipbook reader.
 *
 * The pages are cream paper (PRESS 2 output).  The surrounding chrome is a
 * dark neutral so the spread reads as the only lit object on screen.
 *
 * No web fonts, no external assets, no SVG, no icon fonts - the only glyphs
 * are text nodes already in the DOM.
 */

:root {
  --fb-bg:        #14161a;
  --fb-bg-2:      #1b1e24;
  --fb-rail-bg:   #101216;
  --fb-ink:       #e8e4db;
  --fb-ink-dim:   #9aa0aa;
  --fb-line:      #2c313a;
  --fb-accent:    #c9a227;
  --fb-accent-dim:#7d6420;
  --fb-radius:    3px;
  --fb-gap:       clamp(8px, 1.4vw, 18px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--fb-bg);
  color: var(--fb-ink);
  font-family: Georgia, "Times New Roman", "Liberation Serif", serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ chrome */

.fb-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--fb-gap);
  padding: 10px clamp(12px, 2.4vw, 28px);
  border-bottom: 1px solid var(--fb-line);
  background: linear-gradient(180deg, #1b1e24, #171a1f);
}

.fb-chrome-title {
  margin: 0;
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fb-chrome-author {
  margin: 0;
  font-size: clamp(11px, 1.05vw, 13px);
  color: var(--fb-ink-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fb-chrome-imprint {
  margin: 0 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fb-accent-dim);
}

/* ------------------------------------------------------------------- stage */

.fb-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  position: relative;
}

.fb-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--fb-gap);
  background:
    radial-gradient(120% 90% at 50% 0%, #22262e 0%, var(--fb-bg) 62%);
}

.fb-canvas {
  display: block;
  touch-action: pan-y;
  cursor: pointer;
  border-radius: var(--fb-radius);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.04);
}

.fb-canvas:active { cursor: grabbing; }

/* --------------------------------------------------------------------- hud */

.fb-hud {
  position: absolute;
  left: 50%;
  bottom: calc(var(--fb-gap) + 4px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 7px;
  border: 1px solid var(--fb-line);
  border-radius: 999px;
  background: rgba(16, 18, 22, 0.86);
  backdrop-filter: blur(4px);
}

.fb-btn {
  appearance: none;
  border: 1px solid var(--fb-line);
  background: #1e222a;
  color: var(--fb-ink);
  width: 34px;
  height: 30px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.fb-btn:hover:not(:disabled) {
  border-color: var(--fb-accent-dim);
  color: var(--fb-accent);
}

.fb-btn:disabled { opacity: 0.32; cursor: default; }

.fb-btn:focus-visible,
.fb-thumb:focus-visible,
.fb-textbtn:focus-visible {
  outline: 2px solid var(--fb-accent);
  outline-offset: 2px;
}

.fb-readout {
  min-width: 74px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--fb-ink-dim);
  font-variant-numeric: tabular-nums;
}

.fb-readout .fb-page { color: var(--fb-ink); }

/* ---------------------------------------------------------- text toggle */

.fb-textbtn {
  position: absolute;
  top: 8px;
  right: clamp(12px, 2.4vw, 28px);
  z-index: 3;
  appearance: none;
  border: 1px solid var(--fb-line);
  background: rgba(16, 18, 22, 0.86);
  color: var(--fb-ink-dim);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.fb-textbtn:hover { color: var(--fb-ink); border-color: var(--fb-accent-dim); }

.fb-textbtn[aria-pressed="true"] {
  color: var(--fb-accent);
  border-color: var(--fb-accent-dim);
}

/* -------------------------------------------------------------------- rail */

.fb-rail {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px clamp(12px, 2.4vw, 28px) 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--fb-rail-bg);
  border-top: 1px solid var(--fb-line);
  scrollbar-width: thin;
}

.fb-thumb {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--fb-line);
  border-radius: 2px;
  background: #0d0f13;
  line-height: 0;
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 120ms ease, border-color 120ms ease;
}

.fb-thumb canvas {
  display: block;
  width: 56px;
  height: 76px;
}

.fb-thumb:hover { opacity: 0.9; }

.fb-thumb.is-current {
  opacity: 1;
  border-color: var(--fb-accent);
  box-shadow: 0 0 0 1px var(--fb-accent-dim);
}

.fb-thumbnum {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 9px;
  line-height: 1;
  color: var(--fb-ink-dim);
  background: rgba(10, 12, 15, 0.72);
  padding: 2px 3px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
}

.fb-thumb.is-current .fb-thumbnum { color: var(--fb-accent); }

/* --------------------------------------------------------------- text layer
 *
 * Invisible by default: clipped to a 1px box so it never paints, but still
 * present in the accessibility tree and still selectable by keyboard.
 * The "Text" button reveals it (class .is-open) so the reader can read and
 * select the book text without leaving the reader.
 */

.fb-textlayer {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  z-index: 4;
}

.fb-textlayer.is-open {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: auto;
  height: auto;
  margin: 0;
  padding: clamp(18px, 4vw, 54px);
  overflow-y: auto;
  clip: auto;
  clip-path: none;
  white-space: normal;
  background: #171a1f;
  color: var(--fb-ink);
  font-size: 15px;
  line-height: 1.6;
  user-select: text;
  -webkit-user-select: text;
}

.fb-textlayer:focus-within {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
  padding: var(--fb-gap);
  color: var(--fb-ink);
  font-size: 15px;
  line-height: 1.6;
}

.fb-textlayer.is-open h2,
.fb-textlayer:focus-within h2 {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fb-accent-dim);
}

.fb-textlayer.is-open p,
.fb-textlayer:focus-within p {
  max-width: 62ch;
  margin: 0 0 1.4em;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

/* -------------------------------------------------------------- fallbacks */

.fb-noscript,
.fb-fallback-note {
  padding: var(--fb-gap);
  color: var(--fb-ink-dim);
  font-size: 13px;
}

@media (max-width: 640px) {
  .fb-chrome-imprint { display: none; }
  .fb-thumb canvas { width: 44px; height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .fb-thumb { transition: none; }
}
