/* ── Fonts ───────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "CaskaydiaCove";
  src: url("/static/fonts/CaskaydiaCoveNerdFont-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CaskaydiaCove";
  src: url("/static/fonts/CaskaydiaCoveNerdFont-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CaskaydiaCove";
  src: url("/static/fonts/CaskaydiaCoveNerdFont-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "CaskaydiaCoveMono";
  src: url("/static/fonts/CaskaydiaCoveNerdFontMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CaskaydiaCoveMono";
  src: url("/static/fonts/CaskaydiaCoveNerdFontMono-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */

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

/* Force font inheritance — browsers skip this for pre/code/kbd/input by default */
pre, code, kbd, input, textarea, button, select {
  font-family: inherit;
  font-size: inherit;
}

:root {
  --bg:        #f9f9f7;
  --fg:        #1a1a1a;
  --muted:     #666;      /* was #888 — now passes WCAG AA (4.6:1 on --bg) */
  --border:    #ddd;
  --link:      #1a1a1a;
  --link-vis:  #555;
  --code-bg:   #f0f0ee;
  --font:      "CaskaydiaCove", "Courier New", Courier, monospace;
  --font-mono: "CaskaydiaCoveMono", "Courier New", Courier, monospace;
  --max-width: 860px;
  --line:      1.75;
}

[data-theme="dark"] {
  --bg:        #1a1a1a;
  --fg:        #e8e8e4;
  --muted:     #999;      /* was #666 — on dark bg #999 gives ~4.7:1 */
  --border:    #333;
  --link:      #e8e8e4;
  --link-vis:  #aaa;
  --code-bg:   #242424;
}

/* ── Selection ───────────────────────────────────────────────────────────── */

::selection {
  background: #f5e642;
  color: #000;
}

/* ── Focus ───────────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Theme toggle ────────────────────────────────────────────────────────── */

#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 3px;
  transition: border-color 0.15s, color 0.15s;
  z-index: 100;
}

#theme-toggle:hover {
  border-color: var(--fg);
}

