/* ============================================================
   The Hack Sparrow — terminal theme
   Accent color is driven from the admin (Design → theme settings)
   via the inline --accent custom property set in default.hbs.
   ============================================================ */

:root {
    --accent: #3fb950; /* fallback; overridden inline from admin */

    --bg: #0a0e0d;
    --bg-deep: #070a09;
    --surface: #0f1513;
    --surface-2: #131b18;
    --border: #1d2a26;
    --border-bright: #284039;
    --fg: #cdd8d3;
    --fg-strong: #e7f0ec;
    --muted: #6d7f78;
    --muted-dim: #4a5852;

    --green: var(--accent);
    --green-bright: color-mix(in srgb, var(--accent) 72%, #ffffff);
    --green-dim: color-mix(in srgb, var(--accent) 78%, #000000);
    --green-glow: color-mix(in srgb, var(--accent) 18%, transparent);

    --amber: #d9a441;
    --red: #f85149;
    --magenta: #bc8cff;
    --cyan: #56b6c2;

    --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
    --maxw: 940px;
    --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 50% -10%, #0d1512 0%, var(--bg) 55%, var(--bg-deep) 100%);
    background-attachment: fixed;
    color: var(--fg);
    font-family: var(--mono);
    font-size: 15px;
    line-height: 1.65;
    letter-spacing: .1px;
    -webkit-font-smoothing: antialiased;
    padding: 0 16px 80px;
    min-height: 100vh;
}

/* faint CRT scanlines */
.crt {
    position: fixed; inset: 0; pointer-events: none; z-index: 9;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 3px, rgba(0,0,0,0) 4px);
    mix-blend-mode: multiply; opacity: .5;
}

.wrap { max-width: var(--maxw); margin: 0 auto; }
a { color: var(--green-bright); }
img { max-width: 100%; height: auto; }

/* ---------- terminal window chrome ---------- */
.term {
    margin-top: 26px;
    border: 1px solid var(--border-bright);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 120px);
    box-shadow: 0 24px 60px -24px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.02) inset;
    overflow: hidden;
}
.titlebar {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px; color: var(--muted);
}
.dots { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; opacity: .9; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.titlebar .path { color: var(--green-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar .path b { color: var(--fg); font-weight: 600; }
.titlebar .grow { flex: 1; }
.badge-online { display: inline-flex; align-items: center; gap: 7px; color: var(--green-bright); letter-spacing: .6px; font-size: 11.5px; white-space: nowrap; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bright); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--green-glow); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.pad { padding: 30px clamp(18px, 4vw, 40px); }

/* ---------- site header / nav ---------- */
.site-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; }
.logo { font-size: 22px; font-weight: 700; color: var(--fg-strong); letter-spacing: .4px; text-decoration: none; }
.logo .cur { color: var(--green-bright); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.paths { display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap; font-size: 14px; }
.paths .nav { list-style: none; display: flex; gap: 20px; flex-wrap: wrap; margin: 0; padding: 0; }
.paths .nav-item a { color: var(--muted); text-decoration: none; }
.paths .nav-item a::before { content: "~/"; color: var(--muted-dim); }
.paths .nav-item a:hover { color: var(--green-bright); }
.paths .nav-current a { color: var(--fg-strong); }
.btn-auth { color: var(--green); text-decoration: none; border: 1px solid var(--border-bright); padding: 4px 12px; border-radius: 6px; font-size: 13px; }
.btn-auth::before { content: "$ "; color: var(--muted-dim); }
.btn-auth:hover { background: var(--green-glow); color: var(--green-bright); }

/* ---------- hero ---------- */
.hero { margin-top: 34px; }
.prompt { color: var(--muted); }
.prompt .u { color: var(--green); } .prompt .s { color: var(--cyan); }
.hero .cmd { color: var(--fg-strong); }
.hero .out { color: var(--fg); margin: 6px 0 0; }
.hero .out.err { color: var(--red); }
.hero h1 {
    font-size: clamp(28px, 5.4vw, 42px); line-height: 1.1; margin: 14px 0 8px;
    color: var(--fg-strong); font-weight: 700; text-wrap: balance; letter-spacing: -.5px;
}
.hero .sub { color: var(--muted); max-width: 62ch; }
.hero .count { color: var(--green-dim); font-size: 13px; }
.type-cur { display: inline-block; width: 9px; height: 1.05em; background: var(--green-bright); transform: translateY(2px); margin-left: 3px; animation: blink 1.1s steps(1) infinite; }
.archive-hero h1 { color: var(--green); }
.author-links { display: flex; gap: 16px; margin-top: 10px; }

/* ---------- stats dashboard ---------- */
.stats {
    margin-top: 30px; display: grid; gap: 1px; background: var(--border);
    grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.stat { background: var(--surface); padding: 16px 18px; }
.stat .k { font-size: 11.5px; color: var(--muted); letter-spacing: .7px; text-transform: uppercase; }
.stat .v { font-size: 24px; color: var(--green-bright); font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.15; }

/* ---------- section label ---------- */
.seclabel { margin: 44px 0 4px; color: var(--muted); font-size: 14px; word-break: break-word; }
.seclabel .u { color: var(--green); } .seclabel .cmd { color: var(--fg-strong); } .seclabel .arg { color: var(--amber); } .seclabel .fl { color: var(--cyan); }
.rule { height: 1px; background: linear-gradient(90deg, var(--border-bright), transparent); margin: 14px 0 8px; }

/* ---------- writeups listing ---------- */
.list { display: flex; flex-direction: column; }
.row {
    display: grid; grid-template-columns: 108px 1fr auto; align-items: center; gap: 16px;
    padding: 14px 10px; border-bottom: 1px solid var(--border);
    text-decoration: none; color: inherit; transition: background .12s, border-color .12s;
    border-left: 2px solid transparent;
}
.row:hover { background: #0e1613; border-left-color: var(--green); }
.row .date { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.row .main { min-width: 0; }
.row .main .t { display: block; color: var(--fg-strong); font-size: 16px; word-break: break-word; }
.row:hover .main .t { color: var(--green-bright); }
.row .main .t::before { content: "./"; color: var(--muted-dim); }
.row .main .d { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.row .meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.cat { color: var(--cyan); font-size: 12px; text-decoration: none; }
.cat::before { content: "#"; color: var(--muted-dim); }
.pill { font-size: 11px; padding: 2px 9px; border-radius: 20px; border: 1px solid; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap; }
.pill.easy { color: var(--green-bright); border-color: #1f5a2e; background: rgba(63,185,80,.08); }
.pill.med { color: var(--amber); border-color: #5c4a1e; background: rgba(217,164,65,.08); }
.pill.hard { color: var(--red); border-color: #5c2622; background: rgba(248,81,73,.08); }
.pill.insane { color: var(--magenta); border-color: #43356b; background: rgba(188,140,255,.08); }
.pill.locked-pill { color: var(--amber); border-color: #5c4a1e; background: rgba(217,164,65,.06); }
.pill.locked-pill::before { content: "🔒 "; }

/* ---------- article ---------- */
.article { margin-top: 12px; }
.post-head .kicker { color: var(--green); font-size: 13px; letter-spacing: .5px; margin-top: 14px; }
.article .title { font-size: clamp(24px, 4.4vw, 36px); color: var(--fg-strong); margin: 8px 0 12px; letter-spacing: -.4px; text-wrap: balance; line-height: 1.12; }
.amdata { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.amdata b { color: var(--fg); font-weight: 500; }
.taglist { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.feat { margin: 26px 0 0; }
.feat img { width: 100%; border: 1px solid var(--border-bright); border-radius: 10px; }
.feat figcaption { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 8px; }

/* ---------- prose (gh-content) ---------- */
.prose { margin-top: 26px; }
.prose > * { max-width: 72ch; }
.prose > .kg-width-wide, .prose > .kg-width-full, .prose > figure { max-width: none; }
.prose p { margin: 0 0 20px; color: var(--fg); }
.prose a { color: var(--green-bright); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--green-dim); }
.prose h2, .prose h3, .prose h4 { color: var(--fg-strong); line-height: 1.25; margin: 34px 0 12px; text-wrap: balance; }
.prose h2 { font-size: 22px; } .prose h3 { font-size: 19px; } .prose h4 { font-size: 16px; }
.prose h2::before { content: "# "; color: var(--green); }
.prose h3::before { content: "## "; color: var(--green); }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose ul li::marker { content: "> "; color: var(--green); }
.prose strong { color: var(--fg-strong); }
.prose hr { border: none; border-top: 1px dashed var(--border-bright); margin: 34px 0; }
.prose blockquote {
    margin: 24px 0; padding: 14px 18px;
    border: 1px solid var(--border-bright); border-left: 3px solid var(--amber);
    background: rgba(217,164,65,.05); border-radius: 0 8px 8px 0; color: var(--fg);
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* inline + block code */
.prose :not(pre) > code {
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1px 6px; border-radius: 5px; color: var(--amber); font-size: 13.5px;
    font-family: var(--mono); word-break: break-word;
}
.prose pre {
    margin: 24px 0; padding: 16px; overflow-x: auto;
    background: var(--bg-deep); border: 1px solid var(--border-bright);
    border-radius: 9px; font-size: 13.5px; line-height: 1.7; color: var(--fg-strong);
    font-family: var(--mono);
}
.prose pre code { background: none; border: none; padding: 0; color: inherit; white-space: pre; }

/* koenig cards */
.kg-card { margin: 26px 0; }
.kg-image { border-radius: 10px; border: 1px solid var(--border-bright); }
.kg-embed-card, .kg-gallery-card { margin: 26px 0; }
figure.kg-card img { border-radius: 10px; }
.kg-bookmark-card a { text-decoration: none; }
.kg-bookmark-container {
    display: flex; border: 1px solid var(--border-bright); border-radius: 10px;
    overflow: hidden; background: var(--surface); color: var(--fg);
}
.kg-bookmark-content { padding: 16px; }
.kg-bookmark-title { color: var(--fg-strong); font-weight: 600; }
.kg-bookmark-description { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 13.5px; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
th { background: var(--surface-2); color: var(--fg-strong); }

/* members / paywall CTA (Ghost injects the gate; we style the container) */
.gh-content .gh-post-upgrade-cta, .kg-nft-card { }
.members-cta, .gh-post-upgrade-cta {
    margin: 34px 0; padding: 26px; text-align: center;
    border: 1px solid var(--border-bright); border-radius: 12px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-deep) 100%);
}

/* related + comments */
.related, .comments-area { margin-top: 20px; }

/* ---------- pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 30px; font-size: 14px; }
.pagination a { color: var(--green-bright); text-decoration: none; border: 1px solid var(--border-bright); padding: 6px 14px; border-radius: 6px; }
.pagination a:hover { background: var(--green-glow); }
.pagination .page-number { color: var(--muted); }

/* ---------- footer ---------- */
.site-foot { margin-top: 52px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.site-foot .green, .cur.green { color: var(--green); }
.site-foot .foot-links { display: flex; gap: 14px; align-items: center; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--green-bright); }

/* ---------- error ---------- */
.error-code { font-size: clamp(48px, 12vw, 90px); color: var(--red); }
.btn-back { display: inline-block; margin-top: 10px; color: var(--green-bright); text-decoration: none; border: 1px solid var(--border-bright); padding: 6px 14px; border-radius: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .row { grid-template-columns: 1fr; gap: 6px; }
    .row .meta { justify-content: flex-start; }
    .paths { gap: 14px; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .cur, .type-cur, .pulse { animation: none !important; }
    body { background-attachment: scroll; }
}
