/* ============================================================
   DPC BEFORE / AFTER LAYOUT — dpc-before-after.css
   VERSION: 1.0.0
   ============================================================

   ARCHITECTURE
   ------------
   Styles for layout-before-after.php and dpc-before-after.js.
   Three interactive modes share a single fixed-size container:
     sidebyside — two images at 50% width
     drag       — stacked images with draggable divider
     toggle     — single image with crossfade swap

   RESPONSIVE
   ----------
   Mobile  ( < 768px )  — 1 pair per row
   Desktop ( >= 768px ) — 2 pairs per row

   All mode containers size to the same fixed stage height
   so layout never reflows when modes are switched.

   OVERLAY
   -------
   Centered modal, dark backdrop, fixed position.
   Overlay stage fills available space up to max dimensions.

   ============================================================ */


/* ------------------------------------------------------------
   LAYOUT WRAPPER
   ------------------------------------------------------------ */
.dpc-ba-layout {
    width: 100%;
    box-sizing: border-box;
    padding: 0 0 40px 0;
}


/* ------------------------------------------------------------
   PAGE HEADER
   ------------------------------------------------------------ */
.dpc-ba-header {
    text-align: center;
    margin-bottom: 32px;
}

.dpc-ba-page-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #1a1a1a;
}

.dpc-ba-page-description {
    font-size: 1rem;
    color: #555;
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.6;
}


/* ------------------------------------------------------------
   PAIRS GRID
   Mobile:  1 column
   Desktop: 2 columns
   ------------------------------------------------------------ */
.dpc-ba-pairs-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    width: 100%;
    box-sizing: border-box;
}

/* ------------------------------------------------------------
   INDIVIDUAL PAIR
   ------------------------------------------------------------ */
.dpc-ba-pair {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    box-sizing: border-box;
}


/* ------------------------------------------------------------
   STAGE
   Fixed aspect ratio container — all modes render inside here.
   Uses padding-top trick for responsive aspect ratio (4:3).
   JS builds content inside .dpc-ba-stage-inner.
   ------------------------------------------------------------ */
.dpc-ba-stage {
    position: relative;
    width: 1200px;
    max-width: 100%;
    height: 450px;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0 auto;
    display: block;
}

/* Mobile — constrain stage to natural image proportions */
@media ( max-width: 767px ) {

    .dpc-ba-stage {
        width: 100%;
        height: auto;
        min-height: unset;
    }

    .dpc-ba-stage--toggle {
        width: 85% !important;
        height: auto !important;
        min-height: unset !important;
        aspect-ratio: 4 / 3 !important;
    }

    .dpc-ba-pairs-wrap {
        padding: 0 12px;
        box-sizing: border-box;
    }

    .dpc-ba-pair {
        width: 85%;
    }

    .dpc-ba-stage--sidebyside > *:not(noscript) {
        position: static;
    }

    .dpc-ba-stage--sidebyside {
        display: flex;
        flex-direction: row;
    }

    .dpc-ba-stage--sidebyside .dpc-ba-img--before,
    .dpc-ba-stage--sidebyside .dpc-ba-img--after {
        width: 50%;
        height: auto !important;
        min-height: unset !important;
        object-fit: contain;
    }
}

/* Inner absolutely-positioned container — JS renders into this */
.dpc-ba-stage > *:not(noscript) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}


/* ------------------------------------------------------------
   SHARED IMAGE STYLES
   All mode images fill their container fully.
   object-fit: cover preserves aspect ratio without distortion.
   ------------------------------------------------------------ */
.dpc-ba-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    user-select: none;
    -webkit-user-drag: none;
}


/* ------------------------------------------------------------
   MODE: SIDE BY SIDE
   Both images at 50% width, side by side inside the stage.
   ------------------------------------------------------------ */
.dpc-ba-stage--sidebyside {
    display: flex;
    flex-direction: row;
    gap: 8px;
    background: #fff;
}

.dpc-ba-stage--sidebyside .dpc-ba-img--before,
.dpc-ba-stage--sidebyside .dpc-ba-img--after {
    flex: 1;
    min-width: 0;
    height: 100%;
    object-fit: cover;
    object-position: center;
    position: static;
    display: block;
}

p.dpc-ba-page-description {
    text-align: center;
}

h2.dpc-ba-page-title {
    text-align: center;
    font-weight: normal;
    color: #8b0000;
}

.dpc-ba-stage--sidebyside > * {
    position: static;           /* override absolute positioning */
}

.dpc-ba-stage--sidebyside .dpc-ba-img--before,
.dpc-ba-stage--sidebyside .dpc-ba-img--after {
    width: 50%;
    height: 100%;
    min-height: 200px;
}

