/* Royal Codex Reading Room — Edition 3.
   Visual alignment with the live midnight-blue Royal Codes sales page.
   All manuscript text remains in entitlement-protected Supabase rows. */
:root {
  --night:#fff;
  --night2:#fff;
  --night3:#f7f7f7;
  --mint:#242424;
  --aqua:#343434;
  --paper:#fff;
  --bone:#f7f7f7;
  --ink:#181818;
  --muted:#575757;
  --stroke:rgba(0,0,0,.20);
  --subtle:rgba(0,0,0,.045);
}
html {scroll-padding-top:32px}
body {background:#fdfdfd;color:#202020}
.site-shell {
  background:radial-gradient(ellipse 67% 38% at 78% 0%,rgba(0,0,0,0.025),transparent 75%),
             linear-gradient(180deg,#fdfdfd 0%,#fdfdfd 45%,#fdfdfd 100%);
}
.masthead {
  background:rgba(255,255,255,0.93);
  border-bottom-color:rgba(0,0,0,0.152);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
}
.crest {border-color:rgba(0,0,0,0.400);color:#202020;box-shadow:0 0 29px rgba(0,0,0,0.034),inset 0 0 18px rgba(0,0,0,0.017)}
.identity-kicker,.header-account span,.overline {color:#555}
.identity-title {color:#202020}
.identity-sub,.save-status {color:#202020}
.header-account {background:rgba(0,0,0,0.008);border-color:rgba(0,0,0,0.248);color:#202020}
.side-rail {background:linear-gradient(157deg,#fdfdfd,#fdfdfd 85%);border-right-color:rgba(0,0,0,0.152)}
.family-group[open] {background:rgba(0,0,0,0.045);border-color:rgba(0,0,0,0.150)}
.family-summary,.code-nav button,.playlist-item button {color:#202020}
.family-group[open] .family-summary,.code-nav button:hover,.code-nav button.current {color:#202020}
.code-nav button:hover,.code-nav button.current {background:rgba(0,0,0,0.045)}
.code-nav button:before,.subtle-icon,.rail-note>span,.import-trigger {color:#202020}
.rail-note {background:linear-gradient(130deg,rgba(0,0,0,0.013),rgba(255,255,255,0.93));border-color:rgba(0,0,0,0.160)}
.rail-note p,.welcome p:not(.overline) {color:#555}
.welcome {border-bottom-color:rgba(0,0,0,0.160)}
.welcome h1 em {color:#202020}
.welcome-rule {background:rgba(255,255,255,0.93)}
.return-seal {border-color:rgba(0,0,0,0.280);box-shadow:0 0 0 9px rgba(0,0,0,0.006),0 0 34px rgba(0,0,0,0.027)}
.return-seal span {color:#202020}
.tabs {border-bottom-color:rgba(0,0,0,0.152)}
.tab.active {color:#202020;border-color:#555}
.tab-symbol {color:inherit}
:focus-visible {outline-color:#333}

/* Reading is a primary destination, not a hidden secondary tab. */
.reader-launch {
  display:inline-flex;
  align-items:center;
  gap:14px;
  margin-top:29px;
  padding:7px 8px 7px 19px;
  background:linear-gradient(110deg,rgba(0,0,0,0.014),rgba(0,0,0,0.006));
  border:1px solid rgba(0,0,0,0.240);
  border-radius:999px;
  max-width:100%;
}
.reader-launch-kicker {font:700 .59rem/1.4 'IM Fell French Canon',Arial,sans-serif;letter-spacing:.18em;color:#555}
.reader-launch-button {
  display:inline-flex;
  align-items:center;
  gap:14px;
  padding:12px 19px;
  border:1px solid rgba(0,0,0,0.496);
  background:#fff;
  border-radius:999px;
  color:#202020;
  font:700 .73rem/1.2 'IM Fell French Canon',sans-serif;
  letter-spacing:.025em;
  white-space:nowrap;
  transition:transform .2s,background .2s,box-shadow .2s;
}
.reader-launch-button:hover {background:#efefef;transform:translateY(-1px);box-shadow:0 7px 24px rgba(0,0,0,0.054)}
.reader-launch-button span {font-size:1rem;font-weight:400}

/* Preserve refined print-like manuscript typography and comfortable controls. */
.reader-heading {scroll-margin-top:20px}
.reader-heading h2 {color:#202020}
.reader-description {color:#555}
.reader-tools button,.reader-tools select {background:rgba(255,255,255,0.93);border-color:rgba(0,0,0,0.248);color:#202020}
.reader-tools button:hover,.reader-tools select:hover {border-color:rgba(0,0,0,0.544)}
.reader-tools #readerFocusToggle[aria-pressed="true"] {background:#efefef;color:#202020;border-color:#555}
.book-frame {
  border-color:rgba(0,0,0,0.328);
  box-shadow:0 28px 85px rgba(0,0,0,0.130),inset 7px 0 17px rgba(0,0,0,0.024);
}
.book-top {letter-spacing:.17em}
.book-page {font-kerning:normal;letter-spacing:-.012em;text-rendering:optimizeLegibility}
.book-page .codex-paragraph {max-width:32em;line-height:inherit}
.book-page .codex-heading {text-wrap:balance}
.book-page mark {background:#f3e0a1;color:#191919}
.book-page ::selection {background:rgba(210,170,70,0.45);color:inherit}
.book-bottom {background:rgba(0,0,0,0.006)}
.book-bottom button:hover:not(:disabled) {text-decoration:underline;text-underline-offset:4px}
.reader-side {border-color:rgba(0,0,0,0.216)}
.reader-access-note {border-color:rgba(0,0,0,0.272)}
.reader-access-note button {background:#fff;color:#202020}
.reader-access-note button:hover {background:#efefef}

/* Immersive reading view. No separate data state or change to buyer access. */
.site-shell.reader-immersive .desktop-layout {display:block}
.site-shell.reader-immersive .side-rail,
.site-shell.reader-immersive .welcome,
.site-shell.reader-immersive .install-prompt,
.site-shell.reader-immersive .tabs {display:none!important}
.site-shell.reader-immersive .main-stage {max-width:1390px;padding:clamp(20px,3vw,48px) clamp(17px,3.6vw,55px) 90px}
.site-shell.reader-immersive .reader-heading {margin-bottom:31px}
.site-shell.reader-immersive .reader-layout {grid-template-columns:minmax(0,1fr) minmax(215px,265px);gap:clamp(16px,3.5vw,56px)}
.site-shell.reader-immersive .book-frame {box-shadow:0 40px 100px rgba(0,0,0,0.130),inset 7px 0 19px rgba(0,0,0,0.027)}
.site-shell.reader-immersive .book-page {min-height:min(66vh,800px);padding-top:clamp(45px,6vw,98px);padding-bottom:clamp(48px,6vw,103px)}
.site-shell.reader-immersive .reader-side {top:20px}

/* Mobile reading stays full-width and navigable. */
@media(max-width:1050px) {
  .site-shell.reader-immersive .reader-layout {display:flex;flex-direction:column;gap:22px}
  .site-shell.reader-immersive .reader-side {position:static;max-height:none;width:100%}
  .site-shell.reader-immersive .reader-book-column {width:100%}
}
@media(max-width:720px) {
  .reader-launch {display:flex;justify-content:space-between;gap:9px;padding:6px 7px 6px 12px;margin-top:23px}
  .reader-launch-kicker {font-size:.52rem;letter-spacing:.10em}
  .reader-launch-button {font-size:.68rem;padding:11px 13px;gap:8px}
  .site-shell.reader-immersive .main-stage {padding:20px 14px 100px}
  .site-shell.reader-immersive .reader-heading {margin-top:0}
  .site-shell.reader-immersive .book-page {min-height:430px;padding:35px 24px 42px}
}
@media(max-width:390px) {
  .reader-launch-kicker {display:none}
  .reader-launch {width:max-content}
}
@media(prefers-reduced-motion:reduce) {.reader-launch-button{transition:none}}
