/* News reader specific variables (colors come from site_kit base.css) */
:root {
  --border-light: #3a4058;
  --shadow: rgba(0, 0, 0, 0.3);
  --sources-down-bg: #3a2828;
  --sources-down-border: #6b3a3a;
  --category-accent: var(--link);
}

[data-theme="light"] {
  --border-light: #e5e8ef;
  --shadow: rgba(0, 0, 0, 0.08);
  --sources-down-bg: #fef2f2;
  --sources-down-border: #e8aaaa;
}

/* ===================================
   Reset and Base
   =================================== */

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
    sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ===================================
   Container
   =================================== */

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* ===================================
   Header
   =================================== */

/* The upstream site_kit makes every <header> sticky with z-index 100.
   We want only the post-date to stick on an article page. Site-header
   scrolling away also fixes a mobile bug: when it wrapped to two rows,
   the post-header (shorter) only covered the top row, leaving the
   About/RSS row visible behind the date. */
.site-header {
  position: static;
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  background-color: var(--header-bg);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

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

.site-title:hover {
  color: var(--link);
}

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

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

.site-nav a:hover {
  color: var(--link);
}

/* Language switcher — visually paired with nav links but slightly muted. */
.site-nav a.lang-switch {
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.82rem;
}

.site-nav a.lang-switch:hover {
  border-color: var(--link);
}

/* ===================================
   Theme Toggle
   =================================== */

.theme-toggle {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--link);
  color: var(--link);
}

/* ===================================
   Main Content
   =================================== */

main {
  flex: 1;
  padding: 2.5rem 1.5rem;
}

/* ===================================
   Index / Post List
   =================================== */

.index-description {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  border-bottom: 1px solid var(--border);
}

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

.post-list-link {
  display: block;
  padding: 0.75rem 0;
  text-decoration: none;
  transition: color 0.15s ease;
}

.post-list-link:hover .post-list-date {
  color: var(--link);
}

.post-list-date {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ===================================
   Post
   =================================== */

.post-header {
  margin-bottom: 2rem;
  text-align: center;
}

.post-date {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 600;
  display: block;
  letter-spacing: -0.01em;
}

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

.post-generated {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.sources-down {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--sources-down-bg);
  border: 1px solid var(--sources-down-border);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
}

/* ===================================
   Post Content Typography
   =================================== */

.post-content h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--category-accent);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.post-content h2:first-child,
.post-content p + h2 {
  margin-top: 1.5rem;
}

.post-content h1,
.post-content h3,
.post-content h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.post-content h1 { font-size: 1.3rem; }
.post-content h3 { font-size: 1.05rem; }
.post-content h4 { font-size: 0.95rem; }

.post-content p {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.post-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.post-content a:hover {
  color: var(--link-hover);
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

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

.post-content strong {
  font-weight: 600;
}

/* ===================================
   Details / Summary (Expandable Items)
   =================================== */

.post-content details {
  margin-bottom: 0.5rem;
  border-left: 2px solid var(--border-light);
  background: transparent;
  transition: border-color 0.15s ease;
}

.post-content details:hover {
  border-left-color: var(--link);
}

.post-content details[open] {
  border-left-color: var(--link);
  margin-bottom: 0.75rem;
}

.post-content details summary {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  list-style: none;
  display: block;
  transition: background-color 0.1s ease;
}

.post-content details summary:hover {
  background: var(--code-bg);
}

.post-content details summary::-webkit-details-marker {
  display: none;
}

.post-content details[open] > summary {
  background: var(--code-bg);
  margin-bottom: 0.5rem;
}

.post-content details > *:not(summary) {
  padding: 0 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.post-content details > p:last-child {
  padding-bottom: 0.75rem;
}

/* ===================================
   Per-item share button (inside each <details>)
   =================================== */

.post-content details .item-share-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 0.15rem 0.6rem 0.7rem;
}

.post-content details .item-share {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.3rem 0.7rem;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.post-content details .item-share:hover,
.post-content details .item-share:focus-visible {
  border-color: var(--link);
  color: var(--link);
  outline: none;
}

.post-content details .item-share--copied {
  border-color: var(--link);
  color: var(--link);
  background: var(--code-bg);
}

/* Briefly flash the anchored item when scrolled to via a share link. */
.post-content details:target {
  border-left-color: var(--link);
}

/* ===================================
   Code Blocks
   =================================== */

.post-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Consolas",
    monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--link);
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.85rem;
  color: var(--text);
}

/* ===================================
   Blockquotes
   =================================== */

.post-content blockquote {
  border-left: 3px solid var(--link);
  padding: 0.5rem 1rem;
  margin: 0 0 1.25rem 0;
  color: var(--text-muted);
  background: var(--code-bg);
  border-radius: 0 6px 6px 0;
}

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

/* ===================================
   Tables
   =================================== */

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
}

