:root {
  --text: #1a1a1a;
  --bg: #fff;
  --muted: #666;
  --border: #e0e0e0;
  --link: #1a1a1a;
  --mono: "SF Mono", "Menlo", "Consolas", monospace;
  --sans: "Inter", "Helvetica Neue", "Arial", sans-serif;
  --max-w: 64em;
  --sidebar-w: 12em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e0e0e0;
    --bg: #1a1025;
    --muted: #a89bb5;
    --border: #2e2440;
    --link: #e0e0e0;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* --- desktop: sidebar layout --- */

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  padding: 2rem 2rem 2rem calc(var(--sidebar-w) + 3rem);
  max-width: calc(var(--max-w) + var(--sidebar-w) + 3rem);
  margin: 0 auto;
}

#site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-right: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}

/* hide quarto's TOC nav — we don't use it */
#TOC { display: none; }

.site-title {
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 1rem;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links a:hover { color: var(--text); }

.menu-toggle { display: none; }

/* --- mobile: top bar + hamburger --- */

@media (max-width: 720px) {
  body {
    padding: 4.5rem 1.5rem 2rem;
    max-width: var(--max-w);
  }

  #site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.8rem 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .site-title { margin-bottom: 0; }

  .menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
  }

  .menu-toggle span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--text);
    transition: transform 0.2s, opacity 0.2s;
  }

  /* animate to X */
  #site-nav.open .menu-toggle span:first-child { transform: translateY(3.25px) rotate(45deg); }
  #site-nav.open .menu-toggle span:last-child { transform: translateY(-3.25px) rotate(-45deg); }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.5rem;
    gap: 0.5rem;
  }

  #site-nav.open .nav-links { display: flex; }
}

/* --- content --- */

/* headings */
h1, h2, h3 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }

/* links */
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration: none; }

/* paragraphs, lists */
p { margin-bottom: 1rem; }
ul, ol { margin: 0 0 1rem 1.2rem; }
li { margin-bottom: 0.3rem; }

/* blockquotes / callouts */
blockquote {
  border-left: 3px solid var(--border);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  background: color-mix(in srgb, var(--text) 4%, var(--bg));
  border-radius: 0 4px 4px 0;
}
blockquote > p:last-child { margin-bottom: 0; }
blockquote > p:first-child > strong:only-child {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

/* code */
code { font-family: var(--mono); font-size: 0.88em; background: color-mix(in srgb, var(--text) 8%, transparent); padding: 0.15em 0.35em; border-radius: 3px; }
pre { overflow-x: auto; padding: 1rem; margin: 1rem 0; border: 1px solid var(--border); border-radius: 4px; background: color-mix(in srgb, var(--text) 4%, var(--bg)); }
pre code { background: none; padding: 0; }
div.sourceCode { margin: 1rem 0; }

/* syntax highlighting — light */
code span.kw { color: #7928a1; }           /* keyword */
code span.cf { color: #7928a1; }           /* control flow */
code span.fu { color: #005cc5; }           /* function */
code span.st { color: #22863a; }           /* string */
code span.co { color: #999; font-style: italic; } /* comment */
code span.dv, code span.fl, code span.bn { color: #d73a49; } /* numbers */
code span.cn { color: #005cc5; }           /* constant (TRUE/FALSE/NULL) */
code span.op { color: #666; }              /* operator */
code span.ot { color: #005cc5; }           /* other */
code span.sc { color: #22863a; }           /* special char */
code span.al, code span.er { color: #d73a49; font-weight: 600; } /* alert/error */
code span.wa { color: #e36209; font-style: italic; } /* warning */
code span.at { color: #005cc5; }           /* attribute */
code span.dt { color: #7928a1; }           /* data type */
code span.va { color: var(--text); }       /* variable */

/* syntax highlighting — dark */
@media (prefers-color-scheme: dark) {
  code span.kw { color: #c792ea; }
  code span.cf { color: #c792ea; }
  code span.fu { color: #82aaff; }
  code span.st { color: #c3e88d; }
  code span.co { color: #666; }
  code span.dv, code span.fl, code span.bn { color: #f78c6c; }
  code span.cn { color: #82aaff; }
  code span.op { color: #89ddff; }
  code span.ot { color: #82aaff; }
  code span.sc { color: #c3e88d; }
  code span.al, code span.er { color: #ff5370; }
  code span.wa { color: #ffcb6b; }
  code span.at { color: #82aaff; }
  code span.dt { color: #c792ea; }
  code span.va { color: var(--text); }
}

/* blog listing */
.quarto-listing { margin-top: 0; }

/* filter inline with blog header */
.listing-actions-group { float: right; margin-top: -2.4rem; }
.quarto-listing-filter { margin: 0; display: flex; }
.quarto-listing-filter .input-group-text { display: none; }
.quarto-listing-filter input[type="text"] {
  width: 280px; padding: 0.35rem 0.6rem; font-family: var(--sans); font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text);
}
.quarto-listing-filter input[type="text"]::placeholder { color: var(--muted); }
.quarto-listing-filter input[type="text"]:focus { outline: none; border-color: var(--muted); }

/* hide "no matching items" when not filtering */
.listing-no-matching { display: none; }
.listing-no-matching.d-none { display: none !important; }
.list.quarto-listing-default .quarto-post { border-bottom: 1px solid var(--border); padding: 1rem 0; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.quarto-post .body { flex: 1; min-width: 0; }
.quarto-post .listing-subtitle { display: none; }
.quarto-post .listing-title { font-weight: 600; font-size: 1.05rem; }
.quarto-post .listing-description { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.quarto-post .metadata { flex-shrink: 0; }
.quarto-post .listing-date { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); white-space: nowrap; }
.listing-title a { text-decoration: none; }
.listing-title a:hover { text-decoration: underline; }
.listing-category {
  font-size: 0.75rem; color: var(--muted); border: 1px solid var(--border);
  padding: 0.1rem 0.45rem; border-radius: 3px; cursor: pointer;
}
.listing-category:hover { color: var(--text); border-color: var(--muted); }

/* images */
img { max-width: 100%; height: auto; }

/* gallery */
.gallery { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.gallery-col { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.gallery a { display: block; }
.gallery img { width: 100%; height: auto; border-radius: 3px; display: block; transition: opacity 0.15s; }
.gallery img:hover { opacity: 0.85; }
@media (max-width: 720px) { .gallery { flex-wrap: wrap; }
  .gallery-col { flex: 1 1 calc(50% - 0.25rem); } }

/* lightbox */
.lightbox { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.9); align-items: center; justify-content: center; }
.lightbox.active { display: flex; }
#lb-img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
.lb-close { position: absolute; top: 1rem; right: 1.5rem; background: none; border: none; color: #fff; font-size: 2.5rem; cursor: pointer; line-height: 1; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); background: none; border: none; color: #fff; font-size: 3rem; cursor: pointer; padding: 0.5rem; line-height: 1; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-prev:hover, .lb-next:hover, .lb-close:hover { color: #ccc; }
.gallery a { cursor: zoom-in; }

/* quarto overrides — kill bloat */
.quarto-title-meta, .quarto-title-banner { display: none; }
#quarto-header, #quarto-footer { all: unset; }
.page-columns { display: block; }
#quarto-content { padding: 0; }
.quarto-title .title { font-size: 1.4rem; margin-bottom: 0.3rem; }
