/* blog.css — blog reader (S10) + blog typography (S12.1). Requires base.css. */
/* ==================== Blog page (Session 10) ==================== */

/* ---- Featured post hero ---- */
.blog-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-radius: 28px;
  overflow: hidden;
  background-color: #FFFFFF;
  border: 1px solid #F8DBC0;
  box-shadow: 0 16px 40px -20px rgba(250, 170, 141, 0.4);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.blog-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 56px -24px rgba(255, 64, 0, 0.3);
}

@media (min-width: 768px) {
  .blog-hero {
    grid-template-columns: 5fr 4fr;
  }
}

.blog-hero-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.blog-hero-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.1) 100%);
}

.blog-hero-cover .emoji {
  font-size: 7rem;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.2));
  position: relative;
  z-index: 1;
}

/* Featured flag chip trên cover hero */
.blog-hero-flag {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 9999px;
  background-color: rgba(255, 255, 255, 0.92);
  color: #FF4000;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.25);
}

.blog-hero-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 768px) {
  .blog-hero-body {
    padding: 40px;
  }
}

/* ---- Category pills (filter) ---- */
.blog-category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}

.blog-category-pills::-webkit-scrollbar { display: none; }

.blog-category-pills button {
  padding: 8px 16px;
  border-radius: 9999px;
  background-color: #FFFFFF;
  border: 1px solid #F2C5A5;
  color: #4A4548;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.blog-category-pills button:hover:not(.is-active) {
  border-color: #FF4000;
  color: #201E1F;
}

.blog-category-pills button.is-active {
  background-color: #201E1F;
  color: #FEEFDD;
  border-color: #201E1F;
}

/* ---- Search input ---- */
.blog-search-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 9999px;
  background-color: #FFFFFF;
  border: 1px solid #F2C5A5;
  font-family: inherit;
  /* 16px: chống iOS Safari auto-zoom viewport khi focus input */
  font-size: 16px;
  color: #201E1F;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.blog-search-input:focus {
  border-color: #FF4000;
  box-shadow: 0 0 0 3px rgba(255, 64, 0, 0.15);
}

.blog-search-input::placeholder {
  color: #B8AFA6;
}

@media (min-width: 640px) {
  .blog-search-input {
    width: 240px;
  }
}

/* ---- Blog post card ---- */
.blog-card {
  background-color: #FFFFFF;
  border: 1px solid #F8DBC0;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.blog-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 64, 0, 0.3);
  box-shadow: 0 16px 32px -16px rgba(250, 170, 141, 0.5);
}

.blog-card-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.blog-card-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.08) 100%);
}

.blog-card-cover .emoji {
  font-size: 4rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.18));
  position: relative;
  z-index: 1;
}

.blog-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.blog-category-mini {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  background-color: rgba(255, 64, 0, 0.1);
  color: #FF4000;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  align-self: flex-start;
}

