/* Live book imprinted on the scroll (prototype).
   iOS-safe layout: .bw-imprint is a direct child of <body>, position:fixed, and NOTHING from the
   imprint down to the scroller (.bw-body) has a transform, filter, perspective or mask.
   The scroller is an absolutely-filled box (definite height) with overflow-y:scroll.
   The ink is visible at rest; the press animation is only an enhancement. */
.bw-imprint {
  --ink: #2c2118;
  --ink-soft: #5a4636;
  --ink-faint: #7a6450;
  --rule: rgba(44, 33, 24, 0.22);
  --good: #1f4a2c;
  --bad: #6b2230;
  position: fixed;
  z-index: 40; /* body-level: above the room; leaves the bottom strip free for Step back */
  top: max(8px, env(safe-area-inset-top));
  bottom: calc(60px + env(safe-area-inset-bottom)); /* Step back sits at bottom:16px, ~40px tall */
  left: 0;
  right: 0;
  width: auto;
  max-width: 916px;
  margin: 0 auto;
  display: none;
  flex-direction: column;
  color: var(--ink);
  font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 320ms ease-out;
}
.bw-imprint *, .bw-imprint *::before, .bw-imprint *::after { box-sizing: border-box; }
.bw-imprint.bwi-on { display: flex; }
.bw-imprint.bwi-in { opacity: 1; }
.bw-imprint.bwi-out { opacity: 0; transition: opacity 280ms ease-in; }

/* Shadow under the visible paper: a box-shadow on a sibling layer, never a filter on an ancestor of the scroller. */
.bw-imprint::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 5%;
  right: 5%;
  top: 4%;
  bottom: 3%;
  border-radius: 10px;
  box-shadow: 0 16px 26px rgba(8, 4, 2, 0.55), 0 4px 10px rgba(8, 4, 2, 0.35);
  pointer-events: none;
}

/* Paper chrome: the same rolled ends and laid paper as the scroll on the desk. The art has transparent
   torn margins, so the backgrounds are drawn at 118% width and centered: the visible paper is ~94% of the
   layer and nothing overflows the viewport. */
.bwi-roll {
  flex: none;
  position: relative;
  z-index: 2;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: 118% 100%;
}
.bwi-roll.top { background-image: url(/scroll-top.png); height: clamp(46px, 12vw, 96px); margin: 0 0 -3.4vw; }
.bwi-roll.bottom { background-image: url(/scroll-bottom.png); height: clamp(48px, 13vw, 104px); margin: -3.8vw 0 0; }
@media (min-width: 800px) {
  .bwi-roll.top { margin-bottom: -26px; }
  .bwi-roll.bottom { margin-top: -30px; }
}
.bwi-paper {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  background-image: url(/scroll-paper.png);
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: 118% 100%;
}

/* Fixed masthead on the paper: always visible, with the way into the dashboard. */
.bwi-head {
  flex: none;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: calc(3.4vw + 10px) 8.7% 10px 9.9%;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 800px) { .bwi-head { padding: 34px 8.7% 14px 9.9%; } }
