/* ============================================================
   fallow — main stylesheet
   ============================================================ */

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

/* === Variables === */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --bg:           #ffffff;
  --surface:      #f8f7f4;
  --border:       #e8e7e3;
  --text:         #111111;
  --text-muted:   #6b6b6b;
  --text-faint:   #aaaaaa;
  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-bg:    #eef2ff;

  --code-bg:      #1e1e2e;
  --code-text:    #cdd6f4;
  --code-border:  #313244;

  --max-w:        720px;
  --gap:          1.5rem;
  --radius:       6px;
  --radius-sm:    3px;
  --transition:   150ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0e0e0e;
    --surface:      #181818;
    --border:       #282828;
    --text:         #e8e8e8;
    --text-muted:   #8a8a8a;
    --text-faint:   #484848;
    --accent:       #818cf8;
    --accent-hover: #a5b4fc;
    --accent-bg:    #1e1b4b;

    --code-bg:      #111111;
    --code-border:  #222222;
  }
}

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

/* === Base === */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* === Layout === */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gap);
}

main {
  flex: 1;
  padding: 3rem 0 5rem;
}

/* === Header === */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 0;
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}

.site-header nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.site-name:hover { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.nav-links a:hover { color: var(--text); }

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

/* === Home — intro === */
.home-intro {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 0.4rem;
}

.site-desc {
  color: var(--text-muted);
  font-size: 1rem;
}

/* === Post list === */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

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

.post-meta {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.post-item h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.35;
  margin-bottom: 0.35rem;
}

.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { color: var(--accent); }

.post-excerpt {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === Tags === */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
}

.tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.tag:hover {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* === Post page === */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.2;
  margin-bottom: 0.85rem;
}

.post-header-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.post-header-meta time { font-weight: 500; }

.reading-time {
  color: var(--text-faint);
}
.reading-time::before {
  content: "·";
  margin-right: 0.5rem;
}

/* === Article content === */
.post-content {
  font-size: 1.05rem;
  line-height: 1.78;
}

.post-content > * + * { margin-top: 1.5em; }

.post-content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-top: 2.5em;
  margin-bottom: 0.5em;
}

.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2em;
  margin-bottom: 0.4em;
}

.post-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.35em;
}

.post-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent);
  text-decoration-thickness: 1px;
}
.post-content a:hover {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

.post-content strong { font-weight: 600; }

.post-content ul,
.post-content ol { padding-left: 1.5em; }
.post-content li + li { margin-top: 0.3em; }

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

/* Inline code */
.post-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.855em;
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* === Code blocks === */
.code-wrapper {
  position: relative;
  margin: 1.75em 0;
}

.post-content .code-wrapper pre,
.post-content pre {
  background: var(--code-bg) !important;
  border-radius: var(--radius);
  border: 1px solid var(--code-border);
  overflow-x: auto;
  margin: 0;
}

.post-content .code-wrapper pre code,
.post-content pre code {
  font-family: var(--font-mono) !important;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--code-text);
  padding: 1.25rem 1.5rem;
  display: block;
  min-width: 100%;
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: #7f8499;
  background: #2a2a3e;
  border: 1px solid #3a3a50;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  z-index: 1;
  line-height: 1.6;
}
.copy-btn:hover { color: var(--code-text); background: #353550; }
.copy-btn.copied { color: #a6e3a1; border-color: #a6e3a1; }

/* === Prism token colors (Catppuccin Mocha) === */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: #6c7086; font-style: italic; }

.token.punctuation { color: #cdd6f4; }

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted { color: #f38ba8; }

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted { color: #a6e3a1; }

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string { color: #89dceb; }

.token.atrule,
.token.attr-value,
.token.keyword { color: #cba6f7; }

.token.function,
.token.class-name { color: #89b4fa; }

.token.regex,
.token.important,
.token.variable { color: #fab387; }

.token.important,
.token.bold { font-weight: bold; }
.token.italic { font-style: italic; }

/* === Blockquotes === */
.post-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.75em 0;
  padding: 0.25em 0 0.25em 1.5em;
  color: var(--text-muted);
}
.post-content blockquote p { margin: 0; font-style: italic; }

/* === Images & figures === */
.post-content img {
  border-radius: var(--radius);
  width: 100%;
}

figure,
.post-figure {
  margin: 2em 0;
}

figure img,
.post-figure img {
  border-radius: var(--radius);
  width: 100%;
}

figcaption {
  text-align: center;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  font-style: italic;
}

/* === YouTube embed === */
.embed-youtube {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  margin: 2em 0;
  background: var(--surface);
}
.embed-youtube iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* === Tables === */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1.75em 0;
}
.post-content th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
}
.post-content td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.post-content tr:last-child td { border-bottom: none; }

/* === About page === */
.post-content > p:first-child {
  font-size: 1.1rem;
}

/* === Responsive === */
@media (max-width: 600px) {
  .site-header nav { gap: 0.75rem; }
  .nav-links { gap: 1rem; }
  .nav-links li:last-child { display: none; } /* hide RSS on mobile */
  .site-footer .container { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .post-header h1 { font-size: 1.65rem; }
  .post-content { font-size: 1rem; }
  .post-content pre code,
  .post-content .code-wrapper pre code { font-size: 0.82rem; padding: 1rem; }
}
