/* Terminal — OMG Debugging Ghost theme
   Fonts: Source Serif 4 (body), DM Sans (UI), JetBrains Mono (code)
   System day/night via prefers-color-scheme + manual override
*/

:root {
  --font-body: "Source Serif 4", Georgia, serif;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --gh-font-heading: var(--font-ui);
  --gh-font-body: var(--font-body);
  --body-size: 1.125rem;
  --body-leading: 1.75;
  --bg: #f2f5f2;
  --surface: #ffffff;
  --panel: #e8eee8;
  --text: #142018;
  --muted: #4a5c4e;
  --accent: #0d7a4f;
  --accent-dim: #d5ede2;
  --warn: #9a7b0a;
  --border: #c5d1c6;
  --code-bg: #e8eee8;
  --code-gutter: #dce5dc;
  --progress-track: #c5d1c6;
  --progress-fill: #0d7a4f;
}

html[data-theme="dark"] {
  --bg: #0b0f0c;
  --surface: #121816;
  --panel: #0f1512;
  --text: #d7e3d4;
  --muted: #7e947c;
  --accent: #3ddc97;
  --accent-dim: #1a3d2e;
  --warn: #e8c547;
  --border: #243028;
  --code-bg: #080c09;
  --code-gutter: #0e1511;
  --progress-track: #243028;
  --progress-fill: #3ddc97;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #0b0f0c;
    --surface: #121816;
    --panel: #0f1512;
    --text: #d7e3d4;
    --muted: #7e947c;
    --accent: #3ddc97;
    --accent-dim: #1a3d2e;
    --warn: #e8c547;
    --border: #243028;
    --code-bg: #080c09;
    --code-gutter: #0e1511;
    --progress-track: #243028;
    --progress-fill: #3ddc97;
  }
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg: #f2f5f2;
    --surface: #ffffff;
    --panel: #e8eee8;
    --text: #142018;
    --muted: #4a5c4e;
    --accent: #0d7a4f;
    --accent-dim: #d5ede2;
    --warn: #9a7b0a;
    --border: #c5d1c6;
    --code-bg: #e8eee8;
    --code-gutter: #dce5dc;
    --progress-track: #c5d1c6;
    --progress-fill: #0d7a4f;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: var(--body-leading);
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Left reading-progress rail */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 3px;
  height: 100vh;
  background: var(--progress-track);
  z-index: 200;
  pointer-events: none;
}

.reading-progress__fill {
  width: 100%;
  height: 0%;
  background: var(--progress-fill);
  box-shadow: 0 0 8px color-mix(in srgb, var(--progress-fill) 55%, transparent);
  transition: height 0.05s linear;
}

.progress-label {
  position: fixed;
  left: 12px;
  bottom: 12px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.25rem 0.45rem;
  z-index: 201;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.progress-label.is-visible {
  opacity: 1;
}

.wrap {
  max-width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 0 1.5rem;
  padding-left: calc(1.5rem + 6px);
}

.wrap.narrow {
  max-width: min(720px, 94vw);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  gap: 1rem;
}

.logo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
}

.logo span {
  color: var(--muted);
  font-weight: 400;
}

.nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.nav a,
.nav .nav-item a,
.nav li a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover,
.nav .nav-item a:hover,
.nav li a:hover {
  color: var(--accent);
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  height: 2rem;
  padding: 0 0.5rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  min-width: 2.6rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

main {
  padding: 2rem 0 4rem;
}

.prompt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.prompt b {
  color: var(--accent);
  font-weight: 500;
}

.hero h1 {
  font-family: var(--font-ui);
  font-size: clamp(1.5rem, 2.8vw, 1.9rem);
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--warn);
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
}

.log {
  margin-top: 2rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.post-card {
  position: relative;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.1rem;
  align-items: start;
  padding: 1.15rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

/* Stretch the title link across the card (no empty <a> — Chrome breaks on those) */
.post-card .post-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post-card .tag,
.post-card .more {
  position: relative;
  z-index: 2;
}

.post-card--text {
  grid-template-columns: 1fr;
}

.post-card:last-child {
  border-bottom: 0;
}

.post-card:hover {
  background: var(--panel);
}

.empty-log {
  margin: 0;
  padding: 1.5rem 1.2rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

@media (max-width: 700px) {
  .post-card {
    grid-template-columns: 1fr;
  }
}

/* Tags index */
.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 2rem;
}

.tag-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tag-pill:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.tag-pill__name {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.tag-pill .count {
  color: var(--muted);
  font-size: 0.75rem;
}

.post-thumb {
  border: 1px solid var(--border);
  overflow: hidden;
  display: block;
}

.post-thumb img,
.featured-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.featured-image {
  border: 1px solid var(--border);
  margin: 1.1rem 0 1.6rem;
  overflow: hidden;
  padding: 0;
}

.featured-image figcaption {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}

.post-title {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.post-title a {
  color: var(--text);
  text-decoration: none;
}

.post-title a:hover {
  color: var(--accent);
}

.meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}

.dot {
  opacity: 0.5;
}

.excerpt {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: none;
}

.more {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--warn);
  font-weight: 500;
  text-decoration: none;
}

.post-hero h1 {
  font-family: var(--font-ui);
  font-size: clamp(1.45rem, 2.8vw, 1.85rem);
  margin: 0 0 0.75rem;
  color: var(--warn);
  line-height: 1.3;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.prose {
  font-family: var(--font-body);
}

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--accent);
  margin: 2rem 0 0.65rem;
  scroll-margin-top: 4.5rem;
  letter-spacing: -0.01em;
}

.prose h2 {
  font-size: 1.15rem;
}

.prose h3 {
  font-size: 1.05rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
}

.prose a {
  color: var(--accent);
}

.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border: 1px solid var(--border);
}