.post-content th,
.post-content td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  background: var(--code-bg);
  font-weight: 600;
}

/* ===================================
   Horizontal Rule
   =================================== */

.post-content hr {
  display: none;
}

/* ===================================
   Post Navigation (Prev/Next)
   =================================== */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.5rem 0 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  max-width: 45%;
  transition: color 0.15s ease;
}

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

.post-nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.post-nav-title {
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-nav-prev {
  align-items: flex-start;
}

.post-nav-next {
  align-items: flex-end;
  margin-left: auto;
}

/* ===================================
   About / Page Content
   =================================== */

.page-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.page-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.page-content p {
  margin-bottom: 1rem;
  line-height: 1.7;
  font-size: 0.95rem;
}

.page-content ul {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.page-content li {
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.page-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-content strong {
  font-weight: 600;
}

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

/* ===================================
   Bias Tables (About Page)
   =================================== */

.bias-table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  table-layout: fixed;
}

.bias-table th,
.bias-table td {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bias-table th:nth-child(1),
.bias-table td:nth-child(1) { width: 38%; }
.bias-table th:nth-child(2),
.bias-table td:nth-child(2) { width: 34%; }
.bias-table th:nth-child(3),
.bias-table td:nth-child(3) { width: 14%; }
.bias-table th:nth-child(4),
.bias-table td:nth-child(4) { width: 14%; }

.bias-table th {
  background: var(--code-bg);
  font-weight: 600;
}

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

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

.bias-status {
  display: inline-block;
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
}

.bias-status--confirmed {
  background: rgba(78, 205, 196, 0.15);
  color: var(--link);
}

.bias-status--suggested {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

[data-theme="light"] .bias-status--confirmed {
  background: rgba(10, 158, 148, 0.12);
  color: #0a9e94;
}

[data-theme="light"] .bias-status--suggested {
  background: rgba(202, 138, 4, 0.12);
  color: #ca8a04;
}

.bias-source-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  max-width: 100%;
}

.bias-source-section > summary {
  cursor: pointer;
  padding: 0.6rem 1rem;
  background: var(--code-bg);
  list-style: none;
  display: block;
}

.bias-source-section > summary::-webkit-details-marker {
  display: none;
}

.bias-source-section > summary:hover {
  background: var(--border-light);
}

.bias-source-heading {
  display: inline;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.bias-count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.bias-source-section > .bias-table {
  margin-bottom: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
}

.bias-detail-list {
  margin: 0.3rem 0;
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  list-style: disc;
}

.bias-detail-list li {
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.bias-detail-list strong {
  color: var(--text);
}

.bias-foldable {
  margin-top: 0.4rem;
  border-left: 2px solid var(--border-light);
  padding: 0;
  font-size: 0.8rem;
  max-width: 100%;
  overflow: hidden;
}

.bias-foldable summary {
  cursor: pointer;
  color: var(--link);
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
}

.bias-foldable summary:hover {
  text-decoration: underline;
}

.bias-foldable blockquote {
  margin: 0.3rem 0.4rem;
  padding: 0.3rem 0.5rem;
  background: var(--code-bg);
  border-left: 2px solid var(--link);
  border-radius: 0 4px 4px 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bias-foldable a {
  display: inline-block;
  margin: 0.2rem 0.4rem;
  font-size: 0.72rem;
  color: var(--link);
  word-break: break-all;
}

/* ===================================
   Footer
   =================================== */

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

.site-footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ===================================
   Responsive
   =================================== */

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

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav {
    gap: 1rem;
  }

  main {
    padding: 1.5rem 1rem;
  }

  .container {
    padding: 0 1rem;
  }

  .post-content details summary {
    padding: 0.5rem 0.6rem;
  }

  .post-content details > *:not(summary) {
    padding: 0 0.6rem;
  }

  /* Keep prev/next on opposite sides even on narrow screens. A single
     missing neighbour (e.g. no next post) must still leave the other
     pinned to its side, which margin-auto handles. */
  .post-nav {
    flex-direction: row;
    gap: 0.5rem;
  }

  .post-nav a {
    max-width: 48%;
  }

  .post-nav-prev {
    margin-right: auto;
  }

  .post-nav-next {
    margin-left: auto;
  }
}

/* ===================================
   Subscribe form
   =================================== */

.subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  margin: 24px 0;
}

.subscribe-form label {
  font-size: 0.9rem;
  font-weight: 600;
}

.subscribe-form input[type="email"] {
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background-color: var(--bg);
  color: var(--text);
}

.subscribe-form button {
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  border: 0;
  border-radius: 6px;
  background-color: var(--link);
  color: var(--bg);
  cursor: pointer;
}

.subscribe-form button:hover {
  filter: brightness(1.1);
}

.subscribe-error {
  color: #c0392b;
  font-size: 0.9rem;
}
