/*
 * Mobile category discovery: these product-bearing categories contain long,
 * useful editorial descriptions. Keep the content and its links in the DOM,
 * but show the purchasable product grid first on small screens.
 *
 * Category IDs: Ruoka 59, Juomat 75, Kasvoöljyt ja seerumit 81,
 * Shampoot 102, D-vitamiini 219.
 */
@media (max-width: 767px) {
  html.category-59 #product-category #content,
  html.category-75 #product-category #content,
  html.category-81 #product-category #content,
  html.category-102 #product-category #content,
  html.category-219 #product-category #content {
    display: flex;
    flex-direction: column;
  }

  html.category-59 #product-category #content > .main-products-wrapper,
  html.category-75 #product-category #content > .main-products-wrapper,
  html.category-81 #product-category #content > .main-products-wrapper,
  html.category-102 #product-category #content > .main-products-wrapper,
  html.category-219 #product-category #content > .main-products-wrapper {
    order: 1;
  }

  html.category-59 #product-category #content > .category-description,
  html.category-75 #product-category #content > .category-description,
  html.category-81 #product-category #content > .category-description,
  html.category-102 #product-category #content > .category-description,
  html.category-219 #product-category #content > .category-description {
    order: 2;
    margin-top: 24px;
  }
}

/*
 * Ravintolisät: preserve the complete need-based navigation, but prevent the
 * narrow-screen one-column fallback from placing six rich cards before the
 * product grid.  The cards contain no images: a compact two-column grid keeps
 * every title, explanation and subcategory link visible and tappable.
 */
@media (max-width: 767px) {
  html.category-64 .need-based-navigation {
    margin: 20px 0 24px;
  }

  html.category-64 .need-based-navigation h2 {
    margin: 0 0 5px;
    font-size: 21px;
    line-height: 1.22;
  }

  html.category-64 .need-based-lead {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.35;
  }

  html.category-64 .need-based-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  html.category-64 .need-based-card {
    min-height: 0;
    padding: 10px;
  }

  html.category-64 .need-based-card h3 {
    margin: 0 0 5px;
    font-size: 16px;
    line-height: 1.22;
  }

  html.category-64 .need-based-card p {
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.34;
  }

  html.category-64 .need-based-links {
    gap: 5px 8px;
  }

  html.category-64 .need-based-links a {
    font-size: 13px;
    line-height: 1.28;
  }
}

/*
 * Ravintolisät: retain one shopper-facing orientation paragraph, then the
 * need navigation and products. The two explanatory continuation paragraphs
 * remain server-rendered and follow the product list on mobile. This keeps
 * every word in the HTML without duplicating or hiding content.
 */
@media (max-width: 767px) {
  html.category-64 #product-category #content {
    display: flex;
    flex-direction: column;
  }

  html.category-64 .ravintolisat-intro {
    display: contents;
  }

  html.category-64 .ravintolisat-intro > p:nth-of-type(1) {
    order: 1;
  }

  html.category-64 .need-based-navigation {
    order: 2;
  }

  html.category-64 #content-top {
    order: 3;
  }

  html.category-64 .main-products-wrapper {
    order: 4;
  }

  html.category-64 .ravintolisat-intro > p:nth-of-type(2),
  html.category-64 .ravintolisat-intro > p:nth-of-type(3) {
    order: 5;
  }

  html.category-64 .category-description {
    order: 6;
  }
}

/* Journal3 places route-product-product on <html>, not <body>.
   The product detail CTA is #button-cart; this selector also styles its sticky presentation if Journal3 reuses the node. */
html.route-product-product #button-cart,
html.route-product-product .cross-sell-add.btn-primary {
  color: #fff !important;
  background-color: #347A50 !important;
  border-color: #347A50 !important;
}

@media (hover: hover) {
  html.route-product-product #button-cart:hover:not(:disabled),
  html.route-product-product .cross-sell-add.btn-primary:hover:not(:disabled) {
    color: #fff !important;
    background-color: #256344 !important;
    border-color: #256344 !important;
  }
}
html.route-product-product #button-cart:active:not(:disabled),
html.route-product-product .cross-sell-add.btn-primary:active:not(:disabled) {
  color: #fff !important;
  background-color: #256344 !important;
  border-color: #256344 !important;
}

/* Product cards stay secondary: outlined green at rest, filled green on interaction. */
.product-thumb .btn-cart.btn,
.main-products-style.product-grid .product-thumb .button-group .btn-cart.btn:not(:disabled) {
  color: #347A50 !important;
  background-color: #fff !important;
  border-color: #347A50 !important;
}
@media (hover: hover) {
  .product-thumb .btn-cart.btn:hover:not(:disabled),
  .main-products-style.product-grid .product-thumb .button-group .btn-cart.btn:hover:not(:disabled) {
    color: #fff !important;
    background-color: #347A50 !important;
    border-color: #347A50 !important;
  }
}
.product-thumb .btn-cart.btn:active:not(:disabled),
.main-products-style.product-grid .product-thumb .button-group .btn-cart.btn:active:not(:disabled) {
  color: #fff !important;
  background-color: #347A50 !important;
  border-color: #347A50 !important;
}

/* Keyboard focus remains explicit and independent of color semantics. */
html.route-product-product #button-cart:focus-visible,
html.route-product-product .cross-sell-add.btn-primary:focus-visible,
.product-thumb .btn-cart.btn:focus-visible,
.main-products-style.product-grid .product-thumb .button-group .btn-cart.btn:not(:disabled):focus-visible {
  outline: 3px solid #256344 !important;
  outline-offset: 3px;
}

/* Restyle only semantic disabled states; do not infer disabled from opacity/loading classes. */
html.route-product-product #button-cart:disabled,
html.route-product-product #button-cart[aria-disabled="true"],
html.route-product-product .cross-sell-add.btn-primary:disabled,
html.route-product-product .cross-sell-add.btn-primary[aria-disabled="true"],
.product-thumb .btn-cart.btn:disabled,
.main-products-style.product-grid .product-thumb .button-group .btn-cart.btn:disabled,
.product-thumb .btn-cart.btn[aria-disabled="true"],
.main-products-style.product-grid .product-thumb .button-group .btn-cart.btn[aria-disabled="true"] {
  color: #263D31 !important;
  background-color: #E9F3EA !important;
  border-color: #CBD8CC !important;
  opacity: 1;
  cursor: not-allowed;
}


/* Homepage layout repair — 2026-10-11 */
html.route-common-home .site-wrapper {
  margin-top: 0 !important;
}

html.route-common-home .grid-items > .grid-item.grid-module-top-2-1-1 {
  transform: none !important;
}

html.route-common-home .top .grid-row-top-2 {
  padding-top: 24px !important;
}

html.route-common-home .top .grid-row-top-3 {
  padding-top: 0 !important;
  padding-bottom: 24px !important;
}

html.route-common-home .module-banners-1178 .auto-grid-items {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 16px !important;
  width: 100% !important;
}

html.route-common-home .module-banners-1178 .module-item {
  width: 100% !important;
  min-width: 0 !important;
}

@media (max-width: 1023px) {
  html.route-common-home .module-banners-1178 .auto-grid-items {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Homepage layout repair — contain wrapped mobile logo within header */
@media (max-width: 767px) {
  html.route-common-home header,
  html.route-common-home header .mobile-header {
    height: 88px !important;
    min-height: 88px !important;
  }
}
