/* Beacon theme — pure CSS, no framework
   Rule 29: simplicity, restrained color, predictable flow, calm vibe
   ------------------------------------------------------------------ */

/* ── Variables ────────────────────────────────────────────────────── */

:root {
  --bg:            #1a1a1a;
  --bg-secondary:  #242424;
  --bg-code:       #2a2a2a;
  --text:          #e0e0e0;
  --text-muted:    #888888;
  --accent:        #5a9e8f;
  --accent-dim:    #4a8a7b;
  --border:        #333333;
  --border-light:  #2e2e2e;

  --max-width:     760px;
  --sidebar-width: 260px;
  --gap:           3rem;

  --font-body:     system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:     "SF Mono", "Fira Code", "Fira Mono", monospace;

  --radius:        4px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f8f8f8;
    --bg-secondary: #efefef;
    --bg-code:      #f0f0f0;
    --text:         #1a1a1a;
    --text-muted:   #666666;
    --border:       #dddddd;
    --border-light: #e8e8e8;
  }
}


/* ── Reset ────────────────────────────────────────────────────────── */

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.0625rem);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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


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

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

h1 { font-size: clamp(1.6rem, 4vw, 2rem); margin-top: 0; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4, h5, h6 { font-size: 1rem; }

p {
  margin-bottom: 1.25rem;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 100ms ease;
}

a:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

strong, b { font-weight: 600; }
em, i { font-style: italic; }

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li { margin-bottom: 0.3rem; }

blockquote {
  border-left: 3px solid var(--border);
  padding: 0.25rem 0 0.25rem 1.25rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
}

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


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

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.55;
}

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


/* ── Layout ───────────────────────────────────────────────────────── */

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

.header-inner {
  max-width: calc(var(--max-width) + var(--sidebar-width) + var(--gap) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

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

nav[aria-label="Site navigation"] a {
  color: var(--text-muted);
  font-size: 0.9rem;
}

nav[aria-label="Site navigation"] a:hover {
  color: var(--text);
  text-decoration: none;
}

main {
  padding: 2.5rem 0 4rem;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  gap: var(--gap);
  max-width: calc(var(--max-width) + var(--sidebar-width) + var(--gap) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-grid--single {
  grid-template-columns: minmax(0, 1fr);
  max-width: calc(var(--max-width) + 3rem);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
}

.footer-inner {
  max-width: calc(var(--max-width) + var(--sidebar-width) + var(--gap) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}


/* ── Article ──────────────────────────────────────────────────────── */

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

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

.article-meta time { color: var(--text-muted); }

.article-meta .tags a {
  color: var(--text-muted);
}

.article-meta .tags a:hover {
  color: var(--accent);
}

.difficulty {
  font-size: 0.8rem;
  padding: 0.15em 0.5em;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.difficulty--beginner     { border-color: #4a7c6f; color: #4a7c6f; }
.difficulty--intermediate { border-color: var(--text-muted); color: var(--text-muted); }
.difficulty--advanced     { border-color: #8f6a5a; color: #8f6a5a; }

.article-body {
  max-width: var(--max-width);
}

.article-body h2,
.article-body h3,
.article-body h4 {
  margin-top: 2.5rem;
}

.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

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

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


/* ── Article card (index / tag / category) ────────────────────────── */

.article-card {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.article-card:last-of-type {
  border-bottom: none;
}

.article-card__title {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}

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

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

.article-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.article-card__summary {
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
}

.article-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.15em 0.5em;
  border-radius: var(--radius);
  text-decoration: none;
}

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


/* ── FAQ ──────────────────────────────────────────────────────────── */

.faq {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.faq h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.faq-item {
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 0;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  list-style: none;
  padding-right: 1rem;
  position: relative;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  position: absolute;
  right: 0;
  color: var(--text-muted);
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-item p {
  margin-top: 0.75rem;
  color: var(--text-muted);
}


/* ── Sidebar ──────────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  font-size: 0.875rem;
}

.sidebar-divider {
  margin: 1.5rem 0;
}

.toc-heading,
.subscribe-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

/* TOC generated by pelican-toc */
.toc ul {
  padding-left: 1rem;
  margin: 0;
}

.toc li {
  margin-bottom: 0.3rem;
}

.toc a {
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.subscribe-description {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
}


/* ── Subscribe form ───────────────────────────────────────────────── */

.subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subscribe-form input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.subscribe-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
}

.subscribe-form input[type="email"]::placeholder {
  color: var(--text-muted);
}

.subscribe-form button {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease;
}

.subscribe-form button:hover {
  background: var(--accent-dim);
}

.subscribe-form button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Loading indicator for HTMX in-flight state */
.subscribe-form__indicator {
  display: none;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.htmx-request .subscribe-form__indicator {
  display: inline;
}

.htmx-request .subscribe-form__indicator::after {
  content: 'Subscribing…';
}


/* ── Archives ─────────────────────────────────────────────────────── */

.archives-year {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-light);
}

.archives-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.archives-item {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

.archives-item time {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.archives-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}


/* ── Pagination ───────────────────────────────────────────────────── */

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}


/* ── Accessibility ────────────────────────────────────────────────── */

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


/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 800px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    border-top: 1px solid var(--border);
    padding-top: 2rem;
    margin-top: 1rem;
  }

  .archives-item {
    grid-template-columns: 4rem 1fr;
  }

  .archives-meta {
    display: none;
  }
}

@media (max-width: 480px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  nav[aria-label="Site navigation"] {
    gap: 1rem;
  }
}
