/* Phase12 candidate only. Root must publish after current DOM + D/M proof.
 * Exact owned category classes; no global Elementor/image/commerce resets.
 * Equal-width image frames + stretched title areas keep first baselines and
 * card bottoms aligned without clipping, clamping, or shortening any title.
 */
body.kf-presentation-v12.kf-layout-v7 {
  --kf-p12-category-gap: 24px;
  --kf-p12-category-title-gap: 16px;
  --kf-p12-category-title-line: 1.4;
}

/* Native companion and the Core kf-store category block. Keep native columns. */
body.kf-presentation-v12.kf-layout-v7 :is(.kfn-category-grid__items, .category-grid, .kf-category-grid) {
  align-items: stretch;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kfn-category-grid__items > .kfn-category-card, .category-grid > .category-card, .kf-category-grid > .kf-category-card) {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: auto;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kfn-category-card > img, .kfn-category-card__placeholder, .category-grid > .category-card > img, .kf-category-grid > .kf-category-card > img) {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kfn-category-card > span:not(.kfn-category-card__placeholder), .category-grid > .category-card > span, .kf-category-grid > .kf-category-card > span) {
  display: block;
  flex: 1 0 auto;
  margin: 0;
  padding-block: var(--kf-p12-category-title-gap);
  line-height: var(--kf-p12-category-title-line);
  overflow-wrap: anywhere;
}

/* Wood companion: replace the former staggered editorial category layout. */
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-grid, .kf-room-grid, .kf-routine-grid, .kf-gear-grid) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: var(--kf-p12-category-gap);
}
body.kf-presentation-v12.kf-layout-v7 .kf-editorial-category-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-grid > .wp-block-column, .kf-room-grid > .kf-category-item, .kf-routine-grid > .kf-category-item, .kf-gear-grid > .kf-category-item):is(:nth-child(n)) {
  display: flex;
  flex-direction: column;
  grid-column: auto;
  align-self: stretch;
  min-width: 0;
  width: auto;
  max-width: none;
  margin-block: 0;
  padding-block: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-image, .kf-category-item > .kf-category-image) {
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  aspect-ratio: 1 / 1;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-image a, .kf-category-item > .kf-category-image a) {
  display: block;
  height: 100%;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-image img, .kf-category-item > .kf-category-image img) {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-grid .kf-editorial-category-title, :is(.kf-room-grid, .kf-routine-grid, .kf-gear-grid) > .kf-category-item > .kf-category-label) {
  flex: 1 0 auto;
  margin: 0;
  padding-block: var(--kf-p12-category-title-gap);
  line-height: var(--kf-p12-category-title-line);
  overflow-wrap: anywhere;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-title a, :is(.kf-room-grid, .kf-routine-grid, .kf-gear-grid) > .kf-category-item > .kf-category-label a) {
  align-items: baseline;
  min-height: 0;
  line-height: inherit;
}

/* Mini companion: owned category columns, never arbitrary Elementor columns. */
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-grid, .kf-v21-category-cards) > .elementor-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  align-items: stretch;
  gap: var(--kf-p12-category-gap);
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-grid, .kf-v21-category-cards) > .elementor-container > :is(.kf-bt-category-card, .kf-v21-category) {
  display: flex;
  min-width: 0;
  width: auto !important; /* exact owned Mini preset width is !important */
  max-width: none;
  margin: 0;
  padding: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) > .elementor-widget-wrap {
  display: flex;
  flex-direction: column;
  align-content: stretch;
  width: 100%;
  margin: 0;
  padding: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) .kf-bt-photo {
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) .kf-bt-photo :is(.elementor-widget-container, a) {
  display: block;
  width: 100%;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) .kf-bt-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin: 0;
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) :is(.kf-bt-category-title, .kf-v21-category-label) {
  flex: 1 0 auto;
  width: 100%;
  margin: 0;
  padding-block: var(--kf-p12-category-title-gap);
}
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-category-card, .kf-v21-category) :is(.kf-bt-category-title, .kf-v21-category-label) .elementor-heading-title {
  margin: 0;
  line-height: var(--kf-p12-category-title-line);
  overflow-wrap: anywhere;
}

