/* ============================================================
   Nhan's Blog — dark academic style, inspired by Lil'Log
   ============================================================ */

:root {
  --bg:        #1d1e20;
  --surface:   #26272b;
  --border:    #35363b;
  --text:      #dadadb;
  --muted:     #9b9c9d;
  --accent:    #7eb8f7;
  --accent-h:  #5da0e6;
  --danger:    #e06c75;
  --success:   #98c379;
  --warning:   #e5c07b;
  --code-bg:   #373842;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-serif: Georgia, "Times New Roman", serif;
  --max-width: 760px;
  --radius: 4px;
}

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

html { scroll-behavior: smooth; }

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

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

/* ---- Header ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.site-title:hover { color: var(--accent); text-decoration: none; }

.site-nav { display: flex; gap: 1.5rem; }
.site-nav a { color: var(--muted); font-size: 0.9rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* ---- Main ---- */
.site-main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---- Post list (index) ---- */
.post-list { display: flex; flex-direction: column; gap: 2.5rem; }

.post-card { }
.post-card .post-meta { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.3rem; }
.post-card .post-title { font-size: 1.35rem; font-weight: 600; margin-bottom: 0.4rem; line-height: 1.3; }
.post-card .post-title a { color: var(--text); }
.post-card .post-title a:hover { color: var(--accent); text-decoration: none; }
.post-card .post-summary { color: var(--muted); margin-bottom: 0.5rem; }
.read-more { font-size: 0.88rem; }

.empty-state { color: var(--muted); font-style: italic; }

/* ---- Full post ---- */
.post-full { margin-bottom: 3rem; }
.post-header { margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.post-header .post-title { font-size: 2rem; font-weight: 700; line-height: 1.2; margin-bottom: 0.6rem; }
.post-header .post-meta { color: var(--muted); font-size: 0.85rem; }

.draft-badge {
  display: inline-block;
  background: var(--warning);
  color: #1d1e20;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

/* ---- Post body (rendered markdown) ---- */
.post-body { font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.8; }

.post-body h1, .post-body h2, .post-body h3,
.post-body h4, .post-body h5, .post-body h6 {
  font-family: var(--font-sans);
  color: var(--text);
  margin: 1.8rem 0 0.6rem;
  line-height: 1.3;
  font-weight: 600;
}
.post-body h1 { font-size: 1.7rem; }
.post-body h2 { font-size: 1.35rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.post-body h3 { font-size: 1.15rem; }

.post-body p { margin-bottom: 1.1rem; }

.post-body ul, .post-body ol { margin: 0 0 1rem 1.5rem; }
.post-body li { margin-bottom: 0.25rem; }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.25rem 0;
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-style: italic;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: var(--radius);
  color: #e5c07b;
}

.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
.post-body pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.88rem;
}

.post-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
  display: block;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.post-body th, .post-body td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  text-align: left;
}
.post-body th { background: var(--surface); color: var(--muted); font-weight: 600; }

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

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

/* ---- Comments ---- */
.comments-section {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}
.comments-heading { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.5rem; }

.comment {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.comment-meta { margin-bottom: 0.35rem; }
.comment-author { color: var(--accent); margin-right: 0.6rem; }
.comment-time { color: var(--muted); font-size: 0.8rem; }
.comment-body { color: var(--text); font-size: 0.95rem; }

.comment-form-wrap { margin-top: 2rem; }
.comment-form-wrap h3 { margin-bottom: 1rem; font-size: 1rem; }

/* ---- Forms (shared) ---- */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  margin-top: 1rem;
}
label:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: 0.8em; }

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.55rem 0.8rem;
  transition: border-color 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; font-family: var(--font-mono); font-size: 0.88rem; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.checkbox-label input { width: auto; }

.form-row { margin-top: 1rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.form-error {
  background: rgba(224, 108, 117, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--border); text-decoration: none; color: var(--text); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d0e10;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #0d0e10; }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(224, 108, 117, 0.15); }

.btn-toggle { border-color: var(--warning); color: var(--warning); }
.btn-toggle:hover { background: rgba(229, 192, 123, 0.12); }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }

/* ---- Admin dashboard ---- */
.admin-dashboard { }
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}
.dashboard-header h1 { font-size: 1.5rem; }

.post-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.post-table th, .post-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.post-table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.post-table tr:hover td { background: var(--surface); }
.post-table .actions { white-space: nowrap; display: flex; gap: 0.4rem; }

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}
.status-badge.published { background: rgba(152, 195, 121, 0.15); color: var(--success); }
.status-badge.draft { background: rgba(155, 156, 157, 0.15); color: var(--muted); }

/* ---- Admin edit ---- */
.admin-edit h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.admin-edit #content { min-height: 400px; }

/* ---- Auth box ---- */
.auth-box {
  max-width: 360px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.auth-box h1 { font-size: 1.3rem; margin-bottom: 1.25rem; }
.auth-box button { margin-top: 1.25rem; width: 100%; padding: 0.6rem; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .post-header .post-title { font-size: 1.55rem; }
  .post-table { display: block; overflow-x: auto; }
}
