@import url('https://fonts.bunny.net/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* Belshaw Brain Archive — Nord Theme */

:root {
  /* Nord Light (default) */
  --bg: #eceff4;      /* nord6 */
  --fg: #2e3440;      /* nord0 */
  --muted: #4c566a;   /* nord3 */
  --accent: #5e81ac;  /* nord10 */
  --rule: #d8dee9;    /* nord4 */
  --code-bg: #e5e9f0; /* nord5 */
  --badge-bg: #d8dee9;/* nord4 */
  
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --serif: "IBM Plex Sans", system-ui, sans-serif;
  
  --nav-bg: rgba(236, 239, 244, 0.85);
  --header-border: #d8dee9;
}

[data-theme="dark"] {
  /* Nord Dark */
  --bg: #2e3440;      /* nord0 */
  --fg: #eceff4;      /* nord6 */
  --muted: #d8dee9;   /* nord4 */
  --accent: #88c0d0;  /* nord8 */
  --rule: #3b4252;    /* nord1 */
  --code-bg: #3b4252; /* nord1 */
  --badge-bg: #434c5e;/* nord2 */
  
  --nav-bg: rgba(46, 52, 64, 0.85);
  --header-border: #3b4252;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2e3440;
    --fg: #eceff4;
    --muted: #d8dee9;
    --accent: #88c0d0;
    --rule: #3b4252;
    --code-bg: #3b4252;
    --badge-bg: #434c5e;
    --nav-bg: rgba(46, 52, 64, 0.85);
    --header-border: #3b4252;
  }
}

/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  transition: background-color 0.3s ease, color 0.3s ease;
}

body {
  font-family: var(--serif);
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

/* Typography Links */
h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--fg);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

/* HEADER & NAV REFINEMENTS */
.archive-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--header-border);
  margin-bottom: 3rem;
  padding: 1rem 0;
  font-family: var(--sans);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.archive-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  padding-right: 3rem; /* Space for the toggle */
}

.archive-wordmark {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg) !important;
  text-decoration: none !important;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.nav-links li {
  display: flex;
  align-items: center;
}

.nav-links a {
  color: var(--muted) !important;
  text-decoration: none !important;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--accent) !important;
}

/* THEME TOGGLE BUTTON */
.theme-toggle {
  position: absolute;
  top: 1rem;
  right: 0;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.theme-toggle:hover {
  background: var(--code-bg);
  color: var(--fg);
  border-color: var(--muted);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Toggle Logic: Default is Light Mode -> show Moon (to switch to dark) */
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }

/* When Dark Mode is active -> show Sun (to switch to light) */
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}

/* FORCE DOCUMENT STYLE: Kill all 'button' styling in content */
.post-body a,
p a,
li a,
.kg-bookmark-card,
.kg-bookmark-container,
.kg-bookmark-content,
.kg-bookmark-title {
  all: unset !important;
  color: var(--accent) !important;
  text-decoration: underline !important;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px !important;
  cursor: pointer !important;
  display: inline !important;
  font-family: inherit !important;
}

.post-body a:hover,
p a:hover,
li a:hover {
  color: var(--fg) !important;
  text-decoration-thickness: 2px !important;
}

/* Restore focus visibility removed by all: unset */
.post-body a:focus-visible,
p a:focus-visible,
li a:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
  border-radius: 2px !important;
}

/* Hide Ghost bookmark description/metadata */
.kg-bookmark-description,
.kg-bookmark-metadata,
.kg-bookmark-icon,
.kg-bookmark-thumbnail {
  display: none !important;
}

/* Images & Figures */
figure {
  max-width: 100% !important;
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

.post-body img, img, .kg-card img {
  max-width: 100% !important;
  width: auto;
  height: auto !important;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  box-sizing: border-box;
}

/* Fix wrapper links around images */
a:has(img), .kg-image-card a {
  display: block !important;
  text-decoration: none !important;
}

/* Blockquotes */
.post-body blockquote, blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.2rem;
  margin: 2rem 0;
  color: var(--muted);
  font-style: italic;
  font-size: 1.1rem;
  background: var(--code-bg);
  border-radius: 0 4px 4px 0;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
blockquote p {
  margin-bottom: 0.8rem;
}
blockquote p:last-child {
  margin-bottom: 0;
}

/* Tables */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
  overflow-x: auto;
  display: block;
}
.post-body table thead {
  display: table-header-group;
}
.post-body table tbody {
  display: table-row-group;
}
.post-body table tr {
  display: table-row;
}
.post-body th, .post-body td {
  display: table-cell;
  border: 1px solid var(--rule);
  padding: 0.6rem 0.9rem;
  text-align: left;
  vertical-align: top;
}
.post-body th {
  background: var(--code-bg);
  font-weight: 600;
}

/* Paragraphs and Lists */
p { margin-bottom: 1.2rem; }
ul, ol { margin-left: 1.5rem; margin-bottom: 1.2rem; }
li { margin-bottom: 0.5rem; }

/* Code blocks */
pre, code {
  font-family: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
  background: var(--code-bg);
  border-radius: 4px;
  transition: background-color 0.3s ease;
}
code { padding: 0.15rem 0.3rem; font-size: 0.85em; }
pre { padding: 1rem; overflow-x: auto; margin-bottom: 1.5rem; font-size: 0.85em; }

/* Footer */
.archive-footer {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}
.archive-footer a { color: var(--muted); }
.archive-footer a:hover { color: var(--accent); }
.license, .integrity { margin-top: 0.35rem; }
.integrity code { font-size: 0.75rem; }

