/* ==========================================================================
   ITSTCK layer for the Journal theme
   Loaded after assets/built/screen.css, so these rules win.
   Dark (graphite/black) by default; light (white/light grey) with
   <html data-theme="light">. One green accent.
   ========================================================================== */

:root {
    color-scheme: dark;
    --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
    --itk-green: #22c55e;          /* same value as Ghost Admin > Design > Accent color */
    --color-white: #0e0f11;        /* page background */
    --color-lighter-gray: #16181b; /* raised surfaces, code */
    --color-light-gray: #262a2f;   /* dividers and borders */
    --color-mid-gray: #3a3f46;     /* hover borders */
    --color-dark-gray: #c4c9cf;
    --color-darker-gray: #f2f4f6;  /* headings */
    --color-black: #ffffff;
    --color-primary-text: #d9dde2; /* body text */
    --color-secondary-text: #9aa2ab;
    --color-border: #262a2f;
    --color-dark-border: #3a3f46;
    --itk-on-accent: #06140b;      /* text on green buttons */
}

html[data-theme="light"] {
    color-scheme: light;
    --color-white: #ffffff;
    --color-lighter-gray: #f4f5f6;
    --color-light-gray: #e2e5e8;
    --color-mid-gray: #c9ced4;
    --color-dark-gray: #3a4048;
    --color-darker-gray: #0b0c0e;
    --color-black: #000000;
    --color-primary-text: #24282d;
    --color-secondary-text: #5b636c;
    --color-border: #e2e5e8;
    --color-dark-border: #c9ced4;
    --ghost-accent-color: #15803d; /* darker green, readable on white */
    --itk-on-accent: #ffffff;
}

body {
    color: var(--color-primary-text);
    background-color: var(--color-white);
}

::selection { background-color: color-mix(in srgb, var(--itk-green) 25%, transparent); }
:focus-visible { outline: 2px solid var(--ghost-accent-color); outline-offset: 2px; }

/* ---------- Header ---------- */
.gh-head {
    position: sticky;
    top: 0;
    z-index: 90;
    background-color: color-mix(in srgb, var(--color-white) 92%, transparent);
    border-bottom: 1px solid var(--color-light-gray);
    backdrop-filter: blur(8px);
}

.gh-head-menu a { color: var(--color-secondary-text); }
.gh-head-menu a:hover,
.gh-head-menu .nav-current a { color: var(--color-darker-gray); opacity: 1; }

.gh-head-logo {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-darker-gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gh-head-logo:not(:has(img))::before {
    content: ">_ ";
    color: var(--ghost-accent-color);
}

.gh-head-actions .gh-icon-btn,
.gh-head .gh-search,
.gh-burger { color: var(--color-secondary-text); }

.gh-primary-btn,
.gh-head-btn.gh-primary-btn { color: var(--itk-on-accent); }

.itk-toggle {
    display: inline-grid;
    place-items: center;
    width: 3.6rem;
    height: 3.6rem;
    padding: 0;
    color: var(--color-secondary-text);
    cursor: pointer;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
}

.itk-toggle:hover { color: var(--color-darker-gray); border-color: var(--color-light-gray); }
html:not([data-theme="light"]) .itk-moon,
html[data-theme="light"] .itk-sun { display: none; }

/* ---------- Section titles ---------- */
.gh-section-title {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-secondary-text);
    letter-spacing: 0.1em;
}

/* ---------- Homepage feed ---------- */
.gh-latest { margin-bottom: 8rem; }

.gh-card + .gh-card {
    padding-top: 3.2rem;
    margin-top: 3.2rem;
    border-top: 1px solid var(--color-light-gray);
}

.gh-card-title {
    font-size: 2.6rem;
    line-height: 1.2;
    color: var(--color-darker-gray);
    letter-spacing: -0.01em;
}

.gh-latest .gh-card-title { font-size: clamp(3rem, 4vw, 4rem); }
.gh-card-link:hover .gh-card-title { color: var(--ghost-accent-color); opacity: 1; }

.gh-card-excerpt {
    margin-top: 1rem;
    font-size: 1.7rem;
    color: var(--color-secondary-text);
}

.gh-card-meta {
    margin-top: 1.4rem;
    font-family: var(--font-mono);
}

.gh-loadmore {
    margin-top: 5.6rem;
    border-radius: 6px;
}

.gh-loadmore:hover { color: var(--ghost-accent-color); border-color: var(--ghost-accent-color); }

/* ---------- Sidebar ---------- */
.gh-sidebar {
    top: 9.6rem;
    border-left: 1px solid var(--color-light-gray);
}

.gh-sidebar .gh-section + .gh-section { margin-top: 5.6rem; }
.gh-about-description { color: var(--color-secondary-text); }

