/* ══════════════════════════════════════
   snowpost — a minimal writing theme
   ══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f0ece4;
  --bg-nav: #ddd8ce;
  --fg: #2a2520;
  --fg-muted: #6b6158;
  --fg-faint: #9e9488;
  --accent: #8b4049;
  --accent-hover: #a34d57;
  --link: #5a6e5a;
  --link-hover: #3d4f3d;
  --border: #cec7bb;
  --code-bg: #e4dfd6;
  --flake-opacity: 0.18;
  --shadow: rgba(42, 37, 32, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1e;
    --bg-nav: #242428;
    --fg: #e0ddd5;
    --fg-muted: #9e9a90;
    --fg-faint: #5e5b54;
    --accent: #d4737d;
    --accent-hover: #e08a93;
    --link: #8aad8a;
    --link-hover: #a3c6a3;
    --border: #333338;
    --code-bg: #222226;
    --flake-opacity: 0.10;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

[data-theme="dark"] {
  --bg: #1a1a1e;
  --bg-nav: #242428;
  --fg: #e0ddd5;
  --fg-muted: #9e9a90;
  --fg-faint: #5e5b54;
  --accent: #d4737d;
  --accent-hover: #e08a93;
  --link: #8aad8a;
  --link-hover: #a3c6a3;
  --border: #333338;
  --code-bg: #222226;
  --flake-opacity: 0.10;
  --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg: #f0ece4;
  --bg-nav: #ddd8ce;
  --fg: #2a2520;
  --fg-muted: #6b6158;
  --fg-faint: #9e9488;
  --accent: #8b4049;
  --accent-hover: #a34d57;
  --link: #5a6e5a;
  --link-hover: #3d4f3d;
  --border: #cec7bb;
  --code-bg: #e4dfd6;
  --flake-opacity: 0.18;
  --shadow: rgba(42, 37, 32, 0.06);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Garamond', 'Georgia', serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── Snowflake field ── */
/* ── Trail markers ── */
.trailmarks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.8rem;
  padding: 1.6rem 2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  opacity: 0.5;
  transition: opacity 0.4s ease;
}

.trailmarks:hover {
  opacity: 1;
}

.trail {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.25s ease, letter-spacing 0.3s ease;
  white-space: nowrap;
}

.trail:hover {
  color: var(--accent);
  letter-spacing: 0.08em;
}

/* ── Navigation ── */
.site-nav {
  background: var(--bg-nav);
  padding: 0.8rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px var(--shadow);
  transition: background 0.3s ease;
}

.site-logo {
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--fg);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s;
}

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

.nav-sep {
  color: var(--fg-faint);
  user-select: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.8rem;
  transition: all 0.2s;
  font-family: inherit;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Main content ── */
.site-main {
  max-width: 640px;
  margin: 0 auto;
}

/* ── Homepage ── */
.home-greeting {
  font-size: 1.6rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.home-desc {
  color: var(--fg-muted);
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
  font-style: italic;
}

/* ── Post list ── */
.post-list {
  list-style: none;
}

.post-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  border-top: 1px solid var(--border);
}

.post-title {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.post-title a {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.2s;
}

.post-title a:hover {
  color: var(--accent);
}

.post-meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.3rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.post-summary {
  margin-top: 0.6rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* ── Single post ── */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-content {
  font-size: 1rem;
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  color: var(--fg);
}

.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.8rem;
}

.post-content p {
  margin-bottom: 1.2rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

a:hover {
  color: var(--link-hover);
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1.2rem;
  margin: 1.5rem 0;
  color: var(--fg-muted);
  font-style: italic;
  background: var(--code-bg);
}

.post-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.post-content ul, .post-content ol {
  margin: 1rem 0 1.2rem 1.5rem;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--fg-faint);
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  border-top: 1px solid var(--border);
  max-width: 640px;
  margin: 0 auto;
}

.site-footer a {
  color: var(--fg-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

/* ── Tags ── */
.tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  text-decoration: none;
  margin-right: 0.35rem;
  margin-top: 0.35rem;
  transition: all 0.2s;
}

.tag:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── Repo links ── */
.repo-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 0.5px solid var(--border);
  color: var(--fg-muted);
  text-decoration: none;
  transition: all 0.2s;
}

.repo-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── 404 ── */
.not-found {
  text-align: center;
  padding: 4rem 0;
}

.not-found h1 {
  font-size: 4rem;
  color: var(--fg-faint);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .site-nav { padding: 0.6rem 1rem; }
  .site-main { padding: 1.5rem 1rem 3rem; }
  .post-header h1 { font-size: 1.6rem; }
}

.widget-embed-scroll {
  margin: 2rem -4rem;
  max-width: calc(100% + 8rem);
}

@media (max-width: 760px) {
  .widget-embed-scroll {
    margin: 1.5rem -1rem;
    max-width: calc(100% + 2rem);
  }
}

.site-avatar {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  -webkit-border-radius: 6px;
  object-fit: cover;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: inline-block;
  flex-shrink: 0;
}

.site-avatar.loaded {
  opacity: 1;
}

@media (max-width: 600px) {
  html { font-size: 16px; }

  .site-nav {
    padding: 0.5rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .site-logo {
    font-size: 0.95rem;
  }

  .site-avatar {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 5px;
  }

  .nav-links {
    font-size: 0.82rem;
    gap: 0.15rem;
  }

  .trailmarks {
    gap: 1rem;
    padding: 1rem 1rem;
    font-size: 0.7rem;
  }

  .site-main {
    padding: 1.5rem 1rem 3rem;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  .post-meta {
    font-size: 0.7rem;
  }

  .tag {
    font-size: 0.65rem;
    padding: 0.05rem 0.35rem;
  }

  .widget-embed iframe {
    min-height: 280px;
  }
}

/* ── Theme toggle icons ── */
.icon-sun, .icon-moon {
  display: none;
  vertical-align: middle;
}

[data-theme="dark"] .icon-sun { display: inline-block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline-block; }

/* Fallback for no data-theme (follows prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: inline-block; }
  :root:not([data-theme]) .icon-moon { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun { display: none; }
  :root:not([data-theme]) .icon-moon { display: inline-block; }
}
