/* Blog - cards & hero (site idiom) + light theme for rich markdown content.
   Layout/overflow rules for .article-content come from chat-rich-content.css
   (specificity-0 :where() selectors); this file only overrides the THEME. */

/* ── Blog list : featured article ── */
.blog-featured-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.blog-featured-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.blog-featured-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  background: var(--primary-gradient);
}

.blog-featured-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: var(--primary-gradient);
  color: rgba(255, 255, 255, 0.85);
  font-size: 3.5rem;
}

.blog-featured-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--spacing-lg, 2rem);
}

/* ── Blog list : full-viewport featured hero ──
   The first screen is entirely devoted to the featured article so the card
   is fully visible without scrolling. Height uses svh (stable small viewport)
   so mobile browser chrome never crops the card. */
.blog-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(74px + clamp(0.75rem, 2.5vh, 1.75rem)) 0 clamp(0.75rem, 2vh, 1.5rem);
  overflow: hidden;
}

.blog-hero-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: clamp(0.75rem, 2.5vh, 1.75rem);
}

.blog-hero-header {
  flex: 0 0 auto;
}

.blog-hero-title {
  margin: clamp(0.35rem, 1vh, 0.75rem) 0 0;
  font-size: clamp(1.35rem, 1.05rem + 2.2vw, 2.6rem);
  line-height: 1.15;
  text-wrap: balance;
}

.blog-hero-intro {
  max-width: 720px;
  margin: clamp(0.35rem, 1vh, 0.65rem) auto 0;
  font-size: clamp(0.82rem, 0.75rem + 0.35vw, 1rem);
  color: var(--text-muted);
}

.blog-hero-card {
  display: grid;
  grid-template-rows: minmax(0, 0.42fr) minmax(0, 0.58fr);
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.blog-hero-media {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.blog-hero-card .blog-featured-cover,
.blog-hero-card .blog-featured-cover-placeholder {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
}

.blog-hero-body {
  min-height: 0;
  overflow: hidden;
  justify-content: center;
  padding: clamp(1rem, 2.5vh, 2rem) clamp(1.1rem, 2.5vw, 2.4rem);
}

.blog-hero-card .blog-category-badge,
.blog-hero-card .blog-draft-badge {
  margin-bottom: clamp(0.4rem, 1vh, 0.75rem);
}

.blog-hero-title-card {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: clamp(0.4rem, 1vh, 0.75rem);
  font-size: clamp(1.15rem, 1rem + 0.9vw, 1.9rem);
}

.blog-hero-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 0 1 auto;
  margin-bottom: clamp(0.4rem, 1.2vh, 0.9rem);
}

.blog-hero-meta {
  margin-bottom: clamp(0.6rem, 1.6vh, 1.1rem);
}

.blog-hero-cta {
  flex: 0 0 auto;
}

/* Landscape: split the card so cover and text share the full width. */
@media (min-width: 768px) {
  .blog-hero-card {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .blog-hero-excerpt {
    -webkit-line-clamp: 5;
  }
}

/* Keep the card whole on short or narrow viewports. */
@media (max-width: 767.98px) {
  .blog-hero-card {
    grid-template-rows: minmax(0, 0.38fr) minmax(0, 0.62fr);
  }

  .blog-hero-title-card {
    -webkit-line-clamp: 2;
  }

  .blog-hero-excerpt {
    -webkit-line-clamp: 2;
  }
}

@media (max-height: 680px) {
  .blog-hero-intro {
    display: none;
  }

  .blog-hero-excerpt {
    -webkit-line-clamp: 2;
  }
}

@media (max-height: 560px) {
  .blog-hero .blog-hero-excerpt {
    display: none;
  }

  .blog-hero-title {
    font-size: clamp(1.1rem, 1rem + 1.4vw, 1.6rem);
  }
}

.blog-archive {
  padding-top: clamp(2rem, 5vh, 4rem);
}

/* ── Blog list : article cards ── */
.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.blog-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.blog-card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--primary-gradient);
}

