/* =============================================================
   לי המפתח – Homepage section styles
   Loaded on the front page only (see functions.php).
   Inherits the palette + tokens declared in main.css :root.
   ============================================================= */

/* ============================================================
   TOP CATEGORIES
   ============================================================ */

/* ── Grid ── */
.top-cats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  gap: 24px;
}

/* ── Card ── */
.top-cat-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.top-cat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
  color: var(--color-text);
}
.top-cat-card:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* ── Media ── */
.top-cat-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  padding: 18px;
  background: linear-gradient(160deg, var(--color-white) 0%, var(--color-light) 100%);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}
.top-cat-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform var(--transition);
}
.top-cat-card:hover .top-cat-img { transform: scale(1.07); }

/* Shown when neither the category nor its products carry an image. */
.top-cat-media-fallback {
  font-size: 54px;
  line-height: 1;
  color: var(--color-border);
}

/* Product-count pill – sits in the right-hand corner of the RTL layout. */
.top-cat-count {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 5px 12px;
  border-radius: 50px;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

/* ── Body ── */
.top-cat-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 0 20px 22px;
  text-align: center;
}

/* Negative margin lifts the badge over the media edge – no absolute
   positioning, so it stays correct in RTL without any overrides. */
.top-cat-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin: -34px auto 14px;
  border: 4px solid var(--color-white);
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 22px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.top-cat-card:hover .top-cat-icon {
  background: var(--color-accent);
  color: var(--color-primary);
  transform: translateY(-2px);
}

.top-cat-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-primary);
}

/* Clamped to three lines so every card's CTA lands on the same baseline. */
.top-cat-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.55em * 3);
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-muted);
}

.top-cat-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: auto;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  transition: color var(--transition);
}
.top-cat-link i { transition: transform var(--transition); }
.top-cat-card:hover .top-cat-link { color: var(--color-accent-hover); }
.top-cat-card:hover .top-cat-link i { transform: translateX(-4px); }

/* ── Responsive ── */
@media (max-width: 1199px) {
  .top-cats-grid { gap: 20px; }
  .top-cat-title { font-size: 17px; }
}

@media (max-width: 991px) {
  .top-cats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Phones: compact 2-up tiles. The blurb and CTA are dropped so all four
   categories fit on roughly one screen – the whole tile is still tappable. */
@media (max-width: 575px) {
  .top-cats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .top-cat-media {
    aspect-ratio: 1 / 1;
    padding: 12px;
  }
  .top-cat-count {
    top: 8px;
    right: 8px;
    padding: 4px 9px;
    font-size: 11px;
  }
  .top-cat-body { padding: 0 12px 16px; }
  .top-cat-icon {
    width: 46px;
    height: 46px;
    margin: -26px auto 10px;
    border-width: 3px;
    font-size: 17px;
  }
  .top-cat-title {
    margin: 0;
    font-size: 15px;
  }
  .top-cat-desc,
  .top-cat-link { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .top-cat-card,
  .top-cat-img,
  .top-cat-icon,
  .top-cat-link i { transition: none; }
  .top-cat-card:hover { transform: none; }
  .top-cat-card:hover .top-cat-img { transform: none; }
  .top-cat-card:hover .top-cat-icon { transform: none; }
  .top-cat-card:hover .top-cat-link i { transform: none; }
}

/* ============================================================
   FEATURED BRANDS (the "יצרנים מובילים" grid)
   The base .vendors-home rules in main.css were written for the
   static, non-clickable logo strip. Now that the cards are real
   links to the brand archives, restore the click affordance.
   ============================================================ */
/* Fewer brands than the 4-up grid expects: size the tracks to the actual
   count and centre the row, rather than leaving a gap on one side.
   Capped at two columns on phones, matching main.css's own breakpoint. */
.vendors-home.vendors-home--few {
  grid-template-columns: repeat(var(--brand-count, 2), minmax(0, 220px));
  justify-content: center;
}
@media (max-width: 575px) {
  .vendors-home.vendors-home--few {
    grid-template-columns: repeat(2, minmax(0, 220px));
  }
}

.vendors-home a.vendor-card { cursor: pointer; }
.vendors-home a.vendor-card .vendor-logo-img {
  transition: transform var(--transition);
}
.vendors-home a.vendor-card:hover .vendor-logo-img { transform: scale(1.06); }
.vendors-home a.vendor-card:hover .vendor-name { color: var(--color-primary); }
.vendors-home a.vendor-card:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .vendors-home a.vendor-card .vendor-logo-img { transition: none; }
  .vendors-home a.vendor-card:hover .vendor-logo-img { transform: none; }
}

/* ============================================================
   ELECTROMECHANICAL LOCKS – infographic section
   Sits directly under .b2b-section (--color-primary) and above the white
   clients marquee, so it takes the light surface: dark -> light -> white
   steps down instead of merging into one dark block with B2B.
   Cards follow the theme's existing white-card language (.service-card).
   ============================================================ */
.emx-section {
  position: relative;
  background: var(--color-light);
  color: var(--color-text);
  overflow: hidden;
}
/* Warm gold wash in the corner, echoing .b2b-section's accent treatment. */
.emx-section::before {
  content: '';
  position: absolute;
  top: -180px;
  left: -140px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(253,191,49,.22) 0%, rgba(253,191,49,0) 70%);
  pointer-events: none;
}
.emx-section > .container { position: relative; z-index: 1; }

