@import url("site-theme.css");

@media (max-width: 768px) {
    html {
        max-width: 100%;
        overflow-x: clip;
    }

    body {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    img,
    video,
    canvas,
    svg {
        max-width: 100%;
    }

    main {
        width: 100%;
        min-width: 0;
        padding: 16px 12px !important;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)) !important;
    }

    .table-wrap,
    .sheet,
    .table-container,
    .table-responsive {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    table {
        display: block;
        width: max-content !important;
        min-width: 100% !important;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th,
    td {
        white-space: nowrap;
    }

    input,
    select,
    textarea {
        max-width: 100%;
    }

    form,
    nav,
    .nav,
    .navlinks,
    .top,
    .page-header,
    .top-buttons,
    .actions,
    .filters {
        max-width: 100%;
        min-width: 0;
        flex-wrap: wrap;
    }

    h1,
    h2,
    h3,
    p,
    a,
    label {
        overflow-wrap: anywhere;
    }

    button,
    .button,
    .btn,
    input[type="submit"] {
        max-width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    body {
        box-sizing: border-box;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    main {
        padding: 14px 0 !important;
    }

    .page-title {
        font-size: 30px;
    }

    .entry,
    .card,
    .sheet {
        padding: 12px;
    }
}

.match-view-toggle {
    display: inline-flex;
    gap: 0;
    margin-top: 18px;
    overflow: hidden;
    border: 1px solid #0f7a33;
    border-radius: 6px;
    background: #fff;
}

.match-view-toggle button {
    min-height: 42px;
    padding: 8px 14px;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #085522;
    font: inherit;
    cursor: pointer;
}

.match-view-toggle button[aria-pressed="true"] {
    background: #0f7a33;
    color: #fff;
}

.match-view-toggle button + button {
    border-left: 1px solid #0f7a33;
}

.match-view-toggle button:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid #1565c0;
    outline-offset: -3px;
}

.table-wrap[hidden],
.pairing-cards[hidden] {
    display: none !important;
}

.pairing-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 390px), 1fr));
    gap: 12px;
    margin-top: 12px;
}

.pairing-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid #dce7de;
    border-radius: 6px;
    background: #fff;
}

.pairing-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dce7de;
}

.pairing-card-heading h2,
.pairing-side h3,
.pairing-side p {
    margin: 0;
}

.pairing-card-heading h2 {
    color: #085522;
    font-size: 18px;
}

.pairing-status {
    color: #405347;
    font-size: 14px;
    text-align: right;
}

.pairing-side {
    padding-top: 12px;
}

.pairing-side + .pairing-side {
    margin-top: 12px;
    border-top: 1px solid #dce7de;
}

.pairing-side h3 {
    font-size: 16px;
}

