/* ===========================================================
   ARTICLES.CSS — CONSOLIDATED (BEST VERSION + FINAL FIXES)
   Focus:
   - Library grid + top-entry layout
   - EMM library SVG fills the card image area on iPhone/iPad (no crop, no overlap)
   - MAIN single logo ~60% bigger (new asset: MAIN-logo.svg)
   - MAIN-only CTA centered (styles)
   =========================================================== */


/* ===========================================================
   1) SINGLE — SPACING
   =========================================================== */
.single-articles h1.article-title{
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 85px;
}
.article-image img{
  margin-top: 1em;
  margin-bottom: 1em;
}

.custom-author,
.month-year,
.pub-name{
  margin: 0.5rem 0;
}

.pub-name a{
  text-decoration: underline;
  font-weight: normal;
  transition: color 0.2s ease, font-weight 0.2s ease;
}

.pub-name a:hover{
  color: #333;
  font-weight: 600;
}

/* Harvest / MAIN single logos */
.single-auto-logo{
  margin: 0.75rem 0;
}

.single-auto-logo img{
  height: 85px;
  width: auto;
  display: block;
}

.single-pub-logo{
  margin: 0.75rem 0 0.5rem;
  line-height: 0;
}

.single-pub-logo img{
  max-height: 60px;
  width: auto;
  display: block;
}

/* MAIN logo — single view only */
.single .single-pub-logo img[src*="MAIN-logo.svg"]{
  height: 220px !important;
  width: auto !important;
  max-height: none !important;
  margin-left: 0 !important;
  margin-right: auto !important;
  display: block;
}
/* ===========================================================
   2) PDF LINK
   =========================================================== */

a[href$=".pdf"]{
  padding-left: 36px;
  background: url("/wp-content/themes/astra-child/assets/download-icon-128.png") no-repeat left 4px;
  background-size: 32px 32px;
  text-decoration: underline;
  font-weight: normal;
  line-height: 36px;
  display: inline-block;
  margin: 0.5em 0 1.5em 0;
}

a[href$=".pdf"]:hover{
  color: #222;
  font-weight: 600;
}

/* ===========================================================
   3) LIBRARY — TOP ENTRY (side-by-side)
   =========================================================== */

