/* PDF Flipbook Reader — library aesthetic. Warm paper, deep green,
   brass bookmarks, a felt reading desk. Handcrafted CSS, no framework. */

:root {
  --ink: #1c1a17;
  --ink-soft: #57524a;
  --ink-faint: #8f8a81;
  --paper: #faf9f6;
  --raised: #ffffff;
  --hairline: #e3dfd7;
  --hairline-strong: #c9c4ba;
  --green: #175d43;
  --green-deep: #114634;
  --green-wash: #e9f1ec;
  --brass: #8a5a00;
  --brass-bright: #b07b1e;
  --brass-wash: #f6efdf;
  --desk: #222b25;
  --desk-edge: #1a211c;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
/* Stop the browser's swipe-back history gesture from hijacking page flips */
html, body { overscroll-behavior-x: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  accent-color: var(--green);
}

img { max-width: 100%; display: block; }
a { color: var(--green); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; text-wrap: balance; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }

.eyebrow {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--green);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; font-weight: 600; font-size: 16px;
  padding: 11px 22px; border-radius: 6px; text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: var(--green-deep); }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink); font-weight: 600; font-size: 16px;
  padding: 10px 20px; border-radius: 6px; border: 1px solid var(--hairline-strong);
  text-decoration: none; background: transparent;
}
.btn-ghost:hover { background: var(--raised); border-color: var(--ink-faint); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 6px; color: var(--ink-soft);
  flex-shrink: 0; position: relative;
}
.icon-btn:hover { background: var(--green-wash); color: var(--ink); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.is-active { color: var(--brass); }
.icon-btn.danger:hover { background: #fbeeec; color: #a02c1f; }

/* ============ LANDING ============ */

.site-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 0;
}
.brand { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand em { font-style: normal; color: var(--green); }
.brand a { color: inherit; text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav a:not(.btn) { color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 15.5px; }
.site-nav a:not(.btn):hover { color: var(--ink); }
@media (max-width: 640px) { .site-nav a:not(.btn) { display: none; } }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 56px; align-items: center; padding: 52px 0 72px;
}
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 44px; padding: 28px 0 56px; }
}
.hero h1 { font-size: clamp(38px, 5.6vw, 58px); margin: 14px 0 18px; }
.hero .lede { font-size: 19px; color: var(--ink-soft); max-width: 34em; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero-trust { margin-top: 22px; font-size: 14.5px; color: var(--ink-faint); }
.hero-trust b { color: var(--ink-soft); font-weight: 600; }

/* The hero demo — an actual flipbook */
.demo-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.demo-wrap { width: 100%; max-width: 430px; }
.demo-wrap:not(.ready) .demo-page:not(:first-child) { display: none; }
.demo-wrap:not(.ready) .demo-page:first-child {
  aspect-ratio: 280 / 372; max-width: 320px; margin: 0 auto;
  box-shadow: 0 18px 40px -18px rgba(28, 26, 23, 0.45);
}
.demo-caption { font-size: 14px; color: var(--ink-faint); }
.demo-page { background: var(--raised); border: 1px solid var(--hairline); overflow: hidden; container-type: size; }
.demo-cover { background: var(--green); border-color: var(--green-deep); color: #f2eee4; }
.demo-cover-inner, .demo-inner {
  height: 100%; display: flex; flex-direction: column; position: relative;
  justify-content: center; align-items: center; text-align: center; padding: 9cqh 7cqw;
}
.demo-rule { width: 26cqw; height: 1px; background: rgba(242, 238, 228, 0.4); margin: 4cqh 0; }
.demo-kicker { font-size: 4.4cqh; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.85; }
.demo-title { font-family: var(--serif); font-size: 11cqh; font-weight: 600; line-height: 1.05; margin: 1.5cqh 0; }
.demo-sub { font-family: var(--serif); font-style: italic; font-size: 5cqh; opacity: 0.9; }
.demo-foot { position: absolute; bottom: 5cqh; font-size: 3.4cqh; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; }
.demo-inner h3 { font-size: 6.8cqh; margin-bottom: 3cqh; }
.demo-inner p { font-size: 4.4cqh; line-height: 1.5; color: var(--ink-soft); }
.demo-no { position: absolute; bottom: 4cqh; font-size: 3.6cqh; color: var(--ink-faint); font-family: var(--serif); }
.demo-cta {
  font-family: var(--serif); font-size: 6.4cqh; font-weight: 600;
  color: #f2eee4; text-decoration: underline; text-underline-offset: 4px;
}

.section { padding: 64px 0; border-top: 1px solid var(--hairline); }
.section-head { margin-bottom: 40px; }
.section-head h2 { font-size: clamp(28px, 3.6vw, 38px); margin-top: 12px; }
.section-head .sub { font-size: 18px; color: var(--ink-soft); margin-top: 12px; max-width: 38em; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr; gap: 28px; } }
.step-no {
  font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--green);
  border: 1px solid var(--green); border-radius: 50%;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.step h3 { font-size: 21px; margin-bottom: 8px; }
.step p { color: var(--ink-soft); font-size: 16px; }

.compare-rows { border-top: 1px solid var(--hairline-strong); }
.compare-row {
  display: grid; grid-template-columns: 200px 1fr auto; gap: 16px; align-items: baseline;
  padding: 16px 4px; border-bottom: 1px solid var(--hairline); font-size: 16.5px;
}
@media (max-width: 640px) { .compare-row { grid-template-columns: 1fr; gap: 2px; padding: 14px 4px; } }
.compare-row .who { font-weight: 600; }
.compare-row .what { color: var(--ink-soft); }
.compare-row .cost { font-weight: 600; color: var(--ink-faint); white-space: nowrap; }
.compare-row.is-us { background: var(--green-wash); border-bottom-color: var(--green); }
.compare-row.is-us .who, .compare-row.is-us .cost { color: var(--green); }
.compare-row.is-us .what { color: var(--ink); }

.export-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; align-items: center; }
@media (max-width: 760px) { .export-grid { grid-template-columns: 1fr; } }
.folder-card {
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 8px;
  padding: 22px 24px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14.5px; line-height: 2; color: var(--ink-soft);
  box-shadow: 0 12px 30px -18px rgba(28, 26, 23, 0.35);
}
.folder-card b { color: var(--ink); font-weight: 600; }
.folder-card .cm { color: var(--ink-faint); }