.bwi-title { min-width: 0; }
.bwi-eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.bwi-head h2 { margin: 2px 0 0; font-family: inherit; font-size: 24px; line-height: 1.1; font-weight: 700; color: var(--ink); letter-spacing: 0; }
.bw-stamp { margin: 4px 0 0; font-size: 12.5px; line-height: 1.3; color: var(--ink-soft); }
.bwi-enter {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--good);
  color: #f6ecd6 !important;
  border: 1px solid rgba(20, 40, 26, 0.9);
  font: 700 15px/1 Palatino, "Palatino Linotype", Georgia, serif;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(12, 24, 14, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  -webkit-tap-highlight-color: rgba(31, 74, 44, 0.25);
  touch-action: manipulation;
  cursor: pointer;
}
.bwi-enter:active { box-shadow: 0 1px 0 rgba(12, 24, 14, 0.35); background: #183d24; }
.bwi-enter span { font-size: 17px; }
@media (max-width: 360px) { .bwi-enter { padding: 0 12px; font-size: 14px; } .bwi-head h2 { font-size: 21px; } }

/* The scroll viewport: a flex item that only provides a definite box; the scroller absolutely fills it. */
.bwi-view {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.bw-imprint .bw-body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 18px 8.7% calc(3.8vw + 30px) 9.9%;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(44, 33, 24, 0.35) transparent;
}
@media (min-width: 800px) { .bw-imprint .bw-body { padding: 24px 8.7% 52px 9.9%; } }

/* Imprint: the ink presses into the paper, once. Visible at rest (opacity 1); if the animation never
   runs, the ink is simply there. No fill-mode, no filter. No quill. */
.bw-imprint .bwi-ink, .bw-imprint .bwi-head > * { opacity: 1; }
.bw-imprint.bwi-in.bwi-anim .bwi-head > * { animation: bwi-press 620ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.bw-imprint.bwi-in.bwi-anim .bwi-ink { animation: bwi-press 820ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes bwi-press {
  0% { opacity: 0; }
  45% { opacity: 0.7; }
  100% { opacity: 1; }
}

.bw-sec + .bw-sec { margin-top: 30px; }
.bw-sec h3 {
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bw-sec h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; }
.bw-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
@media (min-width: 800px) { .bw-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.bw-kpi { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 0 0 10px; border-bottom: 1px dotted var(--rule); }
.bw-kpi.hero { grid-column: 1 / -1; padding-bottom: 12px; }
.bw-kpi .k { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.bw-kpi .v { font-size: 25px; line-height: 1.1; font-weight: 700; color: var(--ink); white-space: nowrap; }
.bw-kpi.hero .v { font-size: 36px; }
.bw-kpi .n { font-size: 11.5px; line-height: 1.35; color: var(--ink-faint); }
.bw-imprint .good { color: var(--good); }
.bw-imprint .bad { color: var(--bad); }

.bw-charts { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 800px) { .bw-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bw-chart { margin: 0; min-width: 0; }
.bw-chart.wide { grid-column: 1 / -1; }
.bw-chart figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-bottom: 8px; }
.bw-chart figcaption .t { font-size: 16.5px; font-weight: 700; color: var(--ink); }
.bw-chart figcaption .s { font-size: 13.5px; color: var(--ink-soft); }
.bw-chart figcaption .s b { font-weight: 700; }
.bw-chart figcaption .u { flex-basis: 100%; font-size: 12px; color: var(--ink-faint); font-style: italic; }
.bw-chart svg { display: block; overflow: visible; shape-rendering: geometricPrecision; max-width: 100%; height: auto; }
.bw-chart .g { stroke: rgba(44, 33, 24, 0.14); stroke-width: 1; }
.bw-chart .ax { stroke: rgba(44, 33, 24, 0.75); stroke-width: 1.2; }
.bw-chart .z { stroke: rgba(44, 33, 24, 0.7); stroke-width: 1.1; stroke-dasharray: 4 4; }
.bw-chart .tk { font-size: 11.5px; fill: #4a3a2c; font-family: Palatino, "Palatino Linotype", Georgia, serif; }
.bw-chart .at { font-size: 12px; font-weight: 700; fill: #2c2118; font-family: Palatino, "Palatino Linotype", Georgia, serif; }
.bw-chart .ln { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.bw-chart .ln.good { stroke: var(--good); }
.bw-chart .ln.bad { stroke: var(--bad); }
.bw-chart .ln.mkt { stroke: #7a6a58; stroke-width: 2; stroke-dasharray: 6 4; }
.bw-chart .ln.mdl { stroke: #2c2118; }
.bw-chart .wash { stroke: none; fill-opacity: 0.14; }
.bw-chart .wash.good { fill: var(--good); }
.bw-chart .wash.bad { fill: var(--bad); }
.bw-chart .dot { stroke: #f3e4c4; stroke-width: 2; }
.bw-chart .dot.good { fill: var(--good); }
.bw-chart .dot.bad { fill: var(--bad); }
.bw-chart .bar.good { fill: var(--good); }
.bw-chart .bar.bad { fill: var(--bad); }
.bw-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-soft); }
.bw-legend li { display: flex; align-items: center; gap: 7px; }
.bw-legend i { display: inline-block; width: 22px; height: 0; border-top: 2.4px solid currentColor; }
.bw-legend i.mkt { border-top: 2px dashed #7a6a58; }
.bw-legend i.mdl { border-top-color: #2c2118; }
.bw-legend i.good { border-top-color: var(--good); }
.bw-legend i.bad { border-top-color: var(--bad); }
.bw-legend i.sq { width: 12px; height: 12px; border: 0; border-radius: 2px; }
.bw-legend i.sq.good { background: var(--good); }
.bw-legend i.sq.bad { background: var(--bad); }
.bw-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 800px) { .bw-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; } }
.bw-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 2px; border-bottom: 1px dotted var(--rule); font-size: 15px; }
.bw-list li span { color: var(--ink-soft); white-space: nowrap; }
.bw-list li strong { font-size: 16px; white-space: nowrap; }
.bw-empty, .bw-loading { margin: 14px 0; color: var(--ink-soft); font-size: 15px; font-style: italic; }
.bw-foot { margin: 26px 0 0; font-size: 12px; color: var(--ink-faint); line-height: 1.5; }
.bw-endcta { margin: 18px 0 4px; text-align: center; }

/* While the imprint is open: no writing quill, no ink-pot dip. The 3D handwritten leaf is hidden only
   once the flat imprint is actually on screen (data-imprint-shown, set by book-wall-v2.js). */
html[data-imprint="1"] .quill,
html[data-imprint="1"] .inkpot,
html[data-imprint="1"] .inkpot-back { visibility: hidden !important; opacity: 0 !important; }
.desk-scene .leaf { transition: opacity 300ms ease; }
html[data-imprint-shown="1"] .desk-scene .leaf { opacity: 0 !important; pointer-events: none !important; }
html[data-imprint-shown="1"] .desk-scene .colophon { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .bw-imprint, .bw-imprint.bwi-out { transition-duration: 1ms; }
  .bw-imprint.bwi-in .bwi-head > *, .bw-imprint.bwi-in .bwi-ink { animation: none !important; opacity: 1; }
}
