/* Reader for the reference section (encyclopedia + care). Hand-written,
   palette hardcoded from the cognac-cream system (site.css). Not Tailwind.
   Fonts (Prata / Golos Text) come from base.html. */

/* reading-progress bar */
.reader-progress{position:fixed;top:0;left:0;height:3px;width:0;z-index:60;
  background:linear-gradient(90deg,#c99f5e,#a24d1b);transition:width .1s linear}

.reader-wrap{max-width:75rem;margin:0 auto;padding:2.5rem 1.5rem 5rem}
.reader-meta{display:flex;flex-wrap:wrap;gap:.5rem .9rem;margin-top:1rem;
  font-family:"Golos Text",system-ui,sans-serif;font-size:.82rem;color:#8a6849}
.reader-meta b{color:#33170a;font-weight:600}
.reader-meta .sep{color:#e3d0ac}

.reader-grid{display:grid;gap:2.6rem;margin-top:2rem}
@media(min-width:1024px){.reader-grid{grid-template-columns:17rem 1fr}}

/* ── rail (TOC + legend + switch) ── */
.reader-rail{align-self:start;font-family:"Golos Text",system-ui,sans-serif}
@media(min-width:1024px){.reader-rail{position:sticky;top:5rem;
  max-height:calc(100vh - 6.5rem);overflow:auto;padding-right:.3rem}}
.reader-toc-toggle{display:none}
.reader-rail h4{font-size:.72rem;text-transform:uppercase;letter-spacing:.16em;
  color:#9a7434;margin:0 0 .7rem;font-weight:600}
.reader-toc{font-size:.86rem;line-height:1.45}
.reader-toc .toc>ul{list-style:none;margin:0;padding:0}
.reader-toc ul{list-style:none;margin:0;padding:0}
.reader-toc ul ul{margin:.1rem 0 .35rem .7rem}
.reader-toc a{display:block;color:#8a6849;text-decoration:none;padding:.28rem .55rem;
  border-radius:.4rem;border-left:2px solid transparent;transition:color .15s,background .15s,border-color .15s}
.reader-toc a:hover{color:#33170a;background:rgba(238,217,182,.5)}
.reader-toc a.active{color:#a24d1b;border-left-color:#a24d1b;background:rgba(238,217,182,.7);font-weight:600}

/* ── body ── */
.reader-body{min-width:0;max-width:44rem}
.reader-body p,.reader-body li{color:#4a2c18;line-height:1.75}
.reader-body p{font-size:1rem}
.reader-body a{color:#a24d1b;text-decoration:underline;text-decoration-color:rgba(162,77,27,.4);
  text-underline-offset:3px}
.reader-body a:hover{text-decoration-color:#a24d1b}
.reader-body strong{color:#33170a}

/* headings: hairline + rhythm, drop-cap on the first paragraph after h2 */
.reader-body h2{font-family:"Prata",Georgia,serif;font-weight:400;font-size:1.95rem;
  line-height:1.12;color:#33170a;margin:3rem 0 .9rem;padding-top:1.6rem;
  border-top:1px solid #e3d0ac;letter-spacing:-.01em;scroll-margin-top:5rem;text-wrap:balance}
.reader-body h2:first-child{border-top:0;padding-top:0;margin-top:0}
.reader-body h3{font-family:"Prata",Georgia,serif;font-weight:400;font-size:1.3rem;
  color:#33170a;margin:1.8rem 0 .55rem;scroll-margin-top:5rem}
.reader-body h4{font-family:"Golos Text",system-ui,sans-serif;font-weight:700;
  color:#33170a;margin:1.3rem 0 .4rem}
.reader-body h2+p::first-letter{font-family:"Prata",Georgia,serif;float:left;font-size:3.1rem;
  line-height:.82;padding:.28rem .5rem 0 0;color:#a24d1b}

/* lists with brass bullets */
.reader-body ul{list-style:none;padding-left:0;margin:1rem 0}
.reader-body ul>li{position:relative;padding-left:1.35rem;margin:.5rem 0}
.reader-body ul>li::before{content:"";position:absolute;left:.2rem;top:.68em;width:.42rem;
  height:.42rem;border-radius:50%;background:#c99f5e}
.reader-body ol{padding-left:1.4rem;margin:1rem 0}
.reader-body ol>li{margin:.5rem 0}
.reader-body ol>li::marker{color:#9a7434;font-variant-numeric:tabular-nums}

/* blockquote -> callout card (variants added by reader.js) */
.reader-body blockquote{margin:1.5rem 0;padding:1rem 1.2rem;border:1px solid #e3d0ac;
  background:rgba(238,217,182,.5);border-radius:.85rem;border-left:4px solid #c99f5e}
.reader-body blockquote p{margin:.35rem 0}
.reader-body blockquote.cw-intro{background:#fbf1dd;border-left-color:#a24d1b}
.reader-body blockquote.cw-warn{background:rgba(162,77,27,.08);border-color:rgba(162,77,27,.28);
  border-left-color:#a24d1b}

/* tables */
.reader-tablescroll{overflow-x:auto;margin:1.4rem 0;border:1px solid #e3d0ac;border-radius:.75rem}
.reader-body table{border-collapse:collapse;width:100%;font-size:.92rem;min-width:32rem}
.reader-body thead th{background:#eed9b6;text-align:left;font-family:"Golos Text",system-ui,sans-serif;
  font-weight:600;color:#33170a;padding:.65rem .8rem;border-bottom:1px solid #e3d0ac}
.reader-body td{padding:.65rem .8rem;border-bottom:1px solid #ecdcbd;vertical-align:top;color:#4a2c18}
.reader-body tbody tr:nth-child(even){background:rgba(238,217,182,.28)}
.reader-body tbody tr:last-child td{border-bottom:0}

/* explanatory schematics (plates of swatches + labelled diagrams) */
.reader-body .enc-fig{margin:1.8rem 0}
.reader-body .enc-fig figcaption{font-family:"Golos Text",system-ui,sans-serif;font-size:.82rem;
  color:#8a6849;text-align:center;margin-top:.7rem}
.reader-body .enc-plate{display:grid;grid-template-columns:repeat(3,1fr);gap:.9rem;margin:0}
.reader-body .enc-swatch{display:flex;flex-direction:column;background:#fbf1dd;border:1px solid #e3d0ac;
  border-radius:.7rem;overflow:hidden}
.reader-body .enc-swatch img{width:100%;aspect-ratio:1;object-fit:cover;display:block;background:#efe2c8}
.reader-body .enc-swatch span{padding:.5rem .6rem;font-family:"Golos Text",system-ui,sans-serif;
  font-size:.82rem;font-weight:600;color:#33170a;line-height:1.2}
.reader-body .enc-swatch small{display:block;font-weight:400;color:#8a6849;font-size:.74rem;margin-top:.15rem}
.reader-body .enc-diagram{position:relative;max-width:27rem;margin:0 auto;border:1px solid #e3d0ac;
  border-radius:.9rem;overflow:hidden;background:#fbf1dd}
.reader-body .enc-diagram img{width:100%;display:block}
.reader-body .enc-mk{position:absolute;width:1.5rem;height:1.5rem;transform:translate(-50%,-50%);
  border-radius:50%;background:#a24d1b;color:#fff;font-family:"Golos Text",system-ui,sans-serif;
  font-size:.82rem;font-weight:700;display:grid;place-items:center;box-shadow:0 1px 4px rgba(0,0,0,.35)}
.reader-body .enc-legend{list-style:none;margin:.85rem 0 0;padding:0;
  font-family:"Golos Text",system-ui,sans-serif;font-size:.86rem}
.reader-body .enc-legend li{display:flex;gap:.55rem;align-items:baseline;margin:.32rem 0;color:#4a2c18}
.reader-body .enc-legend b{display:inline-grid;place-items:center;flex:none;width:1.35rem;height:1.35rem;
  border-radius:50%;background:#eed9b6;color:#7c2f10;font-size:.76rem;font-weight:700}
@media(max-width:560px){.reader-body .enc-plate{grid-template-columns:repeat(2,1fr)}}

/* back to top */
.reader-totop{position:fixed;right:1.3rem;bottom:1.3rem;width:2.8rem;height:2.8rem;border-radius:50%;
  background:#251106;color:#f6e6cc;border:none;cursor:pointer;font-size:1.1rem;display:grid;
  place-items:center;opacity:0;pointer-events:none;transition:opacity .25s,background .2s;z-index:40;
  box-shadow:0 8px 20px rgba(0,0,0,.25)}
.reader-totop.show{opacity:1;pointer-events:auto}
.reader-totop:hover{background:#a24d1b}

/* mobile: with JS the rail collapses into a disclosure; WITHOUT JS the TOC
   stays a plain visible list (the toggle is gated on the .js class). */
@media(max-width:1023px){
  .reader-rail-title{display:none}
  .reader-rail.js .reader-toc-toggle{display:flex;align-items:center;justify-content:space-between;
    width:100%;background:#fbf1dd;border:1px solid #e3d0ac;border-radius:.7rem;padding:.7rem .95rem;
    font-family:"Golos Text",system-ui,sans-serif;font-size:.9rem;color:#33170a;cursor:pointer}
  .reader-toc-toggle .chev{transition:transform .2s}
  .reader-rail.open .reader-toc-toggle .chev{transform:rotate(180deg)}
  .reader-rail.js .reader-rail-body{display:none;margin-top:.6rem}
  .reader-rail.js.open .reader-rail-body{display:block}
}
@media(prefers-reduced-motion:reduce){.reader-progress,.reader-totop{transition:none}}

/* ── Dark theme overrides (reader.css hardcodes hex; mirror atlas espresso-dark) ── */
:root[data-theme="dark"] .reader-meta{color:#a98f6e}
:root[data-theme="dark"] .reader-meta b{color:#f2e7d5}
:root[data-theme="dark"] .reader-meta .sep{color:#3b2c1c}
:root[data-theme="dark"] .reader-rail h4{color:#d8b16f}
:root[data-theme="dark"] .reader-toc a{color:#a98f6e}
:root[data-theme="dark"] .reader-toc a:hover{color:#f2e7d5;background:rgba(44,32,22,.6)}
:root[data-theme="dark"] .reader-toc a.active{color:#e08a4f;border-left-color:#e08a4f;background:rgba(44,32,22,.8)}
:root[data-theme="dark"] .reader-body p,
:root[data-theme="dark"] .reader-body li{color:#d9c6a8}
:root[data-theme="dark"] .reader-body a{color:#e08a4f;text-decoration-color:rgba(224,138,79,.45)}
:root[data-theme="dark"] .reader-body a:hover{text-decoration-color:#e08a4f}

/* remaining reader elements (headings, lists, blockquotes, tables, figures, mobile toc toggle) */
:root[data-theme="dark"] .reader-body strong{color:#f2e7d5}
:root[data-theme="dark"] .reader-body h2{color:#f2e7d5;border-top-color:#3b2c1c}
:root[data-theme="dark"] .reader-body h3{color:#f2e7d5}
:root[data-theme="dark"] .reader-body h4{color:#f2e7d5}
:root[data-theme="dark"] .reader-body h2+p::first-letter{color:#e08a4f}
:root[data-theme="dark"] .reader-body ul>li::before{background:#d8b16f}
:root[data-theme="dark"] .reader-body ol>li::marker{color:#d8b16f}
:root[data-theme="dark"] .reader-body blockquote{border-color:#3b2c1c;background:#2c2016;border-left-color:#d8b16f}
:root[data-theme="dark"] .reader-body blockquote.cw-intro{background:#221812;border-left-color:#e08a4f}
:root[data-theme="dark"] .reader-body blockquote.cw-warn{background:rgba(224,138,79,.12);border-color:rgba(224,138,79,.35);border-left-color:#e08a4f}
:root[data-theme="dark"] .reader-tablescroll{border-color:#3b2c1c}
:root[data-theme="dark"] .reader-body thead th{background:#2c2016;color:#f2e7d5;border-bottom-color:#3b2c1c}
:root[data-theme="dark"] .reader-body td{border-bottom-color:#3b2c1c;color:#d9c6a8}
:root[data-theme="dark"] .reader-body tbody tr:nth-child(even){background:rgba(44,32,22,.5)}
:root[data-theme="dark"] .reader-body .enc-fig figcaption{color:#a98f6e}
:root[data-theme="dark"] .reader-body .enc-swatch{background:#221812;border-color:#3b2c1c}
:root[data-theme="dark"] .reader-body .enc-swatch img{background:#2c2016}
:root[data-theme="dark"] .reader-body .enc-swatch span{color:#f2e7d5}
:root[data-theme="dark"] .reader-body .enc-swatch small{color:#a98f6e}
:root[data-theme="dark"] .reader-body .enc-diagram{border-color:#3b2c1c;background:#221812}
:root[data-theme="dark"] .reader-body .enc-legend li{color:#d9c6a8}
:root[data-theme="dark"] .reader-body .enc-legend b{background:#2c2016;color:#e08a4f}
:root[data-theme="dark"] .reader-rail.js .reader-toc-toggle{background:#2c2016;border-color:#3b2c1c;color:#f2e7d5}
/* page title uses Tailwind `text-ink` (doesn't flip) → force cream in dark */
:root[data-theme="dark"] .reader-wrap h1{color:#f2e7d5}
