/* =========================================================
   U Horses v1.12 — Horse Detail and My Horses layout fixes
   Scoped only to approved horse display modules.
========================================================= */

/* Shared safeguards: never allow grid children to force horizontal overflow. */
.uh-horse-detail-page,
.uh-horse-detail-page *,
.uh-my-horses-page,
.uh-my-horses-page * {
    box-sizing: border-box;
}

.uh-horse-detail-page,
.uh-horse-overview-grid,
.uh-horse-gallery-card,
.uh-horse-summary-card,
.uh-horse-detail-sections,
.uh-horse-detail-section,
.uh-detail-facts,
.uh-detail-item,
.uh-detail-label,
.uh-detail-value,
.uh-summary-meta,
.uh-summary-item,
.uh-summary-label,
.uh-summary-value,
.uh-my-horses-page,
.uh-my-horses-grid,
.uh-my-horse-card,
.uh-my-horse-body,
.uh-my-horse-heading,
.uh-horse-card-info-grid,
.uh-horse-meta-item,
.uh-horse-meta-label,
.uh-horse-meta-value {
    min-width: 0;
}

/* ---------------------------------------------------------
   My Horses cards
--------------------------------------------------------- */
.uh-my-horses-page .uh-my-horses-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.uh-my-horses-page .uh-my-horse-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: visible;
}

.uh-my-horses-page .uh-my-horse-media {
    display: block;
    width: 100%;
    overflow: hidden;
    border-radius: calc(var(--uh-radius-card, 16px) - 2px) calc(var(--uh-radius-card, 16px) - 2px) 0 0;
    background: var(--uh-background);
}

.uh-my-horses-page .uh-my-horse-media img,
.uh-my-horses-page .uh-my-horse-media .uh-horse-placeholder {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
}

.uh-my-horses-page .uh-my-horse-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.uh-my-horses-page .uh-horse-card-status-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    min-height: 26px;
}

.uh-my-horses-page .uh-status-badge {
    position: static;
    inset: auto;
    width: auto;
    max-width: 100%;
    white-space: normal;
}

.uh-my-horses-page .uh-my-horse-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
}

.uh-my-horses-page .uh-my-horse-heading h2 {
    margin: 0;
    color: var(--uh-text);
    font-size: clamp(19px, 1.35vw, 22px);
    font-weight: 700;
    line-height: 1.28;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-my-horses-page .uh-my-horse-heading h2 a {
    color: inherit;
    text-decoration: none;
}

.uh-my-horses-page .uh-my-horse-price {
    display: block;
    max-width: 100%;
    color: var(--uh-primary);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-my-horses-page .uh-horse-card-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
    margin: 0;
}

.uh-my-horses-page .uh-horse-meta-item {
    display: grid;
    align-content: start;
    gap: 4px;
    margin: 0;
}

.uh-my-horses-page .uh-horse-meta-item--full {
    grid-column: 1 / -1;
}

.uh-my-horses-page .uh-horse-meta-label,
.uh-my-horses-page .uh-horse-published dt {
    margin: 0;
    color: var(--uh-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.uh-my-horses-page .uh-horse-meta-value,
.uh-my-horses-page .uh-horse-published dd {
    margin: 0;
    color: var(--uh-muted);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-my-horses-page .uh-horse-card-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 13px 0;
    border-block: 1px solid var(--uh-border);
}

.uh-my-horses-page .uh-horse-card-stats > div {
    min-width: 0;
    text-align: center;
}

.uh-my-horses-page .uh-horse-card-stats dt {
    color: var(--uh-muted);
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
}

.uh-my-horses-page .uh-horse-card-stats dd {
    margin: 4px 0 0;
    color: var(--uh-text);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.uh-my-horses-page .uh-horse-published {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    margin: 0;
    padding-top: 0;
    border: 0;
}

.uh-my-horses-page .uh-my-horse-actions {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: auto;
}

.uh-my-horses-page .uh-my-horse-actions > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    white-space: normal;
    text-align: center;
}

/* ---------------------------------------------------------
   Horse Detail: top overview and summary
--------------------------------------------------------- */
.uh-horse-detail-page {
    display: grid;
    gap: 22px;
    width: 100%;
    max-width: 100%;
}

.uh-horse-detail-page .uh-horse-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, .9fr);
    gap: 22px;
    align-items: start;
}

.uh-horse-detail-page .uh-horse-gallery-card,
.uh-horse-detail-page .uh-horse-summary-card,
.uh-horse-detail-page .uh-seller-information,
.uh-horse-detail-page .uh-horse-detail-section,
.uh-horse-detail-page .uh-horse-related,
.uh-horse-detail-page .uh-horse-reviews {
    padding: 22px !important;
    overflow: visible;
}

.uh-horse-detail-page .uh-horse-main-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 14px;
    background: var(--uh-background);
}

