:root {
    /* Variables UdeM Calendrier */
    --udem-calendrier-ratio: 90%; /* 17/22 */
    --udem-calendrier-margin: 5%; /* (100% - udem-calendrier-ratio) /2 */
    --udem-calendrier-border-radius: 100px;
    --udem-calendrier-no-color-border: 1px solid #cccccc;
}

.tx-udem-calendrier {
    /** Elements copiés de bootstrap pour ne plus en dépendre. */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
    }
    .col-xs-12, .col-sm-6, .col-md-4, .col-lg-3 {
        position: relative;
        min-height: 1px;
        padding-right: var(--spacing-tiny);
        padding-left: var(--spacing-tiny);
    }
    .col-xs-12 {
        float: left;
        width: 100%;
    }
    .row {
        margin-right: calc(var(--spacing-tiny) * -1);
        margin-left: calc(var(--spacing-tiny) * -1);
    }
    .row:before,
    .row:after {
        display: table;
        content: " ";
    }
    .row:after {
        clear: both;
    }

    @media (min-width: 768px) {
        .col-sm-6 {
            float: left;
            width: 50%;
        }
    }
    @media (min-width: 992px) {
        .col-md-4 {
            float: left;
            width: 33.33333333%;
        }
    }
    @media (min-width: 1200px) {
        .col-lg-3 {
            float: left;
            width: 25%;
        }
    }

    /** CSS spécifique au calendrier des instances. */
    height: 100%;
    .equalheight {
        display: flex;
        flex-wrap: wrap;
    }
    .month {
        margin: 0;
        padding: var(--spacing-small);
        font-size: 1em;

        @media print {
            font-size: 11px !important;
        }

        &.current {
            border: 1px solid var(--colors-ui-bordure-secondaire);
            border-radius: var(--border-radius-medium);
            margin: -1px;
        }
        table {
            margin: 0;
            height: auto;
            border-collapse: collapse;
            width: 100%;
            caption {
                margin-bottom: var(--spacing-large);
                text-transform: capitalize;
                font-size: var(--font-size-h6);
                line-height: var(--font-line-height-h6);

                .nomMoisSingle {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    padding-bottom: var(--spacing-default);
                }

                .nomMois {
                    display: flex;
                    justify-content: space-between;
                    align-items: flex-end;
                    padding-bottom: var(--spacing-tiny);
                    border-bottom: 1px solid var(--colors-ui-bordure-defaut);

                    .annee {
                        font-size: var(--font-size-tiny);
                        line-height: var(--font-line-height-tiny);
                    }
                }
            }
            th {
                color: var(--marque-bleu-udem);
                font-size: 1em;
                font-weight: normal;
                padding: var(--spacing-micro) 0;
                text-align: center;
            }
            td {
                padding: var(--spacing-micro) 0;
                margin: 0;
                width: 14.2857%; /* 1/7 */
                .day-wrap {
                    width: 100%;
                    padding-top: var(--udem-calendrier-ratio);
                    display: block;
                    position: relative;

                    .day {
                        display: block;
                        position: absolute;
                        top: 0;
                        left: 0;
                        right: 0;
                        bottom: 0;
                        padding: 0;
                        background: none;
                        border: none;
                        z-index: 20;
                        width: 100%;
                        text-align: center;

                        .middle-aligned {
                            position: absolute;
                            left: 0;
                            top: 50%;
                            -webkit-transform: translateY(-50%);
                            transform: translateY(-50%);
                            width: var(--udem-calendrier-ratio);
                        }
                        &.has-event {
                            &.multiple-events {
                                &, span {
                                    color: var(--blanc-blanc-100) !important;
                                    text-shadow:
                                        -1px -1px 0 var(--marine-scale-marine-gris-62),
                                        1px -1px 0 var(--marine-scale-marine-gris-62),
                                        -1px 1px 0 var(--marine-scale-marine-gris-62),
                                        1px 1px 0 var(--marine-scale-marine-gris-62) !important;
                                }
                            }
                        }
                        &.today {
                            font-weight: bolder;
                        }
                    }

                    .colors {
                        height: var(--udem-calendrier-ratio);
                        aspect-ratio: 1 / 1;
                        position: absolute;
                        top: var(--udem-calendrier-margin);
                        left: var(--udem-calendrier-margin);
                        border-radius: 50%;
                        overflow: hidden;
                        z-index: 10;

                        /* 1 couleur */
                        &.colors1 {
                          background: var(--color0);
                        }

                        /* 2 couleurs — moitiés gauche/droite */
                        &.colors2 {
                          background: conic-gradient(
                            var(--color0) 0% 50%,
                            var(--color1) 50% 100%
                          );
                        }

                        /* 3 couleurs — tiers égaux */
                        &.colors3 {
                          background: conic-gradient(
                            var(--color0) 0% 33.333%,
                            var(--color1) 33.333% 66.666%,
                            var(--color2) 66.666% 100%
                          );
                        }

                        /* 4 couleurs — quarts égaux */
                        &.colors4 {
                          background: conic-gradient(
                            var(--color0) 0% 25%,
                            var(--color1) 25% 50%,
                            var(--color2) 50% 75%,
                            var(--color3) 75% 100%
                          );
                        }
                      }

                }
            }
        }

        &.single {
            padding: 0;
            height: auto;
            font-size: 1em;
        }
    }

    .annual-view {
        margin-top: var(--spacing-default);
        display: flex;
        justify-content: flex-end;
    }

    .legend {
        position: relative;
        h2,
        h3 {
            margin-top: 0;
        }

        ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;

            @media (min-width: 768px) {
                flex-direction: row;
                flex-wrap: wrap;
                column-gap: var(--spacing-large);
            }

            li {
                position: relative;
                padding-left: calc(20px + var(--spacing-small));

                .color {
                    display: inline-block;
                    width: 20px;
                    height: 20px;
                    position: absolute;
                    left: 0;
                    top: 7px;
                    overflow: hidden;

                    background-color: var(--cat-color);
                    &.no-color {
                        border: var(--udem-calendrier-no-color-border);
                    }
                    &.circle {
                        border-radius: var(--udem-calendrier-border-radius);
                    }
                }
            }
        }
    }

    /** TODO P2133-176 */
    /*
    .popover {
        min-width: 300px;
        .popover-content {
            ul {
                list-style-type: none;
                margin: 0;
                padding: 0;
                margin-left: 0;
                margin-top: 0;
                li {
                    margin-bottom: 10px;
                    font-size: 1em;
                    position: relative;
                    padding-left: 20px;
                    background-image: none !important;

                    .color {
                        display: inline-block;
                        width: 14px;
                        height: 14px;
                        margin-right: 6px;
                        position: absolute;
                        left: 0;
                        top: 5px;
                    }

                    .no-color {
                        border: var(--udem-calendrier-no-color-border);
                    }

                    .color.circle {
                        border-radius: var(--udem-calendrier-border-radius);
                    }

                    .category {
                        display: block;
                    }

                    .title {
                        font-weight: bold;
                    }

                    .time {
                        font-style: italic;
                    }
                }
            }
        }
    }*/
    .simple {
        background: var(--colors-ui-section-bg-secondaire);
        padding: var(--spacing-large);
        border-radius: var(--border-radius-medium);

        .color {
            width: 32px;
            height: 32px;
            background-color: var(--cat-color);
            border-radius: var(--udem-calendrier-border-radius);
            margin-bottom: var(--spacing-small);
        }

        p {
            margin-bottom: 0;
            font-weight: var(--font-weight-semi-bold);
        }
    }
}

