/* ============================================================
   ava-code.com — Warm Editorial
   Inspired by prismml.com
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Rethink+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #e8e4df;
  --bg-card: #f2efeb;
  --text: #262c35;
  --text-bold: #12151a;
  --text-muted: #4c5159;
  --text-light: #7a7f87;
  --accent: #5c3535;
  --accent-light: #7a4a4a;
  --accent-bg: rgba(92, 53, 53, 0.08);
  --accent-border: rgba(92, 53, 53, 0.15);
  --muted-bg: #cebebe;
  --border: rgba(38, 44, 53, 0.1);
  --border-strong: rgba(38, 44, 53, 0.18);
  --danger: #8b3a3a;
  --success-bg: rgba(60, 120, 80, 0.1);
  --success-text: #2d5a3a;
  --error-bg: rgba(139, 58, 58, 0.08);
  --error-text: #8b3a3a;
  --radius-bevel: 5px 12px;
  --radius-bevel-lg: 8px 20px;
  --radius-bevel-btn: 15px 24px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --font-sans: 'Rethink Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ── Base ── */
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-wrap: pretty;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-light); }
img { max-width: 100%; display: block; }

/* ── Layout ── */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 48px;
}

/* ── Header ── */
header {
  padding: 24px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bold);
  text-decoration: none;
  letter-spacing: -0.02em;
}

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

.site-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav a {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  padding: 6px 14px;
  border-radius: var(--radius-bevel);
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

nav a:hover {
  color: var(--text-bold);
  background: rgba(38, 44, 53, 0.05);
}

nav a.btn-nav {
  background: var(--text-bold);
  color: var(--bg);
  border-radius: var(--radius-bevel-btn);
  transition: border-radius 0.2s ease, background 0.15s;
}

nav a.btn-nav:hover {
  background: var(--accent);
  color: var(--bg);
  border-radius: 24px 15px 24px 15px;
}

/* ── Divider ── */
.header-divider {
  height: 1px;
  background: repeating-linear-gradient(
    45deg,
    var(--muted-bg) 0 1px,
    transparent 1px 14px
  );
}

/* ── Main ── */
main {
  padding: 48px 0 80px;
  flex: 1;
}

/* ── Messages ── */
.messages { list-style: none; margin-bottom: 24px; }

.message {
  padding: 12px 16px;
  border-radius: var(--radius-bevel);
  font-size: 14px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.message.success { background: var(--success-bg); color: var(--success-text); }
.message.error   { background: var(--error-bg);   color: var(--error-text); }
.message.warning { background: rgba(180, 140, 60, 0.1); color: #6b5520; }
.message.info    { background: var(--accent-bg); color: var(--accent); }

/* ── Post list ── */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel-lg);
  padding: 28px 32px;
  transition: border-radius 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  border-radius: 20px 8px 20px 8px;
}

.post-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

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

.post-cover-thumb {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius-bevel);
  margin-bottom: 20px;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.post-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin-bottom: 10px;
  color: var(--text-bold);
  transition: color 0.15s;
}

.post-excerpt {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-tags {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-bevel);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 400;
  text-decoration: none;
  transition: border-radius 0.2s ease;
}

.tag:hover { border-radius: 12px 5px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 100px 0;
  color: var(--text-muted);
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-bold);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 40px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 8px 16px;
  border-radius: var(--radius-bevel);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--text-bold); color: var(--bg); border-color: var(--text-bold); }

/* ── Post detail ── */
.post-hero {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: var(--radius-bevel-lg);
  margin-bottom: 32px;
}

.post-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 14px 0 0;
  color: var(--text-bold);
}

/* ── Post content ── */
.post-content { font-size: 17px; line-height: 1.8; }

.post-content h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 48px 0 16px;
  color: var(--text-bold);
}

.post-content h3 {
  font-size: 19px;
  font-weight: 600;
  margin: 36px 0 12px;
  color: var(--text-bold);
}

.post-content p { margin-bottom: 20px; }

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-border);
}

.post-content a:hover { text-decoration-color: var(--accent); }
.post-content ul, .post-content ol { padding-left: 24px; margin-bottom: 20px; }
.post-content li { margin-bottom: 6px; }
.post-content strong { font-weight: 700; color: var(--text-bold); }
.post-content em { font-style: italic; }

.post-content img {
  border-radius: var(--radius-bevel-lg);
  margin: 28px 0;
  box-shadow: var(--shadow);
}