.blog-card-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--primary-gradient);
  color: rgba(255, 255, 255, 0.85);
  font-size: 2.25rem;
}

.blog-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--spacing-md, 1.5rem);
}

.blog-card-title {
  font-size: var(--font-size-lg, 1.25rem);
  font-weight: 700;
  color: var(--text-emphasis);
  line-height: 1.3;
}

.blog-card-title a {
  color: inherit;
  text-decoration: none;
}

.blog-card-title a:hover {
  color: var(--primary-dark);
}

.blog-card-excerpt {
  color: var(--text-muted);
  font-size: var(--font-size-sm, 0.9rem);
  flex: 1;
}

.blog-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.25rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: var(--border-radius-pill);
}

/* Draft badge: visible to staff/admin only (template-gated) */
.blog-draft-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.25rem 0.75rem;
  margin-bottom: 0.75rem;
  margin-left: 0.5rem;
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9a6b00;
  background: #fdf3e0;
  border: 1px solid rgba(217, 145, 22, 0.45);
  border-radius: var(--border-radius-pill);
}

.blog-card-meta,
.blog-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: var(--font-size-xs, 0.8rem);
}

.blog-card-meta i,
.blog-article-meta i {
  margin-right: 0.3rem;
  color: var(--primary-color);
}

/* ── Blog list : pagination ── */
.blog-pagination .page-link {
  min-width: 2.5rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-weight: 600;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: var(--border-radius-md);
}

.blog-pagination .page-link:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
  border-color: var(--primary-color);
}

.blog-pagination .page-item.active .page-link {
  color: #fff;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.blog-pagination .page-item.disabled .page-link {
  color: var(--text-muted);
  background: transparent;
  border-color: rgba(var(--primary-rgb), 0.12);
  opacity: 0.6;
}

/* ── Article detail ── */
.blog-article-header {
  padding: calc(var(--spacing-xl, 5rem) + 2rem) 0 var(--spacing-md, 1.5rem);
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--page-bg) 100%);
}

.blog-article-title {
  font-size: var(--font-size-3xl, 2.5rem);
  font-weight: 800;
  color: var(--text-emphasis);
  line-height: 1.15;
  text-wrap: balance;
}

.blog-article-cover {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
}

.blog-breadcrumb {
  font-size: var(--font-size-sm, 0.875rem);
}

.blog-breadcrumb a {
  color: var(--primary-dark);
  text-decoration: none;
}

.blog-breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Rich markdown content : LIGHT theme (scoped .article-content) ── */
.article-content {
  color: var(--text-color);
  font-size: 1.02rem;
  line-height: 1.75;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  margin: 1.8rem 0 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-emphasis);
}

.article-content h1:first-child,
.article-content h2:first-child,
.article-content h3:first-child {
  margin-top: 0;
}

.article-content h2 {
  font-size: 1.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.14);
}

.article-content h3 {
  font-size: 1.3rem;
}

.article-content h4 {
  font-size: 1.1rem;
}

.article-content p {
  margin: 0 0 1.1rem;
}

.article-content a {
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.article-content a:hover {
  color: var(--accent-color);
}

.article-content ul,
.article-content ol {
  margin: 0 0 1.1rem;
  padding-left: 1.5rem;
}

.article-content li {
  margin-bottom: 0.35rem;
}

.article-content blockquote {
  margin: 1.2rem 0;
  padding: 0.8rem 1.2rem;
  border-left: 4px solid var(--primary-color);
  background: var(--primary-light);
  border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
  color: var(--text-color);
}

.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.2rem auto;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}

.article-content hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid rgba(var(--primary-rgb), 0.18);
}

/* Inline code : light chip. Code BLOCKS stay dark (atom-one-dark, like chat). */
.article-content code {
  padding: 0.12rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--primary-dark);
  background: var(--primary-light);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  border-radius: 6px;
}

