/* category label: hidden by default, shown on phones only */
.card-cat{ display: none; }

/* ===========================================================
   MOBILE "EXPLORE" TILES  (phones only, max-width: 600px)
   Product / service cards become edge-to-edge portrait tiles,
   like a video-grid: photo fills the tile, tiny gaps, no card
   info. A bold "Explore" label sits bottom-left.
   Desktop / tablet layouts are untouched.
   Applies to: .grid (home, services, shop pages), the
   "recently viewed" rail, and the saved items list (account).
   =========================================================== */
@media (max-width: 600px){

  /* ----- 3-column grid, 2px gaps, runs edge to edge ----- */
  .grid,
  #savedList{
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-rows: auto !important;     /* turn off the old masonry rows */
    gap: 2px !important;
    align-items: stretch !important;
    margin-left: -10px !important;
    margin-right: -10px !important;
  }
  .rail{ gap: 2px !important; }

  /* ----- the tile ----- */
  .grid .card,
  #savedList .card,
  .rail .card{
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;                 /* portrait tile */
    height: auto;
    grid-row-end: auto !important;       /* ignore masonry spans */
    border: 0 !important;
    border-radius: 0 !important;
    background: #000;
    overflow: hidden;
    animation: none;
    transform: none !important;
    box-shadow: none;
  }
  .rail .card{ flex: 0 0 33% !important; }

  /* ----- photo fills the whole tile ----- */
  .grid .card .card-media,
  #savedList .card .card-media,
  .rail .card .card-media{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto !important;
    background: var(--bg-alt, #1a1a1f);
  }
  .grid .card .card-media img,
  #savedList .card .card-media img,
  .rail .card .card-media img{
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  /* ----- remove ALL product / service info ----- */
  .grid .card .card-body,
  #savedList .card .card-body,
  .rail .card .card-body,
  .grid .card .stock-badge,
  #savedList .card .stock-badge,
  .rail .card .stock-badge{
    display: none !important;
  }

  /* ----- bottom shade + "Explore" label ----- */
  .grid .card::before,
  #savedList .card::before,
  .rail .card::before{
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 42%;
    background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
    z-index: 1;
    pointer-events: none;
  }
  .grid .card::after,
  #savedList .card::after,
  .rail .card::after{
    content: "Explore";
    position: absolute;
    left: 6px; bottom: 6px;
    z-index: 2;
    /* outlined play icon drawn as an inline SVG, so it looks the same on
       every phone (no dependence on font glyphs) */
    padding-left: 17px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 4l14 8-14 8z' fill='none' stroke='white' stroke-width='2.6' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat left center / 13px 13px;
    color: #fff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 700;
    font-size: 13px;
    line-height: 18px;
    letter-spacing: 0;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.55);
    pointer-events: none;
  }

  /* ----- category label, top-left: small, semi-transparent so it never
     hides the photo, and tells shoppers what type of item it is.
     (.service-cat is the same label already used on service cards.) ----- */
  .grid .card .card-cat,
  #savedList .card .card-cat,
  .rail .card .card-cat,
  .grid .card .service-cat,
  #savedList .card .service-cat,
  .rail .card .service-cat{
    display: block;
    position: absolute;
    top: 6px; left: 6px;
    right: auto; bottom: auto;
    max-width: calc(100% - 46px);     /* leave room for the heart on the right */
    z-index: 2;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(0,0,0,0.35) !important;
    color: #fff !important;
    opacity: 0.8;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 9px;
    font-weight: 600;
    line-height: 14px;
    letter-spacing: 0.2px;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
  }
  .grid .card .card-cat:empty,
  #savedList .card .card-cat:empty,
  .rail .card .card-cat:empty{ display: none; }

  /* keep the favourite heart / unsave button tappable above the shade */
  .grid .card .card-media > button,
  #savedList .card .card-media > button,
  .rail .card .card-media > button{ z-index: 3; }

  /* ----- index / services: the grid sits inside a rounded "glass panel"
     that adds its own side padding + border. On phones the panel goes
     full-width and borderless so the tiles touch the screen edges, just
     like the shop page. Chips, headings and notices keep a 10px inset. ----- */
  .glass-panel{
    margin-left: -10px;
    margin-right: -10px;
    border-left-width: 0;
    border-right-width: 0;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .glass-panel > *:not(.grid){
    padding-left: 10px;
    padding-right: 10px;
  }
  .glass-panel > .grid{
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}
