/* Misframe - Minimal blog design system */

:root {
  /* Colors */
  --color-bg: #fcfcfc;
  --color-fg: #222;
  --color-muted: #c0c0c0;
  --color-meta: #5a5a5a;
  --color-prose: #1a1a1a;
  --color-caption: #666;
  --color-border: #111;
  --color-border-light: #e8e8e8;
  --color-code-bg: #f5f5f5;
  
  /* Typography */
  --font-base: 18px;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* Layout */
  --content-width: 50rem;
  --focus-ring: var(--color-meta);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #26292f;
    --color-fg: #eee;
    --color-muted: #888;
    --color-meta: #b8b8b8;
    --color-prose: #e8e8e8;
    --color-caption: #999;
    --color-border: #eee;
    --color-border-light: #33363c;
    --color-code-bg: #1e2126;
  }
}

/* Base */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--color-fg);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern" 1, "liga" 1;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
}

@media (prefers-color-scheme: dark) {
  ::selection {
    background: rgba(255, 255, 255, 0.14);
  }
}

@media (max-width: 40em) { body { font-size: 16px; } }

a {
  color: inherit;
  transition: opacity 0.2s;
}
a:hover { opacity: 0.7; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.mf-meta-tag:focus-visible,
.mf-category:focus-visible,
.mf-tag:focus-visible {
  outline-offset: 3px;
}

/* Layout */
.wrapper {
  margin: 0 auto;
  padding: var(--space-xl) 0;
  width: var(--content-width);
  max-width: 90%;
}

@media (min-width: 60em) { .wrapper { max-width: 85%; } }

/* Header */
.mf-top {
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
}

.mf-top h1 {
  font-size: 1.222rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
  display: inline;
  line-height: 1;
  color: var(--color-fg);
}

.mf-top h1 a {
  text-decoration: none;
  margin-right: var(--space-xs);
}

.mf-top-by-line {
  font-size: 0.889rem;
  color: var(--color-meta);
}
.mf-top-by { font-style: italic; }

.mf-header-nav-links {
  margin-top: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.mf-header-nav-links a {
  text-decoration: none;
  margin-right: var(--space-md);
  color: var(--color-meta);
}

.mf-header-nav-links a:hover {
  color: var(--color-fg);
  opacity: 1;
}

@media (min-width: 38em) {
  .mf-top h1 { font-size: 1.444rem; }
  .mf-header-nav-links {
    margin-top: 0;
    float: right;
    border-bottom: none;
  }
}

/* Post header (also used on About) */
.mf-post-title-date {
  display: block;
  font-size: 0.889rem;
  color: var(--color-meta);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

/* Page title: clearly larger than site wordmark, not display-sized */
.mf-post-title,
.mf-post-title a {
  font-size: 1.75rem;
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-xs) 0;
  text-decoration: none;
}

@media (min-width: 60em) {
  .mf-post-title,
  .mf-post-title a { font-size: 2rem; }
}

.mf-post-subtitle {
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--color-meta);
  margin: var(--space-sm) 0 var(--space-md) 0;
}

@media (min-width: 60em) {
  .mf-post-subtitle { font-size: 1.222rem; }
}

.mf-article-header {
  margin-bottom: 1.45rem;
}

/* Article meta: date • category line, then title (tags sit below body in .mf-article-tags) */
.mf-article-meta-block {
  margin-bottom: var(--space-sm);
}

.mf-article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  font-size: 0.889rem;
  color: var(--color-meta);
  line-height: 1;
}

.mf-meta-date {
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}

.mf-meta-sep {
  margin: 0 0.5em;
  opacity: 0.5;
}

.mf-meta-category {
  text-decoration: none;
  color: var(--color-meta);
  font-weight: var(--weight-medium);
}

.mf-meta-category:hover {
  color: var(--color-fg);
  opacity: 1;
}

.mf-meta-read {
  font-weight: var(--weight-normal);
  font-variant-numeric: tabular-nums;
}

/* Tags: below post body, no separator (Next read section has its own border) */
.mf-article-tags {
  margin-top: var(--space-xl);
}

.mf-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
}

.mf-meta-tag {
  font-size: 0.889rem;
  color: var(--color-meta);
  text-decoration: none;
}

.mf-meta-tag::before {
  content: "#";
  opacity: 0.45;
}

.mf-meta-tag:hover {
  color: var(--color-fg);
  opacity: 1;
}

.mf-article .mf-post {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-prose);
}

.mf-article .mf-post a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.mf-article .mf-post a:hover {
  opacity: 1;
  text-decoration-thickness: 2px;
}

/* Post Content */
.mf-post p {
  margin: var(--space-lg) 0;
  line-height: 1.7;
}

.mf-article .mf-post p {
  margin: 1.45em 0;
  line-height: inherit;
}

.mf-article .mf-post > p:first-of-type {
  margin-top: 0;
}

