/* The official calendar of a competition.
 *
 * One stylesheet for the page and for the PDF: the PDF inlines this file, the
 * page links it. It is a PAPER, so it is black on white whatever theme the
 * site is in, and its measures are in points so the paper and the screen
 * agree.
 */
.cal {
    --cal-line: #000;
    --cal-head: #fff2cc;
    --cal-band: #d9d9d9;
    --cal-bad: #c00000;
    background: #fff;
    color: #000;
    /* ONE font, on the screen and on paper alike. Calibri is not on the
       printer, so naming it first gave the page one font and the PDF another.
       Arial, Liberation Sans and Helvetica have the same widths, which
       fit_the_team_names measures with. */
    font-family: Arial, "Liberation Sans", Helvetica, sans-serif;
    font-size: 10pt;
    line-height: 1.25;
}

.cal-cover {
    text-align: center;
    break-after: page;
    page-break-after: always;
    padding-top: 6mm;
}

.cal-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    gap: 8mm;
    margin: 0 0 8mm;
}

.cal-logos img {
    max-height: 32mm;
    max-width: 55mm;
    object-fit: contain;
}

.cal-kicker { margin: 0; font-size: 13pt; text-transform: uppercase; }
.cal-name { margin: 0; font-size: 14pt; font-weight: 700; text-transform: uppercase; }
.cal-edition { margin: 1mm 0 7mm; font-size: 13pt; }

.cal-teams {
    width: 70%;
    margin: 0 auto 8mm;
    border-collapse: collapse;
    border: 1.5pt solid var(--cal-line);
}

.cal-teams th {
    padding: 2.5mm 2mm;
    border-bottom: 1.5pt solid var(--cal-line);
    text-transform: uppercase;
}

.cal-teams td {
    padding: 0.6mm 2mm 0.6mm 24%;
    border-top: 0.5pt solid var(--cal-line);
    text-align: left;
    white-space: nowrap;
}

/* "1 -" … "10 -" end at the same place, so every name starts at the same
   place: the column Jacobo Garrido asked for on 2026-10-14. */
.cal-teams-number {
    display: inline-block;
    min-width: 2.6em;
    margin-right: 0.35em;
    text-align: right;
}

.cal-phase { margin: 0 0 6mm; }

.cal-table {
    width: 100%;
    border-collapse: collapse;
    border: 1.5pt solid var(--cal-line);
    table-layout: fixed;
}

.cal-table th,
.cal-table td {
    border: 0.5pt solid var(--cal-line);
    padding: 0.5mm 1.5mm;
    text-align: center;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.cal-phase-name {
    background: var(--cal-band);
    padding: 2.2mm 2mm !important;
    font-size: 11pt;
    text-transform: uppercase;
    border-bottom: 1.5pt solid var(--cal-line) !important;
}

.cal-block { break-inside: avoid; page-break-inside: avoid; }

/* The home and away cells: a box as wide as the widest name, centred in
   the cell, each name at its left. So every badge stands in one column and
   every name starts at the same place, as in the list of teams on the first
   page (Tony, 2026-10-14). The width is measured in core/services/
   competition_calendar.py (team_box_em). */
.cal-side {
    display: inline-block;
    max-width: 100%;
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Every line of a game the same height, badge or none. */
.cal-teams td { height: 1.6em; box-sizing: border-box; }
.cal-table tbody tr:not(.cal-head):not(.cal-rest) td {
    height: var(--cal-row, 1.6em);
    padding-top: 0;
    padding-bottom: 0;
    box-sizing: border-box;
}
/* The thick frame under the last game of a table takes half its width out
   of that row; the row is given it back, so it is as tall as the others. */
.cal-table .cal-block:last-child tr:last-child:not(.cal-rest):not(.cal-head) td {
    height: calc(var(--cal-row, 1.6em) + 1px);
}

/* On the first page a team with no badge keeps the badge's place empty, so
   every name starts at the same place. */
.cal-badge--none { visibility: hidden; }

.cal-head th {
    /* A heading may break between its words, never inside one: the size of
       the table is chosen so every word fits (fit_the_team_names). */
    overflow-wrap: normal;
    word-break: normal;
    background: var(--cal-head);
    font-weight: 400;
    text-transform: uppercase;
    border-top: 1.5pt solid var(--cal-line);
    border-bottom: 1.5pt solid var(--cal-line);
}

/* The widths of the columns are drawn by the template from COLUMN_WIDTHS in
   core/services/competition_calendar.py, and the size of the letters of the
   whole table is set there too: one size for every cell. */
.cal-number { white-space: nowrap; overflow-wrap: normal; }
/* The game day's number is the one large figure, as on the federation's
   paper. */
.cal-day { font-size: 14pt; }
/* A word is never cut in two ("PLAYOFF" / "S"); it breaks only at a space. */
.cal-day--words { font-weight: 700; text-transform: uppercase; overflow-wrap: normal; word-break: normal; }
.cal-ground { font-weight: 700; text-transform: uppercase; overflow-wrap: normal; word-break: normal; }
.cal-team { text-transform: uppercase; }
/* A team's name is ONE line, never two (Jacobo Garrido and Tony,
   2026-10-14). The size of the table is chosen so it fits; a name too long
   even at the smallest size ends in "…" and Setup names it. */
.cal-team--one-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
}
.cal-bad { color: var(--cal-bad); font-weight: 700; }
.cal-rest td { text-transform: uppercase; }
.cal-note { margin: 2mm 0 0; font-style: italic; text-align: center; }

/* On the site the paper sits on a sheet of its own, scrolling sideways on a
   narrow screen rather than squeezing its columns. */
.cal-sheet {
    background: #fff;
    border: 1px solid var(--border-color, #d0d0d0);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
}

.cal-sheet .cal { min-width: 640px; max-width: 190mm; margin: 0 auto; }

@media screen {
    .cal-cover { break-after: auto; page-break-after: auto; margin-bottom: 8mm; }
}

/* The red ** before the number of a game played only if its series is still
   alive, and the line under the table that says what it means: the way the
   Canary federation marks it (DSN, "de ser necesario"). */
.cal-star { color: var(--cal-bad); font-weight: 700; margin-right: 0.15em; }
.cal-legend { margin: 1.5mm 0 0; text-align: left; font-size: 9pt; }

/* A club's badge beside its name. The picture itself is named once per club
   in a style block of the page (see _competition_calendar.html). It is
   smaller than the line, so a row with a badge is exactly as tall as a row
   without one (Jacobo Garrido, 2026-10-14: every line the same). */
.cal-badge {
    display: inline-block; width: 1.1em; height: 1.1em;
    margin-right: 0.6em; vertical-align: -0.18em;
    /* The picture sits a hair inside its box: the printer rounds the box to
       whole dots, and a picture filling it lost a sliver of its edge. */
    box-sizing: border-box; padding: 0.06em; background-origin: content-box;
    background-position: center; background-repeat: no-repeat; background-size: contain;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

/* A team that has left the competition: the ground the Canary federation
   prints behind its name on the first page. */
.cal-team-left td, .cal-left-swatch {
    background: #fce4d6;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cal-left-note { width: 70%; margin: -6mm auto 8mm; font-size: 8pt; text-align: left; }
.cal-left-swatch { display: inline-block; width: 3.5mm; height: 3.5mm; margin-right: 1.5mm; border: 0.5pt solid var(--cal-line); vertical-align: -0.6mm; }
