/* Regira Blog public site — styled after regira.com (tokens lifted from its stylesheet) */
:root {
    --bg: #f7f8fa;
    --bg-alt: #fff;
    --bg-soft: #eef0f4;
    --ink: #0b1220;
    --ink-2: #1e2636;
    --muted: #5b6473;
    --muted-2: #8089a0;
    --line: #dfe3ea;
    --line-strong: #c8cfdb;
    --accent: #0a1ce8;
    --accent-soft: #e8eaff;
    --code-bg: #0b1220;
    --code-fg: #e3e6ee;
    --code-muted: #6f7a93;
    --code-key: #8fb3ff;
    --code-str: #b9e6c0;
    --code-num: #f0c178;
    --code-cmt: #5b6473;
    --code-type: #d2b6ff;
    --maxw: 1180px;
    --pad: clamp(16px, 4vw, 56px);
    --f-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --f-mono: "Geist Mono", ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink-2);
    font-family: var(--f-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
    font-family: var(--f-sans);
    letter-spacing: -0.02em;
    color: var(--ink);
    text-wrap: balance;
    margin: 0;
    font-weight: 500;
}
h1 { letter-spacing: -0.035em; font-size: clamp(40px, 6vw, 68px); line-height: 1.02; }
h1 .accent { color: var(--accent); }
h2 { letter-spacing: -0.025em; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; }

.wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    padding-left: var(--pad);
    padding-right: var(--pad);
}

/* header */
.site-header {
    border-bottom: 1px solid var(--line);
    background: var(--bg-alt);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 64px;
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
.wordmark .mark { width: 22px; height: 22px; flex: none; display: inline-block; background: url("/favicon.svg") 50% 50% / contain no-repeat; }
.wordmark-dot { color: var(--accent); }
.wordmark-sub { color: var(--muted); font-weight: 400; margin-left: 2px; }
.nav { display: flex; align-items: center; gap: 28px; }
.nav a { color: var(--ink-2); white-space: nowrap; font-size: 14px; position: relative; }
.nav a:hover, .nav a.active { color: var(--ink); }
.nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    background: var(--accent);
}

/* eyebrow label — the regira.com signature */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.eyebrow::before {
    content: "";
    background: var(--accent);
    width: 6px;
    height: 6px;
    display: inline-block;
    flex-shrink: 0;
}
.eyebrow a:hover { color: var(--accent); }

/* hero */
.hero { padding: clamp(48px, 9vw, 110px) 0 clamp(32px, 5vw, 64px); border-bottom: 1px solid var(--line); background: var(--bg-alt); }
.hero .eyebrow { margin-bottom: 28px; }
.hero-sub { color: var(--muted); font-size: clamp(16px, 1.6vw, 19px); max-width: 56ch; margin: 24px 0 0; }

/* buttons */
.btn {
    font-family: var(--f-sans);
    border: 1px solid var(--line-strong);
    background: var(--bg-alt);
    color: var(--ink);
    cursor: pointer;
    border-radius: 0;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    display: inline-flex;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* filter bar */
.filter-bar { display: flex; gap: 12px; margin: 40px 0 20px; }
.filter-bar input[type="search"] {
    flex: 1;
    max-width: 420px;
    font-family: var(--f-sans);
    font-size: 14px;
    padding: 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 0;
    background: var(--bg-alt);
    color: var(--ink);
}
.filter-bar input[type="search"]:focus { outline: none; border-color: var(--accent); }

.category-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: var(--bg-alt);
    color: var(--ink-2);
    font-size: 13px;
    padding: 5px 12px;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pill:hover { border-color: var(--ink); }
.pill.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.result-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    padding: 3px 10px;
}
.chip a { color: var(--accent); font-weight: 600; }

/* post grid + cards */
.post-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
    margin-bottom: 48px;
}
@media (max-width: 980px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .post-grid { grid-template-columns: 1fr; } }

