/* Elias Silver Library — Claude-Library-v1
   Design language: warm, literary, unhurried. A quiet bookshop after dark
   with good lighting. One library, one book, several doors. */

/* ---------- Design tokens ---------- */
:root {
  color-scheme: light dark;

  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-read: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;

  /* Light theme (default). */
  --bg: #f7f3ea;
  --bg-elev: #fffdf8;
  --bg-sunk: #efe8d8;
  --ink: #23201a;
  --ink-soft: #5c554a;
  --ink-faint: #8a8173;
  --line: #e0d7c4;
  --line-strong: #cdc1a8;
  --gold: #9a7b34;
  --gold-bright: #b8923f;
  --accent: #1b2a4a;
  --accent-ink: #f4efe4;
  --danger: #9a2f2f;
  --ok: #2f6d4f;
  --shadow: 0 1px 2px rgba(35, 32, 26, .06), 0 8px 24px rgba(35, 32, 26, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1080px;
}

:root[data-theme='dark'] {
  --bg: #0d1526;
  --bg-elev: #131e33;
  --bg-sunk: #0a1120;
  --ink: #ece6d8;
  --ink-soft: #b3ac9c;
  --ink-faint: #7d7869;
  --line: #24314c;
  --line-strong: #33436a;
  --gold: #c9a86a;
  --gold-bright: #dcbf83;
  --accent: #c9a86a;
  --accent-ink: #0d1526;
  --danger: #e0857f;
  --ok: #86c8a3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
}

/* ---------- Reset-ish ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; font-weight: 700; }
p { margin: 0 0 1em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: var(--radius-sm); text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brand img { border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 800; letter-spacing: .01em; }
.brand-sub { font-size: .72rem; color: var(--ink-faint); }
.topnav { display: flex; align-items: center; gap: .35rem; }
.topnav a {
  text-decoration: none; padding: .45rem .7rem; border-radius: 999px;
  color: var(--ink-soft); font-weight: 600; font-size: .92rem;
}
.topnav a:hover { background: var(--bg-sunk); color: var(--ink); }
.topnav a[aria-current='page'] { color: var(--ink); background: var(--bg-sunk); }
.icon-btn {
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 999px;
  width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--line-strong); }
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .topnav a[data-nav='about'] { display: none; }
}

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: clamp(1.2rem, 4vw, 2.6rem) clamp(1rem, 4vw, 2rem); }
.stack > * + * { margin-top: 1rem; }

.breadcrumbs { font-size: .85rem; color: var(--ink-faint); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--ink-soft); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.15rem; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; text-decoration: none; font-size: .95rem;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, var(--ink)); }
.btn-gold { background: var(--gold); color: #1a1406; }
.btn-gold:hover { background: var(--gold-bright); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { background: var(--bg-sunk); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.linklike {
  background: none; border: 0; padding: 0; color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 2px; font: inherit;
}
.linklike:hover { color: var(--ink); }

.tag {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .28rem .6rem; border-radius: 999px; border: 1px solid var(--line-strong);
  color: var(--ink-soft); background: var(--bg-sunk);
}
.tag-free { color: #1a1406; background: var(--gold); border-color: transparent; }
.tag-lock { color: var(--ink-soft); }
.tag-soon { opacity: .8; }

/* ---------- Hero (home) ---------- */
.hero {
  border-radius: var(--radius);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-elev), var(--bg-sunk));
  border: 1px solid var(--line);
  padding: clamp(1.6rem, 5vw, 3rem);
  box-shadow: var(--shadow);
}
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); font-family: var(--font-read); letter-spacing: -.01em; }
.hero .lede { font-size: clamp(1.05rem, 2.4vw, 1.25rem); color: var(--ink-soft); max-width: 46ch; }
.hero .doors { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.door-chip {
  font-size: .78rem; font-weight: 700; padding: .35rem .7rem; border-radius: 999px;
  border: 1px dashed var(--line-strong); color: var(--ink-soft);
}
.door-chip.live { border-style: solid; color: var(--ink); background: var(--bg-elev); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 2.2rem 0 1rem; }
.section-head h2 { font-size: 1.3rem; font-family: var(--font-read); }
.section-head p { color: var(--ink-faint); font-size: .9rem; margin: 0; }

/* ---------- Continue reading ---------- */
.continue-card {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  padding: 1rem 1.2rem; border-radius: var(--radius);
  border: 1px solid var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--bg-elev));
}
.continue-card .cc-body { flex: 1 1 240px; }
.continue-card .cc-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 800; }
.progressbar { height: 6px; border-radius: 999px; background: var(--bg-sunk); overflow: hidden; margin-top: .5rem; }
.progressbar > span { display: block; height: 100%; background: var(--gold); }

/* ---------- Series grid ---------- */
.series-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.series-card {
  position: relative; text-decoration: none; color: inherit;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--bg-elev); box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
  display: flex; flex-direction: column;
}
.series-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.series-cover {
  aspect-ratio: 16 / 7; position: relative; display: flex; align-items: flex-end;
  padding: 1rem; color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
.series-cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.45));
}
.series-cover .shelf {
  position: relative; z-index: 1; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; opacity: .95;
}
.series-body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.series-body h3 { font-family: var(--font-read); font-size: 1.25rem; margin: 0; }
.series-body .promise { color: var(--ink-soft); font-size: .92rem; margin: 0; }
.series-meta { margin-top: auto; display: flex; align-items: center; gap: .6rem; font-size: .82rem; color: var(--ink-faint); }
.series-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }

/* ---------- Series / book detail ---------- */
.detail-hero {
  display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 720px) {
  .detail-hero.has-cover { grid-template-columns: 220px minmax(0, 1fr); }
}
.book-cover {
  aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); color: #fff; position: relative;
  display: flex; flex-direction: column; justify-content: space-between; padding: 1.1rem;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  border: 1px solid rgba(0,0,0,.2);
}
.book-cover .bc-series { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.book-cover .bc-title { font-family: var(--font-read); font-size: 1.5rem; line-height: 1.1; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.book-cover .bc-author { font-size: .82rem; opacity: .95; }
.book-cover .bc-num {
  position: absolute; top: .8rem; right: .9rem; font-size: .72rem; font-weight: 700;
  background: rgba(0,0,0,.35); padding: .2rem .5rem; border-radius: 999px;
}

.detail-title { font-family: var(--font-read); font-size: clamp(1.6rem, 4vw, 2.4rem); }
.detail-sub { color: var(--ink-soft); margin-top: -.3rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .8rem 0; }
.desc { font-size: 1.05rem; color: var(--ink); max-width: 62ch; }

.doors-panel { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.doors-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.door-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.door {
  display: flex; align-items: center; gap: .5rem; padding: .55rem .9rem;
  border-radius: 999px; border: 1px solid var(--line-strong); font-weight: 600; font-size: .9rem;
}
.door[data-live='false'] { opacity: .6; }
.door .door-ico { font-size: 1.05rem; }

/* Book list within a series */
.book-list { display: flex; flex-direction: column; gap: .8rem; }
.book-row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 1rem; align-items: center;
  padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: border-color .12s ease, transform .12s ease;
}
.book-row:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.book-spine {
  aspect-ratio: 2/3; border-radius: 6px; background: linear-gradient(150deg, var(--c1), var(--c2));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1rem;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.book-row .br-title { font-family: var(--font-read); font-size: 1.1rem; font-weight: 700; margin: 0; }
.book-row .br-desc { color: var(--ink-faint); font-size: .86rem; margin: .15rem 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-row .br-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
@media (max-width: 560px) {
  .book-row { grid-template-columns: 44px 1fr; }
  .book-row .br-right { grid-column: 1 / -1; flex-direction: row; align-items: center; }
}

/* ---------- Cards / callouts ---------- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); padding: 1.3rem; box-shadow: var(--shadow);
}
.callout {
  border: 1px solid var(--line-strong); border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem; background: var(--bg-sunk);
}
.callout h3 { margin: 0 0 .3rem; }
.muted { color: var(--ink-faint); }
.small { font-size: .85rem; }

/* ---------- Supporter page ---------- */
.price-card { text-align: center; max-width: 520px; margin: 0 auto; }
.price-tag { font-family: var(--font-read); font-size: 2.6rem; color: var(--gold-bright); }
.price-sub { color: var(--ink-faint); margin-top: -.4rem; }
.feature-list { list-style: none; padding: 0; margin: 1.2rem 0; text-align: left; display: grid; gap: .6rem; }
.feature-list li { display: flex; gap: .6rem; align-items: flex-start; }
.feature-list li::before { content: '✓'; color: var(--ok); font-weight: 900; }

.field { display: flex; flex-direction: column; gap: .35rem; text-align: left; margin: .8rem 0; }
.field label { font-weight: 600; font-size: .9rem; }
.field input {
  padding: .7rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font: inherit;
}
.field input:focus-visible { outline-offset: 0; border-color: var(--gold); }
.status-line { min-height: 1.4em; font-size: .9rem; }
.status-line.err { color: var(--danger); }
.status-line.ok { color: var(--ok); }

.supporter-badge {
  display: inline-flex; gap: .5rem; align-items: center; padding: .5rem .9rem;
  border-radius: 999px; background: color-mix(in srgb, var(--ok) 18%, var(--bg-elev));
  border: 1px solid var(--ok); color: var(--ink); font-weight: 600;
}

/* ---------- Reader ---------- */
body.reading { }
.reader-bar {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem clamp(.6rem, 3vw, 1.2rem);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.reader-bar .rb-title { font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.reader-bar .rb-spacer { flex: 1; }
.reader-bar select {
  font: inherit; padding: .4rem .5rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); max-width: 45vw;
}
.rb-btn {
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 999px;
  padding: .4rem .7rem; font-size: .85rem; font-weight: 600; display: inline-flex; gap: .35rem; align-items: center;
}
.rb-btn:hover { border-color: var(--line-strong); }

.reader-progress { height: 3px; background: var(--bg-sunk); position: sticky; top: 0; z-index: 46; }
.reader-progress > span { display: block; height: 100%; background: var(--gold); width: 0; }

.reader {
  --reader-fs: 1.15rem; --reader-lh: 1.7; --reader-width: 38rem;
  font-family: var(--font-read);
  max-width: var(--reader-width); margin: 0 auto;
  padding: 2.5rem clamp(1.1rem, 5vw, 2rem) 5rem;
  font-size: var(--reader-fs); line-height: var(--reader-lh); color: var(--ink);
}
.reader h1 { font-size: 1.9rem; }
.reader .ch-title { font-family: var(--font-read); font-size: 1.5rem; margin-top: 2rem; color: var(--ink); }
.reader p { margin: 0 0 1.1em; }
.reader .ch-kicker { font-family: var(--font-ui); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); }
.reader-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }

/* Reader themes (independent of site theme) */
.reader-scope[data-reader-theme='light'] { --bg: #f7f3ea; --bg-elev: #fffdf8; --ink: #23201a; --ink-soft: #5c554a; --line: #e0d7c4; }
.reader-scope[data-reader-theme='sepia'] { --bg: #f3e9d2; --bg-elev: #f7f0df; --ink: #40372a; --ink-soft: #6b5d47; --line: #e2d3af; }
.reader-scope[data-reader-theme='dark'] { --bg: #12100c; --bg-elev: #1a1712; --ink: #e7ddc7; --ink-soft: #b0a488; --line: #2a2519; }
.reader-scope { background: var(--bg); min-height: 100vh; }

/* Settings sheet */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60;
  display: grid; place-items: end center; padding: 0;
}
.sheet {
  background: var(--bg-elev); color: var(--ink); width: min(560px, 100%);
  border-radius: 18px 18px 0 0; border: 1px solid var(--line); border-bottom: 0;
  padding: 1.3rem clamp(1rem, 4vw, 1.6rem) 2rem; box-shadow: 0 -10px 40px rgba(0,0,0,.3);
  max-height: 85vh; overflow: auto;
}
.sheet h2 { font-size: 1.1rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.control-group { margin: 1rem 0; }
.control-group > .cg-label { font-weight: 700; font-size: .85rem; display: block; margin-bottom: .5rem; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.seg button { padding: .5rem .9rem; background: var(--bg); border: 0; border-right: 1px solid var(--line); font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); }
.stepper { display: inline-flex; align-items: center; gap: .8rem; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg); font-size: 1.2rem; }
.stepper output { min-width: 4ch; text-align: center; font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink); padding: .7rem 1.1rem;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 80; font-weight: 600; font-size: .9rem;
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }

/* ---------- Footer ---------- */
.sitefoot { border-top: 1px solid var(--line); background: var(--bg-elev); margin-top: 3rem; }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 1.4rem clamp(1rem, 4vw, 2rem);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-faint); }
.foot-links { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.foot-links a { color: var(--ink-soft); text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }
.version { font-variant: all-small-caps; letter-spacing: .05em; color: var(--ink-faint); border: 1px solid var(--line); padding: .05rem .4rem; border-radius: 6px; }

/* Reader chrome hides site footer/topbar */
body.reading .topbar, body.reading .sitefoot { display: none; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-faint); }
.divider { height: 1px; background: var(--line); border: 0; margin: 1.5rem 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: .5rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .series-card:hover, .book-row:hover { transform: none; }
}
