/* Pedigree Container */
.apm-pedigree-scroll {
    overflow-x: auto; /* Handles small screens */
    margin-top: 20px;
    border: 1px solid #ddd;
    padding: 10px;
}

/* Optional: Make the wrapper scrollable */
.apm-pedigree-section {
    margin-top: 15px;
    overflow-x: auto;
    border: 1px solid #eee; /* Visual boundary */
}

/* Update this existing rule in your CSS */
.apm-pedigree-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #ccc;
    background: #fff;
    /* CHANGE: Increase min-width so 5 gens don't look squished */
    min-width: 1200px;
}

/* The Cells */
.apm-ped-cell {
    border: 1px solid #ccc;
    padding: 5px;
    vertical-align: middle;
    text-align: center;
    background-color: #f9f9f9;
    min-width: 150px; /* Ensure boxes don't squash */
}

/* The Box inside the cell */
.apm-ped-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.apm-ped-img img {
    max-width: 80px;
    height: auto;
    border-radius: 4px;
    margin-bottom: 5px;
    border: 1px solid #bbb;
}

.apm-ped-info a {
    text-decoration: none;
    color: #333;
}

.apm-reg-num {
    font-size: 0.85em;
    color: #666;
}

/* Hover Effect */
.apm-ped-cell:hover {
    background-color: #eef;
}

/* If the table is Depth 8 or higher, make text smaller to fit better */
.apm-pedigree-table.depth-8 .apm-ped-box,
.apm-pedigree-table.depth-9 .apm-ped-box,
.apm-pedigree-table.depth-10 .apm-ped-box {
    font-size: 11px;
    padding: 2px;
}

.apm-pedigree-table.depth-10 .apm-ped-img img {
    max-width: 40px; /* Make images smaller in deep trees */
}

/* Gallery Grid */
.apm-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.apm-gallery-link img {
    width: 100%;
    height: 150px; /* Fixed height for neat rows */
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    transition: transform 0.2s;
}

.apm-gallery-link img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

/* --- PRETTY LIGHTBOX STYLES --- */

/* The Container (Hidden state) */
.apm-lightbox-overlay {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;

    /* Background: Dark but see-through with blur */
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px); /* Creates the "Frosted Glass" look */

    /* Flexbox to center the image perfectly */
    display: flex;
    justify-content: center;
    align-items: center;

    /* Animation Initial State: Invisible */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* The Active State (Added by JS) */
.apm-lightbox-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* The Image Content */
.apm-lightbox-content {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 8px; /* Soft corners */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); /* Deep shadow for depth */

    /* Animation Initial State: Slightly smaller */
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}

/* Image Scale Up on Open */
.apm-lightbox-overlay.is-active .apm-lightbox-content {
    transform: scale(1);
}

/* The Close Button */
.apm-lightbox-close {
    position: absolute;
    top: 25px;
    right: 30px;
    width: 40px;
    height: 40px;

    /* Style: Circular semi-transparent button */
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.apm-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg); /* Playful rotation effect */
}

/* --- LIGHTBOX NAVIGATION ARROWS --- */
.apm-lightbox-prev,
.apm-lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -25px; /* Center vertically */
    color: white;
    font-weight: bold;
    font-size: 35px;
    transition: 0.3s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    text-decoration: none;
    z-index: 10000;
}

/* Position Next to the Right */
.apm-lightbox-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

/* Position Prev to the Left */
.apm-lightbox-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

/* Hover Effect */
.apm-lightbox-prev:hover,
.apm-lightbox-next:hover {
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
}