.post-card {
    position: relative;
    background: var(--bg-alt);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, transform 0.15s;
}
.post-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.post-card .card-link { position: absolute; inset: 0; z-index: 1; }
.post-card-media { border-bottom: 1px solid var(--line); background: var(--code-bg); }
.post-card-media img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }
.post-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.post-card-title { font-size: 19px; line-height: 1.25; letter-spacing: -0.015em; }
.post-card:hover .post-card-title { color: var(--accent); }
.post-card-summary {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.post-card-meta { margin-top: auto; display: flex; align-items: center; gap: 14px; color: var(--muted-2); font-size: 13px; padding-top: 6px; }
.pin-flag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* pager */
.pager { display: flex; align-items: center; gap: 16px; justify-content: center; margin: 0 0 64px; }
.pager-info { color: var(--muted); font-size: 14px; }

/* empty state */
.empty-state { text-align: center; padding: 64px 0; color: var(--muted); }
.empty-state.tall { padding: 96px 0; }
.empty-state h1 { font-size: clamp(28px, 4vw, 44px); margin: 12px 0; }
.empty-state .btn { margin-top: 12px; }

/* article */
.article { max-width: 860px; padding-top: 40px; }
.back-link { color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--accent); }
.article-header { margin: 24px 0 32px; }
.article-header .eyebrow { margin-bottom: 18px; }
.article-header h1 { font-size: clamp(32px, 4.6vw, 52px); }
.article-summary { color: var(--muted); font-size: clamp(16px, 1.8vw, 19px); margin: 18px 0 0; max-width: 60ch; }
/* a rich summary arrives as <p> blocks - keep them visually identical to the plain-text version */
.article-summary p { margin: 0 0 0.4em; }
.article-summary p:last-child { margin-bottom: 0; }
.article-summary code { font-family: var(--f-mono); font-size: 0.9em; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; color: var(--muted-2); font-size: 14px; margin-top: 18px; }
.article-meta > * + *::before { content: "·"; margin-right: 10px; color: var(--line-strong); }
.article-meta strong { color: var(--ink-2); font-weight: 500; }
.meta-type { color: var(--accent); font-weight: 600; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.article-cover { border: 1px solid var(--line); margin-bottom: 36px; background: var(--code-bg); }
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 8px; }

/* prose — the rendered post body */
.prose { font-size: 16.5px; line-height: 1.75; color: var(--ink-2); }
.prose h2 { font-size: clamp(22px, 2.6vw, 30px); margin: 44px 0 16px; }
.prose h3 { font-size: 20px; margin: 32px 0 12px; }
.prose p { margin: 0 0 20px; }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 24px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--accent); }
.prose a:hover { text-decoration: underline; }
.prose img { border: 1px solid var(--line); margin: 28px 0; }
.prose blockquote {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    margin: 28px 0;
    padding: 16px 22px;
    color: var(--ink-2);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
/* markdown tables — display:block keeps a wide table scrollable instead of stretching the column */
.prose table {
    display: block;
    overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    margin: 28px 0;
}
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-soft); color: var(--ink); font-weight: 600; }
.prose code {
    font-family: var(--f-mono);
    font-size: 0.86em;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    padding: 1px 5px;
    color: var(--ink);
    /* long unbroken tokens (connection strings, urls) must not widen the page on phones */
    overflow-wrap: anywhere;
}
.prose a { overflow-wrap: anywhere; }
.prose pre {
    background: var(--code-bg);
    color: var(--code-fg);
    font-family: var(--f-mono);
    font-size: 13.5px;
    line-height: 1.6;
    padding: 20px 24px;
    overflow-x: auto;
    margin: 28px 0;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }

/* highlight.js — mapped onto regira.com's code palette */
.hljs { color: var(--code-fg); background: var(--code-bg); }
.hljs-keyword, .hljs-literal, .hljs-doctag, .hljs-selector-tag { color: var(--code-key); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--code-str); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--code-num); }
.hljs-comment, .hljs-quote, .hljs-deletion { color: var(--code-cmt); font-style: italic; }
.hljs-title, .hljs-title.class_, .hljs-title.function_, .hljs-type, .hljs-built_in { color: var(--code-type); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-params, .hljs-name { color: var(--code-fg); }
.hljs-meta, .hljs-punctuation, .hljs-tag { color: var(--code-muted); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* related section */
.related { border-top: 1px solid var(--line); margin-top: 64px; padding-top: 48px; padding-bottom: 32px; }
.section-head { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: baseline; gap: 48px; margin-bottom: 48px; }
.section-head > * { min-width: 0; }
@media (max-width: 760px) { .section-head { grid-template-columns: 1fr; gap: 8px; margin-bottom: 32px; } }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-alt); margin-top: 32px; }
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    padding-top: 28px;
    padding-bottom: 28px;
    color: var(--muted);
    font-size: 13px;
}
.footer-inner a:hover { color: var(--accent); }
.footer-note { color: var(--muted-2); }