.mf-article .mf-post > h2:first-child,
.mf-article .mf-post > h3:first-child,
.mf-article .mf-post > h4:first-child {
  margin-top: 0;
}

.mf-article .mf-post h2,
.mf-article .mf-post h3,
.mf-article .mf-post h4 {
  color: var(--color-fg);
}

.mf-post ul,
.mf-post ol {
  margin: var(--space-md) 0;
  line-height: 1.6;
}

.mf-article .mf-post ul,
.mf-article .mf-post ol {
  line-height: 1.62;
  margin: 0.85em 0;
}

.mf-post li { margin: var(--space-xs) 0; }

.mf-post h2,
.mf-post h3,
.mf-post h4 {
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.mf-post h2 {
  font-size: 1.444rem;
  margin: 1.45rem 0;
  scroll-margin-top: 1.25rem;
}

.mf-post h3 {
  font-size: 1.222rem;
  margin: 1.45rem 0;
  scroll-margin-top: 1.25rem;
}

.mf-post h4 {
  font-size: 1.111rem;
  margin: 1.45rem 0;
  scroll-margin-top: 1.25rem;
}

.mf-post strong { font-weight: var(--weight-bold); }

.mf-post img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Blockquotes & HR */
blockquote {
  margin: var(--space-lg) 0;
  margin-left: 0;
  padding-left: var(--space-lg);
  border-left: 4px solid var(--color-border-light);
  color: var(--color-prose);
  overflow: auto;
}

@media (prefers-color-scheme: dark) {
  blockquote {
    border-left-color: var(--color-meta);
  }
}

blockquote *:first-child { margin-top: 0; }
blockquote *:last-child { margin-bottom: 0; }

hr {
  border: none;
  height: 1px;
  width: 100%;
  max-width: var(--content-width);
  background: var(--color-border-light);
  opacity: 1;
  margin: var(--space-xl) auto;
}

/* Tables */
table { border-collapse: collapse; }
table td,
table th {
  padding: var(--space-sm);
  border: 1px solid var(--color-border-light);
}

/* Code */
code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
}

pre {
  font-size: 14px;
  line-height: 1.5;
  padding: 1.25em 1.5em;
  margin: var(--space-lg) 0;
  background: var(--color-code-bg);
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  overflow: auto;
  tab-size: 4;
}

p code,
li code {
  font-size: 0.88em;
  padding: 0.2em 0.4em;
  background: var(--color-code-bg);
  border: 1px solid var(--color-border-light);
  border-radius: 3px;
}

/* Images */
.mf-captioned-image {
  margin: var(--space-2xl) 0;
  text-align: center;
}

.mf-captioned-image img {
  margin: 0 auto;
  display: block;
}

.mf-caption {
  font-size: 0.889rem;
  line-height: 1.5;
  color: var(--color-caption);
  font-style: italic;
  margin-top: 0.75em;
  text-align: center;
  max-width: 90%;
  margin-left: auto;
  margin-right: auto;
}

/* Full-width image */
.mf-image-full,
.mf-image-fullscreen {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  margin-top: var(--space-3xl);
  margin-bottom: var(--space-3xl);
}

.mf-image-full img {
  width: 100%;
  display: block;
}

.mf-image-full .mf-caption {
  padding: 0 5%;
  margin-top: var(--space-md);
}

/* Hero image */
.mf-image-fullscreen {
  min-height: 70vh;
}

.mf-image-fullscreen img {
  width: 100%;
  height: 70vh;
  object-fit: cover;
  display: block;
}

.mf-image-fullscreen .mf-caption {
  padding: var(--space-lg) 5%;
  background: var(--color-bg);
}

/* Large image */
.mf-image-large {
  margin: var(--space-2xl) -10%;
  max-width: 120%;
}

@media (max-width: 60em) {
  .mf-image-large {
    margin: var(--space-2xl) -5%;
    max-width: 110%;
  }
}

@media (max-width: 38em) {
  .mf-image-large {
    margin: var(--space-2xl) 0;
    max-width: 100%;
  }
}

.mf-image-large img {
  width: 100%;
  display: block;
}

.mf-image-large .mf-caption {
  margin-top: var(--space-md);
}

/* Gallery */
.mf-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-2xl) 0;
}

.mf-image-gallery img {
  width: 100%;
  display: block;
}

.mf-image-gallery .mf-caption {
  margin-top: var(--space-sm);
}

/* Pull quote */
.mf-pullquote {
  font-size: 1.778rem;
  line-height: 1.45;
  font-style: italic;
  text-align: center;
  margin: 2.5em 0;
}

@media (min-width: 60em) {
  .mf-pullquote {
    font-size: 2rem;
    line-height: 1.4;
  }
}

/* Taxonomy list pages (categories index, tags index) */
.mf-post-categories,
.mf-post-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
}

.mf-category,
.mf-tag {
  display: inline-block;
  font-size: 0.778rem;
  line-height: 1.35;
  color: var(--color-meta);
  background: var(--color-code-bg);
  padding: 0.25em 0.6em;
  border-radius: 3px;
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}

