/* ============================================================================
   home-categories-premium.css — the homepage "Shop by Category" photo grid
   ----------------------------------------------------------------------------
   Markup: templates/_partials/home-categories.tpl, spliced by index.tpl into
   $HOOK_HOME directly under the hero. Loaded from index.tpl only, AFTER
   home-premium.css, so the `#index` tokens declared there (--sk-radius,
   --sk-pink-line, --sk-shadow-*, --sk-ease, --sk-dur) resolve here; every
   var() carries a fallback in case that file ever fails to load.

   Five tiles in one row from 600px (196px each inside a centred 1080px track
   at 1200px+, 126px at 768px, 100px at 600px). Below 600px: three columns,
   3 + 2 with the pair centred (103–121px tiles on 360–414px phones) — all five
   visible, nothing cut off. Additive: delete this file and the grid still
   renders as a plain list.
   ========================================================================== */

#index .sk-cats {
  /* Padding, not margin — theme.css zeroes margins on homepage sections. The
     "Popular Products" rail below brings its own --sk-section-y top padding. */
  padding-block: clamp(1.75rem, 3.5vw, 2.75rem) 0;
  background: var(--sk-paper, #fff);
}

#index .sk-cats__grid {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 1080px;
  display: grid;
  /* One column per tile, however many the catalogue has (five today): 196px
     each in the 1080px track, 131px at 768, 104px at 600; a sixth category
     simply narrows the row. */
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: clamp(1rem, 2.2vw, 1.5rem);
}

#index .sk-cats__item {
  min-width: 0;
}

#index .sk-cats__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .625rem;
  color: var(--sk-ink, #1a0010);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* The tile. `contain: paint` keeps the scaled image inside the rounded corners
   in Safari, which otherwise lets a transformed child leak past `overflow`. */
#index .sk-cats__media {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--sk-radius, 16px);
  border: 1px solid var(--sk-pink-line, #f0dce8);
  background: #fff;
  box-shadow: var(--sk-shadow-1, 0 1px 2px rgba(26, 0, 16, .04), 0 10px 28px rgba(213, 0, 117, .055));
  overflow: hidden;
  contain: paint;
  transition:
    transform var(--sk-dur, 320ms) var(--sk-ease, ease),
    box-shadow var(--sk-dur, 320ms) var(--sk-ease, ease);
}

#index .sk-cats__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--sk-dur-slow, 550ms) var(--sk-ease-out, ease);
}

/* A category with no photo mapped yet: the mega menu's box icon on the brand
   tint, so an added category never shows a broken image. */
#index .sk-cats__fallback {
  width: 34%;
  height: 34%;
  fill: none;
  stroke: var(--sk-pink, #d50075);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#index .sk-cats__media:has(> .sk-cats__fallback) {
  background: var(--sk-pink-tint, #fef0f7);
}

#index .sk-cats__name {
  font-family: 'Inter', var(--bs-body-font-family, sans-serif);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: .01em;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: break-word;
  transition: color var(--sk-dur, 320ms) var(--sk-ease, ease);
}

/* ---- States ---------------------------------------------------------------
   Hover only on devices that have one (theme.css's :hover latches after a tap
   on touchscreens); a short press for coarse pointers instead. */
@media (hover: hover) {
  #index .sk-cats__card:hover .sk-cats__media {
    transform: translateY(-3px);
    box-shadow: var(--sk-shadow-2, 0 2px 6px rgba(26, 0, 16, .06), 0 24px 52px rgba(213, 0, 117, .15));
    border-color: rgba(213, 0, 117, .28);
  }
  #index .sk-cats__card:hover .sk-cats__img {
    transform: scale(1.045);
  }
  #index .sk-cats__card:hover .sk-cats__name {
    color: var(--sk-pink, #d50075);
  }
}

@media (hover: none), (pointer: coarse) {
  #index .sk-cats__card:active .sk-cats__media {
    transform: scale(.97);
    transition-duration: 90ms;
  }
}

#index .sk-cats__card:focus-visible {
  outline: none;
}
#index .sk-cats__card:focus-visible .sk-cats__media {
  outline: 2px solid var(--sk-pink, #d50075);
  outline-offset: 3px;
}
#index .sk-cats__card:focus-visible .sk-cats__name {
  color: var(--sk-pink, #d50075);
}

/* ---- Below 768px: no Bootstrap container width, a 16px gutter -------------
   Bootstrap's .container is 540px wide from 576px up, which would leave five
   tiles of 95px at 600–767px; the section sets its own gutter instead so the
   tiles use the viewport (100px at 600, 120px at 700). */
@media (max-width: 767.98px) {
  #index .sk-cats {
    padding-block: 1.25rem .5rem;
  }
  #index .sk-cats > .container {
    max-width: none;
    padding-inline: 1rem;
  }
  #index .sk-cats__grid {
    max-width: none;
    gap: .75rem;
  }
  #index .sk-cats__media {
    border-radius: 12px;
  }
  #index .sk-cats__card {
    gap: .375rem;
  }
  /* 12px at 360, 13px from 394px. The name box is 10px wider than its tile
     (the column gap, split either side): "Setting Machines" at 12px/600 is
     ~100px, a 103px tile with padding was one pixel short and pushed it to a
     third line. Two lines are always reserved so a one-line "Consumables"
     cannot float its neighbours' second row. */
  #index .sk-cats__name {
    font-size: clamp(12px, 3.3vw, 13px);
    line-height: 1.25;
    min-height: 2.5em;
    letter-spacing: 0;
    padding-inline: 0;
    margin-inline: -5px;
  }
}

/* 600–767px, five across at 104–131px: 12px until the tiles pass ~120px
   (about 680px wide), then 13px — the same "Setting Machines" fit. */
@media (min-width: 600px) and (max-width: 767.98px) {
  #index .sk-cats__name {
    font-size: clamp(12px, 1.9vw, 13px);
    margin-inline: -6px;
  }
}

/* ---- Phones (< 600px): three columns, 3 + 2, the pair exactly centred --------
   Chosen over a scrolling rail (2026-09-27, four independent reviews): five
   categories fit on one screen with nothing cut off or hidden behind a swipe.
   A six-column grid makes the centred pair land on the same tracks and gaps
   as the first row — flex centring rounds a pixel off. Tiles: 103px at 360,
   113px at 390, 121px at 414. The centring rules only match a set of exactly
   five (4th-and-second-last, 5th-and-last); four tiles centre the lone
   fourth, six make two even rows, anything else flows three per row. */
@media (max-width: 599.98px) {
  #index .sk-cats__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    column-gap: 10px;
    row-gap: 1rem;
  }
  #index .sk-cats__item {
    grid-column: span 2;
  }
  #index .sk-cats__item:nth-child(4):nth-last-child(2) {
    grid-column: 2 / span 2;
  }
  #index .sk-cats__item:nth-child(5):last-child {
    grid-column: 4 / span 2;
  }
  #index .sk-cats__item:nth-child(4):last-child {
    grid-column: 3 / span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  #index .sk-cats__media,
  #index .sk-cats__img,
  #index .sk-cats__name {
    transition: none;
  }
  #index .sk-cats__card:hover .sk-cats__media,
  #index .sk-cats__card:hover .sk-cats__img,
  #index .sk-cats__card:active .sk-cats__media {
    transform: none;
  }
}
