/* Blog pages: list, detail, and create layout inspired by provided reference. */
:root {
  color-scheme: light;
  --bg: #f6eee7;
  --panel: #ffffff;
  --border: #e3d8ce;
  --text: #2b2019;
  --muted: #7b6c62;
  --accent: #5a3c31;
  --accent-2: #d6b58c;
  --shadow: 0 16px 40px rgba(40, 24, 18, 0.08);
}

* {
  box-sizing: border-box;
}

body.blog-body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body.blog-body main {
  background: transparent;
}

.blog-page,
.blog-detail-page,
.blog-create-page {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 52px 0 80px;
}

.blog-header,
.create-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.header-text h1 {
  margin: 6px 0 10px;
  font-size: 2.4rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 640px;
  line-height: 1.6;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.blog-tools {
  margin-bottom: 26px;
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 220px;
  font-weight: 600;
}

.filter-field input,
.filter-field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fefbf8;
  color: var(--text);
}

.filter-field input::placeholder {
  color: var(--muted);
}

.filter-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

.btn.ghost {
  background: transparent;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.blog-card,
.empty-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 48px rgba(40, 24, 18, 0.14);
}

.card-image {
  width: 100%;
  height: 320px;
  overflow: hidden;
  background: #f0e7de;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 18px 18px 22px;
}

.card-meta-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 10px;
}

.card-meta-line .dot {
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.7;
}

.card-author {
  font-weight: 600;
}

.blog-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.card-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.card-actions form {
  margin: 0;
}

.empty-card {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.notice {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff7ef;
  color: var(--text);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.notice.error {
  background: #ffeaea;
}

.draft-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.input-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

.input-grid input,
.input-grid textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fefbf8;
  color: var(--text);
}

.input-grid input::placeholder,
.input-grid textarea::placeholder {
  color: var(--muted);
}

.editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fefbf8;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.tool {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border 0.2s ease;
}

.tool:hover {
  background: #f6ede5;
  border-color: var(--accent-2);
}

.draft-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.draft-toggle input {
  display: none;
}

.toggle-pill {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #ded3c9;
  position: relative;
  display: inline-block;
}

.toggle-pill::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.draft-toggle input:checked + .toggle-pill::after {
  transform: translateX(20px);
  background: var(--accent);
}

.editor-area {
  min-height: 220px;
  padding: 14px;
  line-height: 1.6;
  outline: none;
}

.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.draft-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.blog-detail-page .detail-hero h1 {
  margin: 6px 0 8px;
  font-size: 2rem;
}

.detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  align-items: center;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff7ef;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
}

.pill-draft {
  background: #fff5de;
}

.pill-live {
  background: #e5f6d7;
}

.cover-wrapper {
  margin: 18px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.cover-wrapper img {
  width: 100%;
  display: block;
}

.detail-body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.prose {
  line-height: 1.7;
  color: var(--text);
}

.prose p {
  margin: 0 0 14px;
}

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

.prose img,
.editor-area img {
  max-width: 100%;
  border-radius: 16px;
  display: block;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.detail-footer {
  margin-top: 14px;
}

.pill-link {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.blog-card-wrapper {
  position: relative;
}

.card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 0.5rem;
}

.btn-edit,
.btn-delete {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  height: 100%;
}

.btn-edit {
  background: #2563eb;
  color: white;
  border: none;
}

.btn-delete {
  background: #dc2626;
  color: white;
  border: none;
}

.btn-close {
  border: none;
  background-color: white;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.show {
  display: block;
}

.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 1.5rem;
  z-index: 100;
  width: 500px;
  max-width: 90%;
  border-radius: 8px;
}

.blog-modal {
  display: flex;
  flex-direction: column;
}

#blogTitle, #blogSummary{
  width: 100%;
  padding: 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid #ccc;
  background: #f9fafb;
}

.blog-modal-header {
  display: flex;
  justify-content: space-between;
}

.blog-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.field-block {
  margin-bottom: 1.2rem;
}

.field-block label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.blog-modal-submit {
  background-color: #22c55e;
  border: none;
  border-radius: 5px;
  color: white;
  text-align: end;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.6rem 0.9rem;
  text-decoration: none;
}

.image-preview,
.image-upload-block,
.image-grid {
  margin-top: 1.5rem;
}

.image-preview img {
  display: block;
  max-width: 260px;
  width: 100%;
  border-radius: 16px;
  margin-top: 0.75rem;
}

.image-preview .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.image-upload-block .hint {
  margin-top: 0.5rem;
  color: #6b7280;
  font-size: 0.9rem;
}


.hover-light {
  transition: filter 0.2s ease;
}

.hover-light:hover {
 filter: brightness(0.8);
}

@media (max-width: 768px) {
  .blog-page,
  .blog-detail-page,
  .blog-create-page {
    width: 100%;
    padding: 28px 16px 60px;
  }

  .blog-header,
  .create-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .blog-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-actions {
    width: 100%;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }
}
