/* =========================================================
   WEMAXA ENCYCLOPEDIA — FINAL LAYOUT SAFETY LAYER
   Loaded after all topic-specific CSS.
   Keeps topic color styling while preventing geometry conflicts.
   ========================================================= */
html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  overflow-x:clip;
}
body,.ec-page{overflow-x:clip!important}
.ec-shell{
  width:min(1180px,calc(100% - 32px))!important;
  max-width:1180px!important;
  margin-inline:auto!important;
}
.ec-article{
  width:100%!important;
  max-width:1120px!important;
  margin-inline:auto!important;
  min-width:0!important;
}
.ec-hero,.ec-block,.ec-story,.ec-reference,.ec-section-card,.ec-commons-gallery-block{
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
}
.ec-hero-grid{
  display:grid!important;
  grid-template-columns:minmax(0,1.08fr) minmax(340px,.92fr)!important;
  gap:28px!important;
  align-items:start!important;
}
.ec-hero-copy,.ec-hero-art,.ec-media-card,.ec-commons-gallery,.ec-commons-figure{
  min-width:0!important;
}
.ec-hero h1{
  max-width:14ch!important;
  font-size:clamp(44px,6vw,76px)!important;
  line-height:.96!important;
  letter-spacing:-.055em!important;
  overflow-wrap:normal!important;
  word-break:normal!important;
}
.ec-lead{max-width:760px!important}

/* Stable real-image presentation */
.ec-media-card{
  width:100%!important;
  overflow:hidden!important;
  border-radius:20px!important;
}
.ec-media-card img{
  display:block!important;
  width:100%!important;
  height:auto!important;
  aspect-ratio:4/3!important;
  object-fit:cover!important;
  object-position:center!important;
}
.ec-media-credit{
  display:block!important;
  width:100%!important;
  margin:10px 0 0!important;
  padding:0 3px!important;
  font-size:11px!important;
  line-height:1.5!important;
  overflow-wrap:anywhere!important;
}
.ec-media-credit:empty{display:none!important}
.ec-media-credit span,.ec-media-credit a{
  display:block!important;
  margin:0 0 4px!important;
}

/* Commons gallery: no spanning tiles, no overlap, no masonry tricks */
.ec-commons-gallery{
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  grid-auto-flow:row!important;
  align-items:start!important;
  gap:16px!important;
  padding:18px!important;
}
.ec-commons-figure,.ec-commons-figure--wide{
  grid-column:auto!important;
  grid-row:auto!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  height:auto!important;
  margin:0!important;
  position:relative!important;
  transform:none!important;
  overflow:hidden!important;
  align-self:start!important;
}
.ec-commons-image-link{display:block!important;width:100%!important;overflow:hidden!important}
.ec-commons-figure img,.ec-commons-figure--wide img{
  display:block!important;
  width:100%!important;
  height:auto!important;
  aspect-ratio:4/3!important;
  object-fit:cover!important;
  transform:none!important;
}
.ec-commons-figure:hover img{transform:none!important}
.ec-commons-figure figcaption{
  display:block!important;
  width:100%!important;
  min-width:0!important;
  padding:12px 13px!important;
  font-size:11px!important;
  line-height:1.55!important;
  overflow-wrap:anywhere!important;
  word-break:normal!important;
}
.ec-commons-figure figcaption span,.ec-commons-figure figcaption small{display:block!important}
.ec-commons-figure figcaption small{margin-top:5px!important}

/* Article text measure */
.ec-section-card p,.ec-reference-copy p,.ec-story-copy p,.ec-block p{
  max-width:900px!important;
}
.ec-section-card h2,.ec-reference-copy h3,.ec-story h2{
  overflow-wrap:normal!important;
  word-break:normal!important;
}

/* Index remains dense but predictable */
.ec-grid{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:18px!important;
}
.ec-card{
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  position:relative!important;
  transform:none;
}
.ec-card-art img{width:100%!important;object-fit:cover!important}

