/* Site layout on top of the Socle kit (tokens.css + socle.css).
   Mobile first: base styles target small screens, media queries widen. */

:root {
  color-scheme: light dark;
  --gutter: 16px;
  --wrap: 1080px;
  --measure: 70ch;
  --header-h: 64px;
}
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

@media (min-width: 640px) { :root { --gutter: 24px; } }
@media (min-width: 1024px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 24px;
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

img, svg, video { max-width: 100%; height: auto; }
::selection { background: var(--klein); color: var(--on-klein); }
:focus-visible { outline: 2px solid var(--klein); outline-offset: 3px; }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }

/* Skip link: first focusable element on every page */
.skip-link {
  position: absolute; left: var(--gutter); top: -100px; z-index: 10;
  font: 500 12px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 12px 16px; background: var(--klein); color: var(--on-klein);
  border: 2px solid var(--line); box-shadow: var(--shadow-hard); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 2px solid var(--line); background: var(--paper); }
.site-header .sc-spectrum { border-width: 0 0 2px; }
.site-header__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px;
  color: var(--ink); text-decoration: none;
}
.brand__mark {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  background: var(--klein); color: var(--on-klein); border: 2px solid var(--line);
  font: 800 16px/1 var(--font-display); letter-spacing: -.02em;
}
.brand__name { font: 800 18px/1.1 var(--font-display); letter-spacing: -.02em; }
.brand__sub { display: none; }
@media (min-width: 480px) { .brand__sub { display: block; color: var(--ink-muted); margin-top: 2px; } }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* Primary nav: always visible (no hidden hamburger for four links).
   Small screens: own row under the brand, scrolls sideways if needed. */
.site-nav { border-top: 2px solid var(--line); }
.site-nav ul {
  display: flex; gap: 0; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
  list-style: none; overflow-x: auto; scrollbar-width: none;
}
.site-nav ul::-webkit-scrollbar { display: none; }
.site-nav a {
  display: flex; align-items: center; min-height: 48px; padding: 0 14px;
  font: 500 12px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  border-bottom: 4px solid transparent; border-top: 4px solid transparent;
}
.site-nav li:first-child a { padding-left: 0; }
.site-nav a:hover { color: var(--klein); }
.site-nav a[aria-current] { border-bottom-color: var(--klein); color: var(--klein); }

@media (min-width: 760px) {
  .site-header__inner { display: flex; align-items: center; gap: 24px; }
  .site-header__bar { flex: 1; }
  .site-nav { border-top: 0; order: 0; }
  .site-nav ul { margin: 0; padding: 0; overflow: visible; }
  .site-nav li:first-child a { padding-left: 14px; }
  .site-nav a { min-height: var(--header-h); }
  .header-actions { order: 1; }
}

/* Theme toggle (hidden until JS enables it) */
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 2px solid var(--line); background: var(--paper-raised); color: var(--ink);
  box-shadow: var(--shadow-hard-sm); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.icon-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* ---------- Main ---------- */
main { flex: 1; padding: 40px 0 64px; }
@media (min-width: 760px) { main { padding: 64px 0 96px; } }

.stack > * + * { margin-top: 56px; }
@media (min-width: 760px) { .stack > * + * { margin-top: 80px; } }

/* Fluid type scale overrides for the kit's fixed sizes */
.display { font-size: clamp(38px, 9vw, 56px); line-height: 1.02; margin: 0; overflow-wrap: anywhere; }
.h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.12; margin: 0; overflow-wrap: anywhere; }
.h2 { margin: 0; }
.lead { font: 400 18px/1.55 var(--font-sans); color: var(--ink-muted); margin: 0; max-width: 60ch; }
@media (min-width: 760px) { .lead { font-size: 20px; } }

.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--ink-muted); margin: 0 0 16px; }
.eyebrow .sc-label { color: inherit; }

/* Hero */
.hero { display: grid; gap: 24px; }
.hero__title { color: var(--klein); }
.hero__intro p { margin: 0; }
.hero__intro p + p { margin-top: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 16px; padding: 4px 4px 4px 0; }
.sc-btn { text-decoration: none; min-height: 44px; }

/* Section heads */
.section-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px;
  padding-bottom: 12px; margin-bottom: 28px; border-bottom: 2px solid var(--line);
}
.section-head .sc-label { color: var(--ink-muted); display: block; margin-bottom: 6px; }
.more-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  font: 500 12px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--klein); text-decoration: none;
}
.more-link:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.more-link .icon { width: 16px; height: 16px; }