.blog-card-title {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #201E1F;
  line-height: 1.3;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-excerpt {
  font-size: 13px;
  color: #4A4548;
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #8E8588;
  padding-top: 10px;
  border-top: 1px solid #F8DBC0;
}

.blog-card-meta .sep { color: #C0B5A8; }

/* ---- Sidebar widget ---- */
.sidebar-widget {
  background-color: #FFFFFF;
  border: 1px solid #F8DBC0;
  border-radius: 22px;
  padding: 20px;
}

.sidebar-popular-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F8DBC0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.sidebar-popular-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.sidebar-popular-item:first-child {
  padding-top: 0;
}

.sidebar-popular-item:hover {
  opacity: 0.7;
}

.sidebar-popular-cover {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-popular-info {
  flex: 1;
  min-width: 0;
}

.sidebar-popular-info .title {
  font-size: 13px;
  font-weight: 600;
  color: #201E1F;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-popular-info .meta {
  font-size: 11px;
  color: #8E8588;
}

/* ---- Post detail modal ---- */
.post-detail-modal {
  background-color: #FFFFFF;
  border-radius: 28px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalScaleIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  scrollbar-width: thin;
}

.post-detail-modal::-webkit-scrollbar { width: 8px; }
.post-detail-modal::-webkit-scrollbar-thumb { background: #F2C5A5; border-radius: 4px; }
.post-detail-modal::-webkit-scrollbar-track { background: transparent; }

.post-detail-close {
  /* sticky trong khối cuộn (.post-detail-modal) → nút ✕ luôn thấy khi cuộn bài dài.
     margin-left:auto canh phải (KHÔNG dùng float để tránh ép hẹp ảnh cover);
     margin-bottom âm để nút không chiếm chỗ, nằm đè lên góc trên phải cover. */
  position: sticky;
  top: 12px;
  z-index: 20;
  margin: 12px 12px -44px auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid #F2C5A5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #4A4548;
  transition: background-color 0.2s ease, color 0.2s ease;
  font-family: inherit;
}

.post-detail-close:hover {
  background-color: #FF4000;
  color: #FEEFDD;
  border-color: #FF4000;
}

.post-detail-cover {
  aspect-ratio: 16 / 7;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.post-detail-cover .emoji {
  font-size: 5rem;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.25));
}

.post-detail-body {
  padding: 28px;
}

@media (min-width: 640px) {
  .post-detail-body { padding: 36px; }
}

.post-detail-content p {
  font-size: 15px;
  color: #4A4548;
  line-height: 1.7;
  margin-bottom: 14px;
}

.post-detail-content p:last-child { margin-bottom: 0; }

.post-detail-content strong {
  color: #201E1F;
  font-weight: 700;
}

.post-detail-content em {
  color: #8E8588;
  font-style: italic;
}

/* ---- Reader typography (Bug 6 — rich content h2/h3/list/quote/link/img) ---- */
.post-detail-content {
  font-size: 15px;
  line-height: 1.75;
  color: #4A4548;
}

.post-detail-content h2,
.post-detail-content h3,
.post-detail-content h4 {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: #201E1F;
  font-weight: 700;
  line-height: 1.25;
  margin: 28px 0 12px;
}

.post-detail-content h2 { font-size: 22px; letter-spacing: -0.01em; }
.post-detail-content h3 { font-size: 18px; }
.post-detail-content h4 { font-size: 16px; }
.post-detail-content > h2:first-child,
.post-detail-content > h3:first-child { margin-top: 0; }

.post-detail-content ul,
.post-detail-content ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.post-detail-content ul { list-style: disc; }
.post-detail-content ol { list-style: decimal; }

.post-detail-content li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.post-detail-content li::marker { color: #FF4000; }

.post-detail-content a {
  color: #FF4000;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
  word-break: break-word;
}

.post-detail-content a:hover { color: #C73000; }

.post-detail-content blockquote {
  margin: 20px 0;
  padding: 4px 18px;
  border-left: 3px solid #FF4000;
  background-color: rgba(255, 64, 0, 0.05);
  border-radius: 0 10px 10px 0;
  color: #4A4548;
  font-style: italic;
}

.post-detail-content blockquote p:last-child { margin-bottom: 0; }

.post-detail-content img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  margin: 18px 0;
  display: block;
}

.post-detail-content hr {
  border: 0;
  border-top: 1px solid #F2C5A5;
  margin: 24px 0;
}

.post-detail-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background-color: rgba(80, 178, 192, 0.12);
  color: #201E1F;
  padding: 2px 6px;
  border-radius: 6px;
}

.post-detail-content pre {
  background-color: #201E1F;
  color: #FEEFDD;
  padding: 16px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 18px 0;
  font-size: 13px;
  line-height: 1.6;
}

.post-detail-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

/* ---- Load more button (Bug 9 — pagination) ---- */
.blog-load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 26px;
  border-radius: 9999px;
  background-color: #FFFFFF;
  border: 1px solid #F2C5A5;
  color: #201E1F;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.blog-load-more:hover {
  border-color: #FF4000;
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -12px rgba(255, 64, 0, 0.4);
}

.blog-load-more:active { transform: translateY(0); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .blog-hero,
  .blog-card,
  .post-detail-modal,
  .blog-search-input,
  .post-detail-close,
  .blog-load-more {
    transition: none !important;
    animation: none !important;
  }
  .blog-hero:hover,
  .blog-card:hover,
  .blog-load-more:hover {
    transform: none !important;
  }
}


/* ==================== Blog typography (S12.1 — admin auto-format text) ==================== */
/* Apply to <p> wraps generated by plainTextToBlogHTML(). Render trong post-detail-modal
   của blog.html cũng như preview admin. Override post-detail-content p với justify. */
.blog-justify {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  line-height: 1.75;
  font-size: 15px;
  color: #4A4548;
  margin-bottom: 14px;
}

.blog-justify:last-child { margin-bottom: 0; }

.blog-justify strong {
  color: #201E1F;
  font-weight: 700;
}

.blog-justify em {
  color: #8E8588;
  font-style: italic;
}

/* Mobile: bỏ justify để tránh khoảng trắng quá lớn giữa từ */
@media (max-width: 640px) {
  .blog-justify {
    text-align: left;
    hyphens: none;
  }
}

