/* Water.css exposes theme variables; reuse them so light/dark just works */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.site-header .brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.site-header nav a { margin-left: 1.25rem; text-decoration: none; }

.site-footer { margin-top: 4rem; text-align: center; color: var(--text-muted); }

.icon {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 1.25rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.4rem;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--background); }

.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 10;
  min-width: 9rem;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--background-body);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.theme-menu li { margin: 0; padding: 0; }

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.6rem;
  background: transparent;
  color: var(--text-main);
  border: 0;
  border-radius: 6px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.theme-menu button:hover { background: var(--background); }
.theme-menu button[aria-pressed="true"] { font-weight: 600; }

.theme-menu .check { margin-left: auto; visibility: hidden; }
.theme-menu button[aria-pressed="true"] .check { visibility: visible; }

.post-list { list-style: none; padding: 0; }
.post-list li { margin-bottom: 1.5rem; }
.post-list p { margin: 0.25rem 0 0; }

.post-meta { color: var(--text-muted); font-size: 0.9rem; margin-left: 0.5rem; }
article header .post-meta { margin-left: 0; }
article img { max-width: 100%; height: auto; }

/* Heading anchors: a "#" that hangs in the left margin and shows on hover */
article :is(h2, h3) { position: relative; scroll-margin-top: 1rem; }
.anchor {
  position: absolute;
  right: 100%;
  padding-right: 0.3em;
  text-decoration: none;
  opacity: 0;
}
article :is(h2, h3):hover .anchor, .anchor:focus { opacity: 1; }

/* Table of contents: a sidebar beside the 800px column, wide screens only */
#toc { display: none; }
@media (min-width: 1280px) {
  #toc {
    display: block;
    position: fixed;
    top: 8rem;
    left: calc(50% + 400px + 2rem);
    width: 12rem;
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
    font-size: 0.9rem;
  }
  #toc .toc-title { margin: 0 0 0.5rem; font-size: 1.1rem; font-weight: 700; color: var(--text-main); }
  #toc ul { margin: 0; padding: 0; list-style: none; }
  #toc li { margin: 0.4rem 0; }
  #toc .toc-sub { padding-left: 1rem; }
  #toc a { color: var(--text-muted); text-decoration: none; }
  #toc a:hover, #toc a.active { color: var(--text-main); }
  #toc a.active { font-weight: 600; }
}

.admonition {
  margin: 1.5rem 0;
  padding: 0.25rem 1rem;
  background: var(--background);
  border-left: 4px solid var(--links);
  border-radius: 0 8px 8px 0;
}
.admonition.warning { border-left-color: #d9822b; }
.admonition.tip { border-left-color: #2f9e5b; }

/* Syntax colors */
:root {
  --tok-keyword: #cf222e;
  --tok-string: #0a3069;
  --tok-comment: #6e7781;
  --tok-number: #0550ae;
  --tok-title: #8250df;
  --tok-meta: #953800;
}
html[data-theme="dark"] {
  --tok-keyword: #ff7b72;
  --tok-string: #a5d6ff;
  --tok-comment: #8b949e;
  --tok-number: #79c0ff;
  --tok-title: #d2a8ff;
  --tok-meta: #ffa657;
}

.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: var(--tok-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--tok-string); }
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-attr,
.hljs-attribute, .hljs-variable, .hljs-template-variable { color: var(--tok-number); }
.hljs-title, .hljs-section, .hljs-name, .hljs-type { color: var(--tok-title); }
.hljs-meta, .hljs-deletion { color: var(--tok-meta); }

/* Code blocks */
.code-block {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--background);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.1rem 0.4rem 0.1rem 0.75rem;
  background: var(--background-alt);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.2rem;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.code-copy:hover { background: var(--border); color: var(--text-main); }
.code-copy .icon-done { display: none; }
.code-copy[data-state="copied"] .icon-copy { display: none; }
.code-copy[data-state="copied"] .icon-done { display: inline-block; color: #2f9e5b; }

.code-body { display: flex; }

.code-block pre {
  margin: 0;
  padding: 0.6rem 0.6rem;
  background: transparent;
  border-radius: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}
.code-block pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  line-height: inherit;
}

.code-block .code-lines {
  flex-shrink: 0;
  padding: 0.6rem 0.5rem;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  text-align: right;
  user-select: none;
}
.code-block .code-content {
  flex: 1;
  min-width: 0;      /* lets long lines scroll instead of stretching the page */
  overflow-x: auto;
}
