/* ===================================================================
 * ADN-CyberSecurity — design system
 * Light + dark mode, responsive, modern type scale.
 * =================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Light theme (default) */
  --bg:           #ffffff;
  --bg-soft:      #f7f7f8;
  --bg-elev:      #ffffff;
  --text:         #0a0a0a;
  --text-soft:    #595959;
  --text-muted:   #8b8b8b;
  --accent:       #cc0000;
  --accent-hover: #990000;
  --accent-soft:  #fdecec;
  --border:       #e6e6e8;
  --code-bg:      #f3f3f5;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 12px 32px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;

  --font-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --w-content:    760px;
  --w-wide:       1180px;

  --t-fast:       .15s ease;
  --t:            .25s cubic-bezier(.22,.61,.36,1);
}

/* Dark theme — auto if system says dark, else opt-in via [data-theme="dark"] */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #0c0d10;
    --bg-soft:      #15171c;
    --bg-elev:      #1a1c22;
    --text:         #f3f4f6;
    --text-soft:    #b3b6bd;
    --text-muted:   #80848d;
    --accent:       #ff5252;
    --accent-hover: #ff7777;
    --accent-soft:  #2a0a0a;
    --border:       #262930;
    --code-bg:      #15171c;
    --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
    --shadow-md:    0 4px 12px rgba(0,0,0,.4);
    --shadow-lg:    0 12px 32px rgba(0,0,0,.5);
  }
}
[data-theme="dark"] {
  --bg:           #0c0d10;
  --bg-soft:      #15171c;
  --bg-elev:      #1a1c22;
  --text:         #f3f4f6;
  --text-soft:    #b3b6bd;
  --text-muted:   #80848d;
  --accent:       #ff5252;
  --accent-hover: #ff7777;
  --accent-soft:  #2a0a0a;
  --border:       #262930;
  --code-bg:      #15171c;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow-md:    0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:    0 12px 32px rgba(0,0,0,.5);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background var(--t-fast), color var(--t-fast);
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }
p  { margin: 0 0 1em; }
small { color: var(--text-muted); }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }
code {
  background: var(--code-bg);
  padding: .15em .4em;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--border);
  line-height: 1.5;
}
pre code { background: transparent; padding: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

::selection { background: var(--accent); color: #fff; }

/* ---------- 3. Layout ---------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff;
  padding: .75rem 1.25rem; border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

.container {
  width: 100%;
  max-width: var(--w-wide);
  margin: 0 auto;
  padding: 0 24px;
}
.container-narrow {
  width: 100%;
  max-width: var(--w-content);
  margin-left: auto;
  margin-right: auto;
}

main { min-height: 60vh; padding: 2rem 0 4rem; }

/* ---------- 4. Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  display: flex; align-items: center; gap: 1rem;
  height: 64px;
  max-width: var(--w-wide); margin: 0 auto; padding: 0 24px;
}
/* Brand wordmark — terminal-style, no image */
.topbar__logo {
  display: inline-flex; align-items: center;
  color: var(--text); text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.topbar__logo:hover { color: var(--text); }
.topbar__logo:hover .brand__cursor { animation-duration: .35s; }

.brand {
  display: inline-flex; align-items: baseline; gap: .15em;
  position: relative;
}
.brand__prompt {
  color: var(--accent);
  font-weight: 800;
  margin-right: .15em;
}
.brand__name { color: var(--text); }
.brand__cursor {
  display: inline-block;
  width: .55em;
  height: 1em;
  margin-left: .12em;
  background: var(--accent);
  align-self: center;
  transform: translateY(.05em);
  animation: brand-cursor-blink 1.1s steps(2, jump-none) infinite;
}
@keyframes brand-cursor-blink {
  0%   { opacity: 1; }
  50%  { opacity: 0; }
  100% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .brand__cursor { animation: none; opacity: 1; }
}
.topbar__nav { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; }
.topbar__nav a { color: var(--text-soft); font-weight: 500; font-size: 15px; }
.topbar__nav a:hover, .topbar__nav a.active { color: var(--text); }
.topbar__nav a.active { font-weight: 600; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-soft);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* mobile nav */
@media (max-width: 720px) {
  .topbar__nav .nav-links { display: none; }
  .topbar__nav { gap: .5rem; }
}

/* ---------- 5. Hero ---------- */
.hero {
  padding: 3rem 0 2rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: .5rem;
}
.hero p {
  font-size: 1.15rem;
  color: var(--text-soft);
  max-width: 580px;
  margin: 0 auto 1.5rem;
}
.hero__tagline {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .9rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: 1.25rem;
}
.hero__tagline::before {
  content: ""; width: 6px; height: 6px; background: var(--accent); border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------- 6. Cards grid ---------- */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 2.5rem 0 1.25rem;
}
.section-title h2 { margin: 0; font-size: 1.5rem; }
.section-title a { font-size: 14px; font-weight: 500; color: var(--text-soft); }
.section-title a:hover { color: var(--accent); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  text-decoration: none;
  color: inherit;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  color: inherit;
}
.card__media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-soft);
  position: relative;
}
.card__media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .6s cubic-bezier(.22,.61,.36,1);
}
.card:hover .card__media img { transform: scale(1.04); }
.card__body { padding: 1rem 1.1rem 1.2rem; flex: 1; display: flex; flex-direction: column; }
.card__tag {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}
.card__title {
  font-size: 1.05rem; font-weight: 600; line-height: 1.35;
  color: var(--text);
  margin: 0 0 .5rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin-top: auto;
  display: flex; gap: .75rem; align-items: center;
  font-size: 12px; color: var(--text-muted);
}
.card__meta time { color: inherit; }
.card__meta .dot { color: var(--text-muted); }