.mf-category:hover,
.mf-tag:hover {
  color: var(--color-fg);
  background: var(--color-border-light);
  opacity: 1;
}

/* Lists */
.mf-list-item {
  margin: var(--space-md) 0;
  display: block;
  clear: both;
  overflow: hidden;
}

.mf-list-link {
  font-size: 1.125rem;
  line-height: 1.4;
  display: inline-block;
  max-width: 75%;
  float: left;
}

.mf-list-link a { text-decoration: none; }

.mf-list-date {
  float: right;
  color: var(--color-meta);
  font-size: 0.889rem;
  line-height: 1.4;
  padding-top: 0.15rem;
}

@media (max-width: 48em) {
  .mf-list-link {
    float: none;
    max-width: 100%;
    display: block;
  }
  .mf-list-date {
    float: none;
    display: block;
    margin-top: var(--space-xs);
  }
}

/* Listing pages (categories / tags index and per-term posts) */
.mf-page-title {
  font-size: 1.75rem;
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-xs) 0;
}

@media (min-width: 60em) {
  .mf-page-title { font-size: 2rem; }
}

.mf-listing-meta {
  margin: 0;
  font-size: 0.889rem;
  font-weight: var(--weight-medium);
  color: var(--color-meta);
  font-variant-numeric: tabular-nums;
}

.mf-taxonomy-header,
.mf-terms-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.mf-taxonomy-page .mf-home-section {
  margin-bottom: var(--space-xl);
}

.mf-terms-page {
  margin-bottom: var(--space-xl);
}

.mf-term-cloud {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.mf-term-cloud li {
  margin: 0;
}

.mf-term-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.35em 0.65em;
  font-size: 0.889rem;
  font-weight: var(--weight-medium);
  color: var(--color-fg);
  background: var(--color-code-bg);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.mf-term-link:hover {
  background: var(--color-bg);
  border-color: var(--color-meta);
  opacity: 1;
}

.mf-term-count {
  font-size: 0.778rem;
  font-weight: var(--weight-normal);
  font-variant-numeric: tabular-nums;
  color: var(--color-meta);
  min-width: 1.25em;
  text-align: center;
}

/* Homepage Sections */
.mf-home-section {
  margin-bottom: 3.5rem;
}

.mf-home-section:last-of-type {
  margin-bottom: var(--space-xl);
}

.mf-section-title {
  font-size: 1.444rem;
  font-weight: var(--weight-medium);
  line-height: 1.25;
  margin-bottom: var(--space-lg);
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--color-border);
}

.mf-section-title a { text-decoration: none; }

.mf-section-more {
  margin-top: var(--space-lg);
  text-align: right;
  font-size: 0.889rem;
}

.mf-section-more a {
  text-decoration: none;
  opacity: 0.6;
}

.mf-section-more a:hover { opacity: 1; }

/* Next Read Section */
.mf-next-read-section {
  border-top: 1px solid var(--color-border-light);
  padding-top: var(--space-lg);
  margin-top: var(--space-2xl);
}

.mf-next-read {
  font-size: 1.125rem;
  font-weight: var(--weight-medium);
  font-style: italic;
  margin-bottom: var(--space-md);
}

.mf-next-read-section .mf-list-item {
  margin: var(--space-sm) 0;
  padding: 0;
}

.mf-next-read-section .mf-list-item:first-of-type {
  margin-top: 0;
}

/* Archive CTA (home): same voice as meta links, not a heavy button */
.mf-archive-link {
  margin: var(--space-xl) 0 var(--space-lg);
}

.mf-archive-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.889rem;
  font-weight: var(--weight-medium);
  color: var(--color-meta);
  text-decoration: none;
  text-underline-offset: 0;
  transition: color 0.15s ease;
}

.mf-archive-link-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.mf-archive-link a:hover {
  color: var(--color-fg);
  opacity: 1;
}

.mf-archive-link a:hover .mf-archive-link-arrow {
  transform: translateX(3px);
}

.mf-archive-year {
  font-size: 1.778rem;
  font-weight: var(--weight-semibold);
  line-height: 1.25;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 3px solid var(--color-border);
}

.mf-archive-year:first-child {
  margin-top: var(--space-sm);
}

/* Footer */
.mf-footer {
  color: var(--color-prose);
  line-height: 1.65;
}

.mf-footer a {
  color: var(--color-fg);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.mf-footer a:hover {
  opacity: 1;
}

.mf-portrait {
  width: 100px;
  border-radius: 100%;
  float: left;
  margin-right: var(--space-md);
}

.mf-footer-copyright {
  clear: both;
  text-align: center;
  color: var(--color-meta);
  font-size: 0.889rem;
  margin-top: var(--space-lg);
}

/* Utilities */
.mf-article-separator { margin: var(--space-3xl) auto; }
.mf-popular { font-size: 0.9em; }
