/* ===== Theme variables ===== */
:root {
  color-scheme: light;

  /* Page backgrounds */
  --bg-page: #f8f8f8;
  --bg-body-image: url(../img/grid.png);
  --bg-zettel: #fcfbf3;
  --bg-header: #f0e6c4;
  --bg-accent: #eee8d5;
  --bg-code: #fff;
  --bg-codehilite: #f8f8f8;
  --bg-tooltip: #002b36;
  --bg-kbd: #333;
  --bg-img: #fff;

  /* Text */
  --text-primary: #444;
  --text-link: #192062;
  --text-header: #4a6888;
  --text-code: #333;
  --text-muted: gray;
  --text-tooltip: #93a1a1;
  --text-kbd: #fff;
  --text-link-code: #2FA4E7;
  --text-link-code-hover: #157AB5;

  /* Borders */
  --border-zettel: lightgray;
  --border-heading: #eaeaea;
  --border-accent: #d4cbb3;
  --border-code: #e1e4e5;
  --border-hr: #aaa;
  --border-img: #ddd;

  /* Navbar */
  --nav-from: #586e75;
  --nav-to: #657b83;

  /* Admonitions */
  --adm-note-text: #3a87ad;
  --adm-note-bg: #d9edf7;
  --adm-note-border: #bce8f1;
  --adm-warning-text: #c09853;
  --adm-warning-bg: #fcf8e3;
  --adm-warning-border: #fbeed5;
  --adm-danger-text: #b94a48;
  --adm-danger-bg: #f2dede;
  --adm-danger-border: #eed3d7;

  /* Syntax highlighting */
  --ch-highlight: #ffffcc;
  --ch-comment: #408080;
  --ch-error-border: #FF0000;
  --ch-keyword: #008000;
  --ch-operator: #666666;
  --ch-preproc: #BC7A00;
  --ch-deleted: #A00000;
  --ch-error: #FF0000;
  --ch-heading: #000080;
  --ch-inserted: #00A000;
  --ch-output: #888888;
  --ch-prompt: #000080;
  --ch-subheading: #800080;
  --ch-traceback: #0044DD;
  --ch-type: #B00040;
  --ch-number: #666666;
  --ch-string: #BA2121;
  --ch-attribute: #7D9029;
  --ch-builtin: #008000;
  --ch-class: #0000FF;
  --ch-constant: #880000;
  --ch-decorator: #AA22FF;
  --ch-entity: #999999;
  --ch-exception: #D2413A;
  --ch-function: #0000FF;
  --ch-label: #A0A000;
  --ch-namespace: #0000FF;
  --ch-tag: #008000;
  --ch-variable: #19177C;
  --ch-op-word: #AA22FF;
  --ch-whitespace: #bbbbbb;
  --ch-string-escape: #BB6622;
  --ch-string-interpol: #BB6688;
  --ch-string-other: #008000;
  --ch-string-regex: #BB6688;
  --ch-linenos-special-text: #000000;
  --ch-linenos-special-bg: #ffffc0;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-page: #002b36;
  --bg-body-image: none;
  --bg-zettel: #073642;
  --bg-header: #094050;
  --bg-accent: #05313e;
  --bg-code: #073642;
  --bg-codehilite: #073642;
  --bg-tooltip: #eee8d5;
  --bg-kbd: #586e75;
  --bg-img: #073642;

  --text-primary: #839496;
  --text-link: #268bd2;
  --text-header: #93a1a1;
  --text-code: #839496;
  --text-muted: #586e75;
  --text-tooltip: #002b36;
  --text-kbd: #fdf6e3;
  --text-link-code: #268bd2;
  --text-link-code-hover: #2aa198;

  --border-zettel: #586e75;
  --border-heading: #586e75;
  --border-accent: #586e75;
  --border-code: #586e75;
  --border-hr: #586e75;
  --border-img: #586e75;

  --nav-from: #073642;
  --nav-to: #002b36;

  --adm-note-text: #268bd2;
  --adm-note-bg: #073642;
  --adm-note-border: #268bd2;
  --adm-warning-text: #b58900;
  --adm-warning-bg: #073642;
  --adm-warning-border: #b58900;
  --adm-danger-text: #dc322f;
  --adm-danger-bg: #073642;
  --adm-danger-border: #dc322f;

  /* Solarized Dark syntax */
  --ch-highlight: #073642;
  --ch-comment: #586e75;
  --ch-error-border: #dc322f;
  --ch-keyword: #859900;
  --ch-operator: #93a1a1;
  --ch-preproc: #cb4b16;
  --ch-deleted: #dc322f;
  --ch-error: #dc322f;
  --ch-heading: #cb4b16;
  --ch-inserted: #859900;
  --ch-output: #586e75;
  --ch-prompt: #268bd2;
  --ch-subheading: #268bd2;
  --ch-traceback: #dc322f;
  --ch-type: #b58900;
  --ch-number: #2aa198;
  --ch-string: #2aa198;
  --ch-attribute: #93a1a1;
  --ch-builtin: #268bd2;
  --ch-class: #268bd2;
  --ch-constant: #b58900;
  --ch-decorator: #cb4b16;
  --ch-entity: #cb4b16;
  --ch-exception: #cb4b16;
  --ch-function: #268bd2;
  --ch-label: #93a1a1;
  --ch-namespace: #93a1a1;
  --ch-tag: #268bd2;
  --ch-variable: #268bd2;
  --ch-op-word: #859900;
  --ch-whitespace: #586e75;
  --ch-string-escape: #cb4b16;
  --ch-string-interpol: #cb4b16;
  --ch-string-other: #2aa198;
  --ch-string-regex: #2aa198;
  --ch-linenos-special-text: #93a1a1;
  --ch-linenos-special-bg: #073642;
}

