/* World of Embyrie — styled after chaingunstudios.com/rpg/dnd site themes */
@import url("https://fonts.googleapis.com/css2?family=Audiowide&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Merriweather:wght@300;400;700&display=swap");

:root{
  --cg-bg:#f0e8d8; --cg-surface:rgba(240,232,215,.92); --cg-surface2:rgba(220,205,178,.75);
  --cg-text:#2a1f12; --cg-heading:#180e04; --cg-muted:#7a6350; --cg-accent:#7a1f00; --cg-accent2:#5e1700;
  --cg-border:#c8a070; --cg-nav-bg:#2d1508; --cg-nav-text:#f0e6cc; --cg-nav-active:#ffc840; --cg-header-bg:rgba(20,8,2,.97);
  --mono-font:"JetBrains Mono",ui-monospace,monospace;
  --embyrie-paper:url("../images/paper.jpg");
  --sidebar-width:260px; --content-max-width:900px; --menu-bar-height:56px;
}

/* Map site-theme tokens onto mdBook chrome variables */
.light,.rust,html:not(.coal):not(.navy):not(.ayu),
html.theme-fantasy,html.theme-modern,html.theme-cyber{
  --bg:var(--cg-bg); --fg:var(--cg-text);
  --sidebar-bg:var(--cg-nav-bg); --sidebar-fg:var(--cg-nav-text); --sidebar-non-existant:#9a8466;
  --sidebar-active:var(--cg-nav-active); --sidebar-spacer:#4a2a14;
  --scrollbar:var(--cg-accent); --icons:var(--cg-muted); --icons-hover:var(--cg-accent);
  --links:var(--cg-accent); --inline-code-color:var(--cg-text);
  --theme-popup-bg:var(--cg-bg); --theme-popup-border:var(--cg-border); --theme-hover:var(--cg-surface2);
  --quote-bg:var(--cg-surface); --quote-border:var(--cg-accent);
  --table-border-color:var(--cg-border); --table-header-bg:rgba(45,21,8,.12); --table-alternate-bg:rgba(200,160,112,.12);
  --searchbar-border-color:var(--cg-border); --searchbar-bg:#fff8ec; --searchbar-fg:var(--cg-text);
  --searchresults-header-fg:var(--cg-muted); --searchresults-border-color:var(--cg-border); --search-mark-bg:#ffc840;
}

html{font-family:Inter,system-ui,sans-serif;}

/* ---------- Fantasy (D&D default) — Chaingun paper background ---------- */
html.theme-fantasy{
  --cg-bg:#f0e8d8; --cg-surface:rgba(240,232,215,.92); --cg-surface2:rgba(220,205,178,.75);
  --cg-text:#2a1f12; --cg-heading:#180e04; --cg-muted:#7a6350; --cg-accent:#7a1f00; --cg-accent2:#5e1700;
  --cg-border:#c8a070; --cg-nav-bg:#2d1508; --cg-nav-text:#f0e6cc; --cg-nav-active:#ffc840; --cg-header-bg:rgba(20,8,2,.97);
  background-color:transparent;
}
html.theme-fantasy body{
  background-color:#f0e8d8;
  background-image:var(--embyrie-paper);
  background-size:cover;
  background-repeat:no-repeat;
  background-position:center top;
}
html.theme-fantasy.fantasy-tile body{
  background-size:2313px 1440px;
  background-repeat:repeat;
}
html.theme-fantasy .page-wrapper,
html.theme-fantasy .content,
html.theme-fantasy .page{
  background-color:transparent;
  background-image:none;
}
html.theme-fantasy .content h1,
html.theme-fantasy .content h2,
html.theme-fantasy .content h3,
html.theme-fantasy .content h4{
  font-family:Merriweather,Georgia,serif;
  color:var(--cg-heading);
}
html.theme-fantasy .menu-title{font-family:Merriweather,Georgia,serif;}

