/* ============================================================
   Threat-intel portfolio — dark, content-first theme
   One restrained accent; everything else gets out of the way.
   ============================================================ */

:root {
  /* Palette */
  --bg:          #0d1117;   /* deep slate, not pure black */
  --surface:     #161b22;   /* cards, code, header */
  --surface-2:   #1c2230;   /* hover / raised */
  --border:      #283039;
  --border-soft: #21262d;

  --text:        #c9d1d9;   /* body — soft, never pure white */
  --text-strong: #e6edf3;   /* headings */
  --muted:       #8b949e;   /* meta, captions */

  --accent:      #3fb950;   /* the single accent — terminal green */
  --accent-2:    #2ea043;
  --accent-soft: rgba(63, 185, 80, 0.12);
  --link:        #58a6ff;   /* links stay blue for scannability */
  --link-hover:  #79c0ff;

  --shodan:      #f0883e;   /* engine accents (badges only) */
  --fofa:        #58a6ff;
  --censys:      #a371f7;

  /* Type */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Layout */
  --maxw: 760px;      /* reading column */
  --maxw-wide: 1080px;/* home / query grid */
  --radius: 10px;
  --radius-sm: 7px;
}

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
::selection { background: var(--accent-soft); color: var(--text-strong); }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Layout wrappers ---------- */
.wrap { width: 100%; max-width: var(--maxw-wide); margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }
.main { flex: 1 0 auto; padding-top: 2.5rem; padding-bottom: 4rem; }

/* Reading column: constrain the text-heavy pages */
.page-head, .post, .post-list, .notfound { max-width: var(--maxw); margin-left: auto; margin-right: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: inline-flex; align-items: baseline; gap: .1rem; color: var(--text-strong); font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: var(--text-strong); }
.brand-mark { color: var(--accent); font-family: var(--mono); font-weight: 700; }
.nav { display: flex; gap: 1.4rem; }
.nav a { color: var(--muted); font-size: .95rem; font-weight: 500; padding: .2rem 0; position: relative; }
.nav a:hover { color: var(--text-strong); text-decoration: none; }
.nav a.active { color: var(--text-strong); }
.nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--accent); border-radius: 2px; }

/* ---------- Hero (home) ---------- */
.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);   /* full-bleed out of the content column */
  margin-top: -2.5rem;             /* sit flush under the sticky header */
  margin-bottom: 3.5rem;
  padding: 5rem 0 4.25rem;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--border-soft);
}
.hero-matrix { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: .5; pointer-events: none; }
.hero::after {                     /* readability vignette + a soft corner glow */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(72% 78% at 30% 45%, rgba(13,17,23,.94), rgba(13,17,23,.55) 55%, rgba(13,17,23,.12) 100%),
    radial-gradient(42% 60% at 90% 6%, var(--accent-soft), transparent 70%);
}
.hero-inner { position: relative; z-index: 2; max-width: var(--maxw-wide); margin: 0 auto; padding: 0 1.25rem; }