.dpc-ba-stage--sidebyside .dpc-ba-img--before {
    border-right: 3px solid #fff;
    margin-right: 4px;
}

.dpc-ba-stage--sidebyside .dpc-ba-img--after {
    margin-left: 4px;
}

/*   MODE: CLICK TOGGLE */

.dpc-ba-stage--toggle {
    cursor: pointer;
    background: #000;
}

/* MODE: IMAGE FADE
   Single image container — centered, 800x600
   Two images stacked, JS controls opacity transition */

/* MODE: IMAGE FADE
   Single image container — centered, 800x600
   Two images stacked, JS controls opacity transition */

.dpc-ba-stage--toggle {
    cursor: pointer;
    background: #000;
    position: relative;
    width: 800px;
    max-width: 100%;
    height: 600px;
    margin: 0 auto;
}

.dpc-ba-stage--toggle .dpc-ba-toggle-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Both images stacked — opacity and transition controlled by JS inline styles */
.dpc-ba-toggle-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    user-select: none;
    -webkit-user-drag: none;
}

/* Fade instruction — below controls, centered */
.dpc-ba-fade-hint {
    text-align: center;
    font-size: 12px;
    color: #555;
    margin-top: 6px;
    font-style: italic;
}

/* ------------------------------------------------------------
 *  LABELS — Before / After
 *  Below the stage, one label per side.
   ------------------------------------------------------------ */
/* Side by side — labels centered under each image */
.dpc-ba-labels {
    display: flex;
    justify-content: space-between;
    padding: 6px 2px;
    margin-top: 4px;
}

.dpc-ba-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #555;
    width: 50%;
}

.dpc-ba-label--before {
    text-align: center;
    padding-right: 4px;
}

.dpc-ba-label--after {
    text-align: center;
    padding-left: 4px;
}

/* Fade mode — single centered label */
.dpc-ba-stage--toggle ~ .dpc-ba-labels {
    justify-content: center;
}

.dpc-ba-stage--toggle ~ .dpc-ba-labels .dpc-ba-label--before,
.dpc-ba-stage--toggle ~ .dpc-ba-labels .dpc-ba-label--after {
    display: none;
}

/* Controls — centered below stage */
.dpc-ba-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}


/* ------------------------------------------------------------
   CONTROLS — mode buttons + fullscreen icon
   ------------------------------------------------------------ */
.dpc-ba-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Mode buttons */
.dpc-ba-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f7f7f7;
    color: #333;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1.4;
}

.dpc-ba-btn:hover {
    background: #e8e8e8;
    border-color: #999;
}

.dpc-ba-btn.is-active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.dpc-ba-btn.is-active:hover {
    background: #1a5a8a;
    border-color: #1a5a8a;
}

/* Full Screen View button */
.dpc-ba-btn--fullscreen {
    margin-left: auto;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #2271b1;
    border-radius: 3px;
    background: #f7f7f7;
    color: #2271b1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.dpc-ba-btn--fullscreen:hover {
    background: #2271b1;
    color: #fff;
}


/* ------------------------------------------------------------
   OVERLAY — centered modal, dark backdrop
   ------------------------------------------------------------ */
.dpc-ba-overlay {
    display: none;   /* JS sets to flex on open */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.88);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 20px;
}

/* Inner panel */
.dpc-ba-overlay-inner {
    position: relative;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    background: #1a1a1a;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.8);
}

/* Close button */
.dpc-ba-overlay-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 36px;
    height: 36px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.dpc-ba-overlay-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Overlay stage — fills available vertical space */
.dpc-ba-stage--overlay {
    flex: 1;
    padding-top: 0;       /* override aspect-ratio padding */
    min-height: 300px;
    max-height: 70vh;
}

/* Overlay labels */
.dpc-ba-labels--overlay {
    padding: 8px 16px;
    background: #111;
}

.dpc-ba-labels--overlay .dpc-ba-label {
    color: #aaa;
}

/* Overlay controls */
.dpc-ba-controls--overlay {
    padding: 10px 16px;
    background: #111;
    border-top: 1px solid #333;
    gap: 8px;
}

.dpc-ba-controls--overlay .dpc-ba-btn {
    background: #2a2a2a;
    border-color: #444;
    color: #ccc;
}

.dpc-ba-controls--overlay .dpc-ba-btn:hover {
    background: #3a3a3a;
    border-color: #666;
    color: #fff;
}

.dpc-ba-controls--overlay .dpc-ba-btn.is-active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}


/* ------------------------------------------------------------
   BEFORE-AFTER OPTIONS BOX — Admin UI panel
   Matches existing .dpc-slider-box styling pattern.
   ------------------------------------------------------------ */
.dpc-before-after-box {
    margin-top: 4px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f6f7f7;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
}

.dpc-before-after-box h3 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}
