/* ============================================================
   1. Custom properties
   ============================================================ */

:root {
  --bg:           #0a0a0f;
  --surface:      #13131e;
  --border:       #2d2d4e;
  --text:         #e2e0f0;
  --text-muted:   #8b87b0;
  --accent:       #a78bfa;
  --accent-hover: #c4b5fd;
  --code-bg:      #1e1e2e;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

  --container-max: 1000px;
  --container-narrow: 720px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f8f8fc;
    --surface:      #ffffff;
    --border:       #e0dff0;
    --text:         #1a1a2e;
    --text-muted:   #6b6890;
    --accent:       #6d28d9;
    --accent-hover: #4c1d95;
    --code-bg:      #f1f0fa;
  }
}

/* ============================================================
   2. Reset & base
   ============================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

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

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

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

/* ============================================================
   3. Focus styles
   ============================================================ */

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

/* ============================================================
   4. Skip link
   ============================================================ */

/* Hidden above the viewport until focused via keyboard (Tab key), then slides
   into view so keyboard/screen reader users can jump past the nav to #main.
   WCAG 2.1 SC 2.4.1 — Bypass Blocks. */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;
  font-weight: 600;
  z-index: 100;
  transition: top 0.1s;
}

.skip-link:focus {
  top: 0;
}

/* ============================================================
   5. Layout containers
   ============================================================ */

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

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

main {
  flex: 1;
  padding: 2rem 0 3rem;
}

/* ============================================================
   6. Site header
   ============================================================ */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

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

.site-logo__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-left: auto;
}

.site-nav__link {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.site-nav__link:hover,
.site-nav__link[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================================================
   7. Site footer
   ============================================================ */

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.site-footer__inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.site-footer__social {
  display: flex;
  gap: 1.25rem;
}

.site-footer__link {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

/* ============================================================
   8. Hero
   ============================================================ */

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

.hero__title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.hero__tagline {
  font-size: 1rem;
  color: var(--text-muted);
}

/* ============================================================
   9. Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
  /* Colors come from --badge-fg / --badge-fg-light set via inline style by the
     badge macro, which reads category colors from config.extra.categories. */
  color: var(--badge-fg, var(--accent));
  background-color: color-mix(in srgb, var(--badge-fg, var(--accent)) 15%, transparent);
}

@media (prefers-color-scheme: light) {
  .badge {
    color: var(--badge-fg-light, var(--accent));
    background-color: color-mix(in srgb, var(--badge-fg-light, var(--accent)) 15%, transparent);
  }
}

/* ============================================================
   10. Article cards
   ============================================================ */

.articles__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

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

.articles__more {
  display: inline-block;
  margin-top: 2rem;
  font-weight: 600;
  color: var(--accent);
}

.articles__more:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: transparent;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-left-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-left-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  color: inherit;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.card__date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.card__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

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

.card__excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.9rem;
}

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

.card__tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* ============================================================
   11. Article page
   ============================================================ */

.article__breadcrumb {
  margin-bottom: 1.75rem;
}

.breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb__item + .breadcrumb__item::before {
  content: '›';
  margin-right: 0.3rem;
  color: var(--border);
}

.breadcrumb__link {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb__link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.article__header .badge {
  margin-bottom: 0.75rem;
}

.article__title {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.75rem;
}

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

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

.article__tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* Article body typography */
.article__content {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
}

.article__content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.article__content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 0.5rem;
}

.article__content h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.5rem 0 0.4rem;
}

.article__content p {
  margin-bottom: 1.25rem;
}

.article__content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.article__content ul,
.article__content ol {
  margin: 0 0 1.25rem 1.5rem;
}

.article__content li {
  margin-bottom: 0.35rem;
}

.article__content li > ul,
.article__content li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.article__content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.article__content blockquote p {
  margin-bottom: 0;
}

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

.article__content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1.5rem auto;
}

.article__content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.article__content th,
.article__content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.article__content th {
  background: var(--surface);
  font-weight: 600;
}

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

.article__discussion-label {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.article__discussion-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}

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

/* Code */
pre {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.65;
  border: 1px solid var(--border);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

pre code {
  font-size: 1em;
  background: none;
  padding: 0;
  border-radius: 0;
}

:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

/* ============================================================
   12. Pagination
   ============================================================ */

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

.pagination__prev,
.pagination__next {
  color: var(--accent);
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.pagination__prev:hover,
.pagination__next:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-hover);
}

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

/* ============================================================
   13. Taxonomy pages (categories & tags listing)
   ============================================================ */

.taxonomy__heading {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.taxonomy__underline {
  width: 2.5rem;
  height: 3px;
  background: var(--accent);
  border-radius: 9999px;
  margin-bottom: 2rem;
}

/* Category cards grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.category-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-left-color 0.15s, box-shadow 0.15s;
}

.category-card:hover {
  border-left-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  color: inherit;
}

.category-card .badge {
  margin-bottom: 0.75rem;
}


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

/* Single taxonomy (category or tag) page */
.taxonomy-single__heading {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.taxonomy-single__underline {
  width: 2.5rem;
  height: 3px;
  background: var(--accent);
  border-radius: 9999px;
  margin-bottom: 0.6rem;
}

.taxonomy-single__count {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ============================================================
   14. Tag cloud
   ============================================================ */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: baseline;
}

.tag-cloud__tag {
  color: var(--accent);
  font-size: calc(0.75rem + var(--count, 1) * 0.08rem);
  line-height: 1.4;
  transition: color 0.15s;
}

.tag-cloud__tag:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   15. 404 page
   ============================================================ */

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

.error__code {
  font-size: 6rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--border);
  line-height: 1;
}

.error__message {
  font-size: 1.1rem;
  color: var(--text-muted);
}

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

.error__back {
  margin-top: 0.5rem;
  display: inline-block;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 1.25rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.error__back:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ============================================================
   16. RSS page
   ============================================================ */

.rss-page__intro {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.rss-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rss-list__link {
  font-weight: 600;
  color: var(--accent);
}

.rss-list__link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   17. Desktop overrides
   ============================================================ */

@media (min-width: 768px) {
  .site-header__inner {
    padding: 0.85rem 2rem;
  }

  .container {
    padding: 0 2rem;
  }

  .hero__title {
    font-size: 2.5rem;
  }

  .article__title {
    font-size: 2.25rem;
  }

  pre {
    font-size: 0.9rem;
  }
}
