/* ==========================================================
   🎨 THEME CUSTOMIZATION VARIABLES
   ========================================================== */
.smile-gallery-wrapper {
    --sg-primary: #3a9fc0;
    --sg-primary-hover: #4bbbdf;
    --sg-secondary: #e9ecef;
    --sg-secondary-text: #333333;
    --sg-text-main: #1a1a1a;
    --sg-font-family: inherit;
    --sg-radius: 12px;
    font-family: var(--sg-font-family);
}

.sg-browse-heading { text-align: center; margin-bottom: 24px; color: var(--sg-text-main); font-weight: bold; }
.filter-bar { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 40px; max-width: 1200px; margin-left: auto; margin-right: auto; }
.filter-btn { background-color: transparent; border: 2px solid var(--sg-primary); color: var(--sg-primary); padding: 10px 20px; border-radius: 30px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; font-family: inherit; }
.filter-btn:hover { background-color: rgba(58, 159, 192, 0.1); }
.filter-btn.active { background-color: var(--sg-primary); color: #ffffff; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 30px; max-width: 1200px; margin: 0 auto; }

/* THE CLEAN CARD FRAME */
.case-card {
    background: #ffffff;
    border-radius: var(--sg-radius);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
    position: relative;
    z-index: 1;
}
.case-card:hover {
    transform: translateY(-4px);
}

/* THE SLIDER CONTAINER */
.ba-slider {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: #f8f9fa;
    border-top-left-radius: var(--sg-radius);
    border-top-right-radius: var(--sg-radius);
    /* THIS IS THE MAGIC! It allows the child image to measure this box */
    container-type: inline-size;
}

.ba-slider .img-after {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    border-top-left-radius: var(--sg-radius);
    border-top-right-radius: var(--sg-radius);
}

/* THE NEW WRAPPER CROP BOX */
.img-before-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50%; /* Adjusted dynamically by JS */
    overflow: hidden; /* This natively slices the image AND label! */
    z-index: 2;
    border-top-left-radius: var(--sg-radius);
}

.img-before-wrapper .img-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100cqw; /* ALWAYS forces the image to be the exact width of .ba-slider! */
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    border-top-left-radius: var(--sg-radius);
    max-width: none;
}

/* Before / After Corner Labels */
.ba-label {
    position: absolute;
    top: 12px;
    padding: 4px 14px;
    background: rgba(0, 0, 0, 0.75);
    color: #e5e7eb;
    font-size: 0.65em;
    font-weight: 500;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .12em;
    z-index: 5;
    pointer-events: none;
}
.label-before { left: 12px; }
.label-after {
    right: 12px;
    color: #00BCD4;
    border: solid 1px #00BCD4;
}

/* Slider Controls */
.slider-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; background: #ffffff; transform: translateX(-50%); z-index: 3; pointer-events: none; box-shadow: 0 0 10px rgba(0,0,0,0.3); }
.ba-slider .slider-input { position: absolute; top: 0; left: -20px; width: calc(100% + 40px); height: 100%; background: transparent; outline: none; margin: 0; -webkit-appearance: none; appearance: none; cursor: ew-resize; z-index: 10; }

.ba-slider .slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9l-4 3 4 3'/%3E%3Cpath d='M16 15l4-3-4-3'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    cursor: pointer;
}
.ba-slider .slider-input::-moz-range-thumb {
    width: 40px;
    height: 40px;
    border: none;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 9l-4 3 4 3'/%3E%3Cpath d='M16 15l4-3-4-3'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    cursor: pointer;
}

/* --- UPDATED CARD INFO & PILLS --- */
.case-info { padding: 24px; flex-grow: 1; display: flex; flex-direction: column; }
.card-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }

.case-info .category-pill,
.case-info .btn-pill-small {
    display: inline-block;
    padding: 6px 14px;
    background: var(--sg-secondary);
    border: 1px solid var(--sg-secondary);
    color: var(--sg-secondary-text);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.case-info .btn-pill-small:hover { filter: brightness(0.9); }

.case-info .category-pill {
    display: inline-block;
    padding: 6px 14px;
    background: var(--sg-secondary);
    color: var(--sg-primary);
    border: 1px solid var(--sg-primary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.case-info .card-header-row .category-pill:hover { background: var(--sg-primary); color: #ffffff; }
.case-info h3 { margin: 0; font-size: 1.25rem; color: var(--sg-text-main); line-height: 1.3; }

/* Case Count Tracker */
.case-count { text-align: center; margin-top: 40px; font-size: 1.05rem; font-weight: 600; color: #666; }
.no-results { grid-column: 1 / -1; text-align: center; padding: 40px; color: #666; font-size: 1.2rem; }

h2.sg-browse-heading,
.case-count{ font-size: 1em; text-transform: uppercase; font-weight: 500; letter-spacing: .15em; margin-bottom: 45px; color: var(--sg-secondary-text); }

/* Modals & Loaders */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); z-index: 9999; justify-content: center; align-items: center; padding: 20px; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-content { background: #ffffff; border-radius: var(--sg-radius); width: 100%; max-width: 900px; max-height: 90vh; overflow-y: auto; position: relative; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: translateY(20px); transition: transform 0.3s ease; font-family: var(--sg-font-family); }
.modal-overlay.active .modal-content { transform: translateY(0); }
.close-modal-btn { position: absolute; top: 20px; right: 20px; background: var(--sg-secondary); border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 1.5rem; cursor: pointer; color: var(--sg-secondary-text); transition: background 0.2s ease; display: flex; align-items: center; justify-content: center; }
.close-modal-btn:hover { filter: brightness(0.9); }
.modal-header h2 { margin-top: 0; color: var(--sg-text-main); border-bottom: 2px solid #f4f7f6; padding-bottom: 15px; margin-bottom: 20px; }
.modal-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.modal-photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.sg-loader { border: 4px solid #f3f3f3; border-top: 4px solid var(--sg-primary); border-radius: 50%; width: 40px; height: 40px; animation: sg-spin 1s linear infinite; margin: 40px auto; }
@keyframes sg-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

@media (max-width: 1261px) { #gallery-container, #filter-bar, .sg-browse-heading { padding: 0 15px; } }