/* ── Section head ── */
.emx-head .h2 { color: var(--color-primary); }
.emx-head .section-description { color: var(--color-muted); max-width: 720px; }
/* Darker gold: #fdbf31 on a light ground is too low-contrast to read. */
.emx-eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--color-accent-hover);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
}

.emx-block { margin-top: 54px; }
.emx-block-title {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
}
.emx-note {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--color-muted);
  text-align: center;
}

/* ── How it works: a connected flow, not four detached cards ──
   The four points tell one story (door shuts and locks -> it is driven
   electrically -> what happens on power loss -> you can always get out),
   so a rail joining the nodes carries far more meaning than boxes. */
.emx-flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.emx-flow-step {
  position: relative;
  padding: 0 14px;
  text-align: center;
}
/* Each step draws the segment back to the previous node, so the rail follows
   the grid however it wraps — a single container-wide line would only ever
   render on the first row. inset-inline-end keeps it correct in RTL and LTR:
   the segment starts at this node's centre and runs one column toward the
   previous one. Hidden on whichever step leads each row. */
.emx-flow-step::before {
  content: '';
  position: absolute;
  top: 33px;
  inset-inline-end: 50%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg,
    var(--color-border) 0%,
    var(--color-accent) 50%,
    var(--color-border) 100%);
}
.emx-flow-step:nth-child(4n + 1)::before { display: none; }
.emx-flow-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  /* Border painted in the section colour so the rail stops at the circle. */
  border: 5px solid var(--color-light);
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 25px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.emx-flow-num {
  position: absolute;
  top: -4px;
  right: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--color-light);
  background: var(--color-accent);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 800;
}
.emx-flow-step:hover .emx-flow-node {
  transform: translateY(-3px);
  background: var(--color-accent);
  color: var(--color-primary);
}
.emx-flow-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--color-primary);
}
.emx-flow-text {
  margin: 0 auto;
  max-width: 250px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-muted);
}

/* ── Standards: one compliance bar rather than four floating boxes ──
   The 1px grid gap over a border-coloured backdrop draws the hairline
   dividers, so the cells stay separated at any column count. */
.emx-standards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--color-accent);
  border-radius: 14px;
  background: var(--color-border);
  overflow: hidden;
}
.emx-standard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 16px;
  background: var(--color-white);
  text-align: center;
}
.emx-standard-icon {
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--color-accent-hover);
}
.emx-standard-code {
  font-size: 19px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: .02em;
}
.emx-standard-text {
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.5;
}

/* ── Door type ── */
.emx-doors {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.emx-door {
  padding: 26px 24px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-white);
  box-shadow: var(--shadow-card);
}
.emx-door-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.emx-door-head i { font-size: 22px; color: var(--color-accent-hover); }
.emx-door-head h4 { margin: 0; font-size: 18px; font-weight: 700; color: var(--color-primary); }
.emx-door-models {
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--color-primary);
  direction: ltr;
  text-align: right;
}
.emx-door-specs { margin: 0; }
.emx-door-specs dt {
  font-size: 13px;
  font-weight: 400;
  color: var(--color-muted);
}
.emx-door-specs dd {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
}
.emx-door-specs dd:last-child { margin-bottom: 0; }

