/* ==========================================================================
   Blog shell: loaded only on the Systeme.io blog served at /blog by the
   Cloudflare Worker (worker/index.mjs). Self-contained: it does NOT load
   Bootstrap or site.css, because those would collide with Systeme.io's CSS.
   Palette matches assets/css/site.css.
   ========================================================================== */

:root {
  --rsw-bg: #0B1220;
  --rsw-panel: #111C30;
  --rsw-card: #152540;
  --rsw-cyan: #33D6FF;
  --rsw-sky: #88DAF5;
  --rsw-text: #F7FAFC;
  --rsw-muted: #A9B7CC;
  --rsw-border: rgba(51, 214, 255, 0.22);
}

/* ---------- Page background and base text ---------------------------------- */
html[data-rsw-blog],
html[data-rsw-blog] body {
  background-color: var(--rsw-bg) !important;
  color: var(--rsw-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-rsw-blog] body {
  margin: 0;
  min-width: 320px;
}

/* ---------- Hide Systeme.io's template header and footer sections ----------
   Systeme.io renders the blog layout as a stack of sections inside #app, each in its own wrapper div.
   The first wrapper (after an empty spacer div) is the header; the last two are the footer and the
   "Created with systeme.io" bar. */
html[data-rsw-blog] #app > div > div > div:nth-child(2),
html[data-rsw-blog] #app > div > div > div:nth-last-child(-n + 2) {
  display: none !important;
}

/* ---------- Theme overrides for Systeme.io content --------------------------- */
/* Systeme.io templates paint light backgrounds on sections and inner wrappers; clear them so the dark
   site background shows through. Images, buttons, and inputs keep their own backgrounds. */
html[data-rsw-blog] #app section,
html[data-rsw-blog] #app section div,
html[data-rsw-blog] #app > div > div > div:first-child {
  background-color: transparent !important;
}

/* Section background images (the template's beige texture) are removed for the same reason. Photos
   placed as <img> elements in the Systeme.io editor are not affected. */
html[data-rsw-blog] #app section {
  background-image: none !important;
}

html[data-rsw-blog] #app h1,
html[data-rsw-blog] #app h2,
html[data-rsw-blog] #app h3,
html[data-rsw-blog] #app h4,
html[data-rsw-blog] #app h5,
html[data-rsw-blog] #app h6,
html[data-rsw-blog] #app h1 *,
html[data-rsw-blog] #app h2 *,
html[data-rsw-blog] #app h3 *,
html[data-rsw-blog] #app h4 *,
html[data-rsw-blog] #app h5 *,
html[data-rsw-blog] #app h6 * {
  color: var(--rsw-text) !important;
  font-family: inherit !important;
}

html[data-rsw-blog] #app p,
html[data-rsw-blog] #app li,
html[data-rsw-blog] #app p *,
html[data-rsw-blog] #app li * {
  color: #D5DFEC !important;
  font-family: inherit !important;
}

html[data-rsw-blog] #app p a,
html[data-rsw-blog] #app li a,
html[data-rsw-blog] #app p a * ,
html[data-rsw-blog] #app li a * {
  color: var(--rsw-cyan) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Post list cards ------------------------------------------------------
   Systeme.io renders a card's category label and title as plain links, not headings or paragraphs,
   so the rules above never reach them and the template's near-black link colors (#1c232d, #1e3030)
   disappear into the dark background. The links are matched by URL, not by Systeme.io's generated
   class names, which change with every build. "div > a" keeps this away from links inside body text,
   which are styled above. Contrast on #0B1220: title 17:1, category 11:1. */
html[data-rsw-blog] #app a[href*="/blog/category/"] {
  color: var(--rsw-cyan) !important;
  font-weight: 600;
  text-decoration: none;
}

html[data-rsw-blog] #app div > a[href*="/blog/"]:not([href*="/blog/category/"]):not([href*="/blog/posts"]):not([href*="/blog/search"]):not([href*="/blog/tag/"]) {
  color: var(--rsw-text) !important;
  text-decoration: none;
}

html[data-rsw-blog] #app div > a[href*="/blog/"]:not([href*="/blog/category/"]):not([href*="/blog/posts"]):not([href*="/blog/search"]):not([href*="/blog/tag/"]):hover,
html[data-rsw-blog] #app div > a[href*="/blog/"]:not([href*="/blog/category/"]):not([href*="/blog/posts"]):not([href*="/blog/search"]):not([href*="/blog/tag/"]):focus-visible {
  color: var(--rsw-cyan) !important;
  text-decoration: underline;
  text-underline-offset: 4px;
}

html[data-rsw-blog] #app a[href*="/blog/"]:focus-visible {
  outline: 2px solid var(--rsw-cyan);
  outline-offset: 3px;
  border-radius: 0.75rem;
}