.top-entry-wrapper{
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.top-entry-image{
  flex: 0 0 40%;
  max-width: 40%;
}

.top-entry-text{
  flex: 1 1 60%;
  max-width: 60%;
}

/* Keep images uncropped and prevent bleed/overlap */
.top-entry-image,
.grid-image{
  height: auto !important;
  max-height: none !important;
  overflow: hidden !important;
}

.top-entry-image img,
.grid-image img{
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  border-radius: 0 !important;

  /* consistent centering */
  margin-left: auto !important;
  margin-right: auto !important;

  /* ensure no leftover transform rules can cause overlap */
  transform: none !important;
}

/* Top entry image size */
.top-entry-image img{
  width: 100% !important;
  height: auto !important;
  max-height: 420px !important;
  object-fit: contain !important;
  object-position: center center !important;
}

/* Top entry title hover matches grid title hover */
h3.top-entry-title a:hover{
  color: #003798;
  text-decoration-line: underline !important;
}
h3.top-entry-title {
  line-height: 32px !important;
}

/* ===========================================================
   4) LIBRARY — GRID (cards)
   =========================================================== */

.articles-grid{
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  margin-top: 2rem;
}

@media (min-width: 600px){
  .articles-grid{
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px){
  .articles-grid{
    grid-template-columns: repeat(3, 1fr);
  }
}

.article-grid-entry{
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: #fff;
  border: 1px solid #eee;
  transition: box-shadow 0.2s ease;
}

.article-grid-entry:hover{
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.grid-image{
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;

  padding: 0.2rem;
  margin-bottom: 0.3rem;

  /* baseline "frame" height so cards feel consistent */
  min-height: 170px;
}

@media (min-width: 960px){
  .grid-image{
    min-height: 190px;
  }
}

h5.grid-title a{
  font-size: 1.1rem;
  font-weight: 600;
  color: #020276;
  text-decoration: none;
}

h5.grid-title a:hover{
  color: #003798;
  text-decoration: underline;
}

.grid-blurb{
  font-size: 0.80rem;
  line-height: 1.3;
  color: #333;
  margin: -0.3rem 0 1rem;
}

h6.grid-meta{
  font-size: 0.85rem;
  color: #000;
  margin: 0.25rem 0 0;
}

/* ===========================================================
   5) LIBRARY — LIST (two-line)
   =========================================================== */

.articles-list-wrapper{
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.article-list-entry{
  margin-bottom: 1.5rem;
}

/* Title line */
h5.article-title a{
  font-size: 1.1rem;
  font-weight: 600;
  color: #020276;
}

/* Pub line */
.pub-line{
  font-size: 0.9rem;
  color: #666;
  line-height: 1.3;
}

/* Tighten spacing between the 2 lines */
.article-list-entry h5.article-title{
  margin-bottom: 0.15rem;
}

.article-list-entry .article-pub-date{
  margin-top: 0;
}

/* ===========================================================
   6) SOURCE-SPECIFIC IMAGE TWEAKS
   =========================================================== */

/* Harvest + Other (stock photos) */
.article-grid-entry.source-hrvst .grid-image img,
.article-grid-entry.source-other .grid-image img{
  width: 100% !important;
  height: auto !important;
  max-height: 260px !important;
  object-fit: contain !important;
  object-position: center center !important;
}

/* EMM logo sizing — separate controls */
/* 1) Singles */
.single-articles img[src*="emm-logo.svg"]{
  height: 70px !important;
  width: auto !important;
  max-width: none !important;
}

/* 2) /library fallback behavior (works everywhere)
   Baseline: treat like stock image (no crop) */
.top-entry-wrapper img[src*="emm-logo-library.svg"],
.article-grid-entry img[src*="emm-logo-library.svg"]{
  width: 100% !important;
  height: auto !important;
  max-height: 260px !important;
  object-fit: contain !important;
  object-position: center center !important;
}

/* Top entry can be taller */
.top-entry-wrapper img[src*="emm-logo-library.svg"]{
  max-height: 420px !important;
}

/* Tablet */
@media (max-width: 1024px){
  .top-entry-wrapper img[src*="emm-logo-library.svg"]{
    max-height: 360px !important;
  }
  .article-grid-entry img[src*="emm-logo-library.svg"]{
    max-height: 320px !important;
  }
  .grid-image{
    min-height: 210px;
  }
}

/* Mobile */
@media (max-width: 768px){
  .top-entry-wrapper img[src*="emm-logo-library.svg"]{
    max-height: 380px !important;
  }
  .article-grid-entry img[src*="emm-logo-library.svg"]{
    max-height: 360px !important;
  }
  .grid-image{
    min-height: 220px;
  }
}

/* ===========================================================
   6B) EMM library SVG — FINAL "FILL THE FRAME" SOLUTION (iPhone/iPad)
   Uses :has() to target ONLY the card(s) that contain the EMM SVG.
   This avoids touching stock photos and avoids transforms/overlap.
   =========================================================== */

@media (max-width: 1400px){

  /* Make ONLY the EMM logo card's image area a predictable "frame" */
  .articles-grid .article-grid-entry .grid-image:has(img[src*="emm-logo-library.svg"]){
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    /* fills the space without overlap */
    height: clamp(180px, 24vw, 260px) !important;
  }

  /* Make the <a> become the full-size frame */
  .articles-grid .article-grid-entry .grid-image:has(img[src*="emm-logo-library.svg"]) > a{
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Now the SVG fills that frame (still NO crop) */
  .articles-grid .article-grid-entry .grid-image img[src*="emm-logo-library.svg"]{
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    display: block !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: none !important;
  }

  /* Top entry (only if the EMM logo ever appears there too) */
  .top-entry-image:has(img[src*="emm-logo-library.svg"]){
    padding: 0 !important;
    overflow: hidden !important;
  }

  .top-entry-image:has(img[src*="emm-logo-library.svg"]) > a{
    display: flex !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .top-entry-image img[src*="emm-logo-library.svg"]{
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    display: block !important;
    object-fit: contain !important;
    object-position: center center !important;
    transform: none !important;
  }
}

/* ===========================================================
   7) RESPONSIVE CLEANUP
   =========================================================== */

@media (max-width: 900px){
  .top-entry-wrapper{
    flex-wrap: wrap;
  }
}

@media (max-width: 768px){
  .top-entry-image,
  .top-entry-text{
    flex: none;
    width: 100%;
    max-width: 100%;
  }

  .article-grid-entry.source-hrvst .grid-image img,
  .article-grid-entry.source-other .grid-image img{
    max-height: 200px !important;
  }
}

/* ===========================================================
   8) BREADCRUMBS (single)
   =========================================================== */

.breadcrumbs{
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

/* ===========================================================
   9) MAIN-only CTA (single)
   =========================================================== */

.main-cta{
  text-align: center;
  margin: 1.5rem 0 0.75rem;
}

.main-cta a{
  text-decoration: underline;
  font-weight: 600;
}