.article-content pre {
  overflow: auto;
  margin: 1.2rem 0;
  padding: 14px;
  background: #081824;
  border: 1px solid rgba(7, 21, 33, 0.4);
  border-radius: var(--border-radius-md);
}

.article-content pre code {
  padding: 0;
  color: #dbeafe;
  background: transparent;
  border: 0;
}

/* Tables : light */
.article-content .table-wrap {
  margin: 1.2rem 0;
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}

.article-content table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.article-content th,
.article-content td {
  padding: 0.6rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(var(--primary-rgb), 0.1);
}

.article-content thead th {
  font-weight: 700;
  color: var(--text-emphasis);
  background: var(--primary-light);
}

.article-content tbody tr:hover {
  background: rgba(var(--primary-rgb), 0.05);
}

/* Callouts : light variants (structure from chat-utils.js transformCallouts) */
.article-content .md-callout {
  margin: 1.2rem 0;
  padding: 0.9rem 1.1rem;
  border-radius: var(--border-radius-md);
  border: 1px solid;
  background: #fff;
}

.article-content .md-callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.article-content .md-callout-icon {
  display: inline-flex;
  width: 1.1rem;
  height: 1.1rem;
}

.article-content .md-callout-body > :last-child {
  margin-bottom: 0;
}

.article-content .md-callout-note {
  border-color: rgba(var(--primary-rgb), 0.35);
  background: var(--primary-light);
}

.article-content .md-callout-note .md-callout-title {
  color: var(--primary-dark);
}

.article-content .md-callout-tip {
  border-color: rgba(25, 131, 111, 0.35);
  background: #e6f6f2;
}

.article-content .md-callout-tip .md-callout-title {
  color: var(--secondary-color);
}

.article-content .md-callout-important {
  border-color: rgba(41, 86, 215, 0.35);
  background: #e9effc;
}

.article-content .md-callout-important .md-callout-title {
  color: var(--accent-color);
}

.article-content .md-callout-warning {
  border-color: rgba(217, 145, 22, 0.4);
  background: #fdf3e0;
}

.article-content .md-callout-warning .md-callout-title {
  color: #a86e0d;
}

.article-content .md-callout-danger {
  border-color: rgba(200, 40, 40, 0.35);
  background: #fdeaea;
}

.article-content .md-callout-danger .md-callout-title {
  color: #b02525;
}

/* Mermaid / Chart.js blocks : light surfaces */
.article-content .mermaid-block,
.article-content .chart-block {
  margin: 1.4rem 0;
  padding: 1.2rem;
  background: #fff;
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}

.article-content .mermaid-error,
.article-content .chart-error {
  margin: 1.2rem 0;
  padding: 0.9rem 1.1rem;
  color: #b02525;
  background: #fdeaea;
  border: 1px solid rgba(200, 40, 40, 0.35);
  border-radius: var(--border-radius-md);
}

.article-content .mermaid-pending,
.article-content .chart-pending {
  display: none;
}

/* Copy / PNG buttons : visible on light surfaces */
.article-content .code-block {
  position: relative;
}

.article-content .code-copy-btn,
.article-content .mermaid-png-btn,
.article-content .chart-png-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.article-content .code-block:hover .code-copy-btn,
.article-content .mermaid-block:hover .mermaid-png-btn,
.article-content .chart-block:hover .chart-png-btn {
  opacity: 1;
}

.article-content .code-copy-btn:hover,
.article-content .mermaid-png-btn:hover,
.article-content .chart-png-btn:hover {
  color: var(--primary-dark);
  border-color: var(--primary-color);
}

.article-content .code-copy-btn svg,
.article-content .mermaid-png-btn svg,
.article-content .chart-png-btn svg {
  width: 0.9rem;
  height: 0.9rem;
}

@media (max-width: 575.98px) {
  .article-content .code-copy-btn,
  .article-content .mermaid-png-btn,
  .article-content .chart-png-btn {
    opacity: 1;
  }

  .blog-article-title {
    font-size: var(--font-size-2xl, 1.9rem);
  }
}
