/* =======================================================================
   LORECRAFT · DOCUMENT PAGE
   Layout of the pages that show a Markdown file from docs/ (regras.html,
   mecanicas.html, the Rules of the player's app): the list of sections on
   the left, the text on the right; one column on a phone, with the sections
   folded at the top. The Rules are numbered: each rule's number in the
   margin, the search of the rules above the sections, the icons of the
   terms and the cards the rules show.
   The page markup and the script are in shared/doc-page.js.
   ======================================================================= */
.wrap{padding-block:32px 96px; display:grid; grid-template-columns:200px minmax(0,1fr); gap:56px; align-items:start}
.wrap:has(.doc.numbered){grid-template-columns:260px minmax(0,1fr); gap:40px}

/* ---------- list of sections ---------- */
.toc{position:sticky; top:80px; max-height:calc(100vh - 104px); overflow:auto; font-size:15px}
.toc summary{display:none}
.toc ol{margin:0; padding:0; list-style:none}
.toc a{display:block; padding:5px 0 5px 12px; border-left:2px solid var(--line); color:var(--muted); text-decoration:none; line-height:1.3}
.toc a:hover{color:var(--fg); border-left-color:var(--muted)}
.toc a.on{color:var(--fg); border-left-color:var(--accent); font-weight:700}
.toc ol ol{margin:0 0 6px}
.toc ol ol a{padding:3px 0 3px 24px; font-size:14px}
.toc .tn{display:inline-block; min-width:2.2em; margin-right:4px; color:var(--accent); font-variant-numeric:tabular-nums; font-weight:700}
.toc ol ol .tn{min-width:2.6em; font-weight:500}

/* the numbered Rules: the search and the sections together, beside the text */
.doc-side{position:sticky; top:72px; max-height:calc(100vh - 96px); overflow:auto; display:grid; gap:18px; align-content:start; padding-right:4px}
.doc-side .toc{position:static; max-height:none; overflow:visible}
.rule-search{display:grid; gap:6px}
.rs-label{font:700 12px/1.2 var(--sans); letter-spacing:.14em; text-transform:uppercase; color:var(--muted)}
.rule-search input{width:100%; box-sizing:border-box; font:400 15px/1.2 var(--sans); color:var(--fg); background:var(--surface); border:1px solid var(--line);
  border-radius:10px; padding:10px 12px}
.rule-search input:focus-visible{outline:2px solid var(--accent); outline-offset:1px}
.rs-count{margin:0; font-size:13px; color:var(--muted)}
.rs-count:empty{display:none}
.rs-hits{margin:0; padding:0; list-style:none; display:grid; gap:2px}
.rs-hits a{display:block; padding:7px 9px; border-radius:8px; color:var(--fg); text-decoration:none; font-size:13.5px; line-height:1.4}
.rs-hits a:hover, .rs-hits a:focus-visible{background:var(--chip); outline:none}
.rs-hits b{color:var(--accent); margin-right:4px; font-variant-numeric:tabular-nums}
.rs-hits mark{background:color-mix(in srgb, var(--accent) 26%, transparent); color:inherit; border-radius:3px; padding:0 1px}
.rs-more{padding:6px 9px; font-size:13px; color:var(--muted)}

/* ---------- the document ---------- */
.doc{max-width:74ch}
.doc > * + *{margin-top:14px}
.doc h1 + p{color:var(--muted); font-size:15px}
.doc h2{margin-top:48px; padding-top:28px; border-top:1px solid var(--line)}
/* the document's own headings and lists, never the cards it shows: a card's name is an h3, and the backs have lists */
.doc h3:not(.doc-cards *){margin-top:28px; font:700 20px/1.2 var(--display)}
.doc :is(ul, ol):not(.doc-cards *){padding-left:1.3em}
.doc li + li:not(.doc-cards *){margin-top:6px}
.doc li:has(> input[type="checkbox"]){list-style:none}
.doc input[type="checkbox"]{margin:0 8px 0 -1.3em}
.table-wrap{overflow-x:auto}
.doc table{width:100%; border-collapse:collapse; font-size:15px; line-height:1.4}
.doc th{padding:0 12px 8px 0; border-bottom:1px solid var(--line); text-align:left; vertical-align:bottom; font:700 12px/1.2 var(--sans); letter-spacing:.12em; text-transform:uppercase; color:var(--muted)}
.doc td{padding:9px 12px 9px 0; border-bottom:1px solid var(--line); vertical-align:top}
.doc .terms td:first-child{font-weight:700; white-space:nowrap}
.doc blockquote{margin:14px 0 0; padding:12px 16px; border-left:3px solid var(--accent); border-radius:0 8px 8px 0; background:var(--surface)}
.doc code{font-size:.9em; padding:1px 5px; border-radius:4px; background:var(--chip)}
.status{color:var(--muted)}

/* a document with wide tables (many columns) uses the whole column */
.doc.wide{max-width:none}

/* ---------- the numbered Rules: each rule's number in the margin, a link to it ---------- */
.doc.numbered{position:relative; max-width:calc(76ch + 78px); padding-left:78px}
.doc.numbered > h1{font:700 clamp(36px,5vw,52px)/1.05 var(--display)}
.doc-count{color:var(--muted); font-size:14px}
.doc .hn{margin-right:.35em; color:var(--accent); font-variant-numeric:tabular-nums}
.doc h2 .hn{display:inline-block; min-width:1.2em}
/* the number sits in the margin, at the height of its rule's first line (its containing block is the document) */
.rn{position:absolute; left:0; width:66px; padding-top:.15em; text-align:right; font:600 12px/1.6 var(--sans); color:var(--muted);
  font-variant-numeric:tabular-nums; text-decoration:none; white-space:nowrap}