/* Scope the new display wrapper only; keep native price amounts/tax outputs. */
body.kf-presentation-v12.kf-layout-v7 .kf-source-reference-price del {
  text-decoration: line-through;
}
body.kf-presentation-v12.kf-layout-v7 .kf-source-reference-price ins {
  text-decoration: none;
}
@media (max-width: 767px) {
  body.kf-presentation-v12.kf-layout-v7 {
    --kf-p12-category-gap: 20px 16px;
    --kf-p12-category-title-gap: 12px;
  }
  body.kf-presentation-v12.kf-layout-v7 :is(.kf-editorial-category-grid, .kf-room-grid, .kf-routine-grid, .kf-gear-grid, .kf-bt-category-grid > .elementor-container, .kf-v21-category-cards > .elementor-container) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Managed footer surfaces: consistent inner end spacing, full content retained.
 * Page-to-footer outer gaps still require Root's actual DOM/ancestor diagnosis.
 */
body.kf-presentation-v12.kf-layout-v7 :is(.kf-bt-footer,.kf-native-footer,.kf-editorial-footer,.kfn-footer-shell) {
  margin-block: 0;
  padding-block: clamp(32px,4vw,56px) 24px;
}
body.kf-presentation-v12.kf-layout-v7.kf-layout-store .site-footer {
  margin-block: 0;
  padding-block: clamp(32px,4vw,48px) 24px;
}
body.kf-presentation-v12.kf-layout-v7 .kf-footer-grid > :last-child > :last-child {
  margin-bottom: 0;
}

/* Phase12 CSS v2: text-only native category index. These are navigation labels,
 * not image cards; the heading remains a section marker, never a fake fourth
 * category. auto-fit supports the actual 3 entries and the canonical 4 entries.
 */
body.kf-presentation-v12.kf-layout-v7 .kf-category-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  align-items: stretch;
  gap: 12px var(--kf-p12-category-title-gap);
  padding-block: 24px;
}
body.kf-presentation-v12.kf-layout-v7 .kf-category-index > .kf-kicker {
  grid-column: auto;
  align-self: start;
  margin: 0;
  padding-block: 8px;
}
body.kf-presentation-v12.kf-layout-v7 .kf-category-index > .kf-category-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 0;
}
body.kf-presentation-v12.kf-layout-v7 .kf-category-index > .kf-category-item > .kf-category-label {
  flex: 1 0 auto;
  margin: 0;
  padding-block: 8px;
  line-height: var(--kf-p12-category-title-line);
  overflow-wrap: anywhere;
}
body.kf-presentation-v12.kf-layout-v7 .kf-category-index > .kf-category-item > .kf-category-label > a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  line-height: inherit;
}
@media (max-width: 767px) {
  body.kf-presentation-v12.kf-layout-v7 .kf-category-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding-block: 20px;
  }
  body.kf-presentation-v12.kf-layout-v7 .kf-category-index > .kf-kicker {
    grid-column: 1 / -1;
    padding-block: 0;
  }
}

/* Retain breathing room when the native Mini/Woo load-more control is present.
 * Existing content/footer stay native; selectors are the actual provider wrappers. */
body.kf-presentation-v12.kf-layout-v7 :is(.minimog-grid-pagination:has(.minimog-load-more-button),nav.woocommerce-pagination[data-type="load-more"],nav.woocommerce-pagination[data-type="infinite"]) {
  margin-block-end: 32px;
}
@media (max-width: 767px) {
  body.kf-presentation-v12.kf-layout-v7 :is(.minimog-grid-pagination:has(.minimog-load-more-button),nav.woocommerce-pagination[data-type="load-more"],nav.woocommerce-pagination[data-type="infinite"]) {
    margin-block-end: 24px;
  }
}
