/* ==========================================================================
   Secure Systems Engineering — editorial stylesheet
   Serif headings, generous measure, light publication ground.
   ========================================================================== */

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

:root {
  /* Ground */
  --bg:            #fdfcfa;
  --bg-subtle:     #f4f2ec;
  --bg-code:       #f7f5f0;

  /* Ink */
  --text:          #22201d;
  --text-muted:    #6b665e;
  --text-faint:    #8d887f;

  /* Structure */
  --rule:          #e4e0d7;
  --rule-strong:   #cdc8bc;

  /* Accent — deep editorial blue */
  --accent:        #0f4c75;
  --accent-hover:  #093a5c;
  --accent-wash:   #eaf0f5;

  /* Type */
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Measure */
  --measure:    43rem;   /* ~688px — 70ish characters at 1.125rem serif */
  --gutter:     1.5rem;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { color: var(--accent-hover); }

::selection {
  background: var(--accent-wash);
  color: var(--text);
}

/* Skip link — keyboard and screen-reader affordance */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  z-index: 200;
}

.skip-link:focus {
  left: 0;
  color: var(--bg);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main {
  flex: 1;
  padding: 0 0 6rem;
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 1.4rem 0;
  background: var(--bg);
}

.nav {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-name {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-name:hover { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: baseline;
  gap: 1.75rem;
  font-family: var(--font-sans);
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  border-bottom-color: var(--rule-strong);
}

.nav-links a.nav-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Home — masthead introduction
   -------------------------------------------------------------------------- */

.home-intro {
  padding: 4.5rem 0 3rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}

.home-intro h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 1.25rem;
  max-width: 16ch;
}

.home-intro .home-lede {
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 34rem;
}

.home-intro .home-byline {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin-top: 1.75rem;
  letter-spacing: 0.01em;
}

.home-intro .home-byline a {
  color: var(--text-muted);
  border-bottom: 1px solid var(--rule-strong);
}

.home-intro .home-byline a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Post list
   -------------------------------------------------------------------------- */

.list-heading {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 2.5rem 0 0.5rem;
}

.post-list {
  display: flex;
  flex-direction: column;
}

.post-card {
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--rule);
}

.post-card:last-child { border-bottom: none; }

.post-card-meta,
.post-header-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.post-card-meta { margin-bottom: 0.75rem; }

.meta-divider { color: var(--rule-strong); }

.post-card-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 0.625rem;
}

.post-card-title a { color: var(--text); }

.post-card-title a:hover { color: var(--accent); }

.post-card-excerpt {
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------------
   Tags
   -------------------------------------------------------------------------- */

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Post
   -------------------------------------------------------------------------- */

.post-header {
  padding: 4rem 0 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}

.post-header-meta { margin-bottom: 1.25rem; }

.post-title {
  font-family: var(--font-serif);
  font-size: 2.375rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.028em;
  color: var(--text);
  margin-bottom: 1rem;
  text-wrap: balance;
}

.post-description {
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.post-byline {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin-top: 1.5rem;
}

/* Body typography */

.post-content {
  font-size: 1.125rem;
  line-height: 1.75;
}

.post-content > p:first-of-type {
  font-size: 1.1875rem;
}

.post-content h2 {
  font-family: var(--font-serif);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 3rem 0 1rem;
}

.post-content h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin: 2.25rem 0 0.75rem;
}

.post-content h4 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 2rem 0 0.625rem;
}

.post-content p { margin-bottom: 1.375rem; }

.post-content ul,
.post-content ol {
  margin: 0 0 1.375rem 1.5rem;
}

.post-content li { margin-bottom: 0.5rem; }

.post-content li::marker { color: var(--text-faint); }

.post-content strong {
  font-weight: 600;
  color: var(--text);
}

.post-content a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-wash);
  transition: border-color 0.15s;
}

.post-content a:hover { border-bottom-color: var(--accent); }

.post-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

.post-content blockquote {
  border-left: 2px solid var(--rule-strong);
  padding-left: 1.5rem;
  margin: 2rem 0;
}

.post-content blockquote p {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.post-content blockquote p:last-child { margin-bottom: 0; }

/* Figures and images */

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
}

.post-content figcaption,
.post-content .caption {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  text-align: center;
  margin-top: -1rem;
  margin-bottom: 2rem;
}