.faq details { border-bottom: 1px solid var(--hairline); }
.faq summary {
  font-family: var(--serif); font-size: 19px; font-weight: 600; padding: 18px 0;
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--green); font-size: 22px; flex-shrink: 0; }
.faq details[open] summary::after { content: "\2013"; }
.faq details p { color: var(--ink-soft); padding: 0 0 20px; max-width: 44em; }

.cta-band { text-align: center; padding: 76px 0; border-top: 1px solid var(--hairline); }
.cta-band h2 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 24px; }

.site-foot {
  border-top: 1px solid var(--hairline); padding: 34px 0 44px;
  font-size: 14.5px; color: var(--ink-faint);
}
.site-foot .foot-row { display: flex; flex-wrap: wrap; gap: 10px 26px; justify-content: space-between; align-items: baseline; }
.site-foot a { color: var(--ink-soft); }

/* ============ APP: LIBRARY ============ */

.lib-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 30px 20px 8px; max-width: 1060px; margin: 0 auto; }
.brand-sub { color: var(--ink-soft); font-size: 15.5px; margin-top: 4px; }
.head-link { font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; }

.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px; padding: 26px 0 10px;
}
.book-card {
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
}
.book-cover { display: block; width: 100%; background: var(--desk); padding: 18px 30px 0; }
.book-cover img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top;
  border: 1px solid rgba(0, 0, 0, 0.25); border-bottom: 0;
  box-shadow: 0 -10px 26px -12px rgba(0, 0, 0, 0.6);
}
.book-meta { padding: 14px 16px 6px; }
.book-title { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.book-sub { font-size: 14px; color: var(--ink-faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.book-progress { font-size: 14.5px; color: var(--green); font-weight: 600; margin-top: 6px; }
.book-actions { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px; margin-top: auto; }
.book-actions .btn { padding: 8px 18px; font-size: 15px; margin-right: auto; }

.add-card {
  border: 1.5px dashed var(--hairline-strong); border-radius: 8px; min-height: 300px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--ink-soft); text-align: center; padding: 24px; font-size: 16px;
  transition: border-color 0.15s, background 0.15s; width: 100%;
}
.add-card:hover, .add-card.drag { border-color: var(--green); background: var(--green-wash); color: var(--ink); }
.add-card .add-plus {
  font-size: 30px; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--hairline-strong); display: flex; align-items: center; justify-content: center;
  color: var(--green); font-weight: 300;
}
.add-card em { font-style: normal; color: var(--ink-faint); }
.add-card .add-note { font-size: 13.5px; color: var(--ink-faint); }
.add-card.is-full { border-style: solid; cursor: default; color: var(--ink-faint); }
.add-card.is-full:hover { background: none; border-color: var(--hairline-strong); }

.lib-note { font-size: 14px; color: var(--ink-faint); padding: 12px 0 40px; }

/* Empty library — the first thing a new visitor sees, composed as such */
.empty-hero {
  min-height: calc(100vh - 210px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; padding: 40px 0 60px;
}
.empty-drop {
  width: min(560px, 100%);
  border: 1.5px dashed var(--hairline-strong); border-radius: 14px;
  padding: 56px 36px; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  color: var(--ink); font-size: 16px;
  transition: border-color 0.15s, background 0.15s;
}
.empty-drop:hover, .empty-drop.drag { border-color: var(--green); background: var(--green-wash); }
.empty-drop svg { width: 54px; height: 54px; color: var(--green); margin-bottom: 10px; }
.empty-drop h2 { font-size: 29px; }
.empty-drop p { color: var(--ink-soft); max-width: 30em; text-wrap: pretty; }
.empty-drop .btn { margin-top: 18px; }
.empty-facts { font-size: 14.5px; color: var(--ink-faint); text-align: center; }

/* ============ OVERLAYS / TOAST ============ */

.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(28, 26, 23, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-card {
  background: var(--paper); border-radius: 10px; padding: 30px 32px;
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px;
  text-align: center; align-items: center;
}
.overlay-title { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.overlay-status { color: var(--ink-soft); font-size: 15.5px; font-variant-numeric: tabular-nums; }
.bar { width: 100%; height: 6px; border-radius: 3px; background: var(--hairline); overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--green); border-radius: 3px; transition: width 0.2s; }
.overlay-note { font-size: 13.5px; color: var(--ink-faint); }
.overlay-card .btn-ghost { margin-top: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 15px; font-weight: 600;
  padding: 11px 20px; border-radius: 8px; z-index: 80; max-width: min(92vw, 480px);
  text-align: center; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* ============ APP: READER ============ */
/* Chrome floats as pills over the desk; the stage is the whole viewport. */

#screen-reader { position: fixed; inset: 0; z-index: 30; background: var(--desk); }

.rd-top {
  position: absolute; top: 14px; left: 14px; right: 14px; z-index: 45;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  pointer-events: none;
}
.rd-pill {
  pointer-events: auto; display: flex; align-items: center; gap: 2px;
  background: var(--paper); border-radius: 999px; padding: 4px;
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.55);
}
.rd-pill .icon-btn { border-radius: 999px; }
.rd-pill-title { padding-inline-end: 16px; gap: 6px; min-width: 0; }
#rd-title {
  font-family: var(--serif); font-weight: 600; font-size: 16px;
  max-width: min(38vw, 340px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rd-actions { flex-shrink: 0; }
.pill {
  position: absolute; top: 3px; right: 3px; background: var(--brass); color: #fff;
  font-size: 10.5px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

.rd-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 76px 26px 92px;
  background: var(--desk);
  /* the stage never scrolls — no touch on it belongs to the browser */
  touch-action: none;
}
/* touch-action none: every touch on the book goes to the flip engine, so the
   page peels under the finger instead of the browser claiming the gesture */
#flip-fit { width: 100%; max-width: 1140px; touch-action: none; }
#flipbook { width: 100%; }
#flipbook .stf__parent { margin: 0 auto; }

.rd-hint {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45); color: rgba(255, 255, 255, 0.9);
  font-size: 13.5px; padding: 7px 16px; border-radius: 16px; pointer-events: none;
  white-space: nowrap;
}

.rd-bottom {
  position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 45;
  max-width: calc(100% - 28px);
  display: flex; align-items: center; gap: 8px;
  background: var(--paper); border-radius: 999px; padding: 6px 10px;
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.55);
}
.rd-bottom .icon-btn { border-radius: 999px; }
#rd-range { width: clamp(120px, 22vw, 200px); height: 26px; }
.rd-pos {
  font-size: 14.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums;
  white-space: nowrap; min-width: 58px; text-align: center;
}

/* ---- the object on the desk reads as a BOOK ----
   A paper block behind the pages carries stacked page-edge shadows and the
   drop shadow; it hugs the open half when only a cover is showing. */
#flipbook .stf__block::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: #fff;
  /* stacked sheets visible on BOTH outer edges and the bottom — the
     thickness of the closed pages under the open spread */
  box-shadow:
    2px 2px 0 0 #f2efe8, 3px 3px 0 0 rgba(0, 0, 0, 0.18),
    5px 4px 0 0 #f2efe8, 6px 5px 0 0 rgba(0, 0, 0, 0.15),
    8px 6px 0 0 #f2efe8, 9px 7px 0 0 rgba(0, 0, 0, 0.12),
    -2px 2px 0 0 #f2efe8, -3px 3px 0 0 rgba(0, 0, 0, 0.18),
    -5px 4px 0 0 #f2efe8, -6px 5px 0 0 rgba(0, 0, 0, 0.15),
    -8px 6px 0 0 #f2efe8, -9px 7px 0 0 rgba(0, 0, 0, 0.12),
    0 42px 72px -22px rgba(0, 0, 0, 0.65);
  transition: left 0.25s ease-out, right 0.25s ease-out;
}
#flipbook.at-cover .stf__wrapper.--landscape .stf__block::before { left: 50%; }
#flipbook.at-back .stf__wrapper.--landscape .stf__block::before { right: 50%; }

/* Gutter: a crisp crease line where the pages meet, plus shading that curves
   into the spine — both ride on the page so they travel through the flip */
.stf__wrapper.--landscape .fb-page.--left {
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.32), inset -36px 0 36px -22px rgba(0, 0, 0, 0.4);
}
.stf__wrapper.--landscape .fb-page.--right {
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.32), inset 36px 0 36px -22px rgba(0, 0, 0, 0.4);
}