/* Skip link */
.skip-link {
  position: fixed;
  top: -48px;
  left: 1.5rem;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  transition: top 0.15s ease;
  white-space: nowrap;
}
.skip-link:focus { top: 0; }

/* Focus styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
button:focus-visible { border-radius: 4px; }

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

/* Lede / intro paragraph */
.lede {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 1.5rem;
}

/* Main content area */
.archive-main {
  padding-top: 0.5rem;
}
.archive-main > h1:first-child,
.archive-hero h1 {
  margin-top: 0.25rem;
}

/* Homepage */
.archive-hero { margin-bottom: 2.5rem; }

/* Archive list (used across archive, tag, search, home) */
.archive-list {
  list-style: none;
  margin-left: 0;
  margin-bottom: 0;
}
.archive-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
  margin-bottom: 0;
}
.archive-list li:last-child { border-bottom: none; }
.archive-list a { color: var(--fg); text-decoration: none; min-width: 0; }
.archive-list a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 0.15em; }

/* Meta span (date · Source) */
.meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Post */
.post { margin-top: 1rem; }
.post-header { margin-bottom: 2rem; }
.post-title {
  font-size: 1.75rem;
  line-height: 1.25;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.post-meta time { color: var(--muted); }
.source-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--badge-bg);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  transition: background-color 0.3s ease;
}
.post-tags { font-size: 0.82rem; }
.post-tags a { color: var(--muted) !important; text-decoration: none !important; }
.post-tags a:hover { color: var(--accent) !important; text-decoration: underline !important; }

/* Reading time */
.read-time {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}

/* Tags cloud */
.tag-cloud {
  list-style: none;
  margin-left: 0;
  columns: 2;
  column-gap: 2rem;
}
.tag-cloud li {
  padding: 0.2rem 0;
  font-size: 0.9rem;
  break-inside: avoid;
  margin-bottom: 0;
  border-bottom: none;
}
.count {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
}

/* Sources list */
.source-list { list-style: none; margin-left: 0; }
.source-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
  margin-bottom: 0;
}
.source-list li:last-child { border-bottom: none; }

/* Stats paragraph (graph page) */
.stats {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* History timeline */
.timeline { list-style: none; margin-left: 0; }
.timeline li {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.timeline li:last-child { border-bottom: none; }
.era {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.era-links {
  font-family: var(--sans);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}
.era-links a { color: var(--muted); text-decoration: none; }
.era-links a:hover { color: var(--accent); text-decoration: underline; }

/* Graph page museum classes (matches existing inline styles) */
.museum-header { font-family: var(--sans); }
.museum-main { padding-top: 0.5rem; }
.museum-footer {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}

/* Legacy content compat */
.wp-block-image, .wp-block-image figure { margin: 2rem 0; }
.wp-block-image img { max-width: 100%; height: auto; }
.wp-block-quote { margin: 0; padding: 0; }
.alignnone { display: block; margin: 1rem 0; max-width: 100%; height: auto; }
.size-full, .size-large { max-width: 100% !important; height: auto !important; }
.graf { margin-bottom: 1.2rem; }
.entry-content p, .post-content p { margin-bottom: 1.2rem; }

/* Mobile responsive nav */
@media (max-width: 640px) {
  html { font-size: 17px; }

  .archive-header nav {
    padding-right: 2.75rem;
    gap: 0.4rem;
  }
  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    font-size: 0.78rem;
    gap: 0.65rem;
  }
  .nav-links::-webkit-scrollbar { display: none; }

  /* Keep Search reachable without scrolling the nav strip */
  .nav-links li:last-child {
    position: sticky;
    right: 0;
    margin-left: 0.4rem;
    padding-left: 0.65rem;
    background: var(--nav-bg);
  }
  .nav-links li:last-child::before {
    content: "";
    position: absolute;
    left: -1.75rem;
    top: 0;
    bottom: 0;
    width: 1.75rem;
    background: linear-gradient(to right, transparent, var(--nav-bg) 70%);
    pointer-events: none;
  }
  .nav-links li:last-child a {
    color: var(--accent) !important;
    font-weight: 700;
  }

.tag-cloud { columns: 1; }
  .post-title { font-size: 1.4rem; }
  .archive-list li { flex-direction: column; gap: 0.1rem; }
  .meta { white-space: normal; }
}

/* Search page */
.search-count {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.search-loading {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
}
.search-results-list { list-style: none; margin-left: 0; }
.search-results-list li { margin-bottom: 1.5rem; }
.search-results-list a {
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  color: var(--accent);
}
.search-results-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.search-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.search-type {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--badge-bg);
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.search-tags a { color: var(--muted); text-decoration: none; }
.search-tags a:hover { color: var(--accent); }
.search-date { white-space: nowrap; }
.search-snippet {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}
.search-snippet mark {
  background: transparent;
  color: var(--fg);
  font-weight: 700;
}
.search-more {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.search-more:hover {
  background: var(--code-bg);
  border-color: var(--muted);
}
.search-container { margin-bottom: 2rem; }
#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.search-note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.5rem;
}

/* Archive year index and per-year pager */
.year-index li { font-size: 1.05rem; }
.year-index .meta { color: var(--muted); }
.year-pager {
  font-family: var(--sans);
  font-size: 0.9rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.year-pager a { color: var(--muted); text-decoration: none; }
.year-pager a:hover { color: var(--accent); }
