/* Detection & Response — shared stylesheet */

/* ---------- Fonts ---------- */
/* JetBrains Mono, self-hosted variable subset (400–700 on one axis). */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
                 U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Theme tokens ---------- */
:root {
  --bg:        #f7f9fb;
  --bg-panel:  #ffffff;
  --bg-code:   #eef2f7;
  --bg-termbar:#eef2f7;
  --bg-thead:  #f0f4f8;
  --border:    #dfe5ec;
  --text:      #33404f;
  --text-dim:  #64748b;
  --heading:   #0f1b2d;
  --accent:    #0d9488;
  --accent-2:  #b45309;
  --red:       #dc2626;
  --green:     #059669;
  --link:      #0e7490;
  --code-ink:  #334155;
  --code-inline: #0b7c72;
  --callout-bg:     #fffaf2;
  --callout-border: #f2e2c9;
  --header-bg: rgba(247,249,251,0.85);
  --stripe:    rgba(16,24,40,0.018);
  --shadow:    0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
  --shadow-lg: 0 6px 18px rgba(16,24,40,0.10);
  --radius:    12px;
  --maxw:      820px;
  --mono:      "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}

/* Dark palette. Applied when the visitor's OS asks for dark, unless they have
   explicitly chosen light via the header toggle (html[data-theme="light"]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e131a;
    --bg-panel:  #151c26;
    --bg-code:   #111823;
    --bg-termbar:#1b2431;
    --bg-thead:  #1b2431;
    --border:    #26313f;
    --text:      #c2ccd8;
    --text-dim:  #8b98a8;
    --heading:   #eef3f9;
    --accent:    #2dd4bf;
    --accent-2:  #fbbf24;
    --red:       #f87171;
    --green:     #34d399;
    --link:      #5eead4;
    --code-ink:  #c2ccd8;
    --code-inline: #5eead4;
    --callout-bg:     #1e1a12;
    --callout-border: #4a3b1d;
    --header-bg: rgba(14,19,26,0.85);
    --stripe:    rgba(255,255,255,0.022);
    --shadow:    0 1px 2px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.36);
    --shadow-lg: 0 6px 18px rgba(0,0,0,0.45);
    color-scheme: dark;
  }
}

/* Same palette, forced on by the toggle regardless of OS preference. */
:root[data-theme="dark"] {
  --bg:        #0e131a;
  --bg-panel:  #151c26;
  --bg-code:   #111823;
  --bg-termbar:#1b2431;
  --bg-thead:  #1b2431;
  --border:    #26313f;
  --text:      #c2ccd8;
  --text-dim:  #8b98a8;
  --heading:   #eef3f9;
  --accent:    #2dd4bf;
  --accent-2:  #fbbf24;
  --red:       #f87171;
  --green:     #34d399;
  --link:      #5eead4;
  --code-ink:  #c2ccd8;
  --code-inline: #5eead4;
  --callout-bg:     #1e1a12;
  --callout-border: #4a3b1d;
  --header-bg: rgba(14,19,26,0.85);
  --stripe:    rgba(255,255,255,0.022);
  --shadow:    0 1px 2px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.36);
  --shadow-lg: 0 6px 18px rgba(0,0,0,0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

code, pre, .mono {
  font-family: var(--mono);
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13,148,136,0.05), transparent);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
  background-color: var(--header-bg);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 16px; padding-bottom: 16px;
}
.brand { font-weight: 700; color: var(--heading); letter-spacing: -0.01em; font-size: 1.05rem; }
.brand .dot { color: var(--accent); }
.nav a { color: var(--text-dim); margin-left: 20px; font-size: 0.92rem; }
.nav a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Hero (index) ---------- */
.hero { padding: 72px 0 44px; border-bottom: 1px solid var(--border); }
.eyebrow {
  display: inline-block; font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 14px; margin-bottom: 22px; background: var(--bg-panel); box-shadow: var(--shadow);
}
.hero h1 { font-size: 2.55rem; line-height: 1.12; margin: 0 0 16px; color: var(--heading); letter-spacing: -0.02em; text-wrap: balance; }
.hero p { font-size: 1.15rem; color: var(--text-dim); max-width: 640px; margin: 0; }

/* ---------- Purpose band ---------- */
/* Two columns so the cover artwork illustrates the copy instead of stacking
   below it — it costs no extra vertical space that way. The art carries its
   own near-white background, so it sits on a permanently light plate and
   reads as a deliberate light surface in dark mode. */
.purpose {
  display: grid; grid-template-columns: 1fr 320px; gap: 34px; align-items: center;
  margin: 46px 0 6px;
}
.purpose-text p:not(.section-title) { margin: 0 0 14px; color: var(--text-dim); font-size: 0.98rem; }
.purpose-text p:last-child { margin-bottom: 0; }
.purpose .section-title { margin-top: 0; }
.cover-figure { margin: 0; }
.cover-figure img {
  display: block; width: 100%; height: auto; background: #fdfdfe;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
@media (max-width: 720px) {
  .purpose { grid-template-columns: 1fr; gap: 24px; }
  .cover-figure { max-width: 380px; margin: 0 auto; }
}

/* ---------- Whoami ---------- */
.whoami { margin: 46px 0 6px; }
.whoami .card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.termbar {
  display: flex; align-items: center; gap: 7px; padding: 10px 15px;
  background: var(--bg-termbar); border-bottom: 1px solid var(--border);
}
.termbar .dot { width: 11px; height: 11px; border-radius: 50%; }
.termbar .r { background: #f87171; }
.termbar .y { background: #fbbf24; }
.termbar .gr { background: #34d399; }
.termbar .label {
  margin-left: 8px; font-family: var(--mono);
  font-size: 0.8rem; color: var(--text-dim);
}
.whoami .body { display: flex; gap: 22px; padding: 24px 26px; align-items: center; }
.avatar {
  flex: 0 0 auto; width: 128px; height: 128px; border-radius: 50%;
  object-fit: cover; background: var(--bg-code);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px rgba(13,148,136,0.08);
}
.who-main { min-width: 0; }
.who-main .name { margin: 0; font-size: 1.3rem; color: var(--heading); letter-spacing: -0.01em; }
.who-main .handle { color: var(--text-dim); font-weight: 500; font-size: 0.92rem; }
.who-main .role {
  margin: 6px 0 2px; color: var(--accent);
  font-family: var(--mono); font-size: 0.84rem;
}
.who-main .tagline {
  margin: 0 0 11px; color: var(--text-dim);
  font-family: var(--mono); font-size: 0.8rem;
}
.who-main .bio { margin: 0 0 14px; font-size: 0.98rem; color: var(--text); }
.socials { display: flex; flex-wrap: wrap; gap: 8px; }
.social {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem;
  padding: 6px 13px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); background: var(--bg-code);
  transition: border-color .15s ease, color .15s ease, transform .15s ease;
}
.social:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.social .ext { opacity: .55; font-size: 0.82em; }
@media (max-width: 640px) {
  .whoami .body { flex-direction: column; align-items: flex-start; gap: 16px; }
  /* Centre the avatar over the left-aligned bio when the card stacks. */
  .whoami .avatar { align-self: center; }
}

/* ---------- Post list ---------- */
.section-title {
  font-size: 0.82rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim);
  margin: 48px 0 18px; scroll-margin-top: 90px;
}
.post-card {
  display: block; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px; margin-bottom: 18px; box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.post-card .pmeta { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.post-card h3 { margin: 0 0 8px; color: var(--heading); font-size: 1.4rem; letter-spacing: -0.01em; }
.post-card p { margin: 0; color: var(--text-dim); font-size: 0.98rem; }
.post-card.disabled { opacity: 0.6; pointer-events: none; box-shadow: none; }

/* ---------- Post search + tag filter ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.filter-bar { margin: 0 0 18px; }
.filter-search {
  width: 100%; padding: 10px 14px; font-family: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .15s ease;
}
.filter-search::placeholder { color: var(--text-dim); }
.filter-search:focus { outline: none; border-color: var(--accent); }
.filter-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.filter-tag {
  font-family: inherit; font-size: 0.76rem; color: var(--text-dim); cursor: pointer;
  padding: 4px 11px; background: var(--bg-code);
  border: 1px solid var(--border); border-radius: 999px;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.filter-tag:hover { border-color: var(--accent); color: var(--accent); }
.filter-tag:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-tag[aria-pressed="true"] {
  color: var(--bg-panel); background: var(--accent); border-color: var(--accent);
}
.no-results { color: var(--text-dim); font-style: italic; margin: 0 0 18px; }

.tags { margin-top: 14px; }
.tag {
  display: inline-block; font-size: 0.72rem; color: var(--accent);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px;
  margin: 0 6px 6px 0; background: var(--bg-code); font-family: inherit;
}

/* ---------- Article ---------- */
.article { padding: 48px 0 40px; }
.hero-figure {
  margin: 0 0 34px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); line-height: 0;
}
.hero-figure img { display: block; width: 100%; height: auto; }
.fig { margin: 32px 0; }
.fig img {
  display: block; width: 100%; height: auto; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.fig figcaption {
  margin-top: 10px; font-size: 0.85rem; color: var(--text-dim);
  text-align: center; font-style: italic; line-height: 1.5;
}
.article .post-head { margin-bottom: 36px; border-bottom: 1px solid var(--border); padding-bottom: 28px; }
.article .post-head .pmeta { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 14px; }
.article h1 { font-size: 2.2rem; line-height: 1.18; margin: 0 0 10px; color: var(--heading); letter-spacing: -0.02em; text-wrap: balance; }
.article .lede { font-size: 1.12rem; color: var(--text-dim); font-style: italic; margin: 0; }

.article h2 {
  font-size: 1.5rem; color: var(--heading); margin: 46px 0 14px; letter-spacing: -0.01em;
  padding-top: 8px; text-wrap: balance;
}
.article h3 { font-size: 1.18rem; color: var(--accent); margin: 34px 0 12px; }
.article p { margin: 0 0 18px; }
.article ul, .article ol { margin: 0 0 18px; padding-left: 22px; }
.article li { margin-bottom: 8px; }
.article strong { color: var(--heading); }
.article hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* inline code */
.article :not(pre) > code {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 6px; font-size: 0.86em; color: var(--code-inline);
}

/* code blocks */
.article pre {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; font-size: 0.85rem; line-height: 1.55;
  margin: 0 0 22px; color: var(--code-ink);
}
.article pre code { background: none; border: none; padding: 0; color: inherit; }

/* blockquote / callout */
.article blockquote {
  margin: 0 0 22px; padding: 16px 20px; background: var(--bg-panel);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text); box-shadow: var(--shadow);
}
.article blockquote p:last-child { margin-bottom: 0; }
.callout {
  background: var(--callout-bg); border: 1px solid var(--callout-border); border-left: 3px solid var(--accent-2);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 16px 20px; margin: 0 0 22px;
}
.callout .label { color: var(--accent-2); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }

/* tables */
.table-scroll { overflow-x: auto; margin: 0 0 22px; border-radius: var(--radius); box-shadow: var(--shadow); }
.article table { border-collapse: collapse; width: 100%; font-size: 0.9rem; background: var(--bg-panel); }
.article th, .article td { text-align: left; padding: 9px 13px; border: 1px solid var(--border); }
.article th { background: var(--bg-thead); color: var(--heading); font-weight: 600; white-space: nowrap; }
.article td { font-variant-numeric: tabular-nums; }
/* JetBrains Mono has a tall x-height, so inline code in the compact table
   cells reads larger than the plain field labels even at the article's 0.86em.
   Nudge it down so a value never looks bigger than its field. */
.article th code, .article td code { font-size: 0.8em; }
.article tbody tr:nth-child(even), .article tr:nth-child(even) { background: var(--stripe); }

.back-link { display: inline-block; margin: 8px 0 0; color: var(--text-dim); font-size: 0.9rem; }
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- Certifications ---------- */
.cert-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.cert-badge {
  display: inline-flex; align-items: stretch; overflow: hidden;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.78rem; font-weight: 700; box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cert-badge:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; }
a.cert-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cert-key { padding: 6px 11px; color: #fff; letter-spacing: 0.02em; }
.cert-val { padding: 6px 11px; background: var(--bg-code); color: var(--text); font-weight: 600; }

/* ---------- Buy me a coffee ---------- */
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; }
.social-badge {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px;
  font-size: 0.85rem; font-weight: 600;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}
.social-badge:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.badge-icon { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.badge-icon svg { width: 18px; height: 18px; fill: currentColor; }
.b-coffee .badge-icon { color: #009cde; }
.badge-text { color: var(--text-dim); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); margin-top: 60px; padding: 30px 0 44px;
  color: var(--text-dim); font-size: 0.85rem;
}
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- Theme toggle ---------- */
.header-right { display: flex; align-items: center; gap: 4px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 14px; padding: 0;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim); cursor: pointer; line-height: 0;
  transition: border-color .15s ease, color .15s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Show the icon for the theme you'd switch *to*. */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: none; }

/* ---------- Code blocks with copy button ---------- */
.code-block { position: relative; }
.code-block > pre { margin-bottom: 0; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 10px; font-family: var(--mono); font-size: 0.72rem;
  color: var(--text-dim); background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-btn.copied { color: var(--green); border-color: var(--green); opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* ---------- Detection file links ---------- */
.detection-links {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 0 0 22px; padding: 14px 16px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
}
.detection-links .dl-label {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim); width: 100%;
}
.detection-links a {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 0.8rem;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-code); color: var(--text);
  transition: border-color .15s ease, color .15s ease;
  /* Filenames are one long unbreakable token; let them wrap and shrink so the
     block never pushes past the article on narrow screens. */
  max-width: 100%; overflow-wrap: anywhere;
}
.detection-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero h1 { font-size: 2rem; }
  .article h1 { font-size: 1.7rem; }
  .site-header { position: static; }
  .site-header .wrap { flex-direction: column; gap: 10px; align-items: flex-start; }
  .header-right { flex-wrap: wrap; }
  .nav a { margin-left: 0; margin-right: 18px; }
  .theme-toggle { margin-left: 0; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .copy-btn, .theme-toggle, .back-link { display: none; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .article pre, .article table { break-inside: avoid; }
  .fig { break-inside: avoid; }
}
