/* ============================================================
   6iang — personal blog
   Pure CSS. No framework, no build step.
   Design tokens live in :root; dark theme overrides in [data-theme="dark"].
   ============================================================ */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", "Noto Serif", serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Fira Code",
    Consolas, "Liberation Mono", monospace;

  /* light theme */
  --bg: #fbfaf8;
  --bg-soft: #f2efe9;
  --surface: #ffffff;
  --text: #1c1b1a;
  --text-soft: #57534e;
  --text-faint: #8a847c;
  --border: #e7e2da;
  --accent: #b3541e;      /* warm terracotta */
  --accent-soft: #f3e4d8;
  --link: #a24717;
  --shadow: 0 1px 2px rgba(28, 27, 26, 0.04), 0 8px 24px rgba(28, 27, 26, 0.06);

  --maxw: 720px;
  --radius: 14px;
  --radius-sm: 9px;
}

[data-theme="dark"] {
  --bg: #14130f;
  --bg-soft: #1d1b16;
  --surface: #1c1a15;
  --text: #ece7dd;
  --text-soft: #b3ab9d;
  --text-faint: #857d6f;
  --border: #302c25;
  --accent: #e08a4f;
  --accent-soft: #2a2018;
  --link: #eb9a63;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 22px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 14px; }
.brand {
  font-weight: 800; font-size: 1.28rem; letter-spacing: -0.02em;
  text-decoration: none; color: var(--text);
}
.brand .dot { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a {
  color: var(--text-soft); text-decoration: none; font-weight: 500;
  font-size: 0.96rem; padding: 7px 10px; border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--bg-soft); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; margin-left: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft);
  cursor: pointer; font-size: 0.9rem; font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s, transform 0.1s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- layout ---------- */
main { padding-block: 40px 72px; }
.section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-faint); font-weight: 700; margin: 0 0 18px;
}

/* ---------- hero ---------- */
.hero { padding-block: 46px 30px; border-bottom: 1px solid var(--border); }
.hero h1 {
  font-size: clamp(2rem, 6vw, 3rem); line-height: 1.08;
  letter-spacing: -0.03em; margin: 0 0 14px; font-weight: 800;
}
.hero .lead { font-size: 1.12rem; color: var(--text-soft); margin: 0; max-width: 46ch; }
.wave { display: inline-block; transform-origin: 70% 70%; }
@media (prefers-reduced-motion: no-preference) {
  .wave { animation: wave 2.4s ease-in-out 1; }
}
@keyframes wave {
  0%,60%,100% { transform: rotate(0); } 10%,30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); }
}

/* ---------- post list ---------- */
.posts { list-style: none; margin: 0; padding: 0; }
.post-card { padding: 22px 0; border-bottom: 1px solid var(--border); }
.post-card:last-child { border-bottom: 0; }
.post-card a.card-link { text-decoration: none; color: inherit; display: block; }
.post-card h3 {
  font-size: 1.32rem; letter-spacing: -0.02em; margin: 0 0 6px;
  font-weight: 700; color: var(--text); transition: color 0.15s;
}
.post-card a.card-link:hover h3 { color: var(--accent); }
.post-card p { margin: 0 0 10px; color: var(--text-soft); font-size: 1rem; }
.post-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 0.82rem; color: var(--text-faint); }
.post-meta time { font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  letter-spacing: 0.01em;
}
.empty { color: var(--text-faint); padding: 30px 0; font-style: italic; }

/* ---------- article ---------- */
.post { padding-top: 8px; }
.back { display: inline-block; margin-bottom: 26px; font-size: 0.92rem;
  color: var(--text-soft); text-decoration: none; font-weight: 500; }
.back:hover { color: var(--accent); }
.post-header { margin-bottom: 30px; }
.post-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.12;
  letter-spacing: -0.03em; margin: 10px 0 0; font-weight: 800;
}
.post-body { font-family: var(--font-serif); font-size: 1.16rem; line-height: 1.75; }
.post-body > *:first-child { margin-top: 0; }
.post-body p { margin: 0 0 1.25em; }
.post-body h2 {
  font-family: var(--font-sans); font-size: 1.5rem; letter-spacing: -0.02em;
  margin: 1.9em 0 0.5em; line-height: 1.2;
}
.post-body h3 {
  font-family: var(--font-sans); font-size: 1.2rem;
  margin: 1.6em 0 0.4em;
}
.post-body a { color: var(--link); }
.post-body ul, .post-body ol { margin: 0 0 1.25em; padding-left: 1.4em; }
.post-body li { margin-bottom: 0.4em; }
.post-body blockquote {
  margin: 1.5em 0; padding: 4px 20px; border-left: 3px solid var(--accent);
  color: var(--text-soft); font-style: italic;
}
.post-body img { border-radius: var(--radius); margin: 1.5em 0; box-shadow: var(--shadow); }
.post-body hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }
.post-body code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-soft); padding: 2px 6px; border-radius: 6px;
}
.post-body pre {
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.6;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; margin: 1.5em 0;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; }

/* ---------- about ---------- */
.prose { font-family: var(--font-serif); font-size: 1.14rem; line-height: 1.75; }
.prose h1 {
  font-family: var(--font-sans); font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.03em; margin: 0 0 20px; font-weight: 800;
}
.prose p { margin: 0 0 1.2em; }
.prose a { color: var(--link); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  padding-block: 26px; font-size: 0.88rem; color: var(--text-faint); }
.foot p { margin: 0; }
.foot a { color: var(--text-soft); }

/* ---------- lang visibility (set by JS via [data-active-lang] on <html>) ---------- */
[data-lang] { display: none; }
html[data-active-lang="vi"] [data-lang="vi"],
html[data-active-lang="en"] [data-lang="en"] { display: revert; }
/* before JS runs, show Vietnamese by default to avoid a blank flash */
html:not([data-active-lang]) [data-lang="vi"] { display: revert; }

/* ---------- misc ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--text); }

@media (max-width: 540px) {
  body { font-size: 17px; }
  .nav-links a { padding: 6px 7px; font-size: 0.9rem; }
  .hero { padding-block: 32px 24px; }
}