@media (max-width:980px){
  .ec-shell{width:min(100% - 24px,920px)!important}
  .ec-hero-grid{grid-template-columns:1fr!important}
  .ec-hero h1{max-width:18ch!important}
  .ec-hero-art{max-width:760px!important}
  .ec-commons-gallery{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

@media (max-width:760px){
  .ec-shell{
    width:calc(100% - 18px)!important;
    max-width:none!important;
    padding-top:10px!important;
  }
  .ec-article{max-width:100%!important}
  .ec-crumb{
    gap:5px!important;
    margin:4px 4px 12px!important;
    font-size:9px!important;
    line-height:1.45!important;
  }
  .ec-hero,.ec-index-hero,.ec-block,.ec-section-card,.ec-reference-head{
    padding:18px!important;
    border-radius:20px!important;
  }
  .ec-labels{gap:6px!important;margin-bottom:14px!important}
  .ec-label{
    min-height:28px!important;
    padding:6px 9px!important;
    font-size:8px!important;
    line-height:1.2!important;
    white-space:normal!important;
  }
  .ec-hero-grid,.ec-index-hero-grid{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:20px!important;
  }
  .ec-hero h1,.ec-index-hero h1{
    max-width:100%!important;
    margin:0!important;
    font-size:clamp(36px,11.5vw,54px)!important;
    line-height:.98!important;
    letter-spacing:-.05em!important;
    overflow-wrap:normal!important;
    word-break:normal!important;
  }
  .ec-lead,.ec-hero p,.ec-index-hero p{
    margin-top:14px!important;
    font-size:15px!important;
    line-height:1.72!important;
  }
  .ec-topic-map{padding:14px!important}
  .ec-chipset{display:flex!important;flex-wrap:wrap!important;gap:7px!important}
  .ec-chip{
    width:auto!important;
    max-width:100%!important;
    padding:7px 9px!important;
    font-size:9px!important;
    line-height:1.3!important;
    overflow-wrap:anywhere!important;
  }
  .ec-hero-art{width:100%!important;max-width:100%!important;margin:0!important}
  .ec-media-card{padding:6px!important;border-radius:16px!important}
  .ec-media-card img{
    width:100%!important;
    height:auto!important;
    aspect-ratio:4/3!important;
    object-fit:cover!important;
    border-radius:11px!important;
  }
  .ec-media-credit{
    display:block!important;
    margin:8px 0 0!important;
    padding:0 2px!important;
    font-size:10px!important;
    line-height:1.5!important;
  }
  .ec-media-credit span,.ec-media-credit a{display:block!important;margin-bottom:4px!important}

  .ec-facts-grid,.ec-scan-grid,.ec-link-grid,.ec-related-grid,.ec-forum-grid,.ec-deep-grid,.ec-question-grid{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
  }
  .ec-fact-card{min-height:0!important;padding:14px!important}
  .ec-fact-card strong{font-size:15px!important;line-height:1.45!important}

  .ec-story-grid{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:15px!important;
    padding:18px!important;
  }
  .ec-story-topline{padding:11px 16px!important}
  .ec-story h2{font-size:30px!important;line-height:1.05!important}
  .ec-story-copy p{font-size:14px!important;line-height:1.75!important}
  .ec-story-copy .ec-story-lede{font-size:19px!important;line-height:1.45!important}

  .ec-commons-gallery-block{border-radius:20px!important}
  .ec-commons-gallery-head p{font-size:13px!important;line-height:1.65!important}
  .ec-commons-gallery{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:12px!important;
    padding:12px!important;
  }
  .ec-commons-figure,.ec-commons-figure--wide{
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    border-radius:15px!important;
  }
  .ec-commons-figure img,.ec-commons-figure--wide img{
    width:100%!important;
    height:auto!important;
    aspect-ratio:4/3!important;
    object-fit:cover!important;
  }
  .ec-commons-figure figcaption{
    display:block!important;
    padding:10px 11px!important;
    font-size:10.5px!important;
    line-height:1.5!important;
  }

  .ec-section-card{padding:18px!important}
  .ec-section-head{
    display:grid!important;
    grid-template-columns:38px minmax(0,1fr)!important;
    gap:10px!important;
  }
  .ec-section-num{width:38px!important;height:38px!important}
  .ec-section-card h2,.ec-reference-copy h3{
    font-size:25px!important;
    line-height:1.08!important;
  }
  .ec-section-card p,.ec-reference-copy p,.ec-block p{
    max-width:100%!important;
    font-size:14px!important;
    line-height:1.78!important;
    overflow-wrap:anywhere!important;
  }
  .ec-reference-card{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    padding:18px!important;
  }
  .ec-reference-num{width:38px!important;height:38px!important}
  .ec-related-card{
    display:grid!important;
    grid-template-columns:110px minmax(0,1fr)!important;
    gap:12px!important;
  }
  .ec-related-card img{width:110px!important;height:90px!important;object-fit:cover!important}
  .ec-nav-links{display:grid!important;grid-template-columns:1fr!important;gap:9px!important}
  .ec-nav-links a{justify-content:flex-start!important;text-align:left!important;min-height:52px!important;padding:12px 14px!important}

  /* index */
  .ec-grid{grid-template-columns:1fr!important;gap:14px!important}
  .ec-card{display:grid!important;grid-template-columns:1fr!important;border-radius:18px!important}
  .ec-card-art{border-right:0!important;border-bottom:1px solid var(--ec-line)!important;padding:8px!important}
  .ec-card-art img{height:auto!important;aspect-ratio:16/10!important;object-fit:cover!important;border-radius:12px!important}
  .ec-card-body{padding:15px!important}
  .ec-card h3{font-size:24px!important;line-height:1.08!important}
  .ec-card p{font-size:13px!important;line-height:1.65!important}
  .ec-mini-facts{gap:6px!important}
  .ec-mini-facts span{font-size:9px!important;line-height:1.3!important;white-space:normal!important}

  img,svg,video,iframe{max-width:100%!important}
  pre,code{max-width:100%!important;overflow-wrap:anywhere!important}
}
