/* NGN e-Edition reader — light brand theme */
:root {
  --ink: #1a1a1a;
  --paper: #F7F7F7;
  --accent: #1B4B91;
  --muted: #6b6b6b;
  --rule: #d8d4cc;
  --bar-h: 52px;
  --nav-h: 56px;
  --font-head: 'Playfair Display', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--paper); overscroll-behavior-y: none; }
body { font-family: var(--font-ui); color: var(--ink); }

#ngn-reader { height: 100%; height: 100dvh; display: flex; flex-direction: column; }

/* ---- top bar ---- */
.nr-bar {
  height: var(--bar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
  position: relative; z-index: 30;
}
.nr-back { color: var(--accent); text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.nr-title { flex: 1 1 auto; min-width: 0; text-align: center; line-height: 1.15; }
.nr-title strong { display: block; font-family: var(--font-head); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nr-title span { font-size: .72rem; color: var(--muted); }
.nr-actions { display: flex; gap: 6px; }
.nr-btn {
  appearance: none; border: 1px solid var(--rule); background: #fff; color: var(--ink);
  width: 34px; height: 34px; border-radius: 6px; font-size: 1.05rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
}
.nr-btn:active { background: #eee; }

/* ---- stage ---- */
.nr-stage { flex: 1 1 auto; position: relative; overflow-y: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nr-loading, .nr-error {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .95rem; text-align: center; padding: 24px;
}

/* mobile: vertical page scroll */
.nr-pages { margin: 0 auto; width: 100%; }
.nr-pg { position: relative; margin: 0 0 10px; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.12); }
.nr-pg canvas, .nr-pg img { display: block; width: 100%; height: auto; }
.nr-pg .nr-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--rule); font-size: .8rem; }

/* desktop: book spread */
.nr-book { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 18px; }
.nr-spread { display: flex; gap: 0; background: #fff; box-shadow: 0 6px 30px rgba(0,0,0,.18); transition: opacity .18s ease, transform .18s ease; }
.nr-spread.nr-turning { opacity: 0; transform: translateX(var(--turn-dir, -24px)) rotateY(6deg); }
.nr-spread canvas { display: block; }
.nr-spread canvas + canvas { border-left: 1px solid #e4e0d8; }

/* ---- bottom nav ---- */
.nr-nav {
  height: var(--nav-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: var(--paper); border-top: 1px solid var(--rule); z-index: 30;
}
.nr-arrow {
  appearance: none; border: 1px solid var(--rule); background: #fff; color: var(--ink);
  width: 44px; height: 38px; border-radius: 8px; font-size: 1.1rem; cursor: pointer;
}
.nr-arrow:disabled { opacity: .35; cursor: default; }
.nr-pageno { font-size: .85rem; color: var(--muted); min-width: 72px; text-align: center; }

/* ---- side tab + thumbnail drawer ---- */
.nr-tab {
  position: fixed; right: 0; top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  appearance: none; border: 1px solid var(--rule); border-right: 0;
  background: var(--accent); color: #fff; font-family: var(--font-ui); font-weight: 600;
  font-size: .78rem; letter-spacing: .06em; padding: 14px 7px;
  border-radius: 0 8px 8px 0; cursor: pointer; z-index: 40;
  box-shadow: -2px 2px 8px rgba(0,0,0,.18);
}
.nr-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 168px; max-width: 60vw;
  background: var(--paper); border-left: 1px solid var(--rule);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 60; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px;
}
.nr-drawer.open { transform: translateX(0); }
.nr-thumbs { display: flex; flex-direction: column; gap: 10px; }
.nr-thumb {
  appearance: none; border: 2px solid var(--rule); background: #fff; padding: 0;
  cursor: pointer; border-radius: 3px; overflow: hidden; position: relative;
}
.nr-thumb.current { border-color: var(--accent); }
.nr-thumb canvas { display: block; width: 100%; height: auto; }
.nr-thumb .nr-tn { position: absolute; bottom: 4px; right: 6px; font-size: .68rem; background: rgba(255,255,255,.9); padding: 1px 5px; border-radius: 3px; color: var(--muted); }
.nr-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none;
  transition: opacity .22s ease; z-index: 50;
}
.nr-scrim.show { opacity: 1; pointer-events: auto; }

/* ---- membership gate ---- */
.nr-gate { max-width: 460px; margin: 6vh auto; padding: 0 20px 40px; text-align: center; }
.nr-gate img { width: 200px; max-width: 60%; border: 1px solid var(--rule); box-shadow: 0 4px 18px rgba(0,0,0,.15); border-radius: 3px; }
.nr-gate h2 { font-family: var(--font-head); font-size: 1.5rem; margin: 1.1rem 0 .4rem; }
.nr-gate p { color: var(--muted); font-size: .95rem; line-height: 1.5; }
.nr-gate .nr-cta {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  font-weight: 600; font-size: .95rem; padding: 12px 26px; border-radius: 8px; margin-top: .6rem;
}
.nr-gate .nr-login { display: block; margin-top: 14px; color: var(--accent); font-size: .85rem; }

@media (max-width: 899px) {
  .nr-nav { display: none; }           /* mobile uses scroll, not arrows */
  .nr-float {                           /* floating page indicator */
    position: fixed; left: 12px; bottom: 14px; z-index: 35;
    background: rgba(26,26,26,.78); color: #fff; font-size: .75rem;
    padding: 5px 10px; border-radius: 14px; pointer-events: none;
  }
}
@media (min-width: 900px) {
  .nr-float { display: none; }
  .nr-title strong { font-size: 1.05rem; }
}
