/* ==========================================================================
   kenhaines.net — Design System
   Dark, developer-focused blog theme adapted from logfmt.net
   Built for BlogFlow (pure CSS, no JS)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Colors */
  --bg: #0a0a0b;
  --surface: #141416;
  --border: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.1);
  --green: #4ade80;

  /* Typography */
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;

  /* Layout */
  --max-width: 42rem;
  --content-width: 64rem;

  /* Surfaces */
  --radius: 8px;
  --radius-lg: 12px;

  /* Motion */
  --transition: 0.2s ease;
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

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

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

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Headings */
h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.35rem); }
h4 { font-size: clamp(1rem, 2vw, 1.15rem); }

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Focus states */
a:focus-visible,
button:focus-visible,
.tag:focus-visible,
.pagination a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  z-index: 200;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.5rem;
}

/* Inline code */
code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}

pre code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 0.85rem;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

/* --------------------------------------------------------------------------
   3. Site Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
}

.site-logo {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-logo:hover {
  text-decoration: none;
}

/* Accent dot after the domain, like logfmt.net's colored dot */
.site-logo .dot {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-nav a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   4. Site Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer__inner {
  max-width: var(--content-width);
  margin: 0 auto;
}

.site-footer__links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
  list-style: none;
}

.site-footer__links a {
  color: var(--muted);
  transition: color var(--transition);
}

.site-footer__links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-footer__copy {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   5. Main Content
   -------------------------------------------------------------------------- */

.main {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}

.main--narrow {
  max-width: var(--max-width);
}

.main--wide {
  max-width: var(--content-width);
}

/* --------------------------------------------------------------------------
   6. Post List / Post Cards (Homepage)
   -------------------------------------------------------------------------- */

.post-list__heading {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin-bottom: 1.5rem;
  color: var(--text);
}

.post-list__heading .tag {
  vertical-align: middle;
  font-size: 0.85rem;
}

.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color var(--transition);
}

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

.post-card__title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.post-card__title a {
  color: var(--text);
  text-decoration: none;
}

.post-card__title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.post-card__meta .sep {
  opacity: 0.4;
}

.post-card__summary {
  color: var(--muted);
  font-size: 0.925rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

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

/* --------------------------------------------------------------------------
   7. Pagination
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition);
}

.pagination a:hover {
  border-color: var(--accent);
  color: var(--text);
  text-decoration: none;
}

.pagination .active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.pagination .disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   8. Single Post — Header
   -------------------------------------------------------------------------- */

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

.post-header__title {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin-bottom: 0.75rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.post-meta .sep {
  opacity: 0.4;
}

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

/* --------------------------------------------------------------------------
   9. Single Post — Content (Prose)
   -------------------------------------------------------------------------- */

.post-content {
  max-width: var(--max-width);
  line-height: 1.8;
}

.post-content > * + * {
  margin-top: 1.5rem;
}

.post-content h2 {
  margin-top: 2.5rem;
}

.post-content h3 {
  margin-top: 2rem;
}

.post-content h4 {
  margin-top: 1.75rem;
}

/* Paragraphs */
.post-content p {
  color: var(--text);
}

/* Lists */
.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
}

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

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

/* Blockquotes */
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin-left: 0;
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-style: italic;
}