.gh-featured .gh-card + .gh-card { padding-top: 2rem; margin-top: 2rem; }
.gh-featured .gh-card-title { font-size: 1.7rem; }

.gh-topic-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-light-gray);
}

.gh-topic-item + .gh-topic-item { margin-top: 0; }
.gh-topic-name { font-size: 1.6rem; }
.gh-topic-item:hover .gh-topic-name { color: var(--ghost-accent-color); }

.gh-topic-count {
    font-family: var(--font-mono);
    color: var(--color-secondary-text);
}

/* ---------- Tag and author pages ---------- */
.gh-tag-label { font-family: var(--font-mono); letter-spacing: 0.08em; }
.gh-pagehead-description { color: var(--color-secondary-text); }

/* ---------- Article header ---------- */
.gh-article-meta { font-family: var(--font-mono); }
.gh-article-meta a { color: var(--ghost-accent-color); }

.gh-article-title {
    font-size: clamp(3.4rem, 4.6vw, 4.8rem);
    font-weight: 700;
    line-height: 1.12;
    color: var(--color-darker-gray);
    letter-spacing: -0.015em;
}

.gh-article-excerpt {
    font-size: 2.1rem;
    line-height: 1.45;
    color: var(--color-secondary-text);
}

/* Severity badges from internal tags: #critical #high #medium #low #exploited */
.gh-article[class*="tag-hash-"] .gh-article-meta::before {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    margin-right: 1rem;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.5;
    letter-spacing: 0.05em;
    vertical-align: middle;
    border: 1px solid currentColor;
    border-radius: 4px;
}