/* Code */

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--rule);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--text);
}

.post-content pre {
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8125rem;
  border-radius: 0;
}

/* Mermaid */

.post-content .mermaid {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1.75rem;
  margin: 2rem 0;
  text-align: center;
  overflow-x: auto;
}

/* Tables */

.table-scroll {
  overflow-x: auto;
  margin: 2rem 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  margin: 2rem 0;
}

.post-content th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--rule-strong);
  padding: 0.5rem 0.75rem 0.5rem 0;
  text-align: left;
}

.post-content td {
  padding: 0.7rem 0.75rem 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.post-content tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------------------------
   Post footer — prev/next
   -------------------------------------------------------------------------- */

.post-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.post-nav {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.post-nav-item { flex: 1; min-width: 0; }

.post-nav-item.is-next { text-align: right; }

.post-nav-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 0.375rem;
}

.post-nav-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

a.post-nav-link:hover .post-nav-title { color: var(--accent); }

.back-link {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.back-link:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */

.page-header {
  padding: 4rem 0 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 2.375rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.028em;
}

.about-page {
  font-size: 1.125rem;
  line-height: 1.75;
}

.about-page p { margin-bottom: 1.375rem; }

.about-page h2 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 2.5rem 0 0.875rem;
}

.about-page ul {
  margin: 0 0 1.375rem 1.5rem;
}

.about-page li { margin-bottom: 0.5rem; }

.about-page a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-wash);
}

.about-page a:hover { border-bottom-color: var(--accent); }

.about-page hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

.about-note {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-faint);
  background: var(--bg-subtle);
  border-left: 2px solid var(--rule-strong);
  padding: 1.125rem 1.375rem;
  margin: 2rem 0;
}

.about-note p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Colophon
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 2.5rem;
  font-family: var(--font-sans);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.site-footer a { color: var(--text-muted); }

.site-footer a:hover { color: var(--accent); }

.footer-disclaimer {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-faint);
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  max-width: 40rem;
}

/* --------------------------------------------------------------------------
   Syntax highlighting (Rouge) — light
   -------------------------------------------------------------------------- */

.highlight .c,  .highlight .c1, .highlight .cm  { color: #6a737d; font-style: italic; }
.highlight .k,  .highlight .kd, .highlight .kn,
.highlight .kp, .highlight .kr, .highlight .kt  { color: #b31d28; }
.highlight .s,  .highlight .s1, .highlight .s2,
.highlight .sb, .highlight .sc, .highlight .sd,
.highlight .se, .highlight .sh, .highlight .si,
.highlight .sx, .highlight .sr, .highlight .ss  { color: #0a3069; }
.highlight .mi, .highlight .mf, .highlight .mh,
.highlight .il, .highlight .m                   { color: #0550ae; }
.highlight .nf, .highlight .fm                  { color: #6639ba; }
.highlight .na                                  { color: #0550ae; }
.highlight .nb, .highlight .bp                  { color: #0550ae; }
.highlight .nc, .highlight .nn                  { color: #6639ba; }
.highlight .o,  .highlight .ow                  { color: #b31d28; }
.highlight .p                                   { color: var(--text); }
.highlight .n,  .highlight .nx                  { color: var(--text); }
.highlight .nt                                  { color: #116329; }
.highlight .nv, .highlight .vc, .highlight .vg,
.highlight .vi                                  { color: #953800; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 40rem) {
  html { font-size: 15px; }

  .home-intro {
    padding: 3rem 0 2.25rem;
  }

  .home-intro h1 {
    font-size: 2rem;
    max-width: none;
  }

  .home-intro .home-lede { font-size: 1.0625rem; }

  .post-header,
  .page-header { padding-top: 2.75rem; }

  .post-title,
  .page-title { font-size: 1.875rem; }

  .post-description { font-size: 1.0625rem; }

  .post-card-title { font-size: 1.3125rem; }

  .post-content h2 { font-size: 1.4375rem; }

  .post-nav {
    flex-direction: column;
    gap: 1.5rem;
  }

  .post-nav-item.is-next { text-align: left; }

  .footer-inner { flex-direction: column; gap: 0.75rem; }
}

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

/* Print — posts should read cleanly on paper */

@media print {
  .site-header, .site-footer, .post-footer, .skip-link { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .post-content a { border: none; text-decoration: underline; }
}
