/* QGIS Live Harness docs — shared stylesheet */
:root {
  --nav-w: 264px;
  --toc-w: 220px;
  --accent: #589632;        /* QGIS green */
  --accent-dark: #3f7022;
  --accent-soft: #eef6e9;
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-code: #f6f8fa;
  --fg: #1f2328;
  --fg-muted: #59636e;
  --border: #d9e0e6;
  --link: #0b6bcb;
  --shadow: 0 1px 3px rgba(31, 35, 40, .08);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7cc24f;
    --accent-dark: #93d168;
    --accent-soft: #223318;
    --bg: #0e1116;
    --bg-soft: #161b22;
    --bg-code: #161b22;
    --fg: #e6edf3;
    --fg-muted: #9aa6b2;
    --border: #2d333b;
    --link: #58a6ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--fg);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; }

/* ---------- sidebar ---------- */
nav.sidebar {
  width: var(--nav-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 20px 14px 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-soft);
}
.sidebar .site {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 8px 14px;
  color: var(--fg);
}
.sidebar .site .logo {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800;
}
.sidebar .group {
  margin: 14px 0 4px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.sidebar a.navlink {
  display: block;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: 7px;
  color: var(--fg);
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar a.navlink:hover { background: var(--accent-soft); text-decoration: none; }
.sidebar a.navlink.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
}
.sidebar a.navlink.ext { color: var(--fg-muted); font-size: 13px; }
.sidebar a.navlink.ext::after { content: " ↗"; font-size: 11px; }

/* ---------- layout ---------- */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 0 40px;
}
main {
  flex: 1;
  min-width: 0;
  max-width: 860px;
  padding: 36px 0 96px;
  overflow-wrap: break-word;
}

/* ---------- page header ---------- */
.page-header { margin-bottom: 28px; }
.page-header .eyebrow {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 0 0 4px;
}
.page-header h1 {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.3;
  border: none;
  padding: 0;
}
.page-header .lead {
  margin: 0;
  color: var(--fg-muted);
  font-size: 17px;
}

/* ---------- typography ---------- */
h1 { font-size: 28px; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
h2 {
  font-size: 22px;
  margin-top: 44px;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 17.5px; margin-top: 30px; }
h2 .anchor, h3 .anchor {
  opacity: 0;
  margin-left: 6px;
  font-size: .8em;
  color: var(--fg-muted);
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }
strong { font-weight: 700; }

/* ---------- code ---------- */
code, pre, kbd { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: .15em .4em;
  border-radius: 6px;
  font-size: 85%;
}
.codeblock { position: relative; margin: 16px 0; }
.codeblock pre {
  margin: 0;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow: auto;
  line-height: 1.6;
  font-size: 13.5px;
}
.codeblock pre code { background: none; border: none; padding: 0; font-size: inherit; }
.codeblock .lang {
  position: absolute;
  top: 0; right: 0;
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-top: none; border-right: none;
  border-radius: 0 var(--radius) 0 8px;
  padding: 2px 10px;
}
.codeblock .copy {
  position: absolute;
  bottom: 8px; right: 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-muted);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.codeblock:hover .copy { opacity: 1; }
.codeblock .copy:hover { color: var(--fg); }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td {
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--bg-soft);
  font-weight: 700;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }

/* ---------- callouts ---------- */
blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg);
}
blockquote p { margin: 0; }
blockquote p + p { margin-top: 8px; }

/* ---------- mermaid ---------- */
.mermaid {
  margin: 20px 0;
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

/* ---------- media (image / video) ---------- */
figure.media {
  margin: 20px 0 28px;
}
figure.media img,
figure.media video {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}
figure.media figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--fg-muted);
  text-align: center;
}

/* ---------- media modal ---------- */
main img { cursor: zoom-in; }
.media-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(0, 0, 0, .78);
}
.media-modal video,
.media-modal img {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  display: block;
  border-radius: var(--radius);
  background: #000;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
}
.media-modal img { cursor: default; }
.media-modal .close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.media-modal .close:hover { background: rgba(255, 255, 255, .32); }

/* ---------- cards (index) ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
}
.cards a.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--fg);
  background: var(--bg);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.cards a.card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}
.cards .card b { display: block; margin-bottom: 4px; color: var(--accent-dark); }
.cards .card span { font-size: 13.5px; color: var(--fg-muted); }

/* ---------- prev / next ---------- */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pager a {
  flex: 1;
  max-width: 48%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--fg);
}
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager a .dir { display: block; font-size: 12px; color: var(--fg-muted); }
.pager a .title { font-weight: 700; color: var(--accent-dark); }
.pager a.next { margin-left: auto; text-align: right; }

/* ---------- on-this-page toc ---------- */
aside.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 44px 0 32px 4px;
  font-size: 13px;
  display: none;
}
aside.toc .toc-title {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
aside.toc a {
  display: block;
  color: var(--fg-muted);
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--border);
  line-height: 1.5;
}
aside.toc a.lv3 { padding-left: 22px; }
aside.toc a:hover { color: var(--fg); text-decoration: none; }
aside.toc a.current { color: var(--accent-dark); border-left-color: var(--accent); font-weight: 600; }
@media (min-width: 1280px) { aside.toc { display: block; } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  body { flex-direction: column; }
  nav.sidebar {
    width: auto;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
  }
  .sidebar .group { display: none; }
  .sidebar .links { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar a.navlink { border-left: none; padding: 5px 10px; }
  .sidebar a.navlink.active { border-left: none; }
  .content { padding: 0 20px; }
  main { padding: 20px 0 64px; }
  .page-header h1 { font-size: 26px; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager a.next { text-align: left; }
}
