/* =============================================================
   Elementor Pages Masonry Grid — v3.1
   ============================================================= */

/* ── Wrapper ── */
.epmg-wrapper {
    position: relative;
    width: 100%;
}

/* ── Grid base: CSS custom properties ── */
.epmg-grid {
    --epmg-cols:    3;
    --epmg-col-gap: 20px;
    --epmg-row-gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* =============================================================
   MASONRY GRID  (Masonry.js float-based)
   ============================================================= */
.epmg-masonry::after {
    content: '';
    display: block;
    clear: both;
}

/* Masonry.js column-width anchor — must be first child */
.epmg-masonry > .epmg-sizer {
    width: calc((100% - (var(--epmg-cols) - 1) * var(--epmg-col-gap)) / var(--epmg-cols));
    float: left;
}

/* Each card in masonry */
.epmg-masonry > .epmg-card {
    width: calc((100% - (var(--epmg-cols) - 1) * var(--epmg-col-gap)) / var(--epmg-cols));
    margin-bottom: var(--epmg-row-gap);
    float: left;
    box-sizing: border-box;
}

/* =============================================================
   EQUAL GRID  (CSS Grid — uniform rows)
   ============================================================= */
.epmg-equal-grid {
    display: grid;
    grid-template-columns: repeat(var(--epmg-cols), 1fr);
    column-gap: var(--epmg-col-gap);
    row-gap:    var(--epmg-row-gap);
}

.epmg-equal-grid > .epmg-card {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Style-2 card fills cell height in equal grid */
.epmg-equal-grid .epmg-style-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.epmg-equal-grid .epmg-style-card .epmg-card__body {
    flex: 1;
}

/* =============================================================
   SHARED IMAGE WRAP
   ============================================================= */
.epmg-card__image-wrap {
    display: block;
    width: 100%;
    overflow: hidden;
    position: relative;
    background: #e8e8e8;
    line-height: 0;          /* kills inline gap below <img> */
}

/* Auto = natural height — best for Masonry */
.epmg-ratio-auto > .epmg-card__image {
    width: 100%;
    height: auto;
    display: block;
}

/* Fixed ratio helpers */
.epmg-ratio-16-9 { aspect-ratio: 16 / 9; }
.epmg-ratio-4-3  { aspect-ratio: 4  / 3; }
.epmg-ratio-1-1  { aspect-ratio: 1  / 1; }
.epmg-ratio-3-4  { aspect-ratio: 3  / 4; }
.epmg-ratio-2-3  { aspect-ratio: 2  / 3; }

.epmg-ratio-16-9 > .epmg-card__image,
.epmg-ratio-4-3  > .epmg-card__image,
.epmg-ratio-1-1  > .epmg-card__image,
.epmg-ratio-3-4  > .epmg-card__image,
.epmg-ratio-2-3  > .epmg-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Image hover zoom */
.epmg-card__image {
    transition: transform .5s cubic-bezier(.25, .8, .25, 1);
    will-change: transform;
}
.epmg-card__link:hover     .epmg-card__image,
.epmg-card__img-link:hover .epmg-card__image {
    transform: scale(1.05);
}

/* Placeholder (no featured image) */
.epmg-card__placeholder {
    width: 100%;
    min-height: 180px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.epmg-card__placeholder span {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
}

/* =============================================================
   STYLE 1 — Overlay (image-only card, hover reveals overlay)
   ============================================================= */
.epmg-style-overlay .epmg-card__link {
    display: block;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    line-height: 0;
}

/* Dark overlay — hidden by default */
.epmg-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    transition: opacity .35s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    /* pointer-events off so underlying link still works */
    pointer-events: none;
}

.epmg-card__link:hover .epmg-card__overlay {
    opacity: 1;
}

/* Overlay text: slide up on hover */
.epmg-card__overlay-content {
    width: 100%;
    text-align: center;
    transform: translateY(10px);
    transition: transform .38s cubic-bezier(.25, .8, .25, 1);
}
.epmg-card__link:hover .epmg-card__overlay-content {
    transform: translateY(0);
}

.epmg-card__date {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, .90);
    margin-bottom: 8px;
    line-height: 1.4;
    letter-spacing: .2px;
}

.epmg-card__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* =============================================================
   STYLE 2 — Card body below image
   ============================================================= */
.epmg-style-card {
    background: #fff;
    border: 1px solid #e2e2e2;
    overflow: hidden;
}

/* Image link — no gap */
.epmg-card__img-link {
    display: block;
    overflow: hidden;
    line-height: 0;
    text-decoration: none;
}

/* Card body text area */
.epmg-card__body {
    padding: 30px;
    line-height: normal;
    box-sizing: border-box;
}

/* Title — uppercase spaced */
.epmg-card__title-below {
    margin: 0 0 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1.6;
}
.epmg-card__title-below a {
    color: #1a1a1a;
    text-decoration: none;
    transition: color .2s;
}
.epmg-card__title-below a:hover { color: #555; }

/* Short divider line */
.epmg-card__divider {
    display: block;
    width: 24px;
    height: 1px;
    background: #1a1a1a;
    margin-bottom: 16px;
}

/* Read more */
.epmg-card__readmore {
    display: inline-block;
    font-size: 13px;
    font-weight: 400;
    color: #1a1a1a;
    text-decoration: none;
    letter-spacing: .1px;
    transition: color .2s;
}
.epmg-card__readmore:hover { color: #777; }

/* =============================================================
   INFINITE SCROLL
   ============================================================= */
.epmg-loading {
    text-align: center;
    padding: 36px 0;
}

.epmg-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, .1);
    border-top-color: #e91e8c;
    border-radius: 50%;
    animation: epmg-spin .7s linear infinite;
}
@keyframes epmg-spin { to { transform: rotate(360deg); } }

.epmg-end-message {
    text-align: center;
    padding: 24px 0;
    color: #aaa;
    font-size: 13px;
    letter-spacing: .3px;
}

/* No pages found */
.epmg-no-pages {
    padding: 48px 24px;
    text-align: center;
    color: #888;
    font-size: 14px;
    background: #f7f7f7;
    border-radius: 6px;
}

/* =============================================================
   ELEMENTOR EDITOR PREVIEW
   Masonry.js doesn't run in the editor, so use CSS Grid there
   ============================================================= */
.elementor-editor-active .epmg-masonry {
    display: grid;
    grid-template-columns: repeat(var(--epmg-cols), 1fr);
    column-gap: var(--epmg-col-gap);
    row-gap:    var(--epmg-row-gap);
}
.elementor-editor-active .epmg-masonry > .epmg-sizer { display: none; }
.elementor-editor-active .epmg-masonry > .epmg-card  {
    width: 100%;
    float: none;
    margin-bottom: 0;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1024px) {
    .epmg-card__title { font-size: 17px; }
}

@media (max-width: 767px) {
    .epmg-card__overlay  { padding: 14px; }
    .epmg-card__title    { font-size: 15px; }
    .epmg-card__date     { font-size: 12px; }
    .epmg-card__body     { padding: 20px; }
    .epmg-card__title-below { font-size: 11px; letter-spacing: 1.5px; }
}
