/*
 * Sports League Management by TreyBraid – Diamond
 * Baseball League Management
 * Diamond 1.0.14 Responsive Regression Hotfix
 * Copyright (C) 2026 TreyBraid
 * License: GNU General Public License version 2 or later (GPL-2.0-or-later)
 */

/* Critical desktop defaults: mobile-only structures must never leak into desktop layouts. */
.diamond-schedule-mobile-card,
.diamond-statleaders-featured-team-logo-mobile,
.diamond-statleaders-mobile-statline,
.diamond-statleaders-mobile-row {
    display: none;
}

/* Critical Boxscore image containment. HTML dimensions provide a second safeguard. */
.diamond-frontend-boxscore .diamond-boxscore-scoring-team img {
    width: 48px !important;
    height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    object-fit: contain !important;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading img {
    width: 34px !important;
    height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;
    flex: 0 0 34px !important;
    object-fit: contain !important;
}

/* Filter labels remain accessible to screen readers but are intentionally not visible. */
.diamond-standings-filter-field > label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Diamond 1.0.14 — Responsive regression hotfix. Loaded last with cache-busting. */
.diamond-schedule-mobile-card,
.diamond-statleaders-featured-team-logo-mobile,
.diamond-statleaders-mobile-statline,
.diamond-statleaders-mobile-row {
    display: none;
}
.diamond-team-link-label-long { display: none; }
.diamond-team-link-label-short { display: inline; }

/* Standings: keep Team | Location together on desktop and mobile. */
.diamond-standings-team {
    flex-direction: row;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}
.diamond-standings-team-location {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: 0;
}
.diamond-standings-location-separator {
    color: var(--bs-secondary-color, #6c757d);
    font-weight: 700;
}

/* Filtered standings: no spacer cells/rows; compact native controls. */
.diamond-standings-filters {
    width: 100%;
    margin-bottom: 1rem;
}
.diamond-standings-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    align-items: end;
}
.diamond-standings-filter-field {
    min-width: 0;
}
.diamond-standings-filter-field label {
    display: block;
    margin: 0 0 .3rem;
    font-weight: 700;
}
.diamond-standings-filter-field select {
    display: block;
    width: 100%;
    max-width: 100%;
}

/* Native baseball Boxscore scoring summary and comparison. */
.diamond-frontend-boxscore .diamond-boxscore-scoring-summary,
.diamond-frontend-boxscore .diamond-boxscore-team-comparison {
    width: 100%;
    font-size: var(--diamond-boxscore-content-size);
    font-weight: var(--diamond-boxscore-content-weight);
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-event {
    display: grid;
    grid-template-columns: 64px minmax(90px, .7fr) minmax(0, 2.4fr);
    align-items: center;
    gap: .65rem;
    min-width: 0;
    padding: .65rem .8rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-event:first-child {
    border-top: 0;
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-team {
    display: flex;
    align-items: center;
    justify-content: center;
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-team img {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-score {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}
.diamond-frontend-boxscore .diamond-boxscore-scoring-note {
    min-width: 0;
    overflow-wrap: anywhere;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.3fr) repeat(2, minmax(0, 1fr));
    align-items: stretch;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-row > div {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: .55rem .65rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    border-right: 1px solid var(--bs-border-color, #dee2e6);
    text-align: center;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-row > div:last-child {
    border-right: 0;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-head > div {
    border-top: 0;
    background: var(--bs-secondary-bg, #e9ecef);
    font-weight: 800;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-label {
    justify-content: flex-start !important;
    text-align: left !important;
    font-weight: 700;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading {
    gap: .35rem;
    overflow: hidden;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading img {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    object-fit: contain;
}
.diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Diamond 1.0.16 — Player Profile circular portrait on desktop and mobile. */
.diamond-player-profile-photo {
    width: min(100%, 320px);
    max-width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    clip-path: circle(50% at 50% 50%);
}

@media (max-width: 767.98px) {
    /* Team Profile: compact baseball navigation labels on phones/tablets. */
    .diamond-team-link-label-long { display: none; }
    .diamond-team-link-label-short { display: inline; }
    .diamond-team-links a.diamond-team-subpage-link { flex-basis: auto; }

    /* Player Profile: same circular portrait treatment used by Stat Leaders. */
    .diamond-player-photo-card-body {
        padding: .8rem;
    }
    .diamond-player-profile-photo {
        width: min(100%, 360px);
        max-width: 100%;
        height: auto;
        max-height: none;
        aspect-ratio: 1 / 1;
        object-fit: cover;
        object-position: center;
        border-radius: 50%;
        clip-path: circle(50% at 50% 50%);
    }

    /* Schedule: purpose-built mobile card; desktop table cells are hidden. */
    .diamond-schedule-page .diamond-schedule-desktop-cell {
        display: none !important;
    }
    .diamond-schedule-page .diamond-schedule-row,
    .diamond-schedule-page .diamond-schedule-grid.diamond-schedule-league .diamond-schedule-row {
        display: grid;
        grid-template-columns: 1fr;
    }
    .diamond-schedule-mobile-card {
        display: block;
        grid-column: 1 / -1;
        min-width: 0;
        padding: .8rem;
    }
    .diamond-schedule-mobile-date {
        display: flex;
        align-items: baseline;
        gap: .35rem;
        margin-bottom: .65rem;
        font-size: clamp(.78rem, 3.2vw, .95rem);
        white-space: nowrap;
    }
    .diamond-schedule-mobile-matchup {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
        gap: .35rem;
        width: 100%;
    }
    .diamond-schedule-mobile-team {
        display: flex;
        align-items: center;
        min-width: 0;
        gap: .35rem;
        font-size: clamp(.66rem, 2.9vw, .9rem);
        font-weight: 700;
        line-height: 1.15;
        white-space: nowrap;
    }
    .diamond-schedule-mobile-team--visitor { justify-content: flex-end; text-align: right; }
    .diamond-schedule-mobile-team--home { justify-content: flex-start; text-align: left; }
    .diamond-schedule-mobile-team span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .diamond-schedule-mobile-team img {
        display: block;
        width: clamp(34px, 10vw, 48px);
        height: clamp(34px, 10vw, 48px);
        flex: 0 0 clamp(34px, 10vw, 48px);
        object-fit: contain;
    }
    .diamond-schedule-mobile-at {
        font-weight: 900;
        font-size: 1rem;
    }
    .diamond-schedule-mobile-result {
        margin: .45rem 0 .55rem;
        text-align: center;
        font-size: clamp(.9rem, 4vw, 1.15rem);
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .diamond-schedule-mobile-meta {
        display: flex;
        align-items: center;
        gap: .35rem;
        min-width: 0;
        margin-top: .55rem;
        font-size: clamp(.66rem, 2.65vw, .84rem);
        line-height: 1.3;
        white-space: nowrap;
    }
    .diamond-schedule-mobile-meta > span:first-child {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .diamond-schedule-mobile-meta a { color: inherit; }
    .diamond-schedule-mobile-links {
        display: flex;
        align-items: center;
        gap: .4rem;
        min-width: 0;
        margin-top: .65rem;
        padding-top: .6rem;
        border-top: 1px solid var(--bs-border-color, #dee2e6);
        font-size: clamp(.62rem, 2.55vw, .78rem);
        white-space: nowrap;
    }
    .diamond-schedule-mobile-links > strong { flex: 0 0 auto; }
    .diamond-schedule-mobile-link-buttons {
        display: flex;
        align-items: center;
        gap: .3rem;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .diamond-schedule-mobile-link-buttons .btn {
        flex: 0 0 auto;
        padding: .32rem .4rem;
        font-size: clamp(.58rem, 2.4vw, .72rem);
        line-height: 1.1;
    }

    /* Stats: team logo overlays featured player portrait and batting stats stay on one line. */
    .diamond-statleaders-featured.is-mobile-batting .diamond-statleaders-featured-stats { display: none; }
    .diamond-statleaders-featured-media--player {
        position: relative;
        overflow: visible;
        border-radius: 0;
        clip-path: none;
    }
    .diamond-statleaders-featured-image--player {
        border-radius: 50%;
        clip-path: circle(50% at 50% 50%);
    }
    .diamond-statleaders-featured-team-logo-mobile {
        position: absolute;
        top: -.15rem;
        right: -.15rem;
        z-index: 3;
        display: block;
        width: clamp(42px, 13vw, 58px);
        height: clamp(42px, 13vw, 58px);
        padding: .18rem;
        border: 2px solid var(--bs-body-bg, #fff);
        border-radius: 50%;
        background: var(--bs-body-bg, #fff);
        object-fit: contain;
        box-shadow: 0 .125rem .3rem rgba(0,0,0,.18);
    }
    .diamond-statleaders-featured-team-logo { display: none; }
    .diamond-statleaders-mobile-statline {
        display: block;
        width: 100%;
        padding: .5rem .35rem;
        background: #ececec;
        border-top: 1px solid var(--bs-border-color, #dee2e6);
        overflow: hidden;
    }
    .diamond-statleaders-mobile-statline--featured { border-top: 1px solid var(--bs-border-color, #dee2e6); }
    .diamond-statleaders-mobile-statlabels,
    .diamond-statleaders-mobile-statvalues {
        display: grid;
        grid-template-columns: repeat(10, minmax(0, 1fr));
        align-items: center;
        width: 100%;
        gap: 0;
        font-size: clamp(.5rem, 2.15vw, .72rem);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }
    .diamond-statleaders-mobile-statlabels {
        margin-bottom: .22rem;
        font-weight: 800;
    }
    .diamond-statleaders-mobile-statlabels span,
    .diamond-statleaders-mobile-statvalues span {
        min-width: 0;
        padding: 0 .05rem;
        text-align: center;
        overflow: hidden;
    }
    .diamond-statleaders-mobile-row {
        display: block;
        grid-column: 1 / -1;
        width: 100%;
        padding: .55rem .35rem .35rem;
    }
    .diamond-statleaders-mobile-name {
        margin-bottom: .35rem;
        font-size: clamp(.78rem, 3vw, .95rem);
    }
    .diamond-statleaders-row-has-mobile-line > .diamond-grid-cell { display: none !important; }
    .diamond-statleaders-row-has-mobile-line .diamond-statleaders-mobile-statline {
        padding: .35rem 0 0;
        border-top: 0;
        background: transparent;
    }

    /* Boxscore headers/content remain visible and fit the phone width. */
    .diamond-frontend-boxscore .diamond-boxscore-card-header,
    .diamond-frontend-boxscore .diamond-boxscore-team-card-header,
    .diamond-frontend-boxscore .diamond-boxscore-section-title {
        display: flex !important;
        align-items: center;
        min-height: 0;
        padding: .5rem .6rem;
        font-size: clamp(.72rem, 3vw, .9rem) !important;
        line-height: 1.2;
    }
    .diamond-frontend-boxscore .diamond-boxscore-stat-label,
    .diamond-frontend-boxscore .diamond-boxscore-stat-value,
    .diamond-frontend-boxscore .diamond-boxscore-player-name {
        display: block !important;
    }
    .diamond-frontend-boxscore .diamond-boxscore-compact-grid {
        min-width: 0;
    }
    .diamond-frontend-boxscore .diamond-boxscore-compact-row {
        grid-template-columns: minmax(70px, 1.7fr) repeat(var(--diamond-boxscore-stat-columns), minmax(21px, .55fr));
        min-height: 32px;
        font-size: clamp(.52rem, 2.15vw, .72rem) !important;
    }
    .diamond-frontend-boxscore .diamond-boxscore-compact-name,
    .diamond-frontend-boxscore .diamond-boxscore-compact-stat {
        min-width: 0;
        padding: .3rem .08rem;
        font-size: inherit !important;
        line-height: 1.1;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .diamond-frontend-boxscore .diamond-boxscore-compact-name { padding-left: .25rem; }
    .diamond-frontend-boxscore .diamond-boxscore-player-stat-card .card-body > .row {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: .2rem;
        margin: 0;
    }
    .diamond-frontend-boxscore .diamond-boxscore-player-stat-card .card-body > .row > .col {
        width: auto;
        max-width: none;
        padding: 0;
    }
    .diamond-frontend-boxscore .diamond-boxscore-stat-chip {
        min-height: 0;
        padding: .3rem .08rem;
        font-size: clamp(.52rem, 2.2vw, .72rem) !important;
    }
    .diamond-frontend-boxscore .diamond-boxscore-stat-chip .diamond-boxscore-stat-label,
    .diamond-frontend-boxscore .diamond-boxscore-stat-chip .diamond-boxscore-stat-value {
        margin: 0;
        font-size: inherit !important;
        line-height: 1.15;
        white-space: nowrap;
    }
    .diamond-frontend-boxscore .diamond-boxscore-content-list .list-group-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        justify-content: space-between;
        gap: .4rem;
        font-size: clamp(.68rem, 2.8vw, .86rem) !important;
        white-space: nowrap;
    }
    .diamond-frontend-boxscore .diamond-boxscore-content-list .list-group-item span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .diamond-frontend-boxscore .diamond-boxscore-scoring-event {
        grid-template-columns: 44px minmax(48px, .55fr) minmax(0, 2.4fr);
        gap: .35rem;
        padding: .5rem .45rem;
        font-size: clamp(.64rem, 2.7vw, .82rem);
    }
    .diamond-frontend-boxscore .diamond-boxscore-scoring-team img {
        width: 38px;
        height: 38px;
    }
    .diamond-frontend-boxscore .diamond-boxscore-scoring-note { line-height: 1.2; }
    .diamond-frontend-boxscore .diamond-boxscore-comparison-row {
        grid-template-columns: minmax(88px, 1.25fr) repeat(2, minmax(0, 1fr));
        font-size: clamp(.6rem, 2.55vw, .8rem);
    }
    .diamond-frontend-boxscore .diamond-boxscore-comparison-row > div {
        padding: .45rem .25rem;
    }
    .diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading {
        flex-direction: column;
        gap: .15rem;
        line-height: 1.05;
    }
    .diamond-frontend-boxscore .diamond-boxscore-comparison-team-heading img {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }
}

@media (max-width: 575.98px) {
    /* Roster list: phone-width circular portrait, then one-line Label Value rows. */
    .diamond-roster-row {
        grid-template-columns: 1fr !important;
    }
    .diamond-roster-photo {
        grid-column: 1 / -1;
        grid-row: auto;
        width: 100%;
        padding: .9rem;
        align-items: center !important;
        justify-content: center !important;
    }
    .diamond-roster-photo::before { display: none !important; }
    .diamond-roster-photo img {
        width: min(100%, 360px) !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
        object-fit: cover;
        object-position: center;
        border-radius: 50% !important;
        clip-path: circle(50% at 50% 50%);
    }
    .diamond-roster-cell:not(.diamond-roster-photo) {
        flex-direction: row !important;
        align-items: baseline !important;
        justify-content: flex-start !important;
        gap: .35rem !important;
        min-height: 0;
        padding: .55rem .65rem;
        white-space: normal;
    }
    .diamond-roster-cell:not(.diamond-roster-photo)::before {
        display: inline !important;
        flex: 0 0 auto;
        margin: 0;
        font-size: .78em;
        line-height: 1.35;
        white-space: nowrap;
    }

    /* Roster cards receive the same phone-width circular portrait treatment. */
    .diamond-roster-card-grid { grid-template-columns: 1fr; }
    .diamond-roster-card-inner { grid-template-columns: 1fr; }
    .diamond-roster-card-photo-wrap {
        width: 100%;
        aspect-ratio: 1 / 1;
        border-radius: 50%;
        clip-path: circle(50% at 50% 50%);
    }
    .diamond-roster-card-photo {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        clip-path: circle(50% at 50% 50%);
    }
    .diamond-roster-card-details > div {
        display: flex;
        align-items: baseline;
        gap: .35rem;
        min-width: 0;
    }
    .diamond-roster-card-details dt,
    .diamond-roster-card-details dd {
        margin: 0;
        white-space: normal;
    }
    .diamond-roster-card-details dt { flex: 0 0 auto; }

    /* Standings: one compact stat line W | L | T | PCT | PF | PA | STK. */
    .diamond-standings-grid.has-ties .diamond-standings-row {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }
    .diamond-standings-grid.no-ties .diamond-standings-row {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
    .diamond-standings-logo {
        grid-column: 1;
        grid-row: 1;
        padding: .55rem .25rem;
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    }
    .diamond-standings-team {
        grid-column: 2 / -1;
        grid-row: 1;
        min-height: 64px;
        padding: .55rem .4rem;
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
        font-size: clamp(.72rem, 3vw, .9rem);
    }
    .diamond-standings-stat {
        grid-row: 2;
        min-width: 0;
        gap: .12rem;
        padding: .42rem .05rem .48rem;
        border-top: 0;
        font-size: clamp(.62rem, 2.6vw, .78rem);
        line-height: 1.1;
    }
    .diamond-standings-stat::before {
        font-size: .72em;
        white-space: nowrap;
    }

    /* Filtered standings dropdowns stack tightly with no empty spacer row. */
    .diamond-standings-filter-grid {
        grid-template-columns: 1fr;
        gap: .35rem;
    }
    .diamond-standings-filter-field label {
        margin-bottom: .12rem;
        font-size: .82rem;
    }
}


/* Diamond 1.0.16 — Team Profile embedded baseball statistics. */
.diamond-team-profile-stats .table-responsive {
    -webkit-overflow-scrolling: touch;
}
.diamond-team-profile-stats .table {
    min-width: max-content;
}
.diamond-team-profile-stats .card-header h3 {
    font-weight: 800;
}
@media (max-width: 767.98px) {
    .diamond-team-profile-stats .d-flex.justify-content-between {
        align-items: flex-start !important;
    }
    .diamond-team-profile-stats .table {
        font-size: clamp(.72rem, 2.8vw, .86rem);
    }
    .diamond-team-profile-stats th,
    .diamond-team-profile-stats td {
        padding: .45rem .5rem;
        white-space: nowrap;
    }
}

/* Diamond 1.0.38: loaded-last frontend Team Administration form normalization. */
.diamond-team-editor .control-group {
    display: block !important;
    width: 100% !important;
    margin: 0 0 1rem !important;
}
.diamond-team-editor .control-label,
.diamond-team-editor .diamond-team-editor-field .control-label {
    float: none !important;
    display: block !important;
    width: auto !important;
    margin: 0 0 .35rem !important;
    padding: 0 !important;
    font-weight: 600;
    text-align: left !important;
}
.diamond-team-editor .controls,
.diamond-team-editor .diamond-team-editor-field .controls {
    display: block !important;
    width: 100% !important;
    margin-left: 0 !important;
}
.diamond-team-editor input[type="text"],
.diamond-team-editor input[type="email"],
.diamond-team-editor input[type="tel"],
.diamond-team-editor input[type="url"],
.diamond-team-editor input[type="number"],
.diamond-team-editor input[type="password"],
.diamond-team-editor input[type="search"],
.diamond-team-editor input[type="date"],
.diamond-team-editor input[type="time"],
.diamond-team-editor select,
.diamond-team-editor textarea,
.diamond-team-editor .input-group,
.diamond-team-editor .field-calendar,
.diamond-team-editor .choices,
.diamond-team-editor .joomla-field-fancy-select {
    width: 100% !important;
    max-width: 100% !important;
}

/* Diamond 1.0.38: Team Administration editor routing/layout runtime hardening. */
.diamond-schedule-editor .diamond-calendar-card,
.diamond-schedule-editor .diamond-calendar-card > .card-body {
    position: relative;
    overflow: visible !important;
    z-index: 20;
}
.diamond-schedule-editor .field-calendar,
.diamond-schedule-editor .field-calendar .input-group {
    position: relative;
    overflow: visible !important;
    z-index: 25;
}
.diamond-schedule-editor .js-calendar,
.diamond-schedule-editor joomla-calendar,
.diamond-schedule-editor .joomla-calendar,
.diamond-schedule-editor .calendar-container {
    z-index: 1200 !important;
}
.diamond-location-editor .diamond-management-card {
    overflow: visible;
}
.diamond-location-editor .diamond-location-fields-card .control-group {
    margin-bottom: 0 !important;
}
.diamond-location-editor .subform-repeatable-wrapper,
.diamond-location-editor .subform-repeatable {
    width: 100%;
}
.diamond-location-editor .subform-repeatable table {
    margin-bottom: 0;
}
@media (max-width: 767.98px) {
    .diamond-location-editor .diamond-management-card > .card-body {
        padding: .9rem;
    }
    .diamond-location-editor .subform-repeatable-wrapper {
        overflow-x: auto;
    }
}
