/* =========================
   Before / After
   ========================= */
.bab-block {
    display: grid;
    margin-bottom: 28px;
    width: 100%;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    width: 100%;
}

.bab-item { min-width: 0; }

.bab-image-wrap {
    position: relative;
    line-height: 0;
}

.bab-image-wrap > .wp-block-image {
    margin: 0;
    width: 100%;
}

.bab-image-wrap > .wp-block-image img {
    width: 100%;
    height: auto;
}

.bab-item img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.bab-label {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 7px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .02em;
    box-sizing: border-box;
    text-shadow: 0 1px 2px rgba(0,0,0,.25);
    box-shadow: 0 2px 6px rgba(0,0,0,.22);
    pointer-events: none;
}

.bab-item:first-child .bab-label { background: #26364a; }
.bab-item:last-child .bab-label { background: #276749; }

.bab-arrow {
    flex: 0 0 auto;
    font-size: 28px;
    line-height: 1;
    color: #555;
    text-align: center;
    transform: rotate(90deg);
}

.bab-popup {
    display: block;
    cursor: zoom-in;
    text-decoration: none;
}

.bab-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    background: #fff;
    color: #1e1e1e;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    font-family: Arial, sans-serif;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.bab-remove:hover { background: #f3f3f3; }

.bab-change {
    position: absolute !important;
    left: 10px;
    bottom: 10px;
    z-index: 3;
    background: #fff !important;
    color: #1e1e1e !important;
    border: 1px solid #d0d0d0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    line-height: 1.4 !important;
}

.bab-select {
    width: 100%;
    min-height: 160px;
    background: #fff !important;
    color: #1e1e1e !important;
    border: 1px solid #c8c8c8 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    line-height: 1.4 !important;
}

@media (max-width: 600px) {
    .bab-block {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .bab-arrow {
        transform: rotate(180deg);
        font-size: 26px;
    }
    .bab-label {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 15px;
    }
}

/* =========================
   Gallery
   ========================= */
.my-gallery-block { width: 100%; box-sizing: border-box; margin-bottom: 28px; }

.my-gallery-grid,
.my-gallery-editor-grid {
    --my-gallery-columns: var(--my-gallery-desktop);
}

.my-gallery-grid.my-gallery-layout-square {
    display: grid;
    grid-template-columns: repeat(var(--my-gallery-columns), minmax(0, 1fr));
    gap: 0;
}

.my-gallery-layout-square .my-gallery-item {
    min-width: 0;
    margin: 0;
    padding: 0;
}

.my-gallery-layout-square .my-gallery-media {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.my-gallery-layout-square .my-gallery-media > img,
.my-gallery-layout-square .my-gallery-media > .my-gallery-link,
.my-gallery-layout-square .my-gallery-media > .my-gallery-link > img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
}

.my-gallery-layout-square .my-gallery-media > img,
.my-gallery-layout-square .my-gallery-link > img {
    object-fit: cover;
}

.my-gallery-grid.my-gallery-layout-tile {
    column-count: var(--my-gallery-columns);
    column-gap: 0;
}

.my-gallery-layout-tile .my-gallery-item {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.my-gallery-layout-tile .my-gallery-media {
    position: relative;
}

.my-gallery-layout-tile .my-gallery-media,
.my-gallery-layout-tile .my-gallery-media > img,
.my-gallery-layout-tile .my-gallery-link,
.my-gallery-layout-tile .my-gallery-link > img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.my-gallery-link {
    cursor: zoom-in;
    text-decoration: none;
}

.my-gallery-caption {
    box-sizing: border-box;
    margin: 0;
    padding: 7px 10px;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
}

.my-gallery-caption-hover {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    color: #fff;
    background: rgba(0, 0, 0, .38);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s ease, transform .18s ease;
}

.my-gallery-media:hover .my-gallery-caption-hover,
.my-gallery-media:focus-within .my-gallery-caption-hover {
    opacity: 1;
    transform: translateY(0);
}

.my-gallery-caption-always {
    display: block;
    background: transparent;
    color: inherit;
}

.my-gallery-caption-display-none .my-gallery-caption {
    display: none;
}

/* Editor */
.my-gallery-editor-grid {
    display: grid;
    grid-template-columns: repeat(var(--my-gallery-columns), minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.my-gallery-editor-item {
    min-width: 0;
    position: relative;
}

.my-gallery-editor-media {
    position: relative;
    width: 100%;
    background: #f6f6f6;
    border: 1px solid #d6d6d6;
    box-sizing: border-box;
}

.my-gallery-editor-grid.my-gallery-layout-square .my-gallery-editor-media {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.my-gallery-editor-media img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.my-gallery-editor-grid.my-gallery-layout-square .my-gallery-editor-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.my-gallery-item-controls { position: absolute; inset: 0; pointer-events: none; }
.my-gallery-item-controls > * { pointer-events: auto; }



.my-gallery-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    background: #fff;
    color: #1e1e1e;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.my-gallery-remove:hover {
    background: #f3f3f3;
}

.my-gallery-remove:focus {
    outline: 2px solid #3858e9;
    outline-offset: 1px;
}

.my-gallery-editor-caption { margin-top: 8px; }
.my-gallery-editor-caption .components-base-control { margin-bottom: 0; }

.my-gallery-order-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 7px;
}

.my-gallery-order-controls .components-button { min-width: 30px; justify-content: center; }
.my-gallery-order-label { min-width: 42px; color: #757575; font-size: 12px; text-align: center; }

.my-gallery-add-more {
    min-height: 42px;
    align-self: start;
    background: #fff !important;
    color: #1e1e1e !important;
    border: 1px solid #ccc !important;
}

@media (max-width: 900px) {
    .my-gallery-grid,
    .my-gallery-editor-grid { --my-gallery-columns: var(--my-gallery-tablet); }
}

@media (max-width: 600px) {
    .my-gallery-grid,
    .my-gallery-editor-grid { --my-gallery-columns: var(--my-gallery-mobile); }
    .my-gallery-editor-grid { gap: 10px; }
}
