﻿/* Dog titles: keep abbreviations inline, provide safe truncation and responsive wrap */
.dog-info {
    min-width: 0;
}
/* allow children to shrink inside flex containers */

.dog-titles {
    display: inline-flex;
    flex-wrap: wrap;        /* allow items to flow to a new line */
    gap: 0.35rem;
    align-items: center;
    white-space: normal;    /* enable wrapping */
    max-width: 100%;
}

    /* Small styling for the abbr elements */
    .dog-titles abbr {
        display: inline-block;
        white-space: nowrap;    /* keep each abbreviation together */
        margin-right: 0;        /* spacing handled by gap */
        font-weight: 600;
        cursor: help;
    }

        /* Preserve accessibility focus outline */
        .dog-titles abbr:focus,
        .dog-titles abbr:focus-visible {
            outline: 3px solid rgba(13,110,253,0.12);
            outline-offset: 2px;
        }

/* On very narrow screens allow wrapping instead of forcing overflow */
@media (max-width: 575.98px) {
    .dog-titles {
        gap: 0.2rem;
    }
}

/* ---------------------------------------------------------------------------
   Thumbnail sizing for dog images inside pedigree views
   - Scoped so it does NOT reduce the larger .dog-cell visuals placed inside
     table cells with the parent's class `td.dog-cell-large`.
   - Uses object-fit: contain to avoid cropping on narrow screens.
   --------------------------------------------------------------------------- */

/* Pedigree table: smaller thumbnails for non-large cells */
.pedigree-table td:not(.dog-cell-large) .dog-cell .dog-image img {
    max-width: 100%;
    max-height: 120px; /* thumbnail height similar to gallery */
    width: auto;
    height: auto;
    object-fit: contain; /* match dog-gallery-img behavior */
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 6px;
}

/* Pedigree vertical / mobile portrait: keep thumbnails compact */
.pedigree-vertical .dog-cell .dog-image img,
.pedigree-row .dog-cell .dog-image img {
    max-width: 100%;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 6px;
}

/* Pedigree grid (uses larger central photo) — keep its existing pedigree-photo untouched.
   But if a small dog-cell appears inside the grid, ensure it's thumbnail-sized. */
.pedigree-grid .dog-cell .dog-image img {
    max-width: 100%;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 6px;
}

/* Ensure virtual-dog placeholder matches thumbnail sizing */
.pedigree-table td:not(.dog-cell-large) .dog-cell .dog-image-virtual,
.pedigree-vertical .dog-cell .dog-image-virtual,
.pedigree-grid .dog-cell .dog-image-virtual {
    min-height: 80px;
    max-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0.25rem;
}

/* Preserve larger images in explicit large cells */
td.dog-cell-large .dog-cell .dog-image img,
.dog-cell-large .dog-image img,
.dog-cell-large .dog-image-virtual {
    /* keep original large behaviour (site.css already handles large; this rule is a safe fallback) */
    max-height: 400px;
    object-fit: contain;
}

/* Pedigree: unified thumbnail sizing for all dog images used by Pedigree.cshtml
   - Scoped to pedigree containers to avoid affecting other pages.
   - Default is 4:3 thumbnails. Adjust the --ped-thumb-w / --ped-thumb-h values to change size.
*/

:root {
    --ped-thumb-w: 140px;
    --ped-thumb-h: 105px; /* 4:3 ratio */
}

/* Target images rendered by the _DogCellPartial inside pedigree views */
.pedigree-dog-container .dog-cell .dog-image img,
.pedigree-table td:not(.dog-cell-large) .dog-cell .dog-image img,
.pedigree-vertical .dog-cell .dog-image img,
.pedigree-grid .dog-cell .dog-image img {
    width: var(--ped-thumb-w);      /* fixed box width */
    height: var(--ped-thumb-h);     /* fixed box height */
    max-width: none;                /* override any width:100% rules */
    max-height: none;               /* override any max-height rules */
    object-fit: contain;            /* use contain to avoid cropping */
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 6px;
}

/* Virtual-dog placeholder should match thumbnail box */
.pedigree-dog-container .dog-cell .dog-image-virtual,
.pedigree-table td:not(.dog-cell-large) .dog-cell .dog-image-virtual,
.pedigree-vertical .dog-cell .dog-image-virtual,
.pedigree-grid .dog-cell .dog-image-virtual {
    width: var(--ped-thumb-w);
    height: var(--ped-thumb-h);
    min-height: unset;
    max-height: unset;
    box-sizing: border-box;
    padding: 0.25rem;
    border-radius: 6px;
}

/* Keep large pedigree cells unaffected */
td.dog-cell-large .dog-cell .dog-image img,
.dog-cell-large .dog-image img {
    width: auto;
    height: auto;
    max-height: 400px;
    object-fit: contain;
}

/* Add these simple rules to target only the partial when used in pedigree contexts */
:root {
    --ped-thumb-w: 140px;
    --ped-thumb-h: 105px;
}

/* Layout: image at left, info at right for pedigree usages */
.pedigree-dog-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    box-sizing: border-box;
}

