/* ==========================================================
   patrickalphac.eth — "Editorial Swamp"
   Refined minimalism with a frog-pond edge.
   ========================================================== */

/* --- Fonts (loaded via <link> in HTML) ---
   Display: Fraunces  |  Body: IBM Plex Mono
   ----------------------------------------- */

/* --- Design tokens --- */
:root {
  --bg: #f5f2eb;
  --text: #1a2e1a;
  --heading: #0f1f0f;
  --accent: #4a7c59;
  --link: #2d5a3d;
  --link-decoration: #4a7c5966;
  --meta: #c4943a;
  --code-bg: #e8e4db;
  --code-border: #4a7c5933;
  --blockquote-border: #c4943a;
  --selection: #6abf7b44;
  --toggle-bg: #4a7c59;
  --divider: #c4c0b6;
}

html.dark {
  --bg: #0d1a0d;
  --text: #d4dcd4;
  --heading: #eaf2ea;
  --accent: #6abf7b;
  --link: #8cc99a;
  --link-decoration: #6abf7b44;
  --meta: #c4943a;
  --code-bg: #162016;
  --code-border: #6abf7b33;
  --blockquote-border: #c4943a;
  --selection: #6abf7b33;
  --toggle-bg: #6abf7b;
  --divider: #2a3d2a;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #0d1a0d;
    --text: #d4dcd4;
    --heading: #eaf2ea;
    --accent: #6abf7b;
    --link: #8cc99a;
    --link-decoration: #6abf7b44;
    --meta: #c4943a;
    --code-bg: #162016;
    --code-border: #6abf7b33;
    --blockquote-border: #c4943a;
    --selection: #6abf7b33;
    --toggle-bg: #6abf7b;
    --divider: #2a3d2a;
  }
}

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

/* --- Links --- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-decoration);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}
a:hover, a:focus {
  text-decoration-color: var(--link);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Fraunces', serif;
  font-optical-sizing: auto;
  color: var(--heading);
  line-height: 1.25;
  margin-top: 2.4rem;
  margin-bottom: 0.8rem;
}
h1 { font-size: 2rem; font-weight: 600; }
h2 { font-size: 1.55rem; font-weight: 500; }
h3 { font-size: 1.25rem; font-weight: 500; }

/* --- Layout --- */
.site-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* --- Header --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--divider);
}
.site-header a {
  text-decoration: none;
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.site-brand img {
  width: 40px;
  height: 40px;
}
.site-brand span {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--heading);
}

/* --- Dark mode toggle --- */
#color-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}
#color-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--text);
  opacity: 0.6;
}
#color-toggle input[type="checkbox"] {
  height: 0;
  width: 0;
  visibility: hidden;
  position: absolute;
}
#color-toggle label {
  cursor: pointer;
  text-indent: -9999px;
  width: 36px;
  height: 18px;
  border-radius: 18px;
  background: var(--toggle-bg);
  display: block;
  position: relative;
}
#color-toggle label::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--bg);
  border-radius: 50%;
  transition: 0.25s ease;
}
#color-toggle input:checked + label::after {
  left: calc(100% - 2px);
  transform: translateX(-100%);
}

/* --- Post list (index) --- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  margin-bottom: 1.8rem;
}
.post-date {
  font-size: 0.8rem;
  color: var(--meta);
  display: block;
  margin-bottom: 0.15rem;
}
.post-title {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 500;
}
.post-title a {
  color: var(--heading);
  text-decoration: none;
}
.post-title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

/* --- Markdown body (post pages) --- */
.markdown-body {
  max-width: 100%;
}
.markdown-body h1:first-child {
  margin-top: 0;
}

.markdown-body img, .markdown-body svg {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

/* Image captions — <em> immediately after an <img> */
.markdown-body img + em,
.markdown-body p:has(> img) + p > em:only-child {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--meta);
  margin-top: 0.4rem;
  margin-bottom: 1.5rem;
}

.markdown-body code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'IBM Plex Mono', monospace;
}

.markdown-body pre {
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  padding: 1em 1.2em;
  overflow-x: auto;
  border-radius: 4px;
  line-height: 1.5;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 0.4em 1.2em;
  border-left: 3px solid var(--blockquote-border);
  color: var(--text);
  opacity: 0.85;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9em;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--divider);
  padding: 0.5em 0.8em;
  text-align: left;
}

.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--divider);
  margin: 2.4rem 0;
}

/* --- Footer --- */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--divider);
  font-size: 0.8rem;
  color: var(--meta);
  display: flex;
  gap: 1.2rem;
  align-items: center;
}
.site-footer a {
  color: var(--meta);
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}

/* --- Responsive (portrait / mobile) --- */
@media only screen and (max-width: 600px) {
  body { font-size: 14px; }
  .site-wrap { padding: 2rem 1rem 3rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .post-title { font-size: 1.1rem; }
}
