/* MEDIPHARM Clinical Q&A v10.5.8 — Desktop Taxonomy Grid Reflow Hotfix
   Exact parent: v10.5.7 Refined Contrast & Hero Border Consistency Hotfix.
   Scope: layout only. No clinical corpus, importer, REST, routing or access-control changes.

   Root cause fixed:
   the foundation desktop rule (.mcqa-app .mcqa-magazine-grid) retained a 3-column
   taxonomy grid because it had higher selector specificity than the v10 editorial rule.
   On disease-group pages where each topic contains only one question, that left two
   empty tracks and visually compressed each Q&A card into a narrow vertical column.
*/

/* Desktop taxonomy/topic sections are intentionally capped at two readable columns.
   Sparse rows expand instead of reserving empty grid tracks. */
@media (min-width:1200px){
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    grid-auto-flow:row!important;
    width:100%!important;
    max-width:none!important;
    min-width:0!important;
    gap:clamp(12px,1.15vw,20px)!important;
    justify-items:stretch!important;
    align-items:stretch!important;
  }

  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card{
    width:100%!important;
    max-width:none!important;
    min-width:0!important;
    justify-self:stretch!important;
  }

  /* One-question topic: use the complete row instead of occupying 1/3 or 1/2. */
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card:only-child{
    grid-column:1/-1!important;
  }

  /* Avoid an orphan narrow card when a topic has an odd number of questions. */
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card:nth-child(odd):last-child:not(:only-child){
    grid-column:1/-1!important;
  }

  /* Full-row cards still keep a readable clinical line length while the visual card
     itself spans the module, so the page no longer looks like a thin left column. */
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card:only-child .mcqa-entry-answer .mcqa-answer-blocks,
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card:nth-child(odd):last-child:not(:only-child) .mcqa-entry-answer .mcqa-answer-blocks{
    max-width:104ch!important;
  }
}

/* Tablet already used auto-fit, but keep the same sparse-row contract explicitly. */
@media (min-width:768px) and (max-width:1199px){
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid{
    grid-template-columns:repeat(auto-fit,minmax(min(330px,100%),1fr))!important;
    width:100%!important;
    max-width:none!important;
  }
  #mcqa-app.mcqa-app .mcqa-tax-section .mcqa-magazine-grid>.mcqa-card{
    width:100%!important;
    max-width:none!important;
    min-width:0!important;
  }
}
