/* ==============
   CCM Category Grid (namespace: ccmcat-)
   Font Awesome (fas/fab) icons expected from theme
   ============== */

/* Grid: 2 columns desktop, 1 column mobile */
.ccmcat-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  width: 100%;
}

@media (max-width: 768px){
  .ccmcat-grid{
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* Card (desktop): 9:16 photo + 9:16 text => total ratio 9:8 */
.ccmcat-card{
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
  overflow: hidden;
  aspect-ratio: 9 / 8;
}

@supports not (aspect-ratio: 1 / 1){
  .ccmcat-card{ min-height: 320px; }
}

/* Left: photo */
.ccmcat-card__photo{
  background: #1f3f3f;
  position: relative;
  overflow: hidden;
}

.ccmcat-card__photo-img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ccmcat-card__photo-empty{
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Right: text panel */
.ccmcat-card__body{
  background: #e6e6e6;
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
}

/* Logo: width 80%, aligned LEFT */
.ccmcat-card__logo{
  width: 80%;
  margin-left: 0;
  margin-right: auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 6px;
}

.ccmcat-card__logo-img{
  max-width: 100%;
  max-height: 44px;
  object-fit: contain;
  display: block;
}

.ccmcat-card__logo-empty{
  font-size: 11px;
  font-weight: 700;
  opacity: .55;
}

/* Title */
.ccmcat-card__title{
  margin: 0 0 12px;
  padding-top: 10px !important;
  color: #1E3C3C;
  font-weight: 900;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Meta block */
.ccmcat-card__meta{
  margin: 0 0 16px 0;
  padding: 0;
}

/* Rows: icon + value */
.ccmcat-card__row{
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  margin-bottom: 10px;
  align-items: start;
}

.ccmcat-card__dt{
  margin: 0;
  line-height: 1;
  color: rgba(0,0,0,.70);
}

.ccmcat-ico{
  font-size: 14px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  display: inline-block;
  transform: translateY(2px);
  color: rgba(0,0,0,.70);
}

.ccmcat-card__dd{
  margin: 0;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.25;
  color: rgba(0,0,0,.85);
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.ccmcat-card__link{
  color: #d14b6a;
  text-decoration: underline;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Description */
.ccmcat-card__desc{
  margin: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
  max-width: 55ch;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ccmcat-grid__empty{
  margin: 0;
}

/* =========================
   MOBILE: STACK + SMALLER PHOTO (horizontal)
   ========================= */
@media (max-width: 520px){
  .ccmcat-card{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    aspect-ratio: auto;
  }

  .ccmcat-card__photo{
    aspect-ratio: 16 / 9;
  }

  .ccmcat-card__photo-img{
    height: 100%;
  }

  .ccmcat-card__body{
    padding: 16px 16px 18px;
  }

  .ccmcat-card__logo{
    width: 80%;
    margin-left: 0;
    margin-right: auto;
    justify-content: flex-start;
    margin-bottom: 10px;
  }

  .ccmcat-card__title{
    font-size: 24px;
    line-height: 1.12;
    margin-bottom: 14px;
    padding-top: 0 !important;
  }

  .ccmcat-card__meta{
    margin: 0 0 18px 0;
  }

  .ccmcat-card__row{
    grid-template-columns: 20px 1fr;
    gap: 12px;
    margin-bottom: 12px;
  }

  .ccmcat-ico{
    font-size: 16px;
    width: 18px;
    height: 18px;
    line-height: 18px;
    transform: translateY(1px);
  }

  .ccmcat-card__dd{
    font-size: 14px;
    line-height: 1.35;
  }

  .ccmcat-card__desc{
    font-size: 15px;
    line-height: 1.6;
    max-width: none;
  }
}

/* =========================
   SAFARI 16.6 DESKTOP FIX
   - do not rely on aspect-ratio on grid container
   - lock ratio via ::before and place halves absolutely
   - does not affect mobile stack
   ========================= */
@supports (-webkit-hyphens:none) and (not (hyphens:none)){
  @media (min-width: 521px){
    .ccmcat-card{
      aspect-ratio: auto;
      display: block;
      position: relative;
    }

    .ccmcat-card::before{
      content:"";
      display:block;
      padding-top: 88.8889%; /* 9/8 */
    }

    .ccmcat-card__photo,
    .ccmcat-card__body{
      position: absolute;
      top: 0;
      bottom: 0;
      width: 50%;
      min-height: 0;
    }

    .ccmcat-card__photo{ left: 0; }
    .ccmcat-card__body { right: 0; }

    /* ensure cover works consistently in Safari */
    .ccmcat-card__photo{
      overflow: hidden;
    }
    .ccmcat-card__photo-img{
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
}