/* flip pages */
.fb-page { background: #fff; overflow: hidden; container-type: size; outline: 1px solid rgba(0, 0, 0, 0.08); outline-offset: -1px; }
.fb-page img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #fff;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
/* Only the glyphs themselves are selectable — margins, corners and whitespace
   pass the drag through to the page, so dragging PEELS the page interactively. */
.fb-text { position: absolute; inset: 0; color: transparent; z-index: 2; pointer-events: none; }
.fb-text span { position: absolute; white-space: pre; line-height: 1; font-family: Georgia, serif; pointer-events: auto; }
.fb-text span::selection { background: rgba(23, 93, 67, 0.3); }
/* On touch screens flipping always wins — selection is a desktop nicety. */
@media (pointer: coarse) {
  .fb-text span { pointer-events: none; user-select: none; -webkit-user-select: none; }
}

/* side panels */
.rd-panel {
  position: absolute; top: 72px; right: 14px; z-index: 44;
  touch-action: auto;
  width: min(340px, calc(100vw - 28px)); max-height: calc(100% - 170px);
  background: var(--paper); border: 1px solid var(--hairline); border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.55);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--hairline);
}
.panel-head p { font-family: var(--serif); font-weight: 600; font-size: 17px; }
#search-input {
  margin: 12px 14px; padding: 9px 12px; border: 1px solid var(--hairline-strong);
  border-radius: 6px; background: var(--raised); font-size: 16px; outline-color: var(--green);
}
.panel-list { overflow-y: auto; padding: 0 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.panel-empty { color: var(--ink-faint); font-size: 14.5px; padding: 10px 8px 14px; }
.result, .bm-row {
  display: flex; align-items: baseline; gap: 10px; text-align: left;
  padding: 9px 8px; border-radius: 6px; font-size: 14.5px; width: 100%;
}
.result:hover, .bm-row:hover { background: var(--green-wash); }
.r-page { color: var(--green); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-snip { color: var(--ink-soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bm-row { justify-content: space-between; }
.bm-jump { font-weight: 600; color: var(--ink); flex: 1; text-align: left; font-size: 15px; }
.bm-del { color: var(--ink-faint); font-size: 17px; padding: 0 6px; }
.bm-del:hover { color: #a02c1f; }

@media (max-width: 560px) {
  .lib-head { flex-direction: column; gap: 4px; }
  .rd-top { top: 10px; left: 10px; right: 10px; }
  #rd-title { font-size: 15px; max-width: 26vw; }
  .icon-btn { width: 38px; height: 38px; }
  .rd-pill .icon-btn, .rd-bottom .icon-btn { width: 42px; height: 42px; }
  .rd-stage { padding: 66px 10px 84px; }
  .rd-bottom { max-width: calc(100% - 20px); }
  #rd-range { width: clamp(96px, 34vw, 160px); }
  .rd-pos { min-width: 50px; font-size: 13.5px; }
}