/* Fixed thumbnail box */
.pedigree-dog-cell .dog-image {
    flex: 0 0 var(--ped-thumb-w);
    width: var(--ped-thumb-w);
    height: var(--ped-thumb-h);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: #f8f9fa;
}

/* Image fills the box (use 'contain' to avoid cropping) */
.pedigree-dog-cell .dog-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Info area to the right */
.pedigree-dog-cell .dog-info {
    flex: 1 1 auto;
    min-width: 0; /* allow truncation */
    text-align: left;
    padding: 0;
}

/* Virtual placeholder matches thumbnail size */
.pedigree-dog-cell .dog-image-virtual {
    width: var(--ped-thumb-w);
    height: var(--ped-thumb-h);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: #fff8e6;
}

/* Responsive: stack on small screens and allow images to scale without cropping */
@media (max-width: 767.98px) {
    :root {
        --ped-thumb-w: 110px;
        --ped-thumb-h: 82px;
    }
    .pedigree-dog-cell {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .pedigree-dog-cell .dog-info { text-align: center; }

    /* Mobile-specific: allow the image container to expand horizontally and the image to
       scale proportionally — preventing top/bottom cropping for portrait images. */
    .pedigree-dog-cell .dog-image,
    .pedigree-vertical .dog-cell .dog-image {
        width: 100%;
        height: auto;
        flex: 0 0 auto;
    }
    .pedigree-dog-cell .dog-image img,
    .pedigree-vertical .dog-cell .dog-image img {
        width: auto;
        max-width: 100%;
        height: auto;
        object-fit: contain;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }

    /* Remove full-width white background behind images on mobile */
    .pedigree-dog-cell .dog-image,
    .pedigree-vertical .dog-cell .dog-image {
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    /* Virtual placeholder should also be transparent on mobile */
    .pedigree-dog-cell .dog-image-virtual,
    .pedigree-vertical .dog-cell .dog-image-virtual {
        background: transparent;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    /* Stack image above info (tablet / small desktop) */
    .pedigree-dog-cell {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.5rem;
    }

        /* Allow the image to expand full-width of the partial, keep aspect */
        .pedigree-dog-cell .dog-image {
            width: 100%;
            height: auto;
            flex: 0 0 auto;
            max-width: var(--ped-thumb-w);
            padding: 0;
            background: transparent;
        }

            .pedigree-dog-cell .dog-image img {
                width: auto;
                max-width: 100%;
                height: auto;
                object-fit: contain;
                display: block;
                margin-left: auto;
                margin-right: auto;
            }

        /* Center info below image and allow truncation where needed */
        .pedigree-dog-cell .dog-info {
            text-align: center;
            width: 100%;
            padding-top: 0.25rem;
        }
}

@media (min-width: 768px) and (max-width: 1999px) {
    /* Info block */
    .pedigree-dog-cell .dog-info,
    .pedigree-table td .dog-cell .dog-info,
    .pedigree-vertical .dog-cell .dog-info {
        font-size: 0.85rem;    /* smaller body text */
        line-height: 1.1;
    }

    /* Dog name / link slightly larger than the rest but reduced */
    .pedigree-dog-cell .dog-cell-link,
    .pedigree-table td .dog-cell .dog-cell-link {
        font-size: 0.95rem;
        font-weight: 600;
    }

    /* Title abbreviations */
    .pedigree-dog-cell .dog-titles abbr,
    .pedigree-table td .dog-cell .dog-titles abbr {
        font-size: 0.7rem;
        font-weight: 500;
    }

    /* Registration and date */
    .pedigree-dog-cell .dog-info small,
    .pedigree-table td .dog-cell .dog-info small {
        font-size: 0.78rem;
    }

    /* Minor tweak for pedigree-grid labels */
    .pedigree-grid .gp-label,
    .pedigree-grid .pedigree-mid > div strong {
        font-size: 0.9rem;
    }
}

@media (min-width: 2000px) {
    /* Info block */
    .pedigree-dog-cell .dog-info,
    .pedigree-table td .dog-cell .dog-info,
    .pedigree-vertical .dog-cell .dog-info {
        font-size: 0.85rem; /* smaller body text */
        line-height: 1.1;
    }

    /* Dog name / link slightly larger than the rest but reduced */
    .pedigree-dog-cell .dog-cell-link,
    .pedigree-table td .dog-cell .dog-cell-link {
        font-size: 0.95rem;
        font-weight: 600;
    }

    /* Title abbreviations */
    .pedigree-dog-cell .dog-titles abbr,
    .pedigree-table td .dog-cell .dog-titles abbr {
        font-size: 0.8rem;
        font-weight: 600;
    }

    /* Registration and date */
    .pedigree-dog-cell .dog-info small,
    .pedigree-table td .dog-cell .dog-info small {
        font-size: 0.78rem;
    }

    /* Minor tweak for pedigree-grid labels */
    .pedigree-grid .gp-label,
    .pedigree-grid .pedigree-mid > div strong {
        font-size: 0.9rem;
    }
