/*
 * Layout refinements on top of the original WordPress theme (medical-clinic).
 * Loaded last on every page by tools/build.py.
 */

/* ---------- content images never overflow ---------- */
:where(.cmsmasters_text, .cmsmasters_post_content, .cmsmasters_post_cont_wrap, .accordion__body, .wp-block-image,
       .wp-caption, .cmsmasters_column_inner, .entry-content) img:not(.pgc-sgb-cb img) {
  max-width: 100%;
  height: auto;
}
:where(.cmsmasters_text, .cmsmasters_post_content, .accordion__body, .entry-content) :is(.wp-caption, figure) {
  max-width: 100%;
}
:where(.cmsmasters_text, .cmsmasters_post_content, .accordion__body, .entry-content) iframe {
  max-width: 100%;
}
/* wide tables scroll inside their own box (wrapper added by enhance.js only when needed) */
.nemji-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* long words / URLs / file names wrap instead of sticking out on phones */
:where(.cmsmasters_text, .cmsmasters_post_content, .middle_content, .accordion__body) {
  overflow-wrap: break-word;
}
.cmsmasters_attach_img_meta, .cmsmasters_attach_img_meta a {
  white-space: normal !important;
  overflow-wrap: anywhere;
}

/* responsive images get width/height attributes (aspect ratio, no layout shift); keep the height proportional
   unless the theme sets one explicitly (:where = zero specificity, still beats the HTML attribute) */
:where(img[srcset*="/static-export/img/"]) { height: auto; }

/* zoomable content images */
img.nemji-zoomable { cursor: zoom-in; }

/* ---------- staff cards: real grid on every screen width ---------- */
.abcfslGridCntr.nemji-staff-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  column-gap: 30px;
  row-gap: 30px;
  align-items: start;
  width: 100% !important;
  max-width: none !important;
}
.abcfslGridCntr.nemji-staff-grid > .abcfslItemCntrLst {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
}
.abcfslGridCntr.nemji-staff-grid .abcfslImgCntrLst img {
  aspect-ratio: 797 / 1024;
  object-fit: cover;
  width: 100%;
  height: auto;
}
.abcfslGridCntr.nemji-staff-grid .abcfslTxtCntrLst {
  overflow-wrap: break-word;
  min-width: 0;
  padding-left: 16px !important;
}
/* photo column narrower, text column takes the rest (e-mails fit on one line) */
.abcfslGridCntr.nemji-staff-grid > .abcfslItemCntrLst {
  display: flex !important;
  align-items: flex-start;
}
.abcfslGridCntr.nemji-staff-grid > .abcfslItemCntrLst > .abcfslImgColLst {
  flex: 0 0 clamp(80px, 28%, 150px);
  width: auto !important;
  float: none !important;
}
.abcfslGridCntr.nemji-staff-grid > .abcfslItemCntrLst > .abcfslTxtColLst {
  flex: 1 1 0;
  min-width: 0;
  width: auto !important;
  float: none !important;
}
/* e-mail / phone line: icon and value always on one line, address never broken mid-word */
.abcfslTxtCntrLst > div:has(> span > i[class*="fa-"]) {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
}
.abcfslTxtCntrLst > div:has(> span > i[class*="fa-"]) > span:first-child { flex: none; }
.abcfslTxtCntrLst > div:has(> span > i[class*="fa-"]) > span + span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* clickable people */
.abcfslItemCntrLst.nemji-has-profile .abcfslImgCntrLst img { transition: opacity .2s; }
.abcfslItemCntrLst.nemji-has-profile .abcfslImgCntrLst a:hover img { opacity: .85; }
.abcfslItemCntrLst h4 a.nemji-profile-link { color: inherit; text-decoration: none; }
.abcfslItemCntrLst h4 a.nemji-profile-link:hover { text-decoration: underline; }

/* ---------- post cards (Content Views): equal height, aligned "Přečíst" ---------- */
.pt-cv-page.nemji-cards-float {
  display: flex !important;
  flex-wrap: wrap;
  row-gap: 30px;
}
.pt-cv-page.nemji-cards-float::before,
.pt-cv-page.nemji-cards-float::after { display: none !important; }
.pt-cv-page.nemji-cards > .pt-cv-content-item {
  float: none !important;
  display: flex !important;
  flex-direction: column;
}
.pt-cv-page.nemji-cards > .pt-cv-content-item > .pt-cv-ifield {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
}
.pt-cv-page.nemji-cards .pt-cv-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.pt-cv-page.nemji-cards .pt-cv-content > br { display: none; }
.pt-cv-page.nemji-cards .pt-cv-rmwrap {
  margin-top: auto;
  padding-top: 12px;
}
.pt-cv-page.nemji-cards .pt-cv-thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 580 / 400;
  object-fit: cover;
}

/* ---------- icon boxes (contacts, locations): equal height, aligned ---------- */
.nemji-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(240px, calc(50% - 20px)), 1fr));
  gap: 20px;
  padding: 10px;
  clear: both;
}
.nemji-box-grid > .cmsmasters_icon_box {
  float: none !important;
  width: auto !important;
  margin: 0 !important;
}

/* ---------- accordions (Helpie FAQ) ---------- */
.helpie-faq .accordion__item.nemji-empty .accordion__header {
  cursor: default;
  pointer-events: none;
}
.helpie-faq .accordion__item.nemji-empty .accordion__header::after,
.helpie-faq .accordion__item.nemji-empty .accordion__header::before { display: none !important; }
.helpie-faq .accordion__item.nemji-empty .accordion__body { display: none !important; }
.helpie-faq .accordion__body { overflow-wrap: anywhere; }
.helpie-faq .accordion__body > :last-child { margin-bottom: 0; }

/* ---------- dead links (target does not exist on the original site either) ---------- */
a[data-nemji-dead] { cursor: default; pointer-events: none; }
a[data-nemji-dead]:not([class*="button"]):not([class*="btn"]) { text-decoration: none !important; }

/* ---------- lightbox ---------- */
.nemji-lb {
  position: fixed; inset: 0; z-index: 2147483000;
  background: rgba(0, 25, 38, .92);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.nemji-lb.is-open { opacity: 1; }
.nemji-lb figure { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; }
.nemji-lb img { max-width: 92vw; max-height: 82vh; width: auto; height: auto; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; }
.nemji-lb figcaption { color: #fff; font-size: 14px; margin-top: 12px; text-align: center; max-width: 80vw; }
.nemji-lb button {
  position: absolute; border: 0; background: rgba(255,255,255,.12); color: #fff;
  width: 48px; height: 48px; border-radius: 50%; font-size: 22px; line-height: 48px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nemji-lb button:hover, .nemji-lb button:focus-visible { background: rgba(255,255,255,.28); outline: none; }
.nemji-lb .nemji-lb-close { top: 18px; right: 18px; }
.nemji-lb .nemji-lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.nemji-lb .nemji-lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.nemji-lb .nemji-lb-count { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.75); font-size: 13px; }
@media (max-width: 600px) {
  .nemji-lb .nemji-lb-prev, .nemji-lb .nemji-lb-next { top: auto; bottom: 12px; transform: none; }
  .nemji-lb .nemji-lb-count { bottom: 28px; }
}
