/* School Pages Store - consistent product grid & card layout */
.sps-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:16px;
  align-items:stretch;
}

/* Card */
.sps-card{
  position:relative;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  height:100%;
  min-height:360px;
  border:1px solid rgba(0,0,0,0.12);
  border-radius:14px;
  background:#fff;
  padding:14px;
  overflow:hidden;           /* prevents any injected/floating elements from spilling into cards */
  isolation:isolate;         /* creates a new stacking context */
  contain:content;           /* reduces layout side-effects */
}

.sps-card *{
  max-width:100%;
  box-sizing:border-box;
  float:none !important;     /* prevents theme/plugin floats inside cards */
}

/* Media */
.sps-card__media{
  width:100%;
  height:170px;
  border-radius:12px;
  overflow:hidden;
  background:rgba(0,0,0,0.04);
  margin-bottom:10px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.sps-card__media img,
.sps-thumb,
.sps-cert-image{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  display:block !important;
  border-radius:0 !important;
  user-select:none;
  -webkit-user-drag:none;
  user-drag:none;
}

/* Fullscreen lightbox */
.sps-lightbox{
  position:fixed;
  inset:0;
  z-index:999999;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.88);
  padding:18px;
  box-sizing:border-box;
  touch-action:none; /* allow custom pinch/pan handling */
}
.sps-lightbox.is-open{ display:flex; }

.sps-lightbox__inner{
  width:100%;
  height:100%;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
}

.sps-lightbox__imgwrap{
  width:100%;
  height:100%;
  /* Slightly smaller than full screen so it always feels "centered" with margins */
  max-width:86vw;
  max-height:70vh;     /* fit fully inside the screen (reduced) */
  display:flex;
  align-items:center;
  justify-content:center;
}

.sps-lightbox__img{
  /* Defend against theme CSS like img{width:100%} */
  width:auto !important;
  height:auto !important;
  max-width:100% !important;
  max-height:100% !important;
  background:#fff;
  border-radius:16px;
  box-shadow:0 10px 30px rgba(0,0,0,0.6);
  object-fit:contain !important;  /* show full image */
  transform:translate(0px,0px) scale(1);
  transform-origin:center center;
  user-select:none;
  -webkit-user-drag:none;
  user-drag:none;
  -webkit-touch-callout:none;
}

.sps-lightbox__controls{
  position:absolute;
  top:14px;
  right:14px;
  display:flex;
  gap:10px;
  z-index:5 !important;
  pointer-events:auto;
}

/* Controls (JS uses .sps-lb-btn) */
.sps-lb-btn{
  appearance:none;
  border:0;
  border-radius:999px;
  width:44px;
  height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  font-size:18px;
  cursor:pointer;
  background:rgba(255,255,255,0.92);
  color:#111;
  line-height:1;
  box-shadow:0 8px 20px rgba(0,0,0,0.25);
}
.sps-lb-btn:active{ transform:scale(0.98); }

.sps-lightbox__hint{
  position:absolute;
  left:14px;
  bottom:14px;
  color:#fff;
  background:rgba(0,0,0,0.35);
  padding:8px 10px;
  border-radius:12px;
  font-size:13px;
  z-index:2;
}

/* Placeholder icon blocks */

.sps-card__icon{
  font-size:40px;
  margin-bottom:10px;
}

/* Title & price */
.sps-card__title{
  margin:0 0 8px 0;
  font-size:15px;
  line-height:1.25;
  font-weight:700;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

.sps-card__price{
  margin:0 0 10px 0;
  font-weight:800;
  font-size:14px;
}

/* Button */
.sps-card__btn{
  width:100%;
  padding:10px 12px;
  border:none;
  border-radius:999px;
  cursor:pointer;
  font-weight:800;
  display:block;
}

/* Ensure forms never stretch */
.sps-card form{
  margin:0;
  width:100%;
  margin-top:auto;
}

/* Responsive */
@media (max-width:768px){
  .sps-grid{
    grid-template-columns:repeat(auto-fill,minmax(180px,1fr));
    gap:12px;
  }
  .sps-card{
    min-height:340px;
  }
}


/* You may also like (cart) */
.sps-you-may-like{
  margin:20px 0;
  padding:16px;
  border-radius:12px;
  background:#f9f9f9;
}
.sps-related-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
  align-items:stretch;
}
@media (max-width: 900px){
  .sps-related-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width: 520px){
  .sps-related-grid{ grid-template-columns:1fr; }
}
.sps-related-card{
  background:#fff;
  border:1px solid rgba(0,0,0,0.08);
  border-radius:12px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:190px;
}
.sps-related-thumb{
  width:100%;
  height:90px !important;           /* small fixed thumbnails */
  background:#eee;
  overflow:hidden;
}
.sps-related-thumb img{
  width:100% !important;
  height:100% !important;
  max-height:90px !important;
  object-fit:cover !important;
  display:block;
  user-select:none;
  -webkit-user-drag:none;
}
.sps-thumb-placeholder{
  width:100%;
  height:100%;
}
.sps-related-body{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  flex:1;
}
.sps-related-title{
  font-weight:600;
  line-height:1.2;
  max-height:2.4em;
  overflow:hidden;
}
.sps-related-price{
  font-weight:700;
}
.sps-related-form{
  margin-top:auto;
}
.sps-related-form .sps-button{
  width:100%;
}
