/* Moved from inline <style> in octane.category.cfm. */
.return {
    margin-top: 48px;
    margin-left: 24px;
}

.flex-container {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;   /* centre lone / partial-row cards */
      gap: 20px;
      margin: 48px 24px;
    }

    .flex-item {
      flex: 1 0 calc(25% - 20px);
      max-width: calc((100% - 60px) / 4);   /* cap at one column so a lone card doesn't span full width */
      background: white;
      padding: 20px;
      border: 1px solid #ddd;
      border-radius: 8px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.05);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      min-height: 400px; /* adjust as needed */
    }
    .flex-item a {
        text-decoration: none;
    }
    .flex-item a .row-text, .flex-item a > .reduced-price {
        text-decoration: none;
        color: #000;
    }
    .reduced-price {
        color: #000;
    }

    .row-image {
      /*height: 100px;*/
      background: #fff;
      margin-bottom: 10px;
      position: relative;
    }

    .img-contain {
      width: 100%;
      height: 100%;
      object-fit: contain;
      display: block;
      max-height: 240px;
    }

    .row-text {
      flex-grow: 1;
      margin-top: 24px;
      margin-bottom: 10px;
      text-align: center;
      font-weight: bold;
      line-height: 1;
    }

    .row-button {
      text-align: center;
      margin: 24px auto;
    }

    /* Tablet: 3 columns */
    @media (max-width: 1024px) {
      .flex-item {
        flex: 1 0 calc(33.333% - 20px);
        max-width: calc((100% - 40px) / 3);
      }
    }

    /* Mobile: 2 columns */
    @media (max-width: 900px) {
      .flex-item {
        flex: 1 0 calc(50% - 20px);
        max-width: calc((100% - 20px) / 2);
      }
    }

    /* Very small devices -- switch each card to a row layout
       with the image on the LEFT and title/price stacked on the
       RIGHT. Mirrors basket.cfm's desktop layout: the image is
       flush against the left edge of the card (no padding or
       margin around it) and spans the full card height; the
       text/price column has its own internal padding. */
    @media (max-width: 800px) {
      .flex-item {
        flex: 1 0 100%;
        max-width: 100%;   /* single column: reset the cap */
        min-height: 0;
        padding: 0;
        overflow: hidden;
      }
      .flex-item > a {
        display: grid;
        grid-template-columns: 110px 1fr;
        grid-template-areas:
          "image info"
          "image price";
        column-gap: 0;
        row-gap: 0;
        align-items: center;
        min-height: 110px;
      }
      .flex-item .row-image {
        grid-area: image;
        margin: 0;
        width: 100%;
        height: 100%;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      /* Image fills the full image cell -- no max-height cap, so
         the image grows with the card height like on basket.cfm. */
      .flex-item .row-image img,
      .flex-item .row-image .img-contain {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: contain;
      }
      .flex-item .row-text {
        grid-area: info;
        margin: 0;
        padding: 12px 12px 4px 12px;
        text-align: left;
        line-height: 1.3;
      }
      /* price.display.cfm emits one of:
           - <p class="price"><div class="price-display">...</div></p>  for retail
           - <div class="price-trade-block">...</div>                   for trade
         The retail markup is *invalid* HTML5 -- a <p> can't contain
         block elements, so the browser auto-closes the <p> before
         the <div>. price.display.cfm now emits a valid wrapper:
         <div class="price"><div class="price-display">...</div></div>
         for retail, or <div class="price-trade-block"> for trade.
         Either way the direct child of the card's <a> is what needs
         the grid-area. */
      .flex-item .price,
      .flex-item .price-trade-block {
        grid-area: price;
        margin: 0;
        padding: 4px 12px 12px 12px;
        text-align: left;
      }

      /* Retail multi-currency price block (rendered by JS into
         .price-display) -- override the site-wide 150% sizing,
         the centred flex, the link-colour bleed on the "INC VAT"
         label, and the gap between the price and label. */
      .flex-item .price-display .reduced-price-container {
        font-size: 0.95rem;
        justify-content: flex-start;
        margin: 0;
        gap: 8px;
        align-items: baseline;
      }
      .flex-item .price-display .reduced-price {
        margin-left: 0;
        font-size: 1.1rem;
        font-weight: 700;
        color: #141414;
      }
      .flex-item .price-display .vat {
        font-size: 0.7rem;
        color: #666;
        text-decoration: none;
        font-weight: 400;
      }
      .flex-item .price-display .regular-price {
        font-size: 0.75rem;
        color: #888;
      }
      .flex-item .price-display .percentage-arrow {
        font-size: 0.65rem;
        padding: 0.25em 0.5em;
      }
      /* Belt-and-braces: the whole card is wrapped in <a> so any
         descendant text inherits link styling. Force the price
         column children back to body colour with no underline. */
      .flex-item a,
      .flex-item a:link,
      .flex-item a:visited,
      .flex-item a:hover {
        text-decoration: none;
        color: #141414;
      }

      /* Trade-price block: scale it down to fit the mobile card.
         The full-size desktop layout (30px price, centred, with an
         inc-VAT sub-line) is too tall to sit next to a 110px-wide
         image. price.display.cfm uses !important on the centre
         alignment (`.price-trade-block > div { text-align:center
         !important }`), so we have to match it to win. */
      .flex-item .price-trade-block,
      .flex-item .price-trade-block > div {
        text-align: left !important;
      }
      .flex-item .price-trade-block .price-trade-badge {
        margin-bottom: 4px;
        padding: 2px 6px;
        font-size: 10px;
        letter-spacing: .3px;
      }
      .flex-item .price-trade-block .price-trade-main {
        font-size: 18px;
        margin-bottom: 2px;
        line-height: 1.1;
      }
      .flex-item .price-trade-block .price-trade-vat-note {
        font-size: 11px;
        margin-left: 4px;
      }
      /* Hide the inc-VAT sub-line on mobile cards -- the ex-VAT
         figure on its own is enough at this size. */
      .flex-item .price-trade-block .price-trade-vat-sub {
        display: none;
      }
      .price-unavailable {
            text-align: left;
            margin-left: 12px;
      }
      .flex-item .price-trade-block .price-trade-rrp {
        font-size: 11px;
        margin: 4px 0;
      }
      .flex-item .price-trade-block .price-trade-discount {
        font-size: 10px;
        padding: 2px 6px;
        margin-top: 2px;
      }
      /* "View Product" button is hidden on mobile -- the whole
         card is already a tap target (parent <a>), so the
         dedicated button just adds clutter on a small screen. */
      .flex-item .row-button { display: none; }
      /* Pull the status label tighter into the image area so it
         doesn't float out into the info column. */
      .flex-item .product--label-container {
        top: 6px;
        left: 6px;
      }
    }
    
.product--label-container {
    position: absolute;
    z-index: 1;
    top: 20px;
    left: 20px;
}

.product--label-container .product--label {
    display: inline-block;
    border-radius: 4px;
    background-color: #007BFF;
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    line-height: 20px;
    padding: 0 10px;
    text-transform: uppercase;
    text-align: center;
    z-index: 2;
}
.product--label-container .product--label.clearance {
    background-color: red;
    color: #fff;
}
.product--label-container .product--label.new {
    background-color: green;
    color: #fff;
}
.category-intro {
    padding: 24px;
    text-align: left;
    font-size: 110%;
}
.category-intro h1 {
    display: block;
    margin: initial;
    margin-bottom: 0;
}
.category-intro h3 {
    font-size: 160%;
    font-weight: bold;
}
.category-intro h3:first-of-type {
    margin-top: 0;
}

/* Clamp a long category description to 4 lines and reveal the rest
   behind a "Read more" toggle. Applies at ALL widths -- the toggle
   itself is only un-hidden by JS when the text genuinely overflows
   the clamp, so a short description shows in full with no button. */
.category-intro-text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.category-intro-text.is-expanded {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}
.category-intro-toggle[hidden] { display: none; }
.category-intro-toggle {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background: #141414;
    color: #fff;
    border: 0;
    border-radius: 2px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}
.category-intro-toggle:hover { background: #5a554e; }

@media (max-width: 800px) {
    .category-intro {
        padding: 16px;
        font-size: 100%;
    }
}