.uh-horse-detail-page .uh-horse-main-image img,
.uh-horse-detail-page .uh-horse-main-image .uh-horse-placeholder {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uh-horse-detail-page .uh-detail-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.uh-horse-detail-page .uh-detail-title-copy {
    min-width: 0;
}

.uh-horse-detail-page .uh-detail-title-row h1 {
    margin: 12px 0 6px;
    color: var(--uh-text);
    font-size: clamp(27px, 2.5vw, 40px);
    font-weight: 700;
    line-height: 1.15;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-horse-detail-page .uh-detail-title-row p {
    margin: 0;
    color: var(--uh-muted);
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-horse-detail-page .uh-detail-price {
    margin: 22px 0;
    color: var(--uh-primary);
    font-size: clamp(28px, 3vw, 40px);
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-horse-detail-page .uh-summary-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.uh-horse-detail-page .uh-summary-item {
    display: grid;
    align-content: start;
    gap: 5px;
    min-height: 68px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--uh-border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--uh-background) 70%, var(--uh-card));
}

.uh-horse-detail-page .uh-summary-item--full {
    grid-column: 1 / -1;
}

.uh-horse-detail-page .uh-summary-label,
.uh-horse-detail-page .uh-detail-label {
    margin: 0;
    color: var(--uh-text) !important;
    font-size: 12px;
    font-weight: 600 !important;
    line-height: 1.35;
    letter-spacing: .01em;
}

.uh-horse-detail-page .uh-summary-value,
.uh-horse-detail-page .uh-detail-value {
    min-width: 0;
    margin: 0;
    color: var(--uh-muted) !important;
    font-size: 14px;
    font-weight: 400 !important;
    line-height: 1.55;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-horse-detail-page .uh-summary-value a,
.uh-horse-detail-page .uh-detail-value a {
    color: var(--uh-primary);
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------
   Horse Detail information cards
--------------------------------------------------------- */
.uh-horse-detail-page .uh-horse-detail-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
    align-items: start;
}

.uh-horse-detail-page .uh-horse-detail-section h2,
.uh-horse-detail-page .uh-seller-information h2,
.uh-horse-detail-page .uh-horse-related h2,
.uh-horse-detail-page .uh-horse-reviews h2 {
    margin: 0 0 17px;
    color: var(--uh-text);
    font-size: 21px;
    font-weight: 700;
    line-height: 1.3;
}

.uh-horse-detail-page .uh-detail-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
    margin: 0;
}

.uh-horse-detail-page .uh-detail-item {
    display: grid;
    align-content: start;
    gap: 5px;
    min-width: 0;
    margin: 0;
    padding: 13px 0;
    border-bottom: 1px solid var(--uh-border);
}

.uh-horse-detail-page .uh-detail-item--full {
    grid-column: 1 / -1;
}

.uh-horse-detail-page .uh-detail-item--stacked {
    display: block;
}

.uh-horse-detail-page .uh-detail-item--stacked .uh-detail-label {
    display: block;
    margin-bottom: 7px;
}

.uh-horse-detail-page .uh-detail-item--stacked .uh-detail-value {
    display: block;
    width: 100%;
    max-width: 100%;
    color: var(--uh-text) !important;
    line-height: 1.65;
}

.uh-horse-detail-page .uh-detail-item--stacked .uh-detail-value p:last-child {
    margin-bottom: 0;
}

.uh-horse-detail-page .uh-detail-description {
    grid-column: 1 / -1;
}

.uh-horse-detail-page .uh-detail-long-text,
.uh-horse-detail-page .uh-detail-long-text p {
    color: var(--uh-text);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.65;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.uh-horse-detail-page .uh-detail-long-text {
    max-width: 86ch;
}

.uh-horse-detail-page .uh-seller-profile > div,
.uh-horse-detail-page .uh-related-horse-grid > *,
.uh-horse-detail-page .uh-horse-reviews article {
    min-width: 0;
}

.uh-horse-detail-page .uh-seller-profile h3,
.uh-horse-detail-page .uh-seller-profile p,
.uh-horse-detail-page .uh-related-horse-grid strong,
.uh-horse-detail-page .uh-horse-reviews p {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

/* ---------------------------------------------------------
   Responsive behavior
--------------------------------------------------------- */
@media (min-width: 1700px) {
    .uh-my-horses-page .uh-my-horses-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1240px) {
    .uh-my-horses-page .uh-my-horses-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .uh-horse-detail-page .uh-horse-overview-grid {
        grid-template-columns: 1fr;
    }

    .uh-horse-detail-page .uh-horse-summary-card {
        position: static;
    }
}

@media (max-width: 900px) {
    .uh-horse-detail-page .uh-horse-detail-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .uh-my-horses-page .uh-my-horses-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .uh-my-horses-page .uh-my-horse-body {
        padding: 17px;
    }

    .uh-my-horses-page .uh-my-horse-actions > a {
        flex: 1 1 calc(50% - 5px);
        min-width: 125px;
    }

    .uh-horse-detail-page {
        gap: 15px;
    }

    .uh-horse-detail-page .uh-horse-gallery-card,
    .uh-horse-detail-page .uh-horse-summary-card,
    .uh-horse-detail-page .uh-seller-information,
    .uh-horse-detail-page .uh-horse-detail-section,
    .uh-horse-detail-page .uh-horse-related,
    .uh-horse-detail-page .uh-horse-reviews {
        padding: 17px !important;
    }

    .uh-horse-detail-page .uh-detail-title-row h1 {
        font-size: 26px;
    }

    .uh-horse-detail-page .uh-related-horse-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .uh-horse-detail-page .uh-summary-meta,
    .uh-horse-detail-page .uh-detail-facts {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .uh-horse-detail-page .uh-summary-meta {
        gap: 10px;
    }

    .uh-horse-detail-page .uh-summary-item,
    .uh-horse-detail-page .uh-summary-item--full,
    .uh-horse-detail-page .uh-detail-item,
    .uh-horse-detail-page .uh-detail-item--full {
        grid-column: auto;
    }

    .uh-horse-detail-page .uh-detail-title-row {
        gap: 10px;
    }

    .uh-my-horses-page .uh-horse-card-info-grid {
        grid-template-columns: 1fr;
    }

    .uh-my-horses-page .uh-horse-meta-item--full {
        grid-column: auto;
    }

    .uh-my-horses-page .uh-horse-published {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

@media (max-width: 380px) {
    .uh-my-horses-page .uh-my-horse-actions > a {
        flex-basis: 100%;
        width: 100%;
    }

    .uh-horse-detail-page .uh-related-horse-grid {
        grid-template-columns: 1fr;
    }

    .uh-horse-detail-page .uh-detail-price {
        font-size: 26px;
    }
}
