/* === Kitchen Recipes: RIGHT RAIL list/grid only === */
/* Scope: body[data-page="recipes"] #rightColumn */

/* Neutralize foreign rail layouts when any right-rail grid exists */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn:has(.rc-rail-grid){
  display: block !important;
}

/* Align the rail chip grid with the top of the first Recipe Card section (adjust if needed) */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn #apothecaryButtons{
  margin-top: 3.25rem !important;
}


/* Ensure right-rail rail-grid is actually a grid even without .rc-wrap */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .rc-rail-grid{
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  gap: 0.75rem !important;
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  grid-auto-rows: auto !important; /* lock against stray overrides */
  align-items: start !important;
}

/* Kitchen & Recipes pages: right-rail UL/VM lists render as a 12-col brick grid */
:is(body[data-page="kitchen"], body[data-page="recipes"]) #rightColumn :is(ul, .vm-list){
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  padding: 0 !important;
  gap: 0.75rem !important;
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  align-items: start !important;
  grid-auto-flow: row dense !important;
}

/* If there is an intermediate wrapper between the rail grid and the chips,
   give THAT wrapper spacing so pills never touch. This does not unhide anything. */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .rc-rail-grid > :is(div, section, nav, article):has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
  align-items: flex-start !important;
}

/* Bootstrap btn-group wrapper also needs spacing when used for chips */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .rc-rail-grid > .btn-group:has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
}

/* --- Right rail: neutralize Bootstrap btn-group compaction everywhere --- */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group:has(.hub-btn, .vm-link){
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
  gap: 0.75rem !important;
}


/* Kill Bootstrap’s negative margin joiners that remove spacing */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group > .btn:not(:first-child),
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group > .btn-group:not(:first-child){
  margin-left: 0 !important;
}

/* Avoid double spacing: inside btn-group, use container gap only */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group .hub-btn,
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group .vm-link,
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn-group .btn{
  margin: 0 !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
}


/* Provide minimal external whitespace so pills never touch even if a grid isn't applied yet */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .rc-rail-grid .hub-btn{
  margin: 0.375rem !important;
}


/* Desktop: 3-up rail cards */
@media (min-width: 992px){
  :is(body[data-page="recipes"], body[data-page="kitchen"]) .rc-wrap .rc-rail-grid > .rc-card{
    grid-column: span 4;
  }
}

/* HARD STOP: right-rail buttons never stretch full width */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .hub-btn,
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .btn.hub-btn{
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
}

/* Unified brick grid for any lists rendered in the right rail */
/* Items: 2-up on mobile (span 6), 3-up on lg+ (span 4) */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn ul > li,
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .vm-list > li{
  list-style: none;
  margin: 0;
  padding: 0;
  grid-column: span 6 !important; /* 2-up mobile */
  break-inside: avoid;
}
@media (min-width: 992px){
  :is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn ul > li,
  :is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .vm-list > li{
    grid-column: span 4 !important; /* 3-up desktop */
  }
}




/* Links/pills inside rail items: never stretch; spacing from grid only */
body[data-page="recipes"] #rightColumn ul > li > .vm-link,
body[data-page="recipes"] #rightColumn ul > li > .hub-btn,
body[data-page="recipes"] #rightColumn .vm-list > li > .vm-link,
body[data-page="recipes"] #rightColumn .vm-list > li > .hub-btn{
  display: inline-flex !important;
  width: auto !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  justify-self: start !important;
  margin: 0.375rem !important; /* yields 0.75rem between adjacent pills */
}

/* FINAL WORD: enforce the 0.75rem spacing on any right-rail grid */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn :is(.rc-rail-grid, ul, .vm-list){
  row-gap: 0.75rem !important;
  column-gap: 0.75rem !important;
  gap: 0.75rem !important;
}

/* Rail recipe cards: width hygiene */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn .rc-card{
  width: auto;
  max-width: 100%;
}
/*  Neutralize accidental container-wide display that can force stretching */
:is(body[data-page="recipes"], body[data-page="kitchen"]) #rightColumn{
  align-items: start !important;
  justify-items: start !important;
}