.post-content code {
  background: rgba(92, 53, 53, 0.07);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

.post-content pre {
  background: var(--text-bold);
  color: #d4d0cb;
  padding: 20px 24px;
  border-radius: var(--radius-bevel-lg);
  overflow-x: auto;
  margin-bottom: 24px;
}

.post-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-content blockquote {
  border-left: 3px solid var(--muted-bg);
  padding-left: 20px;
  color: var(--text-muted);
  margin: 28px 0;
  font-style: italic;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 15px;
}

.post-content th,
.post-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  background: rgba(38, 44, 53, 0.04);
  font-weight: 600;
  color: var(--text-bold);
}

.post-content hr {
  border: none;
  height: 1px;
  background: repeating-linear-gradient(
    45deg,
    var(--muted-bg) 0 1px,
    transparent 1px 14px
  );
  margin: 40px 0;
}

/* ── Post actions ── */
.post-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.post-actions span {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-light);
  margin-right: auto;
}

/* ── Likes ── */
.like-row { margin-top: 32px; }

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel-btn);
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.like-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  border-radius: 24px 15px 24px 15px;
}

.like-btn.liked {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.like-btn.static { cursor: default; }

/* ── Comments ── */
.comments-section {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.comments-heading {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.comment {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel);
  padding: 16px 20px;
  margin-bottom: 10px;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.comment-author { font-weight: 500; color: var(--text-bold); }
.comment-body { font-size: 15px; line-height: 1.65; white-space: pre-wrap; }
.no-comments { font-size: 15px; color: var(--text-muted); padding: 16px 0 28px; }

.comment-form {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-form textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-card);
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 53, 53, 0.08);
}

.comment-login-prompt {
  margin-top: 24px;
  font-size: 15px;
  color: var(--text-muted);
}

.comment-login-prompt a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  background: var(--text-bold);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-bevel-btn);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: border-radius 0.2s ease, background 0.15s;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-radius: 24px 15px 24px 15px;
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-card);
}

.btn-danger {
  background: var(--danger);
  color: var(--bg);
}

.btn-danger:hover { background: var(--accent-light); color: var(--bg); }

/* ── Forms ── */
.form-wrap { max-width: 680px; }
.form-row { margin-bottom: 22px; }

.form-row label {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="email"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel);
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 53, 53, 0.08);
}

.form-row textarea.markdown-editor {
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 480px;
  resize: vertical;
  line-height: 1.6;
}

.form-row .helptext { margin-top: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--text-light); }
.form-row .errorlist { list-style: none; margin-top: 6px; }
.form-row .errorlist li { font-size: 13px; color: var(--danger); }

.form-row .checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.form-row .checkbox-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel);
}

.form-row .checkbox-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.form-row.inline { display: flex; align-items: center; gap: 10px; }
.form-row.inline label { margin-bottom: 0; text-transform: none; }
.form-row.inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

/* ── Auth card ── */
.auth-wrap {
  max-width: 420px;
  margin: 40px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-bevel-lg);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
}

.auth-wrap h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  color: var(--text-bold);
}

/* ── Delete confirm ── */
.danger-zone {
  background: var(--error-bg);
  border: 1px solid rgba(139, 58, 58, 0.15);
  border-radius: var(--radius-bevel-lg);
  padding: 28px;
  margin-top: 24px;
}

.danger-zone p { color: var(--error-text); margin-bottom: 20px; font-size: 15px; }

/* ── Error pages ── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  min-height: 60vh;
}

.error-code {
  font-size: 120px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted-bg);
  margin-bottom: 16px;
  user-select: none;
  letter-spacing: -0.04em;
}

.error-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.error-message {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.6;
  margin-bottom: 36px;
}

.error-art {
  font-size: 64px;
  margin-bottom: 24px;
  line-height: 1;
}

/* ── Footer ── */
footer {
  padding: 20px 0;
}

.footer-divider {
  height: 1px;
  background: repeating-linear-gradient(
    45deg,
    var(--muted-bg) 0 1px,
    transparent 1px 14px
  );
  margin-bottom: 20px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-light);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .container { padding: 0 24px; }
  .post-header h1 { font-size: 26px; }
  .post-title { font-size: 20px; }
  main { padding: 32px 0 56px; }
  .auth-wrap { padding: 28px 20px; margin: 16px auto; }
  .footer-inner { flex-direction: column; gap: 4px; text-align: center; }
  .error-code { font-size: 80px; }
  .post-item { padding: 20px; }
  .post-content h2 { font-size: 21px; }
  .post-meta { font-size: 12px; }
  header { padding: 16px 0; }
}
