.sx-factory-section { background: #f3f2ed; }
.sx-factory-overview { max-inline-size: 58rem; margin-block-end: clamp(2rem, 4vw, 3.4rem); }
.sx-factory-overview h2 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.12; letter-spacing: -.035em; }
.sx-factory-overview p { max-inline-size: 62ch; margin: 0 0 17px; color: #545b62; line-height: 1.8; }
.sx-factory-videos { scroll-margin-top: 105px; margin-block-end: clamp(2.5rem, 5vw, 4.5rem); }
.sx-factory-gallery { scroll-margin-top: 105px; }
.article-body .sx-factory-gallery { margin-block: 2.3rem; }
.sx-factory-heading { margin-block-end: 20px; }
.sx-factory-heading h3 { margin: 0 0 7px; font-size: clamp(1.4rem, 2.6vw, 2.1rem); }
.sx-factory-heading p { margin: 0; color: #545b62; line-height: 1.65; }
.sx-factory-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 10px; }
.sx-factory-gallery [hidden], .sx-factory-viewer [hidden] { display: none; }
.sx-factory-filters button {
  min-block-size: 42px;
  padding: 8px 12px;
  border: 1px solid #d3cfc6;
  border-radius: 7px;
  background: #fffefa;
  color: #292e34;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.sx-factory-filters button:hover { border-color: #9d2d36; }
.sx-factory-filters button[aria-pressed=true] { background: #8e2027; border-color: #8e2027; color: #fff; }
.sx-factory-filters small { margin-inline-start: 4px; font-variant-numeric: tabular-nums; }
.sx-factory-group { padding-block: 24px; border-block-end: 1px solid #ddd9d1; }
.sx-factory-group:last-child { padding-block-end: 0; border: 0; }
.sx-factory-group h4 { display: flex; align-items: center; gap: 11px; margin: 0 0 13px; font-size: clamp(1.06rem, 2vw, 1.35rem); }
.sx-factory-group h4 span { color: #8e2027; font: 650 .73rem ui-monospace, monospace; }
.sx-factory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.5vw, 18px);
}
/* Design: 2 cards — keep 2-col */
[data-factory-group=design] .sx-factory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Storage: 1 card — keep single centered column */
[data-factory-group=storage] .sx-factory-grid { grid-template-columns: minmax(0, 430px); }
/* Testing: 7 cards — use 4-col so rows are 4+3, no lone orphan */
[data-factory-group=testing] .sx-factory-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 14px);
}
/* Production: 3 cards — keep 3-col, fills perfectly */

.sx-factory-card {
  min-inline-size: 0;
  margin: 0;
  border: 1px solid #dedad1;
  border-radius: 10px;
  background: #fffefa;
  overflow: hidden;
  transition: box-shadow .22s, transform .22s;
}
.sx-factory-card:hover {
  box-shadow: 0 6px 24px #1b202514;
  transform: translateY(-2px);
}
.sx-factory-item {
  display: block;
  position: relative;
  border-radius: 9px 9px 0 0;
  background: #e4e2dc;
  text-decoration: none;
  overflow: hidden;
}
/* Uniform aspect-ratio for all images — height:auto is REQUIRED so CSS
   aspect-ratio wins over any HTML height="" attribute on the <img> */
.sx-factory-item img {
  display: block;
  width: 100%;
  height: auto;          /* ← the missing fix: overrides HTML height attr */
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: inherit;
  transition: transform .4s ease;
}
.sx-factory-card:hover .sx-factory-item img { transform: scale(1.04); }
/* Testing group: square crop for the narrower 4-col cards */
[data-factory-group=testing] .sx-factory-item img { aspect-ratio: 1 / 1; }
.sx-factory-expand {
  position: absolute;
  inset-block-end: 7px;
  inset-inline-end: 7px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #ffffff70;
  border-radius: 6px;
  background: #1b2025db;
  color: #fff;
  font-size: 12px;
}
.sx-factory-item:hover .sx-factory-expand, .sx-factory-item:focus-visible .sx-factory-expand { background: #8e2027; }
.sx-factory-card figcaption { padding: 10px 11px 12px; color: #2d3337; line-height: 1.42; }
.sx-factory-photo-title { display: block; font-size: .86rem; font-weight: 700; }
.sx-factory-badge, .sx-factory-viewer-badge { display: inline-block; width: fit-content; margin-block-start: 7px; border-radius: 4px; background: #f6e8d7; color: #694b22; font-size: .73rem; padding: 3px 6px; }

.sx-factory-viewer {
  width: min(1000px, calc(100% - 28px));
  max-block-size: calc(100dvh - 28px);
  padding: 14px;
  border: 1px solid #494c53;
  border-radius: 12px;
  background: #191c22;
  color: #fffaf2;
  box-shadow: 0 17px 60px #12141870;
}
.sx-factory-viewer::backdrop { background: #11141de3; }
.sx-factory-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block-end: 9px; }
.sx-factory-viewer h3 { margin: 0; font-size: clamp(1rem, 2vw, 1.3rem); }
.sx-factory-close { width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid #77717b; border-radius: 7px; background: #282b32; color: #fff; font-size: 24px; cursor: pointer; }
.sx-factory-viewer-image { display: grid; place-items: center; }
.sx-factory-viewer-image img { display: block; max-inline-size: 100%; max-block-size: calc(100dvh - 155px); object-fit: contain; }
.sx-factory-viewer-badge { margin-block-end: 0; }

@media (max-width: 900px) {
  /* Testing drops from 4-col to 3-col: 7 = 3+3+1, still better than before */
  [data-factory-group=testing] .sx-factory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  [data-factory-group=testing] .sx-factory-item img { aspect-ratio: 4 / 3; }
}
@media (max-width: 740px) {
  .sx-factory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-factory-group=testing] .sx-factory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-factory-group=testing] .sx-factory-item img { aspect-ratio: 4 / 3; }
}
@media (max-width: 560px) {
  .sx-factory-group { padding-block: 18px; }
  .sx-factory-photo-title { overflow-wrap: anywhere; }
  .sx-factory-card:hover { transform: none; }
}