/* ---------- Modern ---------- */
html.theme-modern{
  --cg-bg:#0b0f14; --cg-surface:#141a22; --cg-surface2:#1c2533;
  --cg-text:#c8d8e8; --cg-heading:#e8f4ff; --cg-muted:#6a8099; --cg-accent:#39ff6e; --cg-accent2:#1ecb50;
  --cg-border:#2a3a4a; --cg-nav-bg:#0f161e; --cg-nav-text:#c8d8e8; --cg-nav-active:#39ff6e; --cg-header-bg:rgba(10,14,20,.95);
  --searchbar-bg:#141a22; --search-mark-bg:#39ff6e; --table-header-bg:rgba(57,255,110,.12); --table-alternate-bg:rgba(28,37,51,.6);
}
html.theme-modern,
html.theme-modern body,
html.theme-modern .page-wrapper{
  background-color:var(--cg-bg);
  background-image:none;
}
html.theme-modern .content h1,
html.theme-modern .content h2,
html.theme-modern .content h3,
html.theme-modern .content h4{
  font-family:Inter,system-ui,sans-serif;
  color:var(--cg-heading);
}

/* ---------- Cyber ---------- */
html.theme-cyber{
  --cg-bg:#030508; --cg-surface:#07090f; --cg-surface2:#0c0f1a;
  --cg-text:#b8d8f4; --cg-heading:#00f0ff; --cg-muted:#4a6888; --cg-accent:#ff2db4; --cg-accent2:#cc00a0;
  --cg-border:#0a1528; --cg-nav-bg:rgba(3,5,10,.92); --cg-nav-text:#a0c8e8; --cg-nav-active:#00f0ff; --cg-header-bg:rgba(2,4,8,.96);
  --searchbar-bg:#07090f; --search-mark-bg:#00f0ff; --table-header-bg:rgba(0,240,255,.08); --table-alternate-bg:rgba(12,15,26,.7);
  background-color:#030508;
}
html.theme-cyber body{
  background-color:transparent;
  background-image:none;
}
html.theme-cyber .page-wrapper,
html.theme-cyber .content,
html.theme-cyber .page{
  background:transparent;
}
html.theme-cyber .content h1,
html.theme-cyber .content h2{
  font-family:Audiowide,sans-serif;
  color:#00f0ff;
  text-shadow:0 0 20px rgba(0,240,255,.7),0 0 50px rgba(0,240,255,.3);
}
html.theme-cyber .content h3,
html.theme-cyber .content h4{
  font-family:Audiowide,sans-serif;
  color:#00f0ff;
  text-shadow:0 0 12px rgba(0,240,255,.5);
}
html.theme-cyber .menu-title{font-family:Audiowide,sans-serif;color:#00f0ff;}
html.theme-cyber .content a:hover{
  color:#ff80d8;
  text-shadow:0 0 10px var(--cg-accent);
  text-decoration:none;
  opacity:1;
}
html.theme-cyber::after{
  content:"";
  position:fixed;inset:0;z-index:0;pointer-events:none;
  background:repeating-linear-gradient(to bottom,transparent 0px,transparent 3px,rgba(0,240,255,.018) 3px,rgba(0,240,255,.018) 4px);
}
html.theme-cyber #body-container,
html.theme-cyber .page-wrapper,
html.theme-cyber .content{position:relative;z-index:1;}

.cyber-bg-video{
  display:none;position:fixed;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;opacity:.55;pointer-events:none;
}
html.theme-cyber .cyber-bg-video{display:block;}

/* ---------- Shared reading chrome ---------- */
.content{line-height:1.6;font-size:1.6rem;padding:2rem 2.4rem 4rem;}
.content main{max-width:900px;}
.content h1,.content h2,.content h3,.content h4,.content h5,.content h6{font-weight:700;line-height:1.25;}
.content h1{font-size:2.25em;}
.content h2{font-size:1.75em;margin-top:2em;border-bottom:1px solid var(--cg-border);padding-bottom:.25em;}
.content h3{font-size:1.375em;margin-top:1.5em;}
.content h4{font-size:1.125em;margin-top:1.25em;}
.content p{margin-block:0 1em;}
.content li{margin-bottom:.25em;}
.content a:hover{color:var(--cg-accent2);}
.content a:focus-visible,.sidebar a:focus-visible,.icon-button:focus-visible{
  outline:2px solid currentColor;outline-offset:3px;
}
.content table{width:100%;border-collapse:collapse;font-size:.9em;margin-bottom:1.25em;}
.content table th,.content table td{padding:.5em .75em;border:1px solid var(--table-border-color);text-align:left;}
.content table thead th{font-weight:600;}
.content blockquote{border-left:3px solid var(--quote-border);border-top:0;border-bottom:0;padding:.5em 1em;margin:1em 0;border-radius:0 4px 4px 0;color:var(--cg-muted);}
code{background:var(--cg-surface2);border:1px solid var(--cg-border);border-radius:3px;}
pre{background:var(--cg-surface2);}
pre>code{border:0;background:transparent;}
#menu-bar,#menu-bar.bordered{background:var(--cg-header-bg);border-bottom-color:#000;}
#menu-bar .icon-button,.menu-title{color:var(--cg-nav-text);}
.nav-chapters{color:var(--cg-muted);}
.sidebar .chapter li a:hover{color:var(--cg-nav-active);}
.content img{max-width:100%;height:auto;border-radius:4px;}

/* Introduction page — Chaingun-style campaign cards */
.campaign-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(280px,1fr));
  gap:1.5rem;
  margin:2rem 0 2.5rem;
  align-items:stretch;
}
.campaign-card{
  display:flex;
  flex-direction:column;
  height:100%;
  border:1px solid var(--cg-border);
  border-radius:8px;
  overflow:hidden;
  text-decoration:none;
  background:var(--cg-surface);
  transition:border-color .15s,transform .15s;
}
.campaign-card:hover{
  border-color:var(--cg-accent);
  transform:translateY(-2px);
  text-decoration:none;
  opacity:1;
}
/* Equal image frame so card titles/blurbs line up across the row.
   contain keeps cover typography readable (not cropped). */
