/*
 * md-enhance.css — styling for the JS enhancements in md-enhance.js.
 * Long-form prose typography now comes from Tailwind's `prose` class
 * (@tailwindcss/typography, themed in styles/tailwind.config.js). This
 * file only owns the interactive bits the plugin can't express:
 *
 *   .md-code     — the code-block frame (bar + copy button) the JS injects
 *   .md-img      — clickable images
 *   .md-lightbox — the fullscreen image viewer / gallery
 *
 * A plain stylesheet (NOT Tailwind), so it's never purged. Uses the
 * site's theme variables (see styles/input.css).
 */

/* ===== Code preview frame (injected by md-enhance.js) =====
   The JS wraps each <pre> in `.md-code.not-prose`, so `prose` leaves the
   code block alone and this frame fully owns its look. */
.md-code {
  margin: 0 0 1.4em;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--shade-2, #2a2622);
  background: var(--shade, #1b1714);
  box-shadow: 0 14px 34px -22px rgba(27, 23, 20, 0.5);
}
.md-code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: var(--shade-2, #221e1a);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.md-code__lang {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--shade-faint, #8a807a);
}
.md-code__copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--shade-ink, #e9e2da);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.md-code__copy:hover { background: rgba(255, 255, 255, 0.1); }
.md-code__copy.is-copied {
  color: var(--ok, #2f9e6b);
  border-color: color-mix(in srgb, var(--ok, #2f9e6b) 50%, transparent);
}
.md-code pre {
  margin: 0;
  padding: 15px 16px;
  overflow-x: auto;
  background: transparent;
}
.md-code pre code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--shade-ink, #e9e2da);
  background: transparent;
  border: 0;
  padding: 0;
  /* Wrap long lines instead of scrolling the block horizontally. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ===== Images + lightbox ===== */
.md-img {
  cursor: zoom-in;
  border-radius: 12px;
  transition: filter 0.15s ease;
}
.md-img:hover { filter: brightness(0.96); }

.md-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4vh 2vw;
  background: rgba(20, 17, 14, 0.86);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.md-lightbox[aria-hidden="true"] { display: none; }
.md-lightbox__figure {
  margin: 0;
  max-width: min(1100px, 92vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.md-lightbox__img {
  max-width: 100%;
  max-height: 84vh;
  border-radius: 10px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
  object-fit: contain;
}
.md-lightbox__cap {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  text-align: center;
  max-width: 70ch;
}
.md-lightbox__close,
.md-lightbox__nav {
  flex-shrink: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s ease;
}
.md-lightbox__close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 38px;
  height: 38px;
  font-size: 18px;
}
.md-lightbox__nav { width: 46px; height: 46px; font-size: 26px; line-height: 1; }
.md-lightbox__close:hover,
.md-lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }

@media (max-width: 640px) {
  .md-lightbox__nav { width: 38px; height: 38px; font-size: 22px; }
}

/* ===== Tables ===== */
/* `md-enhance.js` wraps each [data-md] <table> in a `.md-table` frame so
   the rounded border can clip the corners and wide tables scroll instead
   of breaking the page. */
.md-table {
  margin: 1em 0;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;          /* clip the table to the rounded corners */
}
/* Inner scroller: wide tables scroll horizontally without breaking the
   rounded frame. The scroll lives here, NOT on the corner-clipping wrapper —
   `overflow-x: auto` on a radius'd box would let the corners bleed. */
.md-table__scroll {
  overflow-x: auto;
}
.md-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.md-table th,
.md-table td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
.md-table th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--ink);
}
.md-table tr:last-child td { border-bottom: 0; }
.md-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

/* ===== Shared markdown prose ===== */
/* One prose component for every rendered-markdown surface (plugin pages,
   notes, blog posts). Lives here (global) so the styling is identical
   everywhere. Code blocks defer to the `.md-code` frame; only an unwrapped
   `> pre` (JS-off fallback) is styled. */
.pd-prose { color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.pd-prose h1, .pd-prose h2, .pd-prose h3 { color: var(--ink); font-weight: 800; letter-spacing: -0.01em; margin: 1.4em 0 0.5em; line-height: 1.25; }
.pd-prose h1 { font-size: 23px; }
.pd-prose h2 { font-size: 20px; }
.pd-prose h3 { font-size: 17px; }
.pd-prose p { margin: 0.8em 0; }
.pd-prose ul, .pd-prose ol { margin: 0.8em 0; padding-left: 1.3em; }
.pd-prose li { margin: 0.3em 0; }
.pd-prose a { color: var(--accent-2); text-decoration: underline; }
.pd-prose code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.88em; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 6px; padding: 0.12em 0.4em; color: var(--ink-2); }
.pd-prose > pre { background: var(--shade); color: var(--shade-ink); border-radius: 14px; padding: 16px 20px; overflow-x: auto; margin: 1em 0; }
.pd-prose > pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.pd-prose blockquote { border-left: 3px solid var(--accent-line); padding-left: 14px; color: var(--muted); margin: 1em 0; }
.pd-prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
.pd-prose th, .pd-prose td { border: 1px solid var(--hairline); padding: 8px 12px; text-align: left; }
.pd-prose th { background: var(--surface-2); font-weight: 700; }