@media (max-width: 640px) {
    .header-inner { height: auto; padding-top: 12px; padding-bottom: 12px; flex-direction: column; gap: 8px; }
    .nav { gap: 18px; }
    .filter-bar { flex-direction: column; }
    .filter-bar input[type="search"] { max-width: none; }
    .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ---------------------------------------------------------------------------
   Dark mode — same mechanism and tokens as regira.com: a data-theme attribute
   on <html>, set before first paint (see _Layout.cshtml). Everything below the
   token block is theme-agnostic because the whole sheet runs on the variables.
   --------------------------------------------------------------------------- */
:root { color-scheme: light; }
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0e17;
    --bg-alt: #0f1422;
    --bg-soft: #141a2b;
    --ink: #e7ebf3;
    --ink-2: #c3cad8;
    --muted: #8089a0;
    --muted-2: #757f9a;
    --line: #1f2737;
    --line-strong: #2b3447;
    --accent: #6e7bff;
    --accent-soft: #1a2152;
    --code-bg: #050811;
    --code-fg: #e3e6ee;
}

/* theme toggle (header) — sun in dark mode, moon in light mode */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    background: var(--bg-alt);
    color: var(--ink-2);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--ink); color: var(--ink); }
.theme-toggle .ic-sun { display: none; }
.theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }


/* two-column article: content left, info rail right (stacks below 960px) */
.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 32px 64px;
    align-items: start;
    padding-top: 40px;
}
.article-main { min-width: 0; }
.article-aside { display: flex; flex-direction: column; gap: 36px; font-size: 14px; padding-top: 8px; }
.aside-block .eyebrow { margin-bottom: 14px; }
.aside-meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.aside-meta dt { color: var(--muted); font-weight: 400; }
.aside-meta dd { margin: 0; color: var(--ink); }
.aside-group + .aside-group { margin-top: 16px; }
.aside-sub { display: block; font-size: 12px; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px; }
.aside-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.aside-links a { color: var(--ink-2); line-height: 1.45; display: block; }
.aside-links a:hover { color: var(--accent); }
@media (max-width: 960px) {
    .article-layout { grid-template-columns: 1fr; gap: 44px; }
    .article-aside { border-top: 1px solid var(--line); padding-top: 32px; }
}

.article-aside .article-tags { margin: 0; }

/* downloadable attachments (sample projects, scripts) - file cards in the info rail */
.article-files { display: flex; flex-direction: column; gap: 12px; }
.article-files .file-card .file-action { margin-left: auto; }
.file-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line-strong);
    background: var(--bg-alt);
    padding: 12px 16px;
    transition: border-color 0.15s, transform 0.15s;
}
.file-card:hover { border-color: var(--accent); transform: translateY(-1px); }
/* narrow screens: cards may fill the row; long file names wrap instead of overflowing */
.file-card { max-width: 100%; min-width: 0; }
.file-card .file-text { min-width: 0; }
.file-card .file-name { overflow-wrap: anywhere; }
.file-card .file-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
}
.file-card .file-text { display: flex; flex-direction: column; gap: 2px; }
.file-card .file-name { font-weight: 600; font-size: 14px; color: var(--ink); font-family: var(--f-mono); }
.file-card .file-info { font-size: 12px; color: var(--muted); }
.file-card .file-action {
    margin-left: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    white-space: nowrap;
}
.file-card:hover .file-action { text-decoration: underline; }

/* brand mark: lift the pure-blue starburst on dark backgrounds (same trick as regira.com) */
[data-theme="dark"] .wordmark .mark { filter: brightness(1.4); }
