/* ==========================================================================
   Utsho — digest.css
   Shared page-scoped styles for pages/digest.html AND
   pages/digest-article.html — they're one visual system (a magazine
   listing page and its article template), so one stylesheet covers
   both rather than duplicating the hero/tag/typography rules twice.
   ========================================================================== */

:root {
  --vivid-green: #16A34A;
  --vivid-green-light: #22C55E;
  --vivid-green-tint: #DCFCE7;
}

/* ==========================================================================
   Hero (listing page only) — same blob-wash background as Dashboard,
   Competitions, and Concept Bank, with a Digest-specific illustration.
   ========================================================================== */
.page-header--digest {
  position: relative;
  overflow: hidden;
  background-color: var(--card);
  background-image: url('../assets/dashboard-hero-blobs.webp');
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-10) var(--space-8) !important;
  min-height: 280px;
}
.digest-hero-content { max-width: 46ch; flex: 1 1 380px; }
.digest-hero-visual { flex: 0 0 auto; width: clamp(180px, 24vw, 280px); display: flex; justify-content: center; }
.digest-hero-visual img { width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(30, 22, 15, 0.16)); }
@media (max-width: 720px) {
  .page-header--digest { flex-direction: column; text-align: center; min-height: 0; }
  .digest-hero-content { max-width: none; }
  .digest-hero-visual { width: 160px; }
}

.section-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 var(--space-2);
}
.section-eyebrow::before { content: ""; width: 28px; height: 1px; background: currentColor; opacity: 0.55; flex-shrink: 0; }
@media (max-width: 720px) { .section-eyebrow { justify-content: center; } }
.digest-hero-content h1 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); }
.digest-hero-content .lede { margin-top: var(--space-3); }