.rn:hover, .rn:focus-visible{color:var(--accent); text-decoration:underline}
.doc li .rn{font-weight:500}
.doc [data-rule]{scroll-margin-top:96px}
.doc h2, .doc h3{scroll-margin-top:80px}
.flash{animation:rule-flash 2.6s ease-out}
.doc tr.flash > td{animation:rule-flash 2.6s ease-out}
@keyframes rule-flash{0%, 30%{background:color-mix(in srgb, var(--accent) 22%, transparent)} 100%{background:transparent}}
@media (prefers-reduced-motion: reduce){ .flash, .doc tr.flash > td{animation:none; background:color-mix(in srgb, var(--accent) 16%, transparent)} }

/* steps: an ordered list of the Rules reads as a sequence, each step in a circle */
/* (only the document's own lists, never one inside a card; floated, not positioned: the rule's number keeps the document as its containing block) */
.doc.numbered > ol{list-style:none; padding-left:0; counter-reset:step}
.doc.numbered > ol > li{counter-increment:step; padding-left:40px; min-height:28px}
.doc.numbered > ol > li::before{content:counter(step); float:left; margin:-2px 0 0 -40px; width:28px; height:28px; border-radius:50%; display:grid; place-items:center;
  background:var(--chip); color:var(--fg); font:700 14px/1 var(--sans); box-shadow:inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent)}

/* ---------- the icons of the terms and the cards the rules show ---------- */
.doc-ic{display:inline-grid; place-items:center; width:1.3em; height:1.3em; margin-right:.4em; vertical-align:-.28em; color:var(--accent)}
.doc-ic svg{width:100%; height:auto; max-height:100%}
.doc-ic.color{border-radius:50%; width:1.45em; height:1.45em; vertical-align:-.36em}
.doc-ic.color svg{width:62%; height:62%}
.doc-ic.res{width:auto; height:auto; vertical-align:baseline}
.doc-ic.rarity-mark{background:var(--rc); -webkit-mask:url("../../art/icones/lorecraft-emblem.svg") center / contain no-repeat;
  mask:url("../../art/icones/lorecraft-emblem.svg") center / contain no-repeat}
.doc-cards{display:flex; flex-wrap:wrap; gap:20px; margin:22px 0 6px; padding:18px; border-radius:14px; background:var(--surface); border:1px solid var(--line)}
.doc-card{width:min(232px, calc(50% - 10px)); display:grid; gap:8px; margin:0; border-radius:10px; cursor:zoom-in}
.doc-card:focus-visible{outline:2px solid var(--accent); outline-offset:4px}
.doc-card figcaption{font-size:13px; line-height:1.3; color:var(--muted); text-align:center}
.doc-toast{position:fixed; left:50%; bottom:24px; transform:translateX(-50%); z-index:30; padding:10px 16px; border-radius:999px; background:var(--fg); color:var(--bg);
  font:600 14px/1.2 var(--sans); box-shadow:0 8px 24px rgb(0 0 0 / .25)}

/* ---------- Glossary, A to Z (regras.html) ---------- */
.letters{display:flex; flex-wrap:wrap; gap:6px}
.letters a{min-width:34px; padding:4px 0; border-radius:6px; background:var(--chip); color:var(--fg); text-align:center; text-decoration:none; font:700 15px/1.3 var(--display)}
.letters a:hover{background:var(--line)}
.glossary h3{margin-top:28px; font:700 22px/1 var(--display); color:var(--accent)}
.glossary dl{margin:8px 0 0; display:grid; grid-template-columns:minmax(120px,190px) minmax(0,1fr)}
.glossary dt, .glossary dd{padding:10px 0; border-top:1px solid var(--line)}
.glossary dt{padding-right:16px; font-weight:700}
.glossary dd{margin:0}
.glossary .src{display:block; margin-top:2px; font-size:13px; color:var(--muted); text-decoration:none}
.glossary .src:hover{color:var(--fg)}
.glossary dt:target, .glossary dt:target + dd, .glossary dt.flash, .glossary dt.flash + dd{background:color-mix(in srgb, var(--accent) 14%, transparent)}

@media (max-width:820px){
  .wrap, .wrap:has(.doc.numbered){grid-template-columns:minmax(0,1fr); gap:24px}
  .toc{position:static; max-height:none; padding:10px 14px; border:1px solid var(--line); border-radius:8px}
  .toc summary{display:list-item; cursor:pointer; font-weight:700}
  .toc ol{margin-top:8px}
  .doc-side{position:static; max-height:none; overflow:visible; padding-right:0}
  .rs-hits{max-height:50vh; overflow:auto}
  .doc.numbered{padding-left:0}
  .rn{position:static; display:inline-block; width:auto; margin-right:8px; padding:0 6px; border-radius:6px; background:var(--chip); font-size:11.5px; line-height:1.6; vertical-align:1px}
  .glossary dl{grid-template-columns:minmax(0,1fr)}
  .glossary dd{padding-top:0; border-top:0}
}