.post-content blockquote p {
  color: var(--muted);
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.post-content thead {
  border-bottom: 2px solid var(--border);
}

.post-content th {
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  color: var(--text);
}

.post-content td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

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

.post-content tbody tr:hover {
  background: var(--surface);
}

/* Images */
.post-content img {
  margin: 2rem auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.post-content figure {
  margin: 2rem 0;
  text-align: center;
}

.post-content figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   10. Code Blocks
   -------------------------------------------------------------------------- */

.post-content pre,
.highlight pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

/* macOS-style window dots */
.highlight {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.highlight::before {
  content: '● ● ●';
  display: block;
  font-size: 0.55rem;
  letter-spacing: 0.35em;
  color: var(--border);
  padding: 0.75rem 1.5rem 0;
  background: var(--surface);
  line-height: 1;
}

.highlight pre {
  border: none;
  border-radius: 0;
  margin-top: 0;
}

/* Chroma syntax highlighting overrides */
.chroma { color: var(--text); background: var(--surface); }

/* Keywords */
.chroma .kw, /* Keyword */
.chroma .kc, /* KeywordConstant */
.chroma .kd, /* KeywordDeclaration */
.chroma .kn, /* KeywordNamespace */
.chroma .kp, /* KeywordPseudo */
.chroma .kr, /* KeywordReserved */
.chroma .kt  /* KeywordType — also cyan below */
  { color: #c084fc; }

/* Strings */
.chroma .s,   /* String */
.chroma .s1,  /* StringSingle */
.chroma .s2,  /* StringDouble */
.chroma .sa,  /* StringAffix */
.chroma .sb,  /* StringBacktick */
.chroma .sc,  /* StringChar */
.chroma .sh,  /* StringHeredoc */
.chroma .si,  /* StringInterpol */
.chroma .sx,  /* StringOther */
.chroma .sr,  /* StringRegex */
.chroma .ss   /* StringSymbol */
  { color: #f9a8d4; }

/* Comments */
.chroma .c,   /* Comment */
.chroma .c1,  /* CommentSingle */
.chroma .ch,  /* CommentHashbang */
.chroma .cm,  /* CommentMultiline */
.chroma .cp,  /* CommentPreproc */
.chroma .cpf, /* CommentPreprocFile */
.chroma .cs   /* CommentSpecial */
  { color: #71717a; font-style: italic; }

/* Names / Functions */
.chroma .n,   /* Name */
.chroma .na,  /* NameAttribute */
.chroma .nb,  /* NameBuiltin */
.chroma .nc,  /* NameClass */
.chroma .nf,  /* NameFunction */
.chroma .nn,  /* NameNamespace */
.chroma .ni   /* NameEntity */
  { color: #fbbf24; }

/* Types — cyan accent */
.chroma .kt   /* KeywordType */
  { color: var(--accent); }

/* Numbers */
.chroma .mi,  /* LiteralNumberInteger */
.chroma .mf,  /* LiteralNumberFloat */
.chroma .mh,  /* LiteralNumberHex */
.chroma .mo,  /* LiteralNumberOct */
.chroma .mb,  /* LiteralNumberBin */
.chroma .il   /* LiteralNumberIntegerLong */
  { color: var(--green); }

/* Operators */
.chroma .o,   /* Operator */
.chroma .ow   /* OperatorWord */
  { color: var(--muted); }

/* Punctuation */
.chroma .p    /* Punctuation */
  { color: var(--muted); }

/* Deleted / Inserted (diffs) */
.chroma .gd   /* GenericDeleted */
  { color: #f87171; background: rgba(248, 113, 113, 0.1); }
.chroma .gi   /* GenericInserted */
  { color: var(--green); background: rgba(74, 222, 128, 0.1); }

/* --------------------------------------------------------------------------
   11. Tag Components
   -------------------------------------------------------------------------- */

.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2em 0.65em;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 9999px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.tag:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

/* Tag listing page */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 3rem;
}

.tag-list .tag {
  font-size: 0.85rem;
  padding: 0.3em 0.85em;
}

/* --------------------------------------------------------------------------
   12. Static Page Styles
   -------------------------------------------------------------------------- */

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

.page-header__title {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
}

.page-content {
  line-height: 1.8;
}

.page-content > * + * {
  margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   13. 404 Page
   -------------------------------------------------------------------------- */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 50vh;
  gap: 1rem;
}

.error-page__code {
  font-family: var(--mono);
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.04em;
}

.error-page__message {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 28rem;
}

.error-page__link {
  margin-top: 0.5rem;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   14. Utility Classes
   -------------------------------------------------------------------------- */

.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;
}

.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }

/* --------------------------------------------------------------------------
   15. Responsive Design
   -------------------------------------------------------------------------- */

/* Tablet & below */
@media (max-width: 768px) {
  .site-header__inner {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .site-nav {
    gap: 1rem;
  }

  .main {
    padding: 1.5rem 1rem;
  }

  .post-card {
    padding: 1.25rem;
  }

  .post-content pre,
  .highlight pre {
    padding: 1rem;
    font-size: 0.8rem;
    border-radius: var(--radius);
  }

  .highlight::before {
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0.6rem 1rem 0;
  }

  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .post-meta .sep {
    display: none;
  }
}

/* Mobile */
@media (max-width: 480px) {
  body {
    font-size: 0.95rem;
  }

  .site-header__inner {
    padding: 0.6rem 0.75rem;
  }

  .site-nav {
    gap: 0.75rem;
    font-size: 0.85rem;
  }

  .main {
    padding: 1rem 0.75rem;
  }

  .post-card {
    padding: 1rem;
    border-radius: var(--radius);
  }

  .post-card__title {
    font-size: 1.1rem;
  }

  .site-footer {
    padding: 1.5rem 0.75rem;
  }

  .site-footer__links {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .pagination a,
  .pagination span {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.85rem;
  }
}

/* --------------------------------------------------------------------------
   16. Print Styles
   -------------------------------------------------------------------------- */

@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .pagination, .skip-link { display: none; }
  a { color: #000; text-decoration: underline; }
  .post-content pre { border: 1px solid #ccc; background: #f5f5f5; color: #000; }
  .tag { background: #eee; color: #333; }
}
