/* blogku — editorial micro+long blog */

:root {
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --bg-hover: #f5f2ee;
  --text: #2c2520;
  --text-muted: #8a7e74;
  --text-light: #b5aa9e;
  --accent: #c45d3e;
  --accent-hover: #a84830;
  --accent-micro: #3e7fc4;
  --accent-long: #c45d3e;
  --border: #e8e2da;
  --border-light: #f0ebe5;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(44,37,32,0.06);
  --font-body: 'Georgia', 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  --max-w: 680px;
}

[data-theme="dark"] {
  --bg: #1a1714;
  --bg-card: #242019;
  --bg-hover: #2e2822;
  --text: #e8e0d6;
  --text-muted: #9a8e82;
  --text-light: #6b6058;
  --accent: #e07050;
  --accent-hover: #f08060;
  --accent-micro: #60a0e0;
  --accent-long: #e07050;
  --border: #3a3430;
  --border-light: #302a24;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
}

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

html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

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

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

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}

.site-header .container {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

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

.site-tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

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

/* Theme toggle */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

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

/* Feed */

.feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-card {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.post-card:first-child { padding-top: 0; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.post-type-badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-type-badge.micro {
  background: color-mix(in srgb, var(--accent-micro) 12%, transparent);
  color: var(--accent-micro);
}

.post-type-badge.long {
  background: color-mix(in srgb, var(--accent-long) 12%, transparent);
  color: var(--accent-long);
}

.post-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

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

.post-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 0.4rem;
}

.read-more {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
}

.micro-body {
  font-size: 1rem;
  line-height: 1.6;
}

/* Single post */

.post-full {
  padding-bottom: 3rem;
}

.post-header {
  margin-bottom: 2rem;
}

.post-header .post-title {
  font-size: 2rem;
  margin-top: 0.5rem;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

/* Prose (rendered markdown) */

.prose h1, .prose h2, .prose h3 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  letter-spacing: -0.01em;
}

.prose h1 { font-size: 1.6rem; }
.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.1rem; }

.prose p {
  margin-bottom: 1.1em;
}

.prose ul, .prose ol {
  margin-bottom: 1.1em;
  padding-left: 1.5em;
}

.prose li { margin-bottom: 0.3em; }

.prose blockquote {
  margin: 1.2em 0;
  padding: 0.6em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-hover);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-hover);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.prose pre {
  margin: 1.2em 0;
  padding: 1em 1.2em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.5;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1em 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.prose a { text-decoration: underline; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.95rem;
  overflow-x: auto;
  display: block;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 0.6em 0.8em;
  text-align: left;
}

.prose th {
  background: var(--bg-hover);
  font-weight: 600;
}

/* Auth */

.auth-section {
  max-width: 340px;
  margin: 3rem auto;
}

.auth-section h1 {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* Forms */

label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.label-hint {
  font-weight: 400;
  color: var(--text-light);
}

input[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  line-height: 1.5;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.field { margin-bottom: 1rem; }

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] { width: auto; }

/* Buttons */

.btn, button[type="submit"] {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.15s;
}

.btn:hover, button[type="submit"]:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.btn-primary, button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover, button[type="submit"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-micro {
  border-color: var(--accent-micro);
  color: var(--accent-micro);
}
.btn-micro:hover {
  background: var(--accent-micro);
  color: #fff;
}

.btn-long {
  border-color: var(--accent-long);
  color: var(--accent-long);
}
.btn-long:hover {
  background: var(--accent-long);
  color: #fff;
}

.btn-muted {
  color: var(--text-muted);
  border-color: var(--border);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--accent); }
.link-btn.danger:hover { color: #c0392b; }

.inline-form { display: inline; }

/* Admin */

.admin-section h1 {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 2rem;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

.post-row.unpublished { opacity: 0.6; }

.post-row-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.post-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-row-date {
  color: var(--text-light);
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.published { background: #2ecc71; }
.status-dot.draft { background: var(--text-light); }

.post-row-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.8rem;
}

.post-row-actions a { color: var(--text-muted); }
.post-row-actions a:hover { color: var(--accent); }

/* Editor */

.editor-section h1 {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
}

.editor-form textarea#body {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

.preview-toggle {
  margin-bottom: 1rem;
}

.preview-toggle summary {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.preview-area {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  min-height: 80px;
}

/* Flash */

.flash {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
}

.flash.error {
  background: color-mix(in srgb, #c0392b 10%, var(--bg));
  color: #c0392b;
  border: 1px solid color-mix(in srgb, #c0392b 25%, transparent);
}

/* Empty */

.empty-state {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
}

/* Pagination */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0 1rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.pagination-link {
  color: var(--text-muted);
}
.pagination-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.pagination-next {
  margin-left: auto;
}

/* Footer */

.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border-light);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-light);
  text-align: center;
}

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

/* Mobile */

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

  .site-header .container { flex-direction: column; gap: 0.3rem; }
  .site-nav { margin-left: 0; }

  .admin-header { flex-direction: column; align-items: flex-start; }
  .admin-actions { flex-wrap: wrap; }

  .post-row { flex-direction: column; align-items: flex-start; }
  .post-row-actions { width: 100%; }

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