.pairing-scores {
    display: grid;
    grid-template-columns: repeat(var(--series-count), minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
}

.pairing-series {
    min-width: 0;
    padding: 6px 3px;
    border-radius: 4px;
    background: #f3f7f3;
    text-align: center;
}

.pairing-series-label {
    display: block;
    color: #59675d;
    font-size: 11px;
}

.pairing-series-score {
    display: block;
    font-size: 17px;
    font-weight: 700;
}

.pairing-total {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px !important;
    font-weight: 700;
}

@media (max-width: 480px) {
    .match-view-toggle {
        display: flex;
        width: 100%;
    }

    .match-view-toggle button {
        flex: 1;
        padding: 8px;
    }

    .pairing-card {
        padding: 12px;
    }
}

@media (max-width: 600px) {
    .card .teams {
        //grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
        gap: 8px;
    }

    .card .club {
        min-width: 0;
        flex-direction: column;
        gap: 4px;
        font-size: 13px;
        line-height: 1.25;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .card .teams .club:first-child,
    .card .teams .club:last-child {
        justify-content: center;
        text-align: center;
    }

    .card .club img {
        width: 30px;
        height: 30px;
    }

    .card .versus {
        width: auto;
        min-width: 0;
        font-size: 11px;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 10px;
    }

    .card .meta {
        font-size: 12px;
        line-height: 1.35;
    }

    .card .teams,
    .card .club {
        font-size: 12px;
    }

    .card .club {
        line-height: 1.2;
    }

    .card .versus {
        font-size: 10px;
    }

    .card .score {
        margin: 8px 0;
        font-size: 18px;
    }

    .card .status {
        padding: 2px 6px;
        font-size: 11px;
    }
}

.page-actions {
    margin-top: 12px;
}

.hero .teams {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.hero .team {
    min-width: 0;
}

.hero .team:first-child {
    justify-content: flex-end;
    text-align: right;
}

.hero .team:last-child {
    justify-content: flex-start;
    text-align: left;
}

.hero .team > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hero h1 {
    font-size: 26px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.hero .team {
    gap: 8px;
    font-size: 16px;
}

.hero .team img {
    width: 42px;
    height: 42px;
}

.hero .team-score,
.hero .mobile-score-label {
    display: none;
}

.hero .score {
    font-size: 19px;
}

@media (max-width: 600px) {
    .hero {
        padding: 14px;
    }

    .hero h1 {
        font-size: 20px;
    }

    .hero .teams {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
        margin: 12px 0;
    }

    .hero .team,
    .hero .team:first-child,
    .hero .team:last-child {
        justify-content: flex-start;
        text-align: left;
        font-size: 14px;
    }

    .hero .team img {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .hero .team-name {
        overflow-wrap: anywhere;
    }

    .hero .team-score {
        display: inline-flex;
        min-width: 32px;
        margin-left: auto;
        padding: 2px 8px;
        justify-content: center;
        border-radius: 4px;
        background: #eaf7ee;
        color: #085522;
        font-size: 15px;
        text-align: center;
    }

    .hero .vs {
        justify-self: center;
        font-size: 12px;
    }

    .hero .mobile-score-label {
        display: block;
        margin: 12px 0 0;
        color: #59675d;
        font-size: 12px;
        font-weight: 600;
    }

    .hero .score {
        margin: 8px 0 0;
        font-size: 15px;
    }
}

@media (max-width: 760px) {
    .grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .table-wrap,
    .table-scroll,
    .table-container,
    .table-responsive,
    .chart-scroll {
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table,
    .table-scroll table,
    .table-container table,
    .table-responsive table {
        width: max-content;
        min-width: 100%;
    }

    .actions > *,
    .filters > *,
    .toolbar > * {
        min-width: 0;
        max-width: 100%;
    }

    .page-heading,
    .heading,
    .toolbar {
        align-items: flex-start;
    }
}

@media (max-width: 360px) {
    body:not(.admin-shell) {
        font-size: 15px;
    }

    body.management main {
        width: calc(100% - 12px);
        padding: 12px !important;
    }

    .login-box {
        padding: 20px;
    }

    .hero .desktop-score {
        display: none;
    }
}

.team-series-heading {
    padding: 6px 8px;
    background: #dcefe1;
}

.series-team-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.series-team-label img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.print-button {
    min-height: 42px;
    padding: 9px 14px;
    border: 0;
    border-radius: 5px;
    background: #0f7a33;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.print-button:hover {
    background: #085522;
}

.print-only {
    display: none !important;
}

@page {
    size: A4 landscape;
    margin: 10mm;
}

@media print {
    html,
    body {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        overflow: visible !important;
        background: #fff !important;
        color: #111 !important;
        font-size: 9pt;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .nav,
    .no-print,
    .match-view-toggle,
    .pairing-cards {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    main {
        display: flex;
        min-height: 190mm;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        flex-direction: column;
    }

    .hero {
        padding: 0 0 3mm;
        border: 0;
        border-bottom: 1px solid #999;
        border-radius: 0;
    }

    .hero > p:first-child {
        margin: 0 0 1mm;
        font-size: 8pt;
    }

    .hero h1 {
        font-size: 16pt;
    }

    .teams {
        margin-top: 2mm;
        gap: 5mm;
    }

    .team {
        gap: 2mm;
        font-size: 10pt;
    }

    .team img {
        width: 8mm;
        height: 8mm;
    }

    .series-team-label {
        gap: 1mm;
        white-space: normal;
    }

    .series-team-label img {
        width: 6mm;
        height: 6mm;
    }

    .score {
        margin: 2mm 0 0;
        font-size: 11pt;
    }

    .forecast {
        margin: 1mm 0 0;
        font-size: 8pt;
    }

    .table-wrap,
    .table-wrap[hidden] {
        display: block !important;
        width: 100%;
        max-width: none;
        margin-top: 3mm;
        overflow: visible !important;
        border: 0;
        border-radius: 0;
    }

    .table-wrap table {
        display: table !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none;
        table-layout: auto;
        font-size: 7.5pt;
    }

    .table-wrap thead {
        display: table-header-group;
    }

    .table-wrap tr {
        break-inside: avoid;
    }

    .table-wrap th,
    .table-wrap td {
        padding: 1.2mm 1mm;
        border: 1px solid #888;
        white-space: normal !important;
        line-height: 1.2;
    }

    .table-wrap th {
        background: #eaf7ee !important;
    }

    .shoot-off-print {
        margin-top: 4mm;
        break-inside: avoid;
    }

    .shoot-off-print h2 {
        margin: 0 0 2mm;
        font-size: 10pt;
    }

    .shoot-off-print table {
        width: auto;
        min-width: 0;
        border-collapse: collapse;
        font-size: 8pt;
    }

    .shoot-off-print th,
    .shoot-off-print td {
        padding: 1mm 3mm;
        border: 1px solid #888;
        text-align: left;
    }

    .print-signatures {
        display: grid !important;
        margin-top: auto;
        padding-top: 12mm;
        grid-template-columns: 1fr 1fr;
        gap: 25mm;
        break-inside: avoid;
    }

    .signature-field {
        text-align: center;
    }

    .signature-line {
        height: 8mm;
        border-bottom: 1px solid #222;
    }

    .signature-field p {
        margin: 2mm 0 0;
        font-size: 8pt;
    }
}