/* ══════════════════════════════════════════
   WFRP Resources – main.css
   Light/Dark theme via [data-theme] + CSS vars
   Mobile-first, responsive
   ══════════════════════════════════════════ */

/* ── Reset (Meyer v2.0 condensed) ── */
*,*::before,*::after{box-sizing:border-box}
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,
strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,
label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,
details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,
section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;vertical-align:baseline}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
ol,ul{list-style:none}
blockquote,q{quotes:none}
blockquote::before,blockquote::after,q::before,q::after{content:""}

/* ── Theme variables ── */
:root,
[data-theme="light"] {
  --bg:            #f8faf5;
  --bg-surface:    #ffffff;
  --bg-card:       #f0e6d2;
  --bg-header:     #2c1810;
  --bg-accent:     #8b4513;
  --bg-code:       #fdf6ec;
  --text:          #33415b;
  --text-heading:  #ffffff;
  --text-muted:    #64748b;
  --text-strong:   #111827;
  --text-code:     #228b22;
  --border:        #d4a574;
  --border-subtle: #e2e8f0;
  --link:          #8b4513;
  --link-hover:    #a0522d;
  --shadow:        rgba(0,0,0,.08);
  --mermaid-bg:    #ffffff;
  --mermaid-node:  #f8fafc;
  --mermaid-stroke:#94a3b8;
  --mermaid-text:  #1f2937;
  --table-border:  #8b4513;
  --blockquote-bg: #fdf6ec;
}

[data-theme="dark"] {
  --bg:            #1a1210;
  --bg-surface:    #2a1f1a;
  --bg-card:       #3a2a20;
  --bg-header:     #0f0a08;
  --bg-accent:     #b5651d;
  --bg-code:       #2a2018;
  --text:          #e8ddd0;
  --text-heading:  #f0e6d2;
  --text-muted:    #a89880;
  --text-strong:   #f5efe8;
  --text-code:     #7dce82;
  --border:        #6b4830;
  --border-subtle: #4a3828;
  --link:          #d4915a;
  --link-hover:    #e8a870;
  --shadow:        rgba(0,0,0,.3);
  --mermaid-bg:    #2a1f1a;
  --mermaid-node:  #3a2a20;
  --mermaid-stroke:#6b4830;
  --mermaid-text:  #e8ddd0;
  --table-border:  #6b4830;
  --blockquote-bg: #2a2018;
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  transition: background-color .25s, color .25s;
}

strong, b { font-weight: 700; color: var(--text-strong); }
sup { font-size: .75em; vertical-align: super; }
sub { font-size: .75em; vertical-align: sub; }

a { color: var(--link); transition: color .2s; }
a:hover { color: var(--link-hover); }

/* ── Site header (injected by site.js) ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 3px solid var(--bg-accent);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.site-brand {
  color: #f0e6d2 !important;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .02em;
}
.site-brand:hover { color: #fff !important; }

.header-links {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.header-links a {
  color: #d4a574;
  text-decoration: none;
  font-size: .85rem;
  padding: .25rem .5rem;
  border-radius: 4px;
  transition: background .2s, color .2s;
}
.header-links a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.theme-btn {
  background: var(--bg-accent);
  color: #fff;
  border: none;
  padding: .35rem .75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .2s;
  white-space: nowrap;
}
.theme-btn:hover { filter: brightness(1.15); }

/* ── Typography ── */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-heading);
  background: var(--bg-accent);
  padding: .75rem 1.25rem;
  margin: 1.5rem 0 1rem;
  border-radius: 6px;
}

h1 { font-size: 1.75rem; text-align: center; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.05rem; }

/* ── Content container (content pages) ── */
.content-wrap,
body > h1:first-of-type,
body > h2,
body > h3,
body > h4,
body > p,
body > ul,
body > ol,
body > dl,
body > pre,
body > blockquote,
body > table,
body > canvas,
body > .mermaid,
body > .mermaid_container,
body > .mermaid-diagram,
body > svg {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

p {
  margin: .75rem 0;
  padding: 0 1.5rem;
}

/* ── Lists ── */
ol li { list-style-type: decimal; }
ul li { list-style-type: disc; }
dl, ol, ul, li {
  margin-left: 2.5rem;
  padding-top: .35rem;
}
ul li ul li { margin-left: 0; }
dd { margin-left: 1.5rem; padding-bottom: .6rem; }

/* ── Code ── */
code, pre {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-code);
  color: var(--text-code);
  border-radius: 4px;
}

pre {
  padding: 1rem 1.25rem;
  margin: 1rem 1.5rem;
  overflow-x: auto;
  line-height: 1.55;
  border: 1px solid var(--border-subtle);
}

code { padding: .15em .35em; }

h1 code, h2 code, h3 code, h4 code, p code, li code {
  margin: 0;
  background: rgba(139,69,19,.12);
  color: var(--text-code);
}

.code-comment { color: #0891b2; font-style: italic; }
.comment-block {
  border-left: 4px solid var(--bg-accent);
  padding: .75rem 1rem;
  margin: 1rem 1.5rem;
  border-radius: 0 6px 6px 0;
  background: var(--blockquote-bg);
}

/* ── Tables ── */
table {
  margin: 1rem auto;
  border-collapse: collapse;
  width: auto;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}
@media (min-width: 640px) { table { display: table; } }

table, td, tr, th {
  border: 1px solid var(--table-border);
  padding: .5rem .75rem;
  text-align: center;
}
th { background: var(--bg-accent); color: #fff; font-weight: 600; }
td { background: var(--bg-surface); }

/* ── Blockquote ── */
blockquote {
  background: var(--blockquote-bg);
  color: var(--text);
  padding: 1rem 1.5rem;
  margin: 1rem 1.5rem;
  border-left: 4px solid var(--bg-accent);
  border-radius: 0 6px 6px 0;
}

/* ── Images & SVG ── */
img { max-width: 100%; height: auto; border-radius: 4px; }
div img { width: 45%; }
svg { display: block; margin: 1rem auto; max-width: 100%; }
canvas { display: block; margin: 1rem auto; max-width: 100%; }

/* ── Mermaid ── */
.mermaid_container, .mermaid-diagram, .mermaid {
  margin: 1.5rem auto;
  padding: 1.25rem;
  background: var(--mermaid-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  max-width: 90%;
  text-align: center;
}

.mermaid svg { margin: 0 auto; display: block; }

.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon,
.mermaid .node path {
  fill: var(--mermaid-node);
  stroke: var(--mermaid-stroke);
}
.mermaid .edgePath .path { stroke: var(--text-muted); }
.mermaid .label,
.mermaid .label text,
.mermaid text,
.mermaid .flowchart-label text,
.mermaid .mindmap-node text,
.mermaid .nodeLabel {
  fill: var(--mermaid-text) !important;
  color: var(--mermaid-text) !important;
}
.mermaid .cluster rect {
  fill: var(--bg-surface);
  stroke: var(--mermaid-stroke);
}

/* ── Prev / Next nav ── */
.prev-next {
  max-width: 900px;
  margin: 2.5rem auto 1rem;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.pn-link {
  display: inline-block;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--link);
  background: var(--bg-surface);
  font-size: .9rem;
  transition: background .2s, transform .15s;
}
.pn-link:hover {
  background: var(--bg-accent);
  color: #fff;
  transform: translateY(-1px);
}

.pn-home { border-color: var(--bg-accent); font-weight: 600; }

/* ── Site footer ── */
.site-footer {
  background: var(--bg-header);
  color: #d4a574;
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 3rem;
  font-size: .9rem;
}
.site-footer p { padding: .25rem 0; color: #d4a574; }
.site-footer a { color: #e8a870; }
.site-footer a:hover { color: #fff; }
.footer-links { margin-top: .5rem; }

/* ── Mobile responsiveness ── */
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }

  p { padding: 0 .75rem; }
  dl, ol, ul, li { margin-left: 1.5rem; }
  pre { margin: .75rem; padding: .75rem; font-size: .85rem; }
  blockquote { margin: .75rem; padding: .75rem 1rem; }

  .header-inner { padding: .5rem .75rem; }
  .site-brand { font-size: 1rem; }
  .header-links { gap: .4rem; }
  .header-links a { font-size: .78rem; padding: .2rem .4rem; }

  .prev-next { flex-direction: column; text-align: center; }
  .pn-link { width: 100%; text-align: center; }

  div img { width: 90%; }
}
