/* ===========================================================================
   Autonomous Blog Engine — theme matching the AIPoll aesthetic
   Dark + light mode with glassmorphism and an animated particle background.
   =========================================================================== */

/* --- Dark theme (default) --- */
:root,
:root.dark-mode {
  --bg: #07070b;
  --bg-2: #0c0c14;
  --purple: #a855f7;
  --purple-bright: #c084fc;
  --purple-deep: #6b21a8;
  --red: #ef4444;
  --red-bright: #ff5252;
  --red-deep: #991b1b;
  --cyan: #22d3ee;
  --text: #e9e9f5;
  --text-dim: #9a9ab0;
  --glass: rgba(20, 20, 34, 0.55);
  --glass-border: rgba(168, 85, 247, 0.35);
  --radius: 18px;
  --shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --card-bg: rgba(20, 20, 34, 0.5);
}

/* --- Light theme overrides --- */
body.light-mode {
  --bg: #f8f9fa;
  --bg-2: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --glass: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(168, 85, 247, 0.25);
  --card-bg: rgba(255, 255, 255, 0.6);
  --shadow: 0 30px 60px rgba(100, 100, 140, 0.2);
}

/* --- Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* --- Background canvas + vignette --- */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(7, 7, 11, 0.55) 100%);
  transition: background 0.3s ease;
}
body.light-mode .vignette {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(248, 249, 250, 0.5) 100%);
}

/* --- Layout --- */
.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 20px 32px;
}

.screen {
  width: 100%;
  max-width: 1200px;
}

.layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

/* --- Sidebar (archive) --- */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-logo {
  font-size: 1.4rem;
  color: var(--purple-bright);
}

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--purple);
}

#archiveTree {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
}

.archive-loading,
.archive-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px 0;
}

.archive-year { margin-bottom: 10px; }

.archive-year-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--purple-bright);
  padding: 6px 8px;
}

.archive-month { margin-left: 6px; margin-bottom: 6px; }

.archive-month-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 4px 8px;
  font-weight: 500;
}

.archive-post {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 4px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.archive-post:hover {
  background: rgba(168, 85, 247, 0.08);
  transform: translateX(3px);
}

.archive-post.active {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(239, 68, 68, 0.12));
  border: 1px solid var(--glass-border);
}

.archive-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

.archive-title {
  flex: 1;
  font-size: 0.87rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-short {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* --- Main content --- */
.content {
  flex: 1;
  min-width: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 32px 36px;
}

/* --- Post --- */
.post-title {
  font-size: clamp(1.875rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--purple);
  margin-bottom: 10px;
}

.post-meta {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 12px;
}

.post-loading {
  color: var(--text-dim);
  text-align: center;
  padding: 48px 0;
  font-size: 1rem;
}

.empty-state {
  text-align: center;
  padding: 56px 0;
  color: var(--text-dim);
}
.empty-state h2 { color: var(--purple); margin-bottom: 8px; }

/* --- Comments --- */
.comments-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--glass-border);
}

.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.comments-header h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--purple);
}

.comment-count {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

#commentsList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item {
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  animation: commentIn 0.3s ease both;
}

.comment-item.hidden { display: none; }

@keyframes commentIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--purple-bright);
}

.comment-title {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.comment-content {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

.comment-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 8px;
}

.no-comments {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  padding: 16px;
}

/* --- Comment form --- */
.comment-form {
  margin-top: 20px;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
}

.comment-form.hidden { display: none; }

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-row input {
  flex: 1;
  min-width: 140px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 11px 14px;
  background: rgba(168, 85, 247, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.2s ease;
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--purple);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}

.comment-form textarea {
  resize: vertical;
  min-height: 80px;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
}

/* --- Buttons --- */
.btn-submit,
.btn-ghost {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 11px 22px;
  border-radius: 50px;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.2s ease;
}

.btn-submit {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.4);
}
.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.65);
}
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--purple);
  background: rgba(168, 85, 247, 0.08);
}

.show-form-btn {
  width: 100%;
  margin-top: 16px;
  text-align: center;
}

.view-more {
  width: 100%;
  margin-top: 4px;
}

/* --- Comment status (locked) --- */
.comment-status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
  color: var(--red-bright);
  font-size: 0.9rem;
  text-align: center;
}
.comment-status.hidden { display: none; }

/* --- Theme switcher --- */
.theme-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.theme-btn:hover {
  border-color: var(--purple);
  transform: translateY(-1px);
}

.theme-icon { font-size: 1.1rem; line-height: 1; }

/* --- Archive "View all" button --- */
.archive-more {
  width: 100%;
  margin-top: 6px;
  text-align: center;
  padding: 10px 14px;
  font-size: 0.85rem;
}

/* --- Logo header --- */
.logo-header {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0;
  margin: 0;
  line-height: 0;
}

.site-logo {
  display: inline-block;
  max-width: 100%;
  height: auto;
  width: auto;
  border-radius: 12px;
  margin: 0 auto;
  padding: 0;
  vertical-align: bottom;
}

/* --- Buy Me a Coffee bar --- */
.bmc-bar {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0;
  margin: 0;
  line-height: 0;
}

.bmc-link {
  display: inline-block;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.bmc-link:hover {
  transform: scale(1.06);
  opacity: 0.9;
}

.bmc-img {
  display: block;
  max-width: 200px;
  height: auto;
  border-radius: 10px;
  margin: 0;
  padding: 0;
  vertical-align: bottom;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    max-height: 320px;
  }
  .content { padding: 24px 20px; }
  .site-logo { max-width: 90%; }
}
