/* ==========================================================================
   Meridian Investor Portal — document reader
   The document is the hero: chrome is thin, quiet, and gets out of the way.
   ========================================================================== */

html, body { height: 100%; }

body.rdbody {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ink-2);
}

/* ---- Top bar ----------------------------------------------------------- */

.rd__bar {
  flex: none;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--ink);
  border-bottom: 1px solid var(--rule-soft);
  z-index: 20;
}

.rd__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}
.rd__back svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.rd__back:hover { color: var(--ivory); }

.rd__id {
  display: flex;
  align-items: baseline;
  gap: 11px;
  min-width: 0;
  padding-left: 6px;
  margin-left: 6px;
  border-left: 1px solid var(--rule);
}
.rd__n {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--orange);
  flex: none;
}
.rd__title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd__kicker {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 13.5px;
  color: var(--dimmer);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rd__grow { flex: 1 1 auto; min-width: 0; }
.rd__tools { display: flex; align-items: center; gap: 2px; flex: none; }
.rd__sep { width: 1px; height: 22px; background: var(--rule); margin: 0 7px; flex: none; }

/* Toolbar buttons (.tb) are shared with the story page — see portal.css */

/* ---- Page control ------------------------------------------------------ */

.pg {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  flex: none;
}
.pg__box { display: flex; align-items: baseline; gap: 6px; padding: 0 4px; }
.pg input {
  width: 3.1em;
  padding: 6px 3px;
  background: rgba(251, 251, 247, 0.06);
  border: 1px solid var(--rule);
  color: var(--ivory);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: center;
  -moz-appearance: textfield;
}
.pg input::-webkit-outer-spin-button,
.pg input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pg input:focus { outline: 1px solid var(--orange); outline-offset: 0; }
.pg__of { color: var(--dimmer); }
.pg__tot { color: var(--dim); }

/* ---- Body: thumbnail rail + stage ------------------------------------- */

.rd__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative;
}

.rd__rail {
  flex: none;
  width: 0;
  overflow: hidden;
  background: var(--ink);
  border-right: 1px solid var(--rule-soft);
  transition: width 0.24s var(--ease);
}
body.is-rail .rd__rail { width: 152px; overflow-y: auto; overscroll-behavior: contain; }

.th {
  display: block;
  width: 100%;
  padding: 9px 12px 11px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.th canvas {
  width: 100%;
  height: auto;
  display: block;
  background: var(--ink-2);
  border: 1px solid var(--rule-soft);
  opacity: 0.5;
  transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease);
}
.th:hover canvas { opacity: 0.85; }
.th.is-cur canvas { opacity: 1; border-color: var(--orange); }
.th span {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--dimmer);
}
.th.is-cur span { color: var(--orange); }

/* The document canvas */
.rd__stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.rd__page {
  margin: auto;
  position: relative;
  line-height: 0;
  background: #0A170F;
}
.rd__page canvas { display: block; max-width: none; }

.rd__spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dimmer);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
body.is-loading .rd__spinner { opacity: 1; }

/* Selectable text sitting invisibly over the canvas */
.textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-align: initial;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
}
.textLayer :is(span, br) {
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
  color: transparent;
}
/* pdf.js emits .markedContent spans into the text layer itself */
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(217, 130, 47, 0.35); }
.textLayer br::selection { background: transparent; }

/* ---- Edge page navigation --------------------------------------------- */

.edge {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8.5%;
  min-width: 56px;
  max-width: 110px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--ivory);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  z-index: 10;
}
.edge--l { left: 0; }
.edge--r { right: 0; }
.edge:hover { opacity: 1; }
.edge:disabled { cursor: default; }
.edge:disabled:hover { opacity: 0; }
.edge i {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: rgba(7, 21, 14, 0.82);
  border: 1px solid var(--rule);
}
.edge svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.6; }

body.is-idle .edge { opacity: 0 !important; }

@media (hover: none) { .edge { display: none; } }

/* ---- Footer: document-to-document navigation ------------------------- */

.rd__foot {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--ink);
  border-top: 1px solid var(--rule-soft);
  z-index: 20;
}
.dn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 8px 0;
  min-width: 0;
  transition: color 0.18s var(--ease);
}
.dn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.dn:hover { color: var(--ivory); }
.dn b { font-weight: 500; color: inherit; }
.dn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dn[hidden] { display: none; }

/* On the last page the next document becomes the one obvious action. */
.dn.is-cta {
  color: #150B02;
  background: var(--orange);
  padding: 9px 16px;
}
.dn.is-cta:hover { background: #E8913B; color: #150B02; }

.rd__count {
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dimmer);
  white-space: nowrap;
}

/* ---- Fullscreen: chrome overlays the page, then fades ---------------- */

body.is-fs .rd__bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(to bottom, rgba(5, 15, 10, 0.94), rgba(5, 15, 10, 0));
  border-bottom: 0;
  transition: opacity 0.3s var(--ease);
}
body.is-fs .rd__body { height: 100%; }
body.is-fs .rd__stage { padding: 10px; }
body.is-fs .rd__foot { display: none; }
body.is-fs.is-idle .rd__bar { opacity: 0; pointer-events: none; }
body.is-fs.is-idle { cursor: none; }

/* ---- End-of-document panel ------------------------------------------- */

.end {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 15, 10, 0.9);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease);
}
.end.is-on { opacity: 1; pointer-events: auto; }

.end__panel {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border-top: 2px solid var(--green);
  padding: 34px 34px 30px;
}
.end__k {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green);
}
.end__k svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.end__done {
  margin: 14px 0 0;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.end__next {
  margin: 26px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.end__nk {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.end__nt {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 25px;
  line-height: 1.2;
  color: var(--ivory-warm);
  margin: 8px 0 0;
}
.end__acts {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
.end__tally {
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dimmer);
}

/* ---- Responsive ------------------------------------------------------- */

@media (max-width: 900px) {
  .rd__kicker { display: none; }
  body.is-rail .rd__rail { width: 118px; }
}

@media (max-width: 760px) {
  .rd__bar { height: 50px; padding: 0 8px; gap: 4px; }
  .rd__back { padding: 8px; }
  .rd__back span { display: none; }
  .rd__id { padding-left: 4px; margin-left: 2px; }
  .rd__title { font-size: 13.5px; }
  .rd__sep { margin: 0 3px; }
  .tb { width: 32px; height: 32px; }
  .tb--hide-sm { display: none; }
  .rd__stage { padding: 10px; }
  .rd__foot { height: 46px; padding: 0 10px; gap: 8px; }
  .dn { font-size: 9.5px; gap: 7px; }
  .dn--prev span { display: none; }
  .rd__count { display: none; }
  .end__panel { padding: 26px 22px 24px; }
  .end__nt { font-size: 21px; }
}

@media (max-width: 420px) {
  .pg input { width: 2.6em; }
}

/* Print: let the browser print the underlying PDF rather than the shell. */
@media print { body.rdbody { display: none; } }
