/*
 * Light: IBM Carbon Design System "White" theme tokens.
 * Dark: Carbonfox (nightfox.nvim), https://github.com/EdenEast/nightfox.nvim
 * Both come from the same IBM Carbon palette, so they stay siblings.
 */
:root {
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --fg: #161616;
  --fg-strong: #161616;
  --muted: #525252;
  --accent: #0f62fe;
  --accent-note: #8a3ffc;
  --accent-tip: #198038;
  --accent-warning: #da1e28;
  --border: #e0e0e0;
  --max-width: 56rem;

  /* Pagefind Component UI theming, see
     https://pagefind.app/docs/css-variables/ */
  --pf-text: var(--fg-strong);
  --pf-text-secondary: var(--fg);
  --pf-text-muted: var(--muted);
  --pf-background: var(--bg);
  --pf-border: var(--border);
  --pf-border-focus: var(--accent);
  --pf-skeleton: var(--bg-alt);
  --pf-skeleton-shine: var(--border);
  --pf-hover: var(--bg-alt);
  --pf-mark: var(--accent);
  --pf-outline-focus: var(--accent);
  --pf-font: var(--font-sans);
  --pf-border-radius: 6px;
  --pf-modal-backdrop: rgba(22, 22, 22, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --bg-alt: #252525;
    --fg: #cdcecf;
    --fg-strong: #f2f4f8;
    --muted: #7b7c7e;
    --accent: #78a9ff;
    --accent-note: #be95ff;
    --accent-tip: #25be6a;
    --accent-warning: #ee5396;
    --border: #393939;
    --pf-modal-backdrop: rgba(0, 0, 0, 0.6);
  }
}

/* IBM Plex, OFL-licensed: https://github.com/IBM/plex (see static/fonts/LICENSE-*.txt) */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/IBMPlexSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/IBMPlexSans-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/IBMPlexSans-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fonts/IBMPlexMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-sans:
    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono:
    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

a:hover {
  border-bottom-color: currentColor;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.site-title {
  display: inline-flex;
  border-bottom: none !important;
  line-height: 0;
}

.site-title:hover {
  opacity: 0.85;
}

.site-logo {
  height: 1.15rem;
  width: auto;
  color: var(--fg-strong);
}

.site-nav a {
  margin-left: 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-family: var(--font-mono);
}

.site-nav a:first-child {
  margin-left: 0;
}

.site-nav pagefind-modal-trigger {
  margin-left: 1.1rem;
  vertical-align: middle;
}

main {
  flex: 1;
}

.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 0;
}

.not-found h1 {
  font-family: var(--font-mono);
  font-size: 4rem;
  margin: 0;
  color: var(--accent-note);
}

.not-found p {
  color: var(--muted);
  margin: 0.5rem 0;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 600;
  color: var(--fg-strong);
}

h1 {
  font-size: 1.9rem;
  margin-bottom: 0.4rem;
}

.tagline {
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.post-list-title {
  color: var(--fg-strong);
  font-weight: 600;
}

.zola-anchor {
  margin-left: 0.4em;
  font-size: 0.75em;
  opacity: 0;
  text-decoration: none;
  border-bottom: none !important;
}

h1:hover .zola-anchor,
h2:hover .zola-anchor,
h3:hover .zola-anchor,
h4:hover .zola-anchor {
  opacity: 0.6;
}

.post-list time,
.post-meta time {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.post-meta {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0;
}

.toc {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
  font-size: 0.9rem;
}

.toc-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc > ul > li {
  margin: 0.3rem 0;
}

.toc ul ul {
  margin-top: 0.3rem;
  padding-left: 1.1rem;
}

.toc ul ul li {
  margin: 0.25rem 0;
}

.toc a {
  color: var(--fg);
}

.toc a:hover {
  color: var(--accent);
}

.post-body {
  margin-top: 1.5rem;
}

.post-body p {
  margin: 1.1rem 0;
}

.post-body blockquote {
  margin: 1.2rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.post-tags {
  margin-top: 2rem;
}

.post-tags a {
  margin-right: 0.6rem;
  color: var(--muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

pre {
  position: relative;
}

/* border on code, not on pre because pre can contain an optional filename,
   which isn't part of the code block block. */
pre > code {
  display: block;
  background: var(--bg-alt) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  transition: border-color 0.15s ease;
}

.code-label + code {
  border-top: none;
  border-radius: 0 0 6px 6px;
}

/* Hovering/focusing the "copy code" button highlights the border of the
   code box and the divider line */
pre:has(.copy-code-button:not(.copy-name-button):hover) > code,
pre:has(.copy-code-button:not(.copy-name-button):focus-visible) > code {
  border-color: var(--accent);
}

pre:has(.copy-code-button:not(.copy-name-button):hover) .code-label,
pre:has(.copy-code-button:not(.copy-name-button):focus-visible) .code-label {
  border-bottom-color: var(--accent);
}

/* Filename label on a code block, built as real DOM elements by copy-code.js */
.code-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem 0.5rem 1.1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  transition: border-color 0.15s ease;
}

.code-filename {
  font-style: italic;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  transition: color 0.15s ease;
}

.code-label:has(.copy-name-button:hover) .code-filename,
.code-label:has(.copy-name-button:focus-visible) .code-filename {
  color: var(--accent);
}

.copy-code-button-right {
  margin-left: auto;
  flex-shrink: 0;
}

.copy-code-button {
  padding: 0.25em 0.6em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.copy-code-button:not(.inline) {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  opacity: 0;
}

pre:hover .copy-code-button:not(.inline),
.copy-code-button:not(.inline):focus-visible {
  opacity: 1;
}

.copy-name-button {
  padding: 0.15em 0.45em;
  font-size: 0.68rem;
}

.copy-code-button:hover {
  color: var(--fg-strong);
  border-color: var(--accent);
}

.copy-code-button.copied {
  color: var(--accent-tip);
  border-color: var(--accent-tip);
  opacity: 1;
}

/* Required by Zola's syntax highlighter for correct line layout, see
   https://www.getzola.org/documentation/content/syntax-highlighting/ */
.giallo-l {
  display: inline-block;
  min-height: 1lh;
  width: 100%;
}

.giallo-ln {
  display: inline-block;
  user-select: none;
  margin-right: 0.4em;
  padding: 0.4em;
  min-width: 3ch;
  text-align: right;
  opacity: 0.8;
}

:not(pre) > code {
  background: var(--bg-alt);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.post-body blockquote[class^='markdown-alert-'] {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  border-left: 4px solid var(--accent-note);
  background: var(--bg-alt);
  color: var(--fg);
}

.post-body blockquote[class^='markdown-alert-'] p {
  margin: 0.3rem 0;
}

.post-body blockquote.markdown-alert-important {
  border-left-color: var(--accent);
}

.post-body blockquote.markdown-alert-tip {
  border-left-color: var(--accent-tip);
}

.post-body blockquote.markdown-alert-warning,
.post-body blockquote.markdown-alert-caution {
  border-left-color: var(--accent-warning);
}

.term-list {
  list-style: none;
  padding: 0;
}

.term-list li {
  padding: 0.4rem 0;
}

.term-count {
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.social-links {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.social-links a {
  display: inline-flex;
  color: var(--muted);
  border-bottom: none !important;
}

.social-links a:hover {
  color: var(--accent);
}

.social-icon {
  width: 1.1rem;
  height: 1.1rem;
}