/* ── The range ── */
.emx-products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.emx-product {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-white);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.emx-product:hover {
  transform: translateY(-4px);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-hover);
  color: var(--color-text);
}
.emx-product:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}
/* Square media box, paired with the cropped thumbnail: the range is shot as a
   slim lock on a wide white canvas, so 1:1 trims margin and enlarges the lock. */
.emx-product-media {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
  padding: 8px;
  border-radius: 8px;
  background: var(--color-light);
  overflow: hidden;
}
.emx-product-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.emx-product-fallback { font-size: 34px; color: var(--color-border); }
.emx-product-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-primary);
}
.emx-product-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}
.emx-product-link i { transition: transform var(--transition); }
.emx-product:hover .emx-product-link i { transform: translateX(-4px); }

/* ── Solutions ── */
.emx-solutions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.emx-solution {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 26px 20px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-white);
  box-shadow: var(--shadow-card);
  color: var(--color-text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.emx-solution:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
  color: var(--color-text);
}
.emx-solution:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
/* Same icon treatment as .top-cat-icon so the two sections read as a set. */
.emx-solution-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 20px;
  transition: background var(--transition), color var(--transition);
}
.emx-solution:hover .emx-solution-icon {
  background: var(--color-accent);
  color: var(--color-primary);
}
.emx-solution-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; color: var(--color-primary); }
.emx-solution-text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--color-muted); }

/* ── CTA ── */
.emx-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 46px;
}

/* ── Responsive ── */
@media (max-width: 991px) {
  .emx-standards,
  .emx-products,
  .emx-solutions { grid-template-columns: repeat(2, 1fr); }

  /* Two per row, so every odd step now leads a row. */
  .emx-flow { grid-template-columns: repeat(2, 1fr); row-gap: 34px; }
  .emx-flow-step:nth-child(4n + 1)::before { display: block; }
  .emx-flow-step:nth-child(odd)::before { display: none; }
  .emx-flow-text { max-width: 300px; }
}

@media (max-width: 575px) {
  .emx-block { margin-top: 40px; }
  .emx-block-title { font-size: 19px; }
  .emx-doors,
  .emx-solutions { grid-template-columns: 1fr; }
  .emx-standards { grid-template-columns: repeat(2, 1fr); }

  /* Phones: the rail turns vertical and the flow reads as a timeline.
     Each segment spans its own step and bridges the row gap, so it stays
     continuous no matter how tall the copy runs; the first and last are
     trimmed to start and stop at their node. */
  .emx-flow { grid-template-columns: 1fr; row-gap: 24px; }
  .emx-flow-step:nth-child(n)::before {
    display: block;
    top: 0;
    bottom: -24px;
    /* inline-START, not end: the node sits in grid column 1, which is the
       right-hand column in RTL, and inline-end resolves to the left there. */
    inset-inline-start: 33px;
    inset-inline-end: auto;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg,
      var(--color-border) 0%,
      var(--color-accent) 50%,
      var(--color-border) 100%);
  }
  .emx-flow-step:first-child::before { top: 34px; }
  .emx-flow-step:last-child::before { top: 0; bottom: auto; height: 34px; }
  .emx-flow-step {
    display: grid;
    grid-template-columns: 68px 1fr;
    column-gap: 16px;
    row-gap: 6px;
    align-items: start;
    padding: 0;
    text-align: right;
  }
  /* Place explicitly: with three children, auto-placement would drop the
     paragraph into the 68px node column and squeeze it to one word a line. */
  .emx-flow-node {
    grid-column: 1;
    grid-row: 1 / span 2;
    margin: 0;
  }
  .emx-flow-title { grid-column: 2; grid-row: 1; margin: 12px 0 0; }
  .emx-flow-text  { grid-column: 2; grid-row: 2; max-width: none; }
  .emx-products { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .emx-product-title { font-size: 13px; }
  .emx-door-models { font-size: 12px; }
  .emx-cta { flex-direction: column; align-items: stretch; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .emx-flow-node,
  .emx-product,
  .emx-solution,
  .emx-solution-icon,
  .emx-product-link i { transition: none; }
  .emx-product:hover,
  .emx-solution:hover { transform: none; }
  .emx-flow-step:hover .emx-flow-node { transform: none; }
  .emx-product:hover .emx-product-link i { transform: none; }
}