/* compact card (used in sidebar / related) */
.card-row {
  display: flex; gap: .9rem; align-items: flex-start;
  padding: .8rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
}
.card-row:last-child { border-bottom: 0; }
.card-row__media {
  flex: 0 0 80px;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
}
.card-row__media img { width: 100%; height: 100%; object-fit: cover; }
.card-row__body { flex: 1; min-width: 0; }
.card-row__title {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  color: var(--text);
  margin: 0 0 .25rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-row__meta { font-size: 11px; color: var(--text-muted); }

/* ---------- 7. Article view ---------- */
.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.article-header__tag {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .75rem;
}
.article-header h1 { margin-bottom: .75rem; }
.article-header__meta {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  font-size: 14px; color: var(--text-soft);
}

.article-content {
  font-size: 17px;
  line-height: 1.75;
}
.article-content :is(h2, h3) {
  margin-top: 2.25rem; margin-bottom: .75rem;
  color: var(--text);
  letter-spacing: -.01em;
}
.article-content h2 { font-size: 1.5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }
.article-content h3 { font-size: 1.2rem; }
.article-content img {
  border-radius: var(--radius-sm);
  margin: 0;
  max-width: 100%;
  height: auto;
}
.article-content figure {
  margin: 1.75rem 0;
  padding: .5rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.article-content figcaption {
  font-size: 13px; color: var(--text-muted);
  margin-top: .6rem;
  font-style: italic;
}
.article-content blockquote {
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.article-content a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.article-content ul, .article-content ol { margin: 1rem 0 1rem 1.5rem; padding: 0; }
.article-content li { margin: .35rem 0; }

/* Semantic callouts kept from legacy article HTML */
.article-content .ioc {
  display: inline-block;
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  padding: .25rem .65rem;
  margin: .35rem 0;
  font-family: var(--font-mono); font-size: .92em;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-content .alert,
.article-content .ok {
  margin: 1.25rem 0;
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
}
.article-content .alert { border-left-color: #f59e0b; }
.article-content .ok    { border-left-color: #22c55e; }
[data-theme="dark"] .article-content .alert { background: rgba(245,158,11,.08); }
[data-theme="dark"] .article-content .ok    { background: rgba(34,197,94,.08); }

.article-footer {
  margin-top: 3rem; padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.share {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  font-size: 14px; color: var(--text-soft);
}
.share__btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: all var(--t-fast);
}
.share__btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.share__btn svg { width: 14px; height: 14px; }

.related { margin-top: 3rem; }

/* ---------- 8. Layout helpers ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; gap: 2rem; }
  .split__sidebar { order: 2; }
}
.sidebar {
  position: sticky; top: 88px;
  font-size: 14px;
}
.sidebar h3 {
  font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 .75rem;
}

/* ---------- 9. Footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding: 2.5rem 0 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 14px;
}
.site-footer__inner {
  max-width: var(--w-wide); margin: 0 auto; padding: 0 24px;
  display: flex; gap: 1.5rem; justify-content: space-between; align-items: center; flex-wrap: wrap;
}
.site-footer a { color: var(--text-soft); }
.site-footer a:hover { color: var(--accent); }
.socials { display: flex; gap: .75rem; }
.socials a {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
}
.socials a:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
  transform: translateY(-2px);
}
.socials svg { width: 16px; height: 16px; }

/* ---------- 10. Infinite scroll + reveal-on-scroll ---------- */
.fade-in,
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity .65s cubic-bezier(.22,.61,.36,1),
    transform .65s cubic-bezier(.22,.61,.36,1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.fade-in.in,
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in, .fade-in.in,
  .reveal,  .reveal.in {
    opacity: 1; transform: none; transition: none;
  }
}

.infscr-sentinel {
  display: flex; justify-content: center; align-items: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 14px;
  min-height: 80px;
}
.infscr-sentinel.loading::before {
  content: "";
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: .75rem;
}
.infscr-sentinel.done::before { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 11. Back-to-top ---------- */
.back-to-top {
  position: fixed; right: 1.5rem; bottom: 1.5rem;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--t), transform var(--t), background var(--t-fast);
  z-index: 40;
}
.back-to-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.back-to-top svg { width: 18px; height: 18px; }

/* ---------- 12. Utility ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.muted { color: var(--text-muted); }