.gh-article.tag-hash-critical .gh-article-meta::before { color: #ef4444; content: "CRITICAL"; }
.gh-article.tag-hash-high .gh-article-meta::before { color: #f97316; content: "HIGH"; }
.gh-article.tag-hash-medium .gh-article-meta::before { color: #eab308; content: "MEDIUM"; }
.gh-article.tag-hash-low .gh-article-meta::before { color: var(--color-secondary-text); content: "LOW"; }
.gh-article.tag-hash-exploited .gh-article-meta::before { color: #ef4444; content: "EXPLOITED"; }
html[data-theme="light"] .gh-article.tag-hash-critical .gh-article-meta::before,
html[data-theme="light"] .gh-article.tag-hash-exploited .gh-article-meta::before { color: #c81e1e; }
html[data-theme="light"] .gh-article.tag-hash-high .gh-article-meta::before { color: #c2410c; }
html[data-theme="light"] .gh-article.tag-hash-medium .gh-article-meta::before { color: #a16207; }

/* ---------- Article body ---------- */
.gh-content {
    font-size: 1.8rem;
    line-height: 1.72;
    color: var(--color-primary-text);
}

.gh-content > h2 {
    margin-top: 1.8em;
    font-size: 2.7rem;
    color: var(--color-darker-gray);
    scroll-margin-top: 9.6rem;
}

.gh-content > h3 {
    font-size: 2.1rem;
    color: var(--color-darker-gray);
    scroll-margin-top: 9.6rem;
}

.gh-content strong { color: var(--color-darker-gray); }

.gh-content a:not([class]) {
    color: var(--ghost-accent-color);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--ghost-accent-color) 45%, transparent);
    text-underline-offset: 3px;
}

.gh-content a:not([class]):hover { text-decoration-color: var(--ghost-accent-color); opacity: 1; }
.gh-content blockquote:not([class]) { border-left-color: var(--ghost-accent-color); }

/* Code */
.gh-content :not(pre) > code {
    padding: 0.1em 0.35em;
    font-family: var(--font-mono);
    font-size: 0.86em;
    color: var(--color-darker-gray);
    background-color: var(--color-lighter-gray);
    border: 1px solid var(--color-light-gray);
    border-radius: 4px;
}

.gh-content pre {
    position: relative;
    padding: 1.6rem 1.8rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 1.45rem;
    line-height: 1.55;
    color: var(--color-primary-text);
    background-color: var(--color-lighter-gray);
    border: 1px solid var(--color-light-gray);
    border-radius: 6px;
}

.gh-content pre code {
    padding: 0;
    font-size: inherit;
    color: inherit;
    background: none;
    border: 0;
}

.itk-copy {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    padding: 0.2rem 0.8rem;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--color-secondary-text);
    cursor: pointer;
    background-color: var(--color-white);
    border: 1px solid var(--color-light-gray);
    border-radius: 4px;
    opacity: 0;
}

.gh-content pre:hover .itk-copy,
.itk-copy:focus { opacity: 1; }
.itk-copy.is-done { color: var(--ghost-accent-color); }

/* Tables */
.itk-table { overflow-x: auto; }

.gh-content table:not(.gist table) {
    width: 100%;
    font-size: 1.55rem;
    border-collapse: collapse;
}

.gh-content table:not(.gist table) th,
.gh-content table:not(.gist table) td {
    padding: 0.9rem 1.2rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-light-gray);
}

.gh-content table:not(.gist table) th {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-width: 2px;
}

/* Boxes emitted by the n8n pipeline */
.gh-content .tldr,
.gh-content .sources {
    padding: 1.6rem 2rem;
    background-color: var(--color-lighter-gray);
    border: 1px solid var(--color-light-gray);
    border-radius: 6px;
}

.gh-content .tldr { border-left: 3px solid var(--ghost-accent-color); }
.gh-content .sources { font-size: 1.55rem; }
.gh-content .tldr > :first-child,
.gh-content .sources > :first-child { margin-top: 0; }

/* Table of contents (built by itstck.js on posts with 3+ H2) */
.itk-toc {
    padding: 1.2rem 1.6rem;
    font-size: 1.5rem;
    background-color: var(--color-lighter-gray);
    border: 1px solid var(--color-light-gray);
    border-radius: 6px;
}

.itk-toc summary {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
}

.itk-toc ol { padding-left: 1.8rem; margin: 1rem 0 0; }
.gh-content .itk-toc a { color: var(--color-primary-text); text-decoration: none; }
.gh-content .itk-toc a:hover { color: var(--ghost-accent-color); }

.itk-anchor {
    margin-left: 0.6rem;
    font-weight: 400;
    color: var(--color-secondary-text);
    text-decoration: none;
    opacity: 0;
}

.gh-content h2:hover .itk-anchor,
.gh-content h3:hover .itk-anchor { opacity: 1; }

/* Ghost cards */
.gh-content .kg-callout-card { border: 1px solid var(--color-light-gray); border-radius: 6px; }
.gh-content .kg-toggle-card,
.gh-content .kg-bookmark-container {
    color: var(--color-primary-text);
    background-color: var(--color-lighter-gray);
    border-color: var(--color-light-gray);
}

/* ---------- Previous / next ---------- */
.gh-navigation-label { font-family: var(--font-mono); font-size: 1.3rem; color: var(--color-secondary-text); }
.gh-navigation-title { font-weight: 600; color: var(--color-darker-gray); }

/* ---------- Footer ---------- */
.gh-foot {
    color: var(--color-secondary-text);
    background-color: var(--color-lighter-gray);
    border-top: 1px solid var(--color-light-gray);
}

.gh-foot a { color: var(--color-secondary-text); }
.gh-foot a:hover { color: var(--color-darker-gray); opacity: 1; }
.gh-copyright { font-family: var(--font-mono); }
.gh-powered-by { display: none; }

/* ---------- Ads: reserved space, no layout shift ---------- */
.itk-ad { min-height: 280px; margin: 3.2rem 0; }

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .gh-card + .gh-card { padding-top: 2.8rem; margin-top: 2.8rem; }
    .gh-card-title { font-size: 2.2rem; }
    .gh-loadmore { margin-top: 4.8rem; }
    .gh-sidebar {
        position: static;
        padding-top: 4.8rem;
        margin-top: 6.4rem;
        border-top: 1px solid var(--color-light-gray);
        border-left: 0;
    }
    .gh-article-title { font-size: 3.2rem; }
    .gh-article-excerpt { font-size: 1.8rem; }
}

/* ---------- Article width = header/footer width ---------- */
/* Change --itk-article-width to 960px if the lines feel too long to read. */
.gh-article .gh-canvas,
.page-template .gh-canvas {
    --itk-gutter: max(4vmin, 20px);
    --itk-article-width: var(--container-width, 1200px);
    grid-template-columns:
        [full-start] minmax(var(--itk-gutter), 1fr)
        [wide-start main-start] min(var(--itk-article-width), calc(100% - var(--itk-gutter) * 2))
        [main-end wide-end] minmax(var(--itk-gutter), 1fr)
        [full-end];
}

.gh-article-excerpt {
    max-width: none;
}

/* Go to top button */
.itk-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--itk-border, rgba(127, 127, 127, .35));
  background: var(--itk-surface, #161a18);
  color: var(--itk-accent, #22c55e);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s, visibility .2s, background .2s, color .2s;
}
.itk-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.itk-top:hover {
  background: var(--itk-accent, #22c55e);
  color: #0b0f0d;
}
html[data-theme="light"] .itk-top {
  background: #fff;
}
@media (max-width: 600px) {
  .itk-top { right: 14px; bottom: 14px; }
}