@media print {
    .list_type-udemcalendrier_year {
        &, .month {
            padding: 0;
        }
    }

    /* Print override for the page-udem-calendrier-year specific page (class added with typoscript) */
    .page-udem-calendrier-year {
        * {
            -webkit-print-color-adjust: exact !important;
        }

        #udem-primary-contents .container .row {
            .col-md-9,
            .col-md-3 {
                float: left;
                padding-left: 10px;
                padding-right: 10px;
            }
            .col-md-9 {
                width: 75%;
            }
            .col-md-3 {
                width: 25%;
            }
        }

        .list_type-udemcalendrier_year .tx-udem-calendrier > .row > div {
            width: 33.33333333%;

            @media (orientation: landscape) {
                width: 25%;
            }
            /* Chrome hack to force 3 columns on portrait and 4 on landscape. */
            @media (orientation: landscape) and (min-width: 520px) and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: .001dpcm) {
                min-width: 180px;
            }
        }

        #udem-primary-nav,
        #udem-breadcrumb {
            display: none;
        }

        .tx-udem-calendrier {
            .month.current {
                margin: 0;
                border: none;
            }
            table td .day-wrap .day.has-event {
                font-weight: bold;
            }
        }

        footer {
            display: none;
        }

        .tx-udem-calendrier table {
            break-inside: avoid;
            page-break-inside: avoid;
        }

        .tx-udem-calendrier table td .day-wrap .colors {
            position: static !important;
            /* Le cercle ne peut plus être superposé, on le cache. */
            display: none !important;
        }

        /* Indiquer visuellement les jours avec événements autrement. On affiche seulement la première couleur, mais c'est un compromis acceptable. */
        .tx-udem-calendrier table td .day-wrap .day.has-event {
            font-weight: var(--font-weight-bold);
            border: 2px solid var(--color0);
            border-radius: 50%;

            * {
                color: #000 !important;
            }
        }
    }
}

/** Si c'est dans un slider ou une grille, on uniformise les hauteurs */
.frame-type-udemcoquille_conteneurslider .list_type-udemcalendrier_simple {
    /* Pour les sliders seulement */
    height: 100%;
}

.frame-type-udemcoquille_conteneurslider .list_type-udemcalendrier_simple,
.frame-type-udemcoquille_conteneurgrille .list_type-udemcalendrier_simple {
    /* Pour les sliders et grilles */
    .contenu {
        height: 100%;

        .simple {
            height: 100%;
        }
    }
}
