/* Theme variables – light (calm, warm neutral) */
:root {
  --color-surface: #f7f3eb;
  --color-surface-elevated: #efe8dc;
  --color-text-primary: #2f2721;
  --color-text-secondary: #7f7268;
  /* Keep purple as interaction accent */
  --color-link-hover: #6d28d9;
  /* Type scale: three sizes — hierarchy via weight + color */
  --text-title: 1.25rem;
  --text-body: 1rem;
  --text-meta: 0.875rem;
}

/* Theme variables – dark (calm, warm charcoal) */
.dark {
  --color-surface: #1f1a17;
  --color-surface-elevated: #2b241f;
  --color-text-primary: #f6efe3;
  --color-text-secondary: #b8a99a;
  /* Keep purple accent readable on warm dark surface */
  --color-link-hover: #cbb7ff;
}

/* Smooth theme transition */
html {
  transition: background-color 0.2s ease, color 0.2s ease;
}

body {
  font-size: var(--text-body);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.site-title {
  font-size: var(--text-body);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--color-text-primary);
}

.page-title {
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.section-label {
  font-size: var(--text-meta);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.type-meta {
  font-size: var(--text-meta);
}

/* Links: no underline; purple on hover (post rows: see .post-row).
   Primary copy blocks: .copy-primary a → secondary. Bio (.index-bio): secondary copy, a → primary.
   Post prose: .post-content a → secondary. Use html body a so we win over Tailwind CDN preflight. */
html body a {
  text-decoration: none;
  transition: color 0.2s ease;
}

html body .copy-primary a:not(.post-row) {
  color: var(--color-text-secondary);
}

html body .index-bio a {
  color: var(--color-text-primary);
}

html body a:not(.post-row):hover {
  color: var(--color-link-hover);
}

/* Keyboard focus: same purple as link hover (links, buttons, cards, form controls) */
*:focus:not(:focus-visible) {
  outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-link-hover);
  outline-offset: 2px;
}

/* Post body: Markdown → HTML (Tailwind Typography plugin not on CDN) */
.post-content {
  font-size: var(--text-body);
  line-height: 1.75;
  color: var(--color-text-primary);
}

.post-content > *:first-child {
  margin-top: 0;
}

.post-content > *:last-child {
  margin-bottom: 0;
}

.post-content p {
  margin: 0 0 1.125em;
}

/* Headings: same size as body; hierarchy = weight + color */
.post-content h2 {
  font-size: var(--text-body);
  font-weight: 700;
  line-height: 1.35;
  margin: 2em 0 0.6em;
  color: var(--color-text-primary);
  letter-spacing: -0.015em;
}

.post-content h2:first-child,
.post-content .post-feature-image + * {
  margin-top: 0;
}

.post-content h3 {
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.4;
  margin: 1.65em 0 0.45em;
  color: var(--color-text-primary);
}

.post-content h4 {
  font-size: var(--text-body);
  font-weight: 600;
  margin: 1.35em 0 0.4em;
  color: var(--color-text-primary);
}

.post-content h5,
.post-content h6 {
  font-size: var(--text-body);
  font-weight: 600;
  margin: 1.2em 0 0.35em;
  color: var(--color-text-secondary);
}

.post-content ul,
.post-content ol {
  margin: 0 0 1.25em;
  padding-left: 1.5em;
}

.post-content ul {
  list-style-type: disc;
}

.post-content ol {
  list-style-type: decimal;
}

.post-content li {
  margin: 0.35em 0;
  padding-left: 0.25em;
}

.post-content li > ul,
.post-content li > ol {
  margin: 0.4em 0 0.4em;
}

html body .post-content a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Pullquote copy is secondary; links read as primary */
html body .post-content blockquote a {
  color: var(--color-text-primary);
}

.post-content strong,
.post-content b {
  font-weight: 600;
  color: var(--color-text-primary);
}

.post-content em,
.post-content i {
  font-style: italic;
}

.post-content blockquote {
  margin: 1.25em 0;
  padding-left: 1em;
  border-left: 3px solid var(--color-text-secondary);
  color: var(--color-text-secondary);
  font-style: italic;
}

.post-content blockquote p {
  margin-bottom: 0.75em;
}

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

.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 1em;
  background: var(--color-surface);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
}

.post-content pre {
  margin: 1.25em 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: var(--text-meta);
  line-height: 1.6;
  background: var(--color-surface);
  border-radius: 0.5rem;
  border: 1px solid rgba(120, 113, 108, 0.2);
}

.dark .post-content pre {
  border-color: rgba(168, 162, 158, 0.2);
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

.post-content hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--color-text-secondary);
  opacity: 0.35;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  font-size: var(--text-body);
}

.post-content th,
.post-content td {
  border: 1px solid var(--color-text-secondary);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

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

.post-content .post-feature-image {
  margin: 0 0 1.75rem;
}

.post-content .post-feature-image img {
  display: block;
  width: 100%;
}

/* Index / topic: minimal post list — hairline dividers, date | title */
.posts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(120, 113, 108, 0.22);
}

.dark .posts-list {
  border-top-color: rgba(168, 162, 158, 0.22);
}

.posts-list__item + .posts-list__item {
  border-top: 1px solid rgba(120, 113, 108, 0.22);
}

.dark .posts-list__item + .posts-list__item {
  border-top-color: rgba(168, 162, 158, 0.22);
}

html body a.post-row {
  display: grid;
  grid-template-columns: minmax(5.75rem, 7.5rem) minmax(0, 1fr);
  column-gap: 1.25rem;
  row-gap: 0.25rem;
  align-items: baseline;
  text-align: left;
  text-decoration: none;
  padding: 0.8rem 0;
  color: inherit;
}

.post-row__date {
  font-size: var(--text-meta);
  line-height: 1.4;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.post-row__title {
  font-size: var(--text-body);
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-text-primary);
  transition: color 0.2s ease;
}

html body a.post-row:hover .post-row__title {
  color: var(--color-link-hover);
}

.load-more-wrap {
  margin-top: 0.75rem;
  padding-top: 0.25rem;
  display: flex;
  justify-content: flex-start;
}

.load-more-btn {
  margin: 0;
  padding: 0.35rem 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.load-more-btn:hover {
  color: var(--color-link-hover);
}

/* Topic/tag list: slash keeps secondary hue but reads lighter than link text */
.topic-separator {
  opacity: 0.5;
}

/* Header theme control: text-only, matches nav link styling */
.theme-link {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  color: inherit;
  -webkit-transition: color 0.2s ease;
  transition: color 0.2s ease;
}

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

/* Label = mode you switch to (not current): light UI → “Dark mode”, dark UI → “Light mode” */
.theme-link__text--light {
  display: none;
}

.theme-link__text--dark {
  display: inline;
}

html.dark .theme-link__text--light {
  display: inline;
}

html.dark .theme-link__text--dark {
  display: none;
}