.campaign-card > img,
.campaign-card__placeholder{
  width:100%;
  aspect-ratio:609 / 431;
  height:auto !important;
  max-width:100%;
  max-height:none !important;
  object-fit:contain;
  object-position:center center;
  display:block;
  border-radius:0 !important;
  background:#1a1008;
}
.campaign-card__placeholder{background:var(--cg-surface2);}
.campaign-card__body{
  display:flex;
  flex-direction:column;
  gap:.35rem;
  flex:1 1 auto;
  padding:1rem 1rem 1.15rem;
}
.campaign-card__title{
  font-family:Merriweather,Georgia,serif;
  font-size:1.25rem;
  font-weight:700;
  line-height:1.25;
  margin:0;
  color:var(--cg-accent);
}
.campaign-card__body p{
  font-size:.9rem;
  line-height:1.45;
  color:var(--cg-muted);
  margin:0;
}
.campaign-card:focus-visible{
  outline:2px solid var(--cg-accent);
  outline-offset:3px;
}
html.theme-modern .campaign-card__title,
html.theme-cyber .campaign-card__title{
  font-family:Inter,system-ui,sans-serif;
}
html.theme-cyber .campaign-card__title{
  font-family:Audiowide,sans-serif;
  text-shadow:0 0 12px rgba(0,240,255,.35);
}
html.theme-modern .campaign-card > img,
html.theme-cyber .campaign-card > img{
  background:#0b0f14;
}

/* Bottom-right site style picker (Chaingun).
   mdBook's .nav-chapters.next is a full-height right hit strip; keep the picker above it. */
#theme-picker-container{
  position:fixed;right:12px;bottom:12px;z-index:10000;
  display:flex;gap:8px;align-items:center;
  pointer-events:auto;
}
#site-theme-picker{
  padding:4px 8px;border-radius:4px;
  border:1px solid var(--cg-border, #333);
  background:var(--cg-surface, #111);
  color:var(--cg-text, #ccc);
  font-size:.8rem;cursor:pointer;
  pointer-events:auto;
}
.nav-chapters.next,.nav-chapters.previous{
  /* Leave the bottom corner free for the site-style control */
  bottom:48px;
}
.sr-only{
  position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;
}

@media (max-width:600px){
  .content{padding:1.25rem 1.6rem 3rem;}
  .content h1{font-size:1.75em}
  .content h2{font-size:1.4em}
  .content table{display:block;overflow-x:auto}
}