.prose pre,
.kg-code-card pre,
.kg-card.kg-code-card pre {
  margin: 1.25rem 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.prose pre code,
.kg-code-card pre code {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Prism / Ghost card_assets token colors */
:root {
  --token-comment: #5a6b5c;
  --token-punctuation: #4a5c4e;
  --token-property: #0b6b8a;
  --token-string: #0d7a4f;
  --token-operator: #9a7b0a;
  --token-keyword: #8a3d9b;
  --token-function: #0b6b8a;
  --token-number: #b35a00;
  --token-boolean: #b35a00;
  --token-class: #0d7a4f;
  --token-regex: #9a7b0a;
}

html[data-theme="dark"] {
  --token-comment: #6a7f68;
  --token-punctuation: #7e947c;
  --token-property: #6ec8e8;
  --token-string: #3ddc97;
  --token-operator: #e8c547;
  --token-keyword: #c792ea;
  --token-function: #82aaff;
  --token-number: #f78c6c;
  --token-boolean: #f78c6c;
  --token-class: #3ddc97;
  --token-regex: #e8c547;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --token-comment: #6a7f68;
    --token-punctuation: #7e947c;
    --token-property: #6ec8e8;
    --token-string: #3ddc97;
    --token-operator: #e8c547;
    --token-keyword: #c792ea;
    --token-function: #82aaff;
    --token-number: #f78c6c;
    --token-boolean: #f78c6c;
    --token-class: #3ddc97;
    --token-regex: #e8c547;
  }
}

code[class*="language-"],
pre[class*="language-"] {
  color: var(--text);
  text-shadow: none;
  font-family: var(--font-mono);
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--token-comment) !important;
  font-style: italic;
}

.token.punctuation {
  color: var(--token-punctuation) !important;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--token-property) !important;
}

.token.boolean,
.token.number {
  color: var(--token-number) !important;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--token-string) !important;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--token-operator) !important;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--token-keyword) !important;
}

.token.function,
.token.class-name {
  color: var(--token-function) !important;
}

.token.regex,
.token.important,
.token.variable {
  color: var(--token-regex) !important;
}

.token.important,
.token.bold {
  font-weight: 600;
}

.token.italic {
  font-style: italic;
}

/* Line numbers (optional Prism plugin / class) */
pre.line-numbers {
  position: relative;
  padding-left: 3.2em;
  counter-reset: linenumber;
}

pre.line-numbers > code {
  position: relative;
  white-space: inherit;
}

.line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 0;
  font-size: 100%;
  left: -3.2em;
  width: 3em;
  letter-spacing: -1px;
  border-right: 1px solid var(--border);
  user-select: none;
}

.line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
}

.line-numbers-rows > span:before {
  content: counter(linenumber);
  color: var(--muted);
  display: block;
  padding-right: 0.8em;
  text-align: right;
}

.prose blockquote {
  margin: 1.35rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--warn);
  color: var(--muted);
  font-style: italic;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose figure {
  margin: 1.25rem 0;
}

.prose figcaption {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}

.prose th {
  background: var(--panel);
  font-family: var(--font-ui);
}

.kg-card {
  margin: 1.35rem 0;
}

.kg-width-wide {
  position: relative;
  width: min(1100px, 94vw);
  max-width: none;
  margin-left: calc(50% - min(550px, 47vw));
  margin-right: calc(50% - min(550px, 47vw));
}

.kg-width-full {
  position: relative;
  width: 100vw;
  max-width: 100vw;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.kg-width-full img,
.kg-width-wide img {
  width: 100%;
  height: auto;
}

.kg-bookmark-card,
.kg-embed-card {
  border: 1px solid var(--border);
  background: var(--surface);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 2rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-links,
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.pagination {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.pagination-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
}

.pagination a {
  color: var(--accent);
  text-decoration: none;
}

.pagination-meta {
  color: var(--muted);
}

@media (max-width: 640px) {
  .reading-progress {
    width: 2px;
  }

  .progress-label {
    display: none;
  }
}
