/* =====================================================================
   Survival Master Guide — online reader chrome
   Self-contained (own tokens) so it never collides with the framed guide CSS.
   ===================================================================== */
:root {
  --paper:  #e9edf1;
  --card:   #ffffff;
  --ink:    #14202e;
  --ink-2:  #36444f;
  --ink-3:  #66727e;
  --line:   #d4dbe3;
  --amber:  #e08a00;
  --amber-d:#b06d00;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --bar-h: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body.reader {
  font-family: var(--sans); color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* buttons (minimal, mirrors site) */
.btn { appearance: none; border: 1.5px solid var(--ink); background: var(--ink); color: #fff;
  font-family: var(--sans); font-weight: 650; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: .5em; text-decoration: none; line-height: 1;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(224,138,0,.4); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #2a1c00; box-shadow: 0 5px 14px rgba(224,138,0,.28); }
.btn-primary:hover { background: #f0950a; }
.btn-sm { padding: 9px 14px; font-size: .85rem; }

/* ---- top bar ------------------------------------------------------- */
.rdr-bar {
  position: sticky; top: 0; z-index: 40; height: var(--bar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: rgba(233,237,241,.9); backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--line);
}
.rdr-home { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.rdr-home svg { width: 20px; height: 20px; }
.rdr-home:hover { color: var(--ink); }
.rdr-title { display: flex; flex-direction: column; line-height: 1.1; margin-left: 6px; min-width: 0; }
.rdr-title-main { font-weight: 800; letter-spacing: -.01em; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rdr-title-sub { font-family: var(--mono); font-size: .58rem; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-3); }
.rdr-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.rdr-contents-btn {
  appearance: none; background: transparent; border: 1.5px solid var(--line); color: var(--ink-2);
  font-family: var(--sans); font-weight: 600; font-size: .88rem; border-radius: 999px; padding: 8px 14px;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; transition: border-color .2s, color .2s;
}
.rdr-contents-btn svg { width: 17px; height: 17px; }
.rdr-contents-btn:hover { border-color: var(--ink); color: var(--ink); }
.rdr-index { font-family: var(--mono); font-size: .82rem; color: var(--ink-2); min-width: 64px; text-align: center; }
.rdr-buy { margin: 0; }

@media (max-width: 640px) {
  .rdr-title-sub { display: none; }
  .rdr-contents-btn span { display: none; }
  .rdr-contents-btn { padding: 8px; }
  .rdr-index { min-width: 50px; font-size: .76rem; }
}

/* ---- contents drawer ---------------------------------------------- */
.rdr-contents {
  position: fixed; top: var(--bar-h); right: 0; z-index: 39;
  width: 340px; max-width: 90vw; height: calc(100vh - var(--bar-h));
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -16px 0 40px rgba(20,32,46,.12);
  overflow-y: auto; animation: drawer .22s ease;
}
@keyframes drawer { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.rdr-contents-inner { padding: 18px 16px 40px; }
.rdr-contents-h { font-family: var(--mono); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin: 6px 8px 12px; }
.rdr-contents-list { list-style: none; margin: 0; padding: 0; }
.rdr-contents-list button {
  width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer;
  display: flex; gap: 12px; align-items: baseline; padding: 10px 10px; border-radius: 9px;
  font-family: var(--sans); color: var(--ink-2); font-size: .92rem; line-height: 1.3;
}
.rdr-contents-list button:hover { background: rgba(20,32,46,.05); color: var(--ink); }
.rdr-contents-list button.active { background: var(--amber); color: #2a1c00; }
.rdr-contents-list button.active .ci-n { color: #2a1c00; }
.ci-n { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); min-width: 22px; }
.ci-t { flex: 1; }

/* ---- stage / sheet / iframe --------------------------------------- */
.rdr-stage {
  display: flex; align-items: flex-start; justify-content: center; gap: 14px;
  padding: 30px 18px 60px; min-height: calc(100vh - var(--bar-h) - 56px);
}
.rdr-sheet {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 2px 6px rgba(20,32,46,.08), 0 24px 50px rgba(20,32,46,.12);
  width: 100%; max-width: 860px; overflow: hidden;
}
#rdr-frame { width: 100%; border: 0; display: block; min-height: 70vh; background: #fff; }

.rdr-nav {
  position: sticky; top: 50vh; flex: none; align-self: flex-start;
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  display: grid; place-items: center; box-shadow: 0 4px 14px rgba(20,32,46,.12);
  transition: transform .15s ease, border-color .2s, opacity .2s;
}
.rdr-nav svg { width: 22px; height: 22px; }
.rdr-nav:hover { border-color: var(--ink); transform: scale(1.06); }
.rdr-nav:disabled { opacity: .35; cursor: default; transform: none; }

@media (max-width: 980px) {
  .rdr-nav { position: fixed; bottom: 22px; top: auto; z-index: 38; }
  .rdr-prev { left: 18px; }
  .rdr-next { right: 18px; }
  .rdr-stage { padding: 22px 14px 90px; }
}

/* ---- footer / toast / noscript ------------------------------------ */
.rdr-foot {
  border-top: 1px solid var(--line); background: var(--card);
  display: flex; gap: 8px 20px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 16px 18px; font-size: .85rem; color: var(--ink-3); text-align: center;
}
.rdr-foot-buy a { color: var(--amber-d); font-weight: 650; text-decoration: none; }
.rdr-foot-buy a:hover { text-decoration: underline; }

.rdr-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 14px);
  z-index: 80; max-width: min(92vw, 460px);
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 12px;
  font-size: .9rem; line-height: 1.4; box-shadow: 0 16px 40px rgba(0,0,0,.3);
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.rdr-toast.show { opacity: 1; transform: translate(-50%, 0); }

.rdr-noscript { padding: 30px; text-align: center; color: var(--ink-2); }
.rdr-noscript a { color: var(--amber-d); font-weight: 650; }

/* ---- printing the reader is blocked ------------------------------- */
@media print {
  body.reader * { visibility: hidden !important; }
  body.reader::before {
    content: "Printing the online reader is disabled. The printable PDF is available to buy at survivalmg.com.";
    visibility: visible; display: block; position: fixed; inset: 0; padding: 40px;
    font-family: var(--sans); font-size: 14pt; color: #000;
  }
}