html {
  font-size: 15px;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: var(--font);
  line-height: var(--line);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

header {
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.site-title {
  font-weight: bold;
  font-size: 1rem;
  text-decoration: none;
  color: var(--fg);
}

.site-title:hover {
  text-decoration: underline;
}

.site-desc {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

footer {
  margin-top: 4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.monologlink {
  color: #d6c60e;
}
.monologlink:visited {
  color: #7d7300;
}

/* ── Index ───────────────────────────────────────────────────────────────── */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-entry {
  display: grid;
  grid-template-columns: 7rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 1rem;
}

.post-date {
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 0.05rem;
  white-space: nowrap;
}

.post-link {
  color: var(--link);
  text-decoration: none;
  font-weight: bold;
}

.post-link:hover {
  text-decoration: underline;
}

.post-desc {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

/* ── Post ────────────────────────────────────────────────────────────────── */

.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.post-header time {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Post Body ───────────────────────────────────────────────────────────── */

.post-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  font-weight: bold;
  margin-top: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body h1 { font-size: 1.25rem; }
.post-body h2 { font-size: 1.15rem; }
.post-body h3 { font-size: 1.05rem; }
.post-body h4 { font-size: 1rem; }

.post-body h2::before { content: "## "; color: var(--muted); }
.post-body h3::before { content: "### "; color: var(--muted); }
.post-body h4::before { content: "#### "; color: var(--muted); }

.post-body p {
}

.post-body a {
  color: var(--link);
}

.post-body a:visited {
  color: var(--link-vis);
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
}

.post-body ol {
  padding-left: 2rem;  /* numbers need more space than bullets */
}

.post-body li {
  margin: 0.1rem 0;
}

.post-body blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  font-style: italic;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Images ──────────────────────────────────────────────────────────────── */

.post-body img {
  max-width: 100%;
  display: block;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
}

/* ── Inline code ─────────────────────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border: 1px solid var(--border);
}

/* ── Keyboard ────────────────────────────────────────────────────────────── */

kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 0.1em 0.35em;
  border-radius: 2px;
  color: var(--fg);
}

[data-theme="light"] kbd {
  background: #f9f9cc;
  border-color: #9d9d63;
  color: #1a1a1a;
}

[data-theme="dark"] kbd {
  background: #f3f392;
  border-color: #9d9d63;
  color: #1a1a1a;
}

/* ── Code blocks ─────────────────────────────────────────────────────────── */

pre {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

/* Pygments wraps code in a div.codehilite — style it like pre */
.codehilite {
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.5;
}

.codehilite pre {
  background: none;
  border: none;
  padding: 1rem;
  overflow-x: visible;
  margin: 0;
}

/* Pygments syntax highlight — lovelace theme */
.codehilite .hll { background-color: #ffffcc }
.codehilite .c   { color: #888; font-style: italic }
.codehilite .err { background-color: #A848A8 }
.codehilite .k   { color: #2838B0 }
.codehilite .o   { color: #666 }
.codehilite .p   { color: #888 }
.codehilite .ch  { color: #287088; font-style: italic }
.codehilite .cm  { color: #888; font-style: italic }
.codehilite .cp  { color: #289870 }
.codehilite .cpf { color: #888; font-style: italic }
.codehilite .c1  { color: #888; font-style: italic }
.codehilite .cs  { color: #888; font-style: italic }
.codehilite .gd  { color: #C02828 }
.codehilite .ge  { font-style: italic }
.codehilite .gr  { color: #C02828 }
.codehilite .gi  { color: #388038 }
.codehilite .go  { color: #666 }
.codehilite .gp  { color: #444 }
.codehilite .gs  { font-weight: bold }
.codehilite .gu  { color: #444 }
.codehilite .gt  { color: #2838B0 }
.codehilite .kc  { color: #444; font-style: italic }
.codehilite .kd  { color: #2838B0; font-style: italic }
.codehilite .kn  { color: #2838B0 }
.codehilite .kp  { color: #2838B0 }
.codehilite .kr  { color: #2838B0 }
.codehilite .kt  { color: #2838B0; font-style: italic }
.codehilite .m   { color: #444 }
.codehilite .s   { color: #B83838 }
.codehilite .na  { color: #388038 }
.codehilite .nb  { color: #388038 }
.codehilite .nc  { color: #287088 }
.codehilite .no  { color: #B85820 }
.codehilite .nd  { color: #287088 }
.codehilite .ni  { color: #709030 }
.codehilite .ne  { color: #908828 }
.codehilite .nf  { color: #785840 }
.codehilite .nl  { color: #289870 }
.codehilite .nn  { color: #289870 }
.codehilite .nt  { color: #2838B0 }
.codehilite .nv  { color: #B04040 }
.codehilite .ow  { color: #A848A8 }
.codehilite .w   { color: #A89028 }
.codehilite .mb  { color: #444 }
.codehilite .mf  { color: #444 }
.codehilite .mh  { color: #444 }
.codehilite .mi  { color: #444 }
.codehilite .mo  { color: #444 }
.codehilite .s1  { color: #B83838 }
.codehilite .s2  { color: #B83838 }
.codehilite .sb  { color: #B83838 }
.codehilite .sc  { color: #A848A8 }
.codehilite .sd  { color: #B85820; font-style: italic }
.codehilite .se  { color: #709030 }
.codehilite .sh  { color: #B83838 }
.codehilite .si  { color: #B83838; text-decoration: underline }
.codehilite .sx  { color: #A848A8 }
.codehilite .sr  { color: #A848A8 }
.codehilite .ss  { color: #B83838 }
.codehilite .bp  { color: #388038; font-style: italic }
.codehilite .fm  { color: #B85820 }
.codehilite .vc  { color: #B04040 }
.codehilite .vg  { color: #908828 }
.codehilite .vi  { color: #B04040 }
.codehilite .vm  { color: #B85820 }
.codehilite .il  { color: #444 }

/* Dark mode — soften lovelace colors against dark background */
[data-theme="dark"] .codehilite .k,
[data-theme="dark"] .codehilite .kd,
[data-theme="dark"] .codehilite .kn,
[data-theme="dark"] .codehilite .kp,
[data-theme="dark"] .codehilite .kr,
[data-theme="dark"] .codehilite .kt  { color: #7090e8 }
[data-theme="dark"] .codehilite .s,
[data-theme="dark"] .codehilite .s1,
[data-theme="dark"] .codehilite .s2,
[data-theme="dark"] .codehilite .sb,
[data-theme="dark"] .codehilite .sh,
[data-theme="dark"] .codehilite .ss  { color: #e87878 }
[data-theme="dark"] .codehilite .na,
[data-theme="dark"] .codehilite .nb,
[data-theme="dark"] .codehilite .bp  { color: #70b870 }
[data-theme="dark"] .codehilite .nc,
[data-theme="dark"] .codehilite .nd  { color: #70b0c8 }
[data-theme="dark"] .codehilite .nf,
[data-theme="dark"] .codehilite .fm  { color: #c8a080 }
[data-theme="dark"] .codehilite .no,
[data-theme="dark"] .codehilite .sd  { color: #e89060 }
[data-theme="dark"] .codehilite .ow,
[data-theme="dark"] .codehilite .sc,
[data-theme="dark"] .codehilite .sx,
[data-theme="dark"] .codehilite .sr  { color: #c878c8 }
[data-theme="dark"] .codehilite .c,
[data-theme="dark"] .codehilite .c1,
[data-theme="dark"] .codehilite .cm  { color: #666 }
[data-theme="dark"] .codehilite .mi,
[data-theme="dark"] .codehilite .mf,
[data-theme="dark"] .codehilite .m   { color: #aaa }
[data-theme="dark"] .codehilite .o,
[data-theme="dark"] .codehilite .p   { color: #aaa }



.post-body table {
  border-collapse: collapse;
  font-size: 0.9rem;
  width: 100%;
}

.post-body th,
.post-body td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  text-align: left;
}

.post-body th {
  background: var(--code-bg);
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */

.post-nav {
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.post-nav a {
  color: var(--muted);
  text-decoration: none;
}

.post-nav a:hover {
  text-decoration: underline;
}

/* ── Error page ──────────────────────────────────────────────────────────── */

.error {
  padding-top: 2rem;
}

.error-code {
  font-size: 3rem;
  font-weight: bold;
  color: var(--muted);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-msg {
  margin-bottom: 2rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/*
  Breakpoints:
    tablet  -> max-width: 768px
    mobile  -> max-width: 480px
*/

/* Tables: scroll horizontally instead of breaking layout */

.post-body table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

/* Tablet (<= 768px) */

@media (max-width: 768px) {
  body {
    padding: 2rem 1.25rem 3rem;
  }

  header {
    margin-bottom: 2rem;
  }

  .site-desc {
    display: block;
    margin-top: 0.2rem;
  }

  .post-entry {
    grid-template-columns: 6rem 1fr;
  }

  .post-body p {
    max-width: 100%;
  }
}

/* Mobile (<= 480px) */

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  body {
    padding: 1.25rem 1rem 2.5rem;
  }

  header {
    margin-bottom: 1.5rem;
  }

  .post-entry {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .post-date {
    font-size: 0.8rem;
  }

  .post-desc {
    margin-top: 0.1rem;
  }

  .post-header {
    margin-bottom: 1.5rem;
  }

  pre {
    padding: 0.75rem;
    font-size: 0.8rem;
  }

  pre code {
    font-size: 0.8rem;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
  }

  code {
    word-break: break-all;
  }

  .post-body img {
    width: 100%;
  }

  .post-body table {
    font-size: 0.8rem;
  }

  .post-body blockquote {
    padding-left: 0.75rem;
  }

  .post-body ul {
    padding-left: 1.1rem;
  }

  .post-body ol {
    padding-left: 1.5rem;
  }

  .post-link,
  .post-nav a {
    display: inline-block;
    padding: 0.15rem 0;
  }

  footer {
    margin-top: 2.5rem;
    font-size: 0.75rem;
  }
}
