/* ═══════════════════════════════════════════════
   HACKER POST — Stylesheet
   Mobile-first. Graceful degradation to no-CSS.
   ═══════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: #2c2c2c;
  background-color: #fefdfb;
}

/* ── Typography ───────────────────────────────── */

h1, h2, h3, h4 {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.3;
  color: #1a1a1a;
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.25rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h1 a:hover,
h1 a:focus {
  color: #b35900;
}

h2 {
  font-size: 1.4rem;
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #b35900;
}

main > h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.75rem;
  color: #4a3520;
}

h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  color: #6b5440;
}

p {
  margin: 0 0 1rem;
  max-width: 65ch;
}

strong {
  color: #1a1a1a;
}

hr {
  border: none;
  border-top: 1px solid #e0d6c8;
  margin: 2rem 0;
  max-width: 65ch;
}

/* ── Links ────────────────────────────────────── */

a {
  color: #b35900;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover,
a:focus {
  color: #7a3d00;
  text-decoration-thickness: 2px;
}

a:visited {
  color: #7a4a2a;
}

/* ── Lists ────────────────────────────────────── */

ul, ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
  max-width: 65ch;
}

li {
  margin-bottom: 0.35rem;
}

li em {
  color: #5a4030;
}

/* ── Definition Lists ─────────────────────────── */

dl {
  margin: 0 0 1.5rem;
  max-width: 65ch;
}

dt {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  color: #b35900;
  margin-top: 1rem;
}

dd {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid #e8ddd0;
}

/* ── Preformatted / Code ──────────────────────── */

pre {
  margin: 0;
  padding: 1rem;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #3a2a1a;
  background-color: #f5f0e8;
  border: 1px solid #e0d6c8;
  border-left: 4px solid #b35900;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

code {
  font-family: inherit;
}

samp {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background-color: #f5f0e8;
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

/* ── Figures (postcard examples) ──────────────── */

figure {
  margin: 1rem 0 1.5rem;
}

/* ── Blockquotes ──────────────────────────────── */

blockquote {
  margin: 1rem 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid #d4c0a8;
  background-color: #faf6f0;
  max-width: 65ch;
}

blockquote p {
  margin-bottom: 0.5rem;
}

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

/* ── Lede ─────────────────────────────────────── */

.lede {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 1.3rem;
  line-height: 1.4;
  color: #1a1a1a;
  margin: 0 0 1.25rem;
}

/* ── Aside (runbook callout boxes) ────────────── */

aside {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background-color: #f9f5ef;
  border: 1px solid #e8ddd0;
  border-left: 4px solid #b35900;
  max-width: 65ch;
}

aside h3 {
  margin-top: 0;
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b5440;
}

aside :last-child {
  margin-bottom: 0;
}

/* ── Tables ───────────────────────────────────── */

table {
  width: 100%;
  max-width: 65ch;
  margin: 1rem 0 1.5rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

caption {
  text-align: left;
  font-style: italic;
  color: #6b5a48;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e0d6c8;
}

thead th {
  background-color: #f0e8dc;
  color: #4a3520;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody th {
  background-color: #faf6f0;
  color: #b35900;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background-color: #fbf8f3;
}

/* ── Header ───────────────────────────────────── */

header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 3px double #b35900;
}

header p {
  font-size: 1.05rem;
  color: #5a4a3a;
  margin: 0;
  font-style: italic;
}

/* ── Site Navigation ──────────────────────────── */

nav[aria-label="Site navigation"] {
  margin-bottom: 2.5rem;
  padding: 0.75rem 1rem;
  background-color: #f9f5ef;
  border: 1px solid #e8ddd0;
}

nav[aria-label="Site navigation"] ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav[aria-label="Site navigation"] li {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

nav[aria-label="Site navigation"] li strong {
  color: #b35900;
}

/* ── Page Navigation (prev/next) ──────────────── */

nav[aria-label="Page navigation"] {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0d6c8;
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

nav[aria-label="Page navigation"] p {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

/* ── Footer ───────────────────────────────────── */

footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 3px double #b35900;
}

footer p {
  font-style: italic;
  color: #6b5a48;
  font-size: 0.95rem;
}

/* ═══════════════════════════════════════════════
   Tablet and up (min-width: 600px)
   ═══════════════════════════════════════════════ */

@media (min-width: 600px) {
  body {
    padding: 2rem;
    font-size: 1.05rem;
  }

  h1 {
    font-size: 2.5rem;
  }

  h2 {
    font-size: 1.6rem;
  }

  pre {
    font-size: 0.875rem;
  }

  nav[aria-label="Site navigation"] {
    padding: 0.75rem 1.25rem;
  }

  nav[aria-label="Site navigation"] ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
  }

  nav[aria-label="Site navigation"] li {
    margin-bottom: 0;
  }
}

/* ═══════════════════════════════════════════════
   Desktop (min-width: 900px)
   ═══════════════════════════════════════════════ */

@media (min-width: 900px) {
  body {
    max-width: 52rem;
    margin: 0 auto;
    padding: 3rem 2.5rem;
  }

  h1 {
    font-size: 3rem;
  }

  header {
    margin-bottom: 2rem;
  }

  dd {
    padding-left: 1.5rem;
  }

  nav[aria-label="Page navigation"] {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
  }

  nav[aria-label="Page navigation"] p {
    margin: 0;
  }
}

/* ═══════════════════════════════════════════════
   Print styles
   ═══════════════════════════════════════════════ */

@media print {
  body {
    font-size: 11pt;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  nav[aria-label="Site navigation"] a[href]::after,
  nav[aria-label="Page navigation"] a[href]::after {
    content: none;
  }

  pre {
    border: 1px solid #999;
    background: #f8f8f8;
  }

  table, th, td {
    border: 1px solid #999;
  }

  thead th, tbody th, tbody tr:nth-child(even) td {
    background: #f0f0f0;
  }

  aside {
    border: 1px solid #999;
    background: #f8f8f8;
  }

  h2, h3 {
    break-after: avoid;
  }

  table, figure, aside {
    break-inside: avoid;
  }
}

/* ═══════════════════════════════════════════════
   High contrast / forced colors
   ═══════════════════════════════════════════════ */

@media (forced-colors: active) {
  pre {
    border: 1px solid;
  }

  nav[aria-label="Site navigation"],
  aside {
    border: 1px solid;
  }

  table, th, td {
    border: 1px solid;
  }

  header,
  footer {
    border-bottom: 1px solid;
    border-top: 1px solid;
  }
}
