/* 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}

.reader-legend{margin-top:1.6rem;background:#fbf1dd;border:1px solid #e3d0ac;
  border-radius:.8rem;padding:.95rem 1rem}
.reader-legend .lg-row{display:flex;gap:.55rem;align-items:center;font-size:.8rem;
  color:#4a2c18;margin:.4rem 0}
.reader-switch{display:flex;align-items:center;gap:.6rem;margin-top:.9rem;padding-top:.85rem;
  border-top:1px dashed #e3d0ac;cursor:pointer;font-size:.82rem;color:#33170a;user-select:none}
.reader-switch input{position:absolute;opacity:0;width:0;height:0}
.reader-switch .track{width:38px;height:22px;border-radius:999px;background:#e3d0ac;
  position:relative;transition:background .2s;flex:none;border:1px solid #ecdcbd}
.reader-switch .track::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;
  border-radius:50%;background:#fff;transition:transform .2s;box-shadow:0 1px 2px rgba(0,0,0,.2)}
.reader-switch input:checked+.track{background:#1c5644}
.reader-switch input:checked+.track::after{transform:translateX(16px)}
.reader-switch input:focus-visible+.track{outline:2px solid #a24d1b;outline-offset:2px}

/* ── 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}
.reader-body td.cell-mark{text-align:center;white-space:nowrap}

/* confidence badges (pills) — emitted by render_reference() */
.mk{display:inline-flex;align-items:center;gap:.32rem;font-family:"Golos Text",system-ui,sans-serif;
  font-size:.68rem;font-weight:600;line-height:1;padding:.24rem .5rem .26rem;border-radius:999px;
  white-space:nowrap;vertical-align:.06em;border:1px solid transparent}
.mk .dot{width:.5rem;height:.5rem;border-radius:50%}
.mk-hi{color:#12483a;background:rgba(28,86,68,.12);border-color:rgba(28,86,68,.22)}
.mk-hi .dot{background:#1c5644}
.mk-med{color:#6f5011;background:rgba(154,116,52,.14);border-color:rgba(154,116,52,.26)}
.mk-med .dot{background:#9a7434}
.mk-lo{color:#7c2f10;background:rgba(162,77,27,.12);border-color:rgba(162,77,27,.24)}
.mk-lo .dot{background:#a24d1b}

/* mark chips in table cells */
.chip{display:inline-grid;place-items:center;width:1.5rem;height:1.5rem;border-radius:50%;
  font-size:.8rem;font-weight:700;margin:0 .1rem}
.chip.c-hi{color:#12483a;background:rgba(28,86,68,.16)}
.chip.c-med{color:#6f5011;background:rgba(154,116,52,.18)}
.chip.c-lo{color:#7c2f10;background:rgba(162,77,27,.16)}

/* "only verified" dimming — blocks marked by reader.js on load */
.reader-body.only-verified .reader-dim{opacity:.32;filter:saturate(.5)}
.reader-dim{transition:opacity .25s,filter .25s}

/* 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-dim,.reader-totop{transition:none}}