/* Card images: rounded corners, and a little room before the category label. The image sits directly
   in the link on the post list and inside a <picture> on the blog home, so both are covered. */
html[data-rsw-blog] #app a[href*="/blog/"] > img,
html[data-rsw-blog] #app a[href*="/blog/"] > picture > img {
  display: block;
  margin-bottom: 0.75rem;
  border-radius: 0.75rem;
}

/* Author photo in the post sidebar. worker/rewrite.mjs swaps the template's stock photo for the site
   owner's headshot (assets/img/cory-diggs-headshot.jpg); frame it as a round avatar. */
html[data-rsw-blog] #app img[src*="cory-diggs-headshot"] {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
}

html[data-rsw-blog] #app blockquote {
  border-left: 4px solid var(--rsw-cyan);
  background: var(--rsw-panel);
}

html[data-rsw-blog] #app pre,
html[data-rsw-blog] #app code {
  background: #070B14 !important;
  color: var(--rsw-sky) !important;
}

/* ---------- Injected site header ------------------------------------------- */
.rsw-skip {
  position: absolute;
  left: -9999px;
  top: 0;
}

.rsw-skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  background: var(--rsw-cyan);
  color: #0B1220;
  font-weight: 700;
  text-decoration: none;
  border-radius: 4px;
}

.rsw-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background-color: rgba(11, 18, 32, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rsw-border);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.rsw-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.rsw-brand {
  color: var(--rsw-text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.rsw-brand span {
  color: var(--rsw-cyan);
}

.rsw-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0;
}

.rsw-nav a {
  padding: 0.5rem 0.75rem;
  color: var(--rsw-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.rsw-nav a:hover,
.rsw-nav a[aria-current="page"] {
  color: var(--rsw-cyan);
}

.rsw-nav .rsw-btn,
.rsw-nav .rsw-btn:hover {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rsw-cyan);
  border-radius: 6px;
  background: var(--rsw-cyan);
  color: #0B1220;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 0 16px rgba(51, 214, 255, 0.35);
}

.rsw-nav .rsw-btn:hover {
  background: var(--rsw-sky);
  border-color: var(--rsw-sky);
}

/* Mobile menu: <details>, no JavaScript. */
.rsw-menu {
  display: contents;
}

.rsw-menu__toggle {
  list-style: none;
  cursor: pointer;
  width: 2.75rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rsw-border);
  border-radius: 6px;
}

.rsw-menu__toggle::-webkit-details-marker {
  display: none;
}

.rsw-menu__toggle span,
.rsw-menu__toggle span::before,
.rsw-menu__toggle span::after {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: var(--rsw-text);
  content: "";
  position: relative;
}

.rsw-menu__toggle span::before {
  position: absolute;
  top: -6px;
}

.rsw-menu__toggle span::after {
  position: absolute;
  top: 6px;
}

.rsw-menu:not([open]) .rsw-nav {
  display: none;
}

.rsw-menu .rsw-nav {
  flex-basis: 100%;
}

@media (min-width: 992px) {
  .rsw-menu::details-content {
    content-visibility: visible;
    display: contents;
  }

  .rsw-menu__toggle {
    display: none;
  }

  .rsw-menu:not([open]) .rsw-nav,
  .rsw-menu .rsw-nav {
    display: flex;
    flex-basis: auto;
    flex-direction: row;
    align-items: center;
    padding: 0;
  }

  .rsw-nav .rsw-btn {
    margin-top: 0;
    margin-left: 0.5rem;
  }
}

.rsw-header a:focus-visible,
.rsw-footer a:focus-visible,
.rsw-menu__toggle:focus-visible {
  outline: 2px solid var(--rsw-cyan);
  outline-offset: 3px;
}

/* ---------- Injected site footer ------------------------------------------- */
.rsw-footer {
  background-color: #070B14;
  border-top: 1px solid var(--rsw-border);
  color: var(--rsw-muted);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
}

.rsw-footer__inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.rsw-footer p {
  margin: 0 0 1rem;
}

.rsw-footer strong {
  color: var(--rsw-text);
}

.rsw-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.rsw-footer a {
  color: var(--rsw-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.rsw-footer a:hover {
  color: var(--rsw-cyan);
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .rsw-nav a,
  .rsw-footer a {
    transition: none;
  }
}

/* Server-rendered "All posts" list: gives crawlers (and no-JS readers) a plain link to every post. */
.rsw-post-list {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1rem;
  color: var(--rsw-text);
}

.rsw-post-list h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--rsw-text);
}

.rsw-post-list ul {
  margin: 0;
  padding-left: 1.25rem;
}

.rsw-post-list li {
  margin-bottom: 0.5rem;
}

.rsw-post-list a {
  color: var(--rsw-cyan);
}

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