.terminal-line { font-family: var(--mono); font-size: .92rem; margin: 0 0 1.2rem; color: var(--muted); }
.term-user { color: var(--accent); }
.term-path { color: var(--link); }
.term-sep  { color: var(--muted); margin: 0 .05rem; }
.term-cmd  { color: var(--text-strong); margin-left: .35rem; }
.term-cursor { display: inline-block; width: .5em; height: 1.05em; background: var(--accent); margin-left: .12rem; vertical-align: -.18em; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero-kicker { color: var(--accent); font-family: var(--mono); font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 .5rem; }
.hero-name { font-size: clamp(2.2rem, 6.5vw, 3.4rem); line-height: 1.08; margin: 0 0 .85rem; color: var(--text-strong); letter-spacing: -.025em; }
.hero-tagline { font-size: 1.2rem; color: var(--text); margin: 0 0 1.8rem; max-width: 50ch; line-height: 1.55; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1.7rem; }
.hero-social { margin-bottom: 0; }
.hero-bio { color: var(--muted); margin-top: 1.6rem; max-width: 60ch; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--mono); font-size: .9rem; padding: .62rem 1.15rem; border-radius: 8px; border: 1px solid var(--border); color: var(--text); background: color-mix(in srgb, var(--surface) 55%, transparent); transition: color .14s, border-color .14s, background .14s, transform .14s; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #07130b; border-color: var(--accent); font-weight: 650; }
.btn-primary:hover { background: var(--accent-2); color: #07130b; border-color: var(--accent-2); }

/* ---------- Home sections ---------- */
.home-section { max-width: var(--maxw-wide); margin: 0 auto 3.5rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--border-soft); padding-bottom: .5rem; margin-bottom: 1.4rem; }
.section-head h2 { margin: 0; font-size: 1.25rem; color: var(--text-strong); }
.see-all { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.see-all:hover { color: var(--accent); text-decoration: none; }
.section-lead { color: var(--muted); }

/* Section header with rule line + "view all" (home) */
.section-head-lg { display: flex; align-items: center; gap: 1rem; margin: 0 0 1.6rem; }
.sec-title { font-family: var(--mono); font-size: 1.5rem; color: var(--text-strong); margin: 0; white-space: nowrap; letter-spacing: -.01em; }
.sec-hash { color: var(--accent); }
.sec-rule { flex: 1 1 auto; height: 1px; background: linear-gradient(to right, var(--accent), transparent); opacity: .5; }
.sec-all { font-family: var(--mono); font-size: .85rem; color: var(--muted); white-space: nowrap; }
.sec-all:hover { color: var(--accent); text-decoration: none; }

/* ---------- Post cards (home writeup grid) ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.4rem; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-3px); }
.card-media { display: block; aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--bg); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media-ph { display: grid; place-items: center; width: 100%; height: 100%; position: relative;
  background: radial-gradient(circle at 22% 15%, var(--accent-soft), transparent 55%), linear-gradient(135deg, #12161d, #0d1117); }
.card-media-ph::before { content: "~/"; position: absolute; right: .5rem; bottom: -.4rem; font-family: var(--mono); font-size: 4.5rem; font-weight: 700; color: var(--accent); opacity: .10; line-height: 1; }
.ph-title { font-family: var(--mono); font-size: .95rem; color: var(--text); padding: 0 1.2rem; text-align: center; line-height: 1.45; position: relative; z-index: 1; }
.card-body { display: flex; flex-direction: column; gap: .55rem; padding: 1rem 1.1rem 1.15rem; flex: 1; }
.card-tech { font-family: var(--mono); font-size: .74rem; color: var(--muted); margin: 0; line-height: 1.55; word-spacing: .12rem; }
.card-title { margin: 0; font-size: 1.18rem; line-height: 1.25; letter-spacing: -.01em; }
.card-title a { color: var(--text-strong); }
.card-title a:hover { color: var(--accent); text-decoration: none; }
.card-desc { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; flex: 1; }
.card-btn { align-self: flex-start; margin-top: .5rem; font-family: var(--mono); font-size: .82rem; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .35rem .8rem; transition: color .13s, border-color .13s; }
.card-btn:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.card-btn-arrow { color: var(--accent); }

/* ---------- Page head (list/section) ---------- */
.page-head { margin-bottom: 2.2rem; }
.page-head h1 { font-size: 2rem; margin: 0 0 .5rem; color: var(--text-strong); letter-spacing: -.02em; }
.page-head h1::before { content: "#"; color: var(--accent); margin-right: .15em; font-weight: 700; }
.page-intro { color: var(--muted); }

/* ---------- Post list ---------- */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-item { padding: 1.4rem 0; border-bottom: 1px solid var(--border-soft); }
.post-item:first-child { padding-top: 0; }
.post-item time { display: block; font-family: var(--mono); font-size: .78rem; color: var(--accent); letter-spacing: .02em; margin-bottom: .3rem; }
.post-item h2, .post-item h3 { margin: 0 0 .4rem; font-size: 1.28rem; line-height: 1.3; letter-spacing: -.01em; }
.post-item h3 { font-size: 1.12rem; }
.post-item h2 a, .post-item h3 a { color: var(--text-strong); }
.post-item h2 a:hover, .post-item h3 a:hover { color: var(--accent); text-decoration: none; }
.post-summary { color: var(--muted); margin: .35rem 0 0; }
.post-item.empty { color: var(--muted); font-style: italic; border: 0; }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.tag { display: inline-block; font-family: var(--mono); font-size: .74rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border-soft); padding: .12rem .5rem; border-radius: 999px; }
a.tag:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.tag-lg { font-size: .95rem; padding: .35rem .8rem; }
.tag-count { color: var(--muted); opacity: .7; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- Single post ---------- */
.post-head { margin-bottom: 2rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--border-soft); }
.post-head h1 { font-size: clamp(1.8rem, 4.5vw, 2.4rem); line-height: 1.2; margin: 0 0 .6rem; color: var(--text-strong); letter-spacing: -.02em; }
.post-meta { font-family: var(--mono); font-size: .82rem; color: var(--muted); margin-bottom: .7rem; }
.post-meta time { color: var(--accent); }
.post-foot { margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--border-soft); }
.back-link { font-family: var(--mono); font-size: .9rem; color: var(--muted); }
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- Prose (article body) ---------- */
.prose { color: var(--text); }
.prose > *:first-child { margin-top: 0; }
.prose h2 { font-size: 1.5rem; margin: 2.4rem 0 .9rem; color: var(--text-strong); letter-spacing: -.01em; scroll-margin-top: 80px; }
.prose h3 { font-size: 1.2rem; margin: 1.9rem 0 .7rem; color: var(--text-strong); scroll-margin-top: 80px; }
.prose h4 { font-size: 1.03rem; margin: 1.5rem 0 .6rem; color: var(--text-strong); }
.prose p { margin: 0 0 1.15rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
.prose li::marker { color: var(--accent); }
.prose a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent); }
.prose a:hover { text-decoration-color: var(--link); }
.prose strong { color: var(--text-strong); font-weight: 650; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border-soft); }

/* Blockquote */
.prose blockquote { margin: 1.4rem 0; padding: .2rem 0 .2rem 1.1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }

/* Tables */
.prose table { width: 100%; border-collapse: collapse; margin: 1.4rem 0; font-size: .94rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: .55rem .8rem; border: 1px solid var(--border); }
.prose th { background: var(--surface); color: var(--text-strong); font-weight: 600; }
.prose tr:nth-child(even) td { background: color-mix(in srgb, var(--surface) 50%, transparent); }

/* ---------- Code ---------- */
code, pre, kbd, samp { font-family: var(--mono); }
.prose :not(pre) > code {
  font-size: .88em; background: var(--surface); color: #f0883e;
  padding: .12em .4em; border-radius: 5px; border: 1px solid var(--border-soft);
}
.prose pre, .prose .highlight { position: relative; margin: 1.3rem 0; }
.prose .highlight { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.prose pre { border-radius: var(--radius); overflow-x: auto; }
.prose .highlight pre { margin: 0; border: 0; border-radius: 0; }
.prose pre { padding: 1rem 1.1rem; font-size: .86rem; line-height: 1.55; background: var(--surface); }
.prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }

/* Copy button (shared by code blocks + query cards) */
.copy-btn {
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .25rem .6rem; border-radius: 6px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.code-copy { position: absolute; top: .55rem; right: .55rem; opacity: 0; }
.prose pre:hover .code-copy, .prose .highlight:hover .code-copy, .code-copy:focus { opacity: 1; }

/* ---------- Query library ---------- */
.query-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin: 0 0 1.8rem; }
.q-search-wrap { position: relative; flex: 1 1 260px; min-width: 220px; }
.q-search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#q-search {
  width: 100%; font-family: var(--sans); font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .8rem .6rem 2.2rem;
}
#q-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#q-search::placeholder { color: var(--muted); }

.q-filters { display: flex; gap: .4rem; flex-wrap: wrap; }
.q-filter {
  font-family: var(--mono); font-size: .82rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: .4rem .8rem; border-radius: 999px; cursor: pointer; transition: all .12s;
}
.q-filter:hover { color: var(--text-strong); border-color: var(--muted); }
.q-filter.active { color: var(--bg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.q-count { opacity: .7; font-size: .95em; }
.q-filter.active .q-count { opacity: .85; }

.query-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.1rem; }
.query-card {
  display: flex; flex-direction: column; gap: .7rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.1rem 1rem;
  transition: border-color .14s, transform .14s;
}
.query-card:hover { border-color: var(--accent); }
.query-card-head { display: flex; align-items: center; gap: .6rem; }
.query-card-head h3 { margin: 0; font-size: 1.02rem; color: var(--text-strong); line-height: 1.3; }
.engine-badge {
  font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; padding: .18rem .5rem; border-radius: 5px; white-space: nowrap; flex-shrink: 0;
  border: 1px solid currentColor;
}
.engine-shodan { color: var(--shodan); background: color-mix(in srgb, var(--shodan) 12%, transparent); }
.engine-fofa   { color: var(--fofa);   background: color-mix(in srgb, var(--fofa) 12%, transparent); }
.engine-censys { color: var(--censys); background: color-mix(in srgb, var(--censys) 12%, transparent); }
.query-desc { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.query-code { position: relative; margin-top: auto; }
.query-code pre {
  margin: 0; background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: .7rem 3.4rem .7rem .8rem;
  overflow-x: auto; font-size: .82rem; line-height: 1.5;
}
.query-code code { color: var(--accent); white-space: pre; }
.query-code .copy-btn { position: absolute; top: .5rem; right: .5rem; }
.query-card-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.query-card-foot .tags { margin: 0; }
.query-ref { font-family: var(--mono); font-size: .74rem; color: var(--muted); white-space: nowrap; }
.query-ref:hover { color: var(--accent); text-decoration: none; }
.q-empty { text-align: center; color: var(--muted); padding: 2.5rem 0; font-style: italic; }

/* Each card links to its own query page */
.query-card.is-link { cursor: pointer; }
.query-card-head h3 a { color: var(--text-strong); }
.query-card-head h3 a:hover { color: var(--accent); text-decoration: none; }
.query-more { margin-left: auto; font-family: var(--mono); font-size: .78rem; color: var(--muted); white-space: nowrap; transition: color .14s; }
.query-card:hover .query-more { color: var(--accent); }

/* Single query page (/queries/<slug>/) */
.query-single { max-width: var(--maxw); margin: 0 auto; }
.query-single .back-link { display: inline-block; margin-bottom: 1.4rem; }
.query-single-head { margin-bottom: 1.6rem; }
.query-single-head .engine-badge { display: inline-block; margin-bottom: .9rem; }
.query-single-head h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 .6rem; color: var(--text-strong); letter-spacing: -.02em; }
.query-single-desc { color: var(--muted); font-size: 1.05rem; margin: 0; line-height: 1.6; }
.query-code-lg pre { font-size: .95rem; padding: 1rem 4rem 1rem 1.1rem; }
.query-code-lg code { white-space: pre-wrap; word-break: break-word; }
.query-single-tags { margin: 1.1rem 0 0; }
.query-single-body { margin-top: 2rem; }
.query-single-empty { margin-top: 2rem; }
.query-single-ref { margin-top: 1.6rem; font-family: var(--mono); font-size: .9rem; }

/* ---------- Footer ---------- */
.site-footer { flex-shrink: 0; border-top: 1px solid var(--border-soft); margin-top: 2rem; padding: 2rem 0; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: .9rem; text-align: center; }
.footer-note { color: var(--muted); font-size: .85rem; margin: 0; }
.footer-note a { color: var(--muted); }
.footer-note a:hover { color: var(--accent); }

/* ---------- Social icons ---------- */
.social { display: flex; gap: .3rem; }
.social a { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; transition: color .12s, border-color .12s, background .12s; }
.social a:hover { color: var(--accent); border-color: var(--border); background: var(--surface); text-decoration: none; }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 4rem 0; }
.nf-code { font-family: var(--mono); font-size: 4rem; color: var(--accent); margin: 0; line-height: 1; }
.notfound h1 { color: var(--text-strong); margin: .5rem 0 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .header-inner { height: 56px; }
  .nav { gap: 1rem; }
  .nav a { font-size: .9rem; }
  .brand-name { display: none; }   /* keep ~/ mark on tiny screens */
  .query-grid { grid-template-columns: 1fr; }
  .query-toolbar { flex-direction: column; align-items: stretch; }
  .q-filters { justify-content: flex-start; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