/* ===== Theme styles ===== */

.bg-primary {
  background-image: linear-gradient(var(--nav-from), var(--nav-to));
  background-repeat: no-repeat;
}

.file-header a,
span {
  color: var(--text-link);
}

a.hidden-hyperlink {
  text-decoration: none;
}

a.hidden-hyperlink:hover {
  text-decoration: none;
  cursor: default;
}

span[data-copy-value] {
  cursor: copy;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tooltip);
  color: var(--text-tooltip);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: normal;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

h1 {
  color: var(--text-link);
}

h1,
h2,
h3 {
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--border-heading);
  margin-bottom: 0.6em;
}

svg.clickable {
  cursor: pointer;
}

.zettel {
  margin-top: 1%;
  margin-bottom: 1%;
  padding: 0;
  border: 1px solid var(--border-zettel);
  border-radius: 7px;
  background-color: var(--bg-zettel);
}

.file-header {
  background-color: var(--bg-header);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  padding: 2.5em;
  padding-top: 0.2em;
  padding-bottom: 0.7em;
  font-size: small;
  color: var(--text-header);
}

.file-header .row {
  margin-top: 0.25em;
}

.file-header svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  font-size: inherit;
  color: inherit;
  vertical-align: -0.125em;
  fill: currentColor;
}

.file-header .date {
  padding-right: 0;
}

.file-body {
  padding: 2em;
  padding-top: 1em;
  padding-bottom: 0;
}

.codehilite,
pre:has(> code) {
  position: relative;
}

.codehilite {
  border: 1px solid var(--border-zettel);
  border-radius: 4px;
  padding: 0.7em;
  margin: 0.3em;
  margin-bottom: 1rem;
}

.copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--bg-accent);
  border: 1px solid var(--border-accent);
  border-radius: 3px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--text-primary);
}

.copy-btn:hover {
  background: var(--border-accent);
}

.codehilite:hover .copy-btn,
pre:has(> code):hover .copy-btn {
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-references h6 .fa {
  font-size: 1.1em;
  margin-right: 0.3em;
}

.file-references {
  background-color: var(--bg-accent);
  border-top: 1px solid var(--border-accent);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  padding: 1em;
  font-style: italic;
  font-size: small;
  color: var(--text-muted);
}

/* Theme toggle button */
#theme-toggle {
  cursor: pointer;
}

#theme-toggle:hover {
  opacity: 0.8;
}

/* Validation badge */
.validation-badge {
  color: #b58900;
  margin-left: 0.5em;
  font-size: 0.9em;
}

/* Editor buttons */
.editor-btn {
  margin-left: 0.3em;
  padding: 0.1em 0.4em;
  font-size: 0.8em;
}