/* ---------- Cards ---------- */
.card-grid { display: grid; gap: 28px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); list-style: none; margin: 0; padding: 0 4px 4px 0; }
.card-grid > li { display: flex; }
.post-card { position: relative; display: flex; flex-direction: column; width: 100%; transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s cubic-bezier(.2,.8,.2,1); }
.post-card .sc-card__body { flex: 1; display: grid; align-content: start; gap: 8px; }
.post-card .sc-card__body h2, .post-card .sc-card__body h3 { font-size: 20px; line-height: 1.25; margin: 0; }
.post-card .sc-card__body p { font-size: 15px; line-height: 1.55; }
.post-card .sc-card__stats div { padding: 10px 12px; }
.post-card .sc-card__head { gap: 12px; }
/* The title link covers the whole card: one tab stop, whole card clickable */
.stretched { color: inherit; text-decoration: none; }
.stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.post-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--line); }
.post-card:hover h3 { color: var(--klein); }
.post-card:focus-within { outline: 2px solid var(--klein); outline-offset: 4px; }
.post-card .stretched:focus-visible { outline: none; }
.sc-card--featured .sc-badge { background: var(--paper-raised); }

/* ---------- News list ---------- */
.news-list { list-style: none; margin: 0; padding: 0; border: 2px solid var(--line); background: var(--paper-raised); box-shadow: var(--shadow-hard); }
.news-list li + li { border-top: 1px solid var(--line-soft); }
.news-row {
  display: grid; gap: 4px; padding: 16px; color: var(--ink); text-decoration: none;
  transition: background-color .12s;
}
.news-row:hover { background: var(--klein-soft); }
.news-row:focus-visible { outline-offset: -4px; }
.news-row time { font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.news-row__title { font: 600 16px/1.35 var(--font-sans); }
.news-row:hover .news-row__title { color: var(--klein); text-decoration: underline; text-underline-offset: 3px; }
.news-row__desc {
  font: 400 14px/1.5 var(--font-sans); color: var(--ink-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
@media (min-width: 760px) {
  .news-row { grid-template-columns: 120px 1fr; column-gap: 24px; padding: 18px 24px; }
  .news-row time { grid-row: span 2; padding-top: 1px; }
}
.featured-news { margin-bottom: 28px; margin-right: 4px; }
.featured-news .sc-card__body { display: grid; gap: 10px; }
.featured-news .sc-card__body h2, .featured-news .sc-card__body h3 { font-size: clamp(20px, 4vw, 26px); line-height: 1.2; }
.featured-news .sc-card__body p { font-size: 16px; line-height: 1.6; }

.after-head { margin-top: 40px; }
.tldr { margin-top: 32px; max-width: var(--measure); }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 40px; padding-right: 4px; }
.pagination__status { font: 500 12px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.pagination .sc-btn[aria-disabled="true"] { opacity: .4; pointer-events: none; box-shadow: none; }
@media (max-width: 479px) {
  .pagination__status { order: -1; width: 100%; text-align: center; }
  .pagination .sc-btn { flex: 1; justify-content: center; }
}

/* ---------- Article ---------- */
.article { max-width: var(--measure); margin: 0 auto; }
.article-head { display: grid; gap: 20px; max-width: var(--measure); }
.article-head .sc-spectrum { max-width: 160px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--ink-muted); }
.meta .data { color: inherit; }
.back-link { margin-bottom: 24px; }

.prose { max-width: var(--measure); margin-top: 32px; font: 400 17px/1.55 var(--font-sans); color: var(--ink); }
@media (min-width: 760px) { .prose { font-size: 18px; } }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote, .prose aside, .prose figure, .prose .table-wrap, .prose table { margin: 0 0 1em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-display); font-weight: 700; color: var(--ink); scroll-margin-top: 24px; }
.prose h1, .prose h2 { font-size: clamp(22px, 4.5vw, 28px); line-height: 1.2; letter-spacing: -.02em; margin: 1.6em 0 .5em; padding-top: 10px; border-top: 2px solid var(--line); }
.prose h3 { font-size: 19px; line-height: 1.3; margin: 1.3em 0 .4em; }
.prose h4 { font-size: 17px; margin: 1.4em 0 .4em; }
.prose a { color: var(--klein); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.prose a:hover { color: var(--klein-strong); text-decoration-thickness: 3px; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose ul { list-style: square; }
.prose li { margin: .2em 0; }
/* news files emit <li> without a <ul>: indent them like a list */
.prose > li { list-style: square; margin-left: 1.4em; }
.prose li::marker { color: var(--klein); }
.prose hr { height: 6px; background: var(--spectrum); border: 2px solid var(--line); margin: 3em 0; }
.prose img { display: block; border: 2px solid var(--line); background: var(--paper-raised); margin: 1.5em 0; }
.prose blockquote { margin-left: 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--klein); color: var(--ink-muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose cite { font: 500 13px/1.4 var(--font-mono); letter-spacing: .04em; font-style: normal; }
.prose aside { border: 2px solid var(--line); background: var(--paper-raised); padding: 16px 20px; box-shadow: var(--shadow-hard-sm); border-top: 8px solid var(--klein); }
.prose aside p:last-child { margin-bottom: 0; }

/* Code */
.prose code { font: 400 .86em/1.5 var(--font-mono); background: var(--klein-soft); padding: .1em .35em; }
.prose pre {
  font: 400 14px/1.6 var(--font-mono); padding: 16px; overflow-x: auto; tab-size: 4;
  background: var(--paper-raised); border: 2px solid var(--line); box-shadow: var(--shadow-hard-sm);
  margin-right: 2px;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
/* Bleed code blocks to the edges on phones so long lines get more room */
@media (max-width: 639px) {
  .prose pre { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-left: 0; border-right: 0; box-shadow: none; }
}

/* Tables (wrapped in .table-wrap by site.js for horizontal scroll) */
.table-wrap { width: fit-content; max-width: 100%; overflow-x: auto; border: 2px solid var(--line); background: var(--paper-raised); box-shadow: var(--shadow-hard-sm); margin-right: 2px; }
.prose table { border-collapse: collapse; font: 400 14px/1.4 var(--font-sans); }
.table-wrap table { margin: 0; }
.prose :not(.table-wrap) > table { border: 2px solid var(--line); }
.prose th { font: 500 11px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; text-align: left; padding: 6px 12px; border-bottom: 2px solid var(--line); }
.prose td { padding: 6px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: var(--paper); }
.prose td:first-child a { font-family: var(--font-mono); font-size: 14px; white-space: nowrap; }

/* Severity column in the daily news tables: dot + word (colour never alone) */
.prose td[data-severity] { font: 500 11px/20px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.prose td[data-severity]::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; vertical-align: 0; border: 1px solid var(--line); background: var(--klein); }
.prose td[data-severity="Low"]::before { background: var(--status-on); }
.prose td[data-severity="Medium"]::before { background: var(--mantis-yellow); }
.prose td[data-severity="High"]::before { background: var(--mantis-orange); }
.prose td[data-severity="Critical"] { color: var(--danger); }
.prose td[data-severity="Critical"]::before { background: var(--status-off); transform: rotate(45deg) scale(.9); }

/* Prev / next */
.post-nav { display: grid; gap: 20px; margin-top: 64px; max-width: var(--measure); padding-right: 4px; }
@media (min-width: 640px) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav a {
  display: grid; gap: 6px; padding: 16px; text-decoration: none; color: var(--ink);
  border: 2px solid var(--line); background: var(--paper-raised); box-shadow: var(--shadow-hard);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s cubic-bezier(.2,.8,.2,1);
}
.post-nav a:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--line); }
.post-nav .sc-label { color: var(--ink-muted); }
.post-nav strong { font: 700 16px/1.3 var(--font-display); }
.post-nav a:hover strong { color: var(--klein); }
.post-nav .next { text-align: right; }
@media (min-width: 640px) { .post-nav .next:only-child { grid-column: 2; } }

/* ---------- 404 ---------- */
.not-found { display: grid; gap: 24px; max-width: 640px; }
.not-found__code { font: 800 clamp(80px, 22vw, 160px)/.9 var(--font-display); letter-spacing: -.04em; color: var(--klein); margin: 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 2px solid var(--line); background: var(--paper-raised); padding: 28px 0; }
/* keep footer content clear of the floating scroll button */
@media (max-width: 759px) { .site-footer__inner { padding-right: calc(var(--gutter) + 64px); } }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; }
.site-footer small { font: 400 13px/20px var(--font-mono); color: var(--ink-muted); }
.social { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.social a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border: 2px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none;
  font: 500 12px/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
}
.social a:hover { background: var(--klein); color: var(--on-klein); }
.social .icon { width: 18px; height: 18px; }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  .post-card:hover, .post-nav a:hover, .icon-btn:hover { transform: none; }
}
@media print {
  .site-header, .site-footer, .post-nav, .back-link, .skip-link { display: none; }
  body { background: #fff; color: #000; }
  .prose a::after { content: " (" attr(href) ")"; font-size: .85em; }
  .prose pre, .table-wrap { box-shadow: none; }
}
