/* Loracle Books: shared styles for book, trope and subgenre pages.
   Layout: the home page's dark hero shrinks to a header (cover + key facts); below it, a reading column beside a sticky buy box. */
:root {
  --bg: #fbf3f1;
  --surface: #ffffff;
  --surface-2: #f6e7ea;
  --ink: #2b1220;
  --muted: #7a5766;
  --line: rgba(43, 18, 32, 0.13);
  --gold: #9a6516;
  --gold-soft: rgba(154, 101, 22, 0.14);
  --rose: #b3365c;
  --rose-ink: #ffffff;
  --warn: #9a4a10;
  --warn-soft: #fbeadb;
  --hero-a: #3a1226;
  --hero-b: #22091a;
  --hero-ink: #f8ebee;
  --hero-muted: #d8b6c3;
  --shadow: 0 1px 2px rgba(43,18,32,.06), 0 10px 30px rgba(43,18,32,.08);
  --font-display: "Gloock", "Didot", "Bodoni 72", Georgia, serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a0a12; --surface: #26111c; --surface-2: #331826; --ink: #f7e9ee; --muted: #c9a5b3;
    --line: rgba(247, 233, 238, 0.13); --gold: #e6bd72; --gold-soft: rgba(230, 189, 114, 0.14);
    --rose: #e87797; --rose-ink: #2a0d1a; --warn: #f0b27e; --warn-soft: rgba(240, 178, 126, 0.13);
    --hero-a: #3d1328; --hero-b: #1a0a12; --hero-ink: #f8ebee; --hero-muted: #d2adbc;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a0a12; --surface: #26111c; --surface-2: #331826; --ink: #f7e9ee; --muted: #c9a5b3;
  --line: rgba(247, 233, 238, 0.13); --gold: #e6bd72; --gold-soft: rgba(230, 189, 114, 0.14);
  --rose: #e87797; --rose-ink: #2a0d1a; --warn: #f0b27e; --warn-soft: rgba(240, 178, 126, 0.13);
  --hero-a: #3d1328; --hero-b: #1a0a12; --hero-ink: #f8ebee; --hero-muted: #d2adbc;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font-body); -webkit-font-smoothing: antialiased; padding-top: env(safe-area-inset-top, 0px); }
img { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 20px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; text-wrap: balance; margin: 0; line-height: 1.12; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.eyebrow { font-size: .74rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.muted { color: var(--muted); }

/* Header */
.hero { background: radial-gradient(120% 110% at 30% 0%, var(--hero-a), var(--hero-b)); color: var(--hero-ink); position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1.4px); background-size: 46px 46px; opacity: .08; pointer-events: none; }
.hero .eyebrow { color: #e6bd72; }
.nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 22px; position: relative; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-size: 1.55rem; color: var(--hero-ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand svg { width: 26px; height: 26px; }
.nav-links { display: flex; gap: 22px; font-size: .92rem; }
.nav-links a { color: var(--hero-muted); text-decoration: none; }
.nav-links a:hover { color: var(--hero-ink); }
.crumbs { position: relative; font-size: .85rem; color: var(--hero-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--hero-muted); text-decoration: none; }
.crumbs a:hover { color: #e6bd72; }

.book-head { position: relative; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 36px; align-items: end; padding-block: 26px 48px; }
.cover { aspect-ratio: 2 / 3; max-width: 100%; border-radius: 8px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 18px 16px; color: #fff8f0; box-shadow: 0 24px 50px rgba(0,0,0,.45); }
.cover::after { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(255,240,215,.45); border-radius: 5px; z-index: 3; pointer-events: none; }
.cover .ct { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.1; position: relative; overflow-wrap: anywhere; }
.cover .ca { font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; opacity: .85; position: relative; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; }
.head-text { min-width: 0; }
.book-head h1 { font-size: clamp(2.2rem, 6vw, 4rem); margin: 10px 0 8px; overflow-wrap: anywhere; }
.byline { color: var(--hero-muted); font-size: 1.05rem; margin: 0 0 20px; }
.byline strong { color: var(--hero-ink); font-weight: 600; }
.glance { display: flex; flex-wrap: wrap; gap: 10px; }
.chipd { border: 1px solid rgba(248,235,238,.22); border-radius: 999px; padding: 6px 14px; font-size: .88rem; display: inline-flex; align-items: center; gap: 8px; color: var(--hero-ink); }
.chipd .flame path { fill: rgba(248,235,238,.25); }
.chipd .flame.lit path { fill: #e6bd72; }

.list-head { position: relative; padding-block: 30px 52px; }
.list-head > * { max-width: 760px; }
.list-head h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); margin: 10px 0 12px; }
.lede { color: var(--hero-muted); max-width: 560px; margin: 0; font-size: 1.05rem; }
.list-head .btn { margin-top: 22px; display: inline-flex; }

/* Body */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; padding-block: 48px 20px; align-items: start; }
.main { display: grid; gap: 44px; min-width: 0; }
.main section { display: grid; gap: 14px; min-width: 0; }
.main h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); }
.main p { margin: 0; max-width: 64ch; }

.faq { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.faq div { padding: 16px 20px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.faq div:first-child { border-top: 0; }
.faq h3 { font-family: var(--font-body); font-weight: 700; font-size: 1rem; line-height: 1.4; }
.faq p { font-size: .96rem; }

.meter { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.meter div { padding: 14px 14px 16px; border-right: 1px solid var(--line); display: grid; gap: 4px; align-content: start; }
.meter div:last-child { border-right: 0; }
.meter b { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; }
.meter small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.meter .on { background: var(--surface-2); box-shadow: inset 0 -3px 0 var(--rose); }
.meter .on small { color: var(--ink); }
.flame { width: 15px; height: 15px; display: block; }
.flame path { fill: var(--line); }
.flame.lit path { fill: var(--rose); }
.fl { display: flex; gap: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--surface-2); border-radius: 8px; padding: 5px 12px; font-size: .9rem; text-decoration: none; }
a.tag:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
details.cw { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.cw summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.cw summary::-webkit-details-marker { display: none; }
details.cw summary::after { content: "Hide"; color: var(--muted); font-weight: 500; font-size: .88rem; }
details.cw:not([open]) summary::after { content: "Show"; }
details.cw .tags { padding: 0 18px 18px; }

.series { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.series li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.series li:first-child { border-top: 0; }
.series .n { font-family: var(--font-display); font-size: 1.2rem; color: var(--gold); }
.series .here { background: var(--surface-2); font-weight: 600; }
.series a { text-underline-offset: 3px; }
.series small { color: var(--muted); }

/* Mini book cards (similar books, list pages) */
.similar, .list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.list-grid { padding-block: 44px 8px; }
.mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 14px; box-shadow: var(--shadow); min-width: 0; align-items: start; transition: border-color .15s; }
.mini:hover { border-color: var(--gold); }
.mc { aspect-ratio: 2 / 3; width: 76px; max-width: 100%; border-radius: 6px; position: relative; overflow: hidden; }
.mc .ca, .mc .ct { display: none; }
.mc img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mb { display: grid; gap: 4px; font-size: .86rem; min-width: 0; }
.mt { font-family: var(--font-display); font-weight: 400; font-size: 1.12rem; line-height: 1.2; overflow-wrap: anywhere; }
.mh { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.why { color: var(--gold); font-weight: 600; font-size: .8rem; }

.trope-cloud { display: flex; flex-wrap: wrap; gap: 10px; padding-block: 44px 8px; }
.trope-cloud a { display: inline-flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; text-decoration: none; }
.trope-cloud a:hover { border-color: var(--gold); }
.trope-cloud small { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Buy box */
aside { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 20px); display: grid; gap: 16px; min-width: 0; }
.buy { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.buy h3 { font-size: 1.3rem; overflow-wrap: anywhere; }
.btn { border: 0; cursor: pointer; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; font-size: .96rem; min-height: 46px; display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
.btn-rose { background: var(--rose); color: var(--rose-ink); }
.btn-rose:hover { filter: brightness(1.07); }
.btn-quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-gold { background: #e6bd72; color: #2a0d1a; }
.btn-gold:hover { background: #f0cd8c; }
.facts { display: grid; gap: 8px; font-size: .9rem; margin: 6px 0 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 600; }
.facts a { text-underline-offset: 3px; }

.cta { margin-top: 56px; background: radial-gradient(120% 140% at 80% 0%, var(--hero-a), var(--hero-b)); color: var(--hero-ink); border-radius: 20px; padding: 32px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.cta h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.cta p { margin: 6px 0 0; color: var(--hero-muted); }

footer { margin-top: 64px; border-top: 1px solid var(--line); padding-block: 28px calc(40px + env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: .85rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
footer p { margin: 0; max-width: 620px; }
footer a { color: inherit; text-underline-offset: 2px; }
.brand-sm { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); text-decoration: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 36px; }
  aside { position: static; order: -1; }
}
@media (max-width: 620px) {
  .nav-links { display: none; }
  .book-head { grid-template-columns: 116px minmax(0, 1fr); gap: 20px; align-items: start; }
  .cover { padding: 12px 10px; }
  .cover .ct { font-size: 1rem; }
  .cover .ca { font-size: .6rem; }
  .meter { grid-template-columns: 1fr; }
  .meter div { border-right: 0; border-bottom: 1px solid var(--line); grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; }
  .meter div:last-child { border-bottom: 0; }
  .series li { grid-template-columns: 28px minmax(0, 1fr); }
  .series li small { grid-column: 2; }
  .cta { padding: 24px; }
}
@media (max-width: 400px) { .book-head { grid-template-columns: 1fr; } .cover { width: 140px; } }