/* ---- Category filter pills ---- */
.digest-filterbar { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-6) 0; }
.digest-pill {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: var(--space-2) var(--space-4); font-size: 0.85rem;
  cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.digest-pill:hover { transform: translateY(-1px); }
.digest-pill--active { color: #FFFFFF; border-color: transparent; background: var(--text); box-shadow: 0 8px 18px rgba(30, 22, 15, 0.22); }

/* ---- Category tag colors — shared by cards on the listing page and
   the badge on the article page ---- */
.tag--science       { background: var(--sky); }
.tag--world         { background: var(--clay-brown); }
.tag--study-tips    { background: var(--vivid-green-light); }
.tag--announcements { background: var(--gold); }
.tag--other         { background: var(--border-strong); color: var(--text); }

/* ==========================================================================
   Featured story — one large horizontal card above the regular grid.
   ========================================================================== */
.digest-featured {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(30, 22, 15, 0.08);
  margin-bottom: var(--space-8);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.digest-featured:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(30, 22, 15, 0.14); }
@media (min-width: 800px) { .digest-featured { display: grid; grid-template-columns: 1.15fr 1fr; align-items: stretch; } }

.digest-featured__image-wrap { position: relative; aspect-ratio: 16 / 9; background: var(--bg-deep); }
@media (min-width: 800px) { .digest-featured__image-wrap { aspect-ratio: auto; min-height: 100%; } }
.digest-featured__image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.digest-featured__image-wrap.digest-no-image { display: flex; align-items: center; justify-content: center; background: var(--gradient-hero-bg); }

.digest-featured__body { padding: var(--space-8); display: flex; flex-direction: column; justify-content: center; gap: var(--space-3); }
.digest-featured__eyebrow { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.digest-featured__title { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; color: var(--text); margin: 0; }
.digest-featured__excerpt { color: var(--muted); font-size: 1rem; line-height: 1.6; margin: 0; }
.digest-featured__meta { display: flex; gap: var(--space-3); font-size: 0.82rem; color: var(--muted); flex-wrap: wrap; margin-top: var(--space-2); }

/* ==========================================================================
   Regular grid
   ========================================================================== */
.digest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-6); }

.digest-card {
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 0 1px 2px rgba(30, 22, 15, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.digest-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(30, 22, 15, 0.12); }

.digest-card__image-wrap { position: relative; aspect-ratio: 16 / 10; background: var(--bg-deep); overflow: hidden; }
.digest-card__image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.digest-card__image-wrap.digest-no-image { display: flex; align-items: center; justify-content: center; background: var(--gradient-hero-bg); }
.digest-card__image-wrap.digest-no-image svg { width: 34px; height: 34px; color: var(--primary); opacity: 0.5; }

.digest-card__category {
  position: absolute; left: var(--space-3); bottom: var(--space-3);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #FFFFFF; padding: 4px 12px; border-radius: 999px;
}

.digest-card__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.digest-card__title { font-family: var(--font-display); font-size: 1.12rem; line-height: 1.32; color: var(--text); }
.digest-card__excerpt {
  color: var(--muted); font-size: 0.9rem; line-height: 1.55; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.digest-card__meta { margin-top: auto; padding-top: var(--space-2); font-size: 0.78rem; color: var(--muted); }

.digest-empty, .digest-loading, .digest-error { text-align: center; color: var(--muted); padding: var(--space-12) 0; grid-column: 1 / -1; }

/* ==========================================================================
   Article page (digest-article.html)
   ========================================================================== */
.digest-back-link {
  display: flex; align-items: center; gap: 6px; width: fit-content;
  color: var(--muted); font-size: 0.88rem; text-decoration: none; margin-bottom: var(--space-4);
}
.digest-back-link:hover { color: var(--primary); }
.digest-back-link svg { width: 15px; height: 15px; }

/* Variant 1: full-bleed cover image behind the title, dark gradient
   for legibility — used when the owner opts into it per-article. */
.digest-article-hero--image {
  position: relative;
  min-height: 400px;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
  margin: 0 calc(50% - 50vw) var(--space-10);
  padding: var(--space-10) var(--page-padding-x) var(--space-8);
}
.digest-article-hero--image::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(30, 22, 15, 0) 15%, rgba(20, 14, 8, 0.82) 100%);
}
.digest-article-hero--image__inner { position: relative; z-index: 1; max-width: var(--content-max-width); margin: 0 auto; width: 100%; }
.digest-article-hero--image .digest-back-link { color: rgba(255, 255, 255, 0.85); }
.digest-article-hero--image .digest-back-link:hover { color: #FFFFFF; }
.digest-article-hero--image .digest-article__title { color: #FFFFFF; }
.digest-article-hero--image .digest-article__meta { color: rgba(255, 255, 255, 0.82); }

/* Variant 2: plain — same shape as every other page-header on the site */
.digest-article-hero--plain { padding: var(--space-10) 0 var(--space-2); max-width: 70ch; }

.digest-article__category {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #FFFFFF; padding: 4px 14px; border-radius: 999px; margin-bottom: var(--space-3);
}
.digest-article__title { font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.16; margin: 0 0 var(--space-3); }
.digest-article__meta { display: flex; gap: var(--space-3); font-size: 0.88rem; color: var(--muted); flex-wrap: wrap; }

.digest-article-body { max-width: 68ch; margin: var(--space-8) auto 0; font-size: 1.05rem; line-height: 1.75; color: var(--text); }
.digest-article-body h2 { font-family: var(--font-display); font-size: 1.4rem; margin: var(--space-8) 0 var(--space-3); }
.digest-article-body h3 { font-family: var(--font-display); font-size: 1.15rem; margin: var(--space-6) 0 var(--space-2); }
.digest-spacer { height: var(--space-4); }
.digest-article-body p { margin: 0 0 var(--space-4); }
.digest-article-body ul, .digest-article-body ol { padding-left: 24px; margin: 0 0 var(--space-4); }
.digest-article-body li { margin-bottom: var(--space-2); }
.digest-article-body hr { border: none; border-top: 1px solid var(--border); margin: var(--space-8) 0; }
.digest-article-body img { width: 100%; border-radius: var(--radius-lg); margin: var(--space-6) 0; box-shadow: 0 12px 28px rgba(30, 22, 15, 0.12); }
.digest-article-body a { color: var(--primary); text-decoration: underline; }
.digest-article-body blockquote {
  margin: var(--space-6) 0; padding: 2px 0 2px var(--space-6);
  border-left: 4px solid var(--primary);
  font-family: var(--font-display); font-style: italic; font-size: 1.25rem; line-height: 1.5; color: var(--text);
}

.digest-article-loading, .digest-article-error { text-align: center; color: var(--muted); padding: var(--space-16) 0; }

@media (max-width: 640px) {
  .digest-filterbar { justify-content: center; }
}
