
@property --pcal67-time-column-width {
    syntax: "*";
    inherits: true;
    initial-value: 4rem;
}
@property --pcal67-header-bar-button-width {
    syntax: "*";
    inherits: true;
    initial-value: 3rem;
}
@property --pcal67-day-column-count {
    syntax: "*";
    inherits: true;
    initial-value: 3;
}
/* The height of the day column areas before 00:00 and after 24:00 */
@property --pcal67-off-limits-height {
    syntax: "*";
    inherits: true;
    initial-value: 4rem; /* The value of this property MUST be stored in rem because p67-cal.js relies on it */
}


@media screen and (orientation: portrait) {
    :root {
        --pcal67-time-column-width: 2rem;
        --pcal67-header-bar-button-width: 2rem;
    }

    .pcal67-hour-text {
        font-size: 0.8rem;
        font-weight: bolder;
    }
}

@media screen and (orientation: landscape) {
    .pcal67-hour-text {
        font-size: 1rem;
    }
}

/* */
@position-try --segment-left {
    inset: auto;
    right: anchor(left);
    top: anchor(center);
    bottom: anchor(center);
    left: auto;
}
@position-try --segment-right {
    inset: auto;
    left: anchor(right);
    top: anchor(center);
    bottom: anchor(center);
    right: auto;
}
@position-try --segment-left-up {
    inset: auto;
    right: anchor(left);
    bottom: anchor(top);
    top: auto;
    left: auto;
}
@position-try --segment-left-down {
    inset: auto;
    right: anchor(left);
    top: anchor(bottom);
    bottom: auto;
    left: auto;
}
@position-try --segment-right-up {
    inset: auto;
    left: anchor(right);
    bottom: anchor(top);
    top: auto;
    right: auto;
}
@position-try --segment-right-down {
    inset: auto;
    left: anchor(right);
    top: anchor(bottom);
    right: auto;
    bottom: auto;
}
@position-try --segment-far-left {
    inset: auto;
    right: calc(anchor(left) + 33vw);
    top: anchor(center);
    bottom: anchor(center);
    left: auto;
}
@position-try --segment-far-right {
    inset: auto;
    left: calc(anchor(right) + 33vw);
    top: anchor(center);
    bottom: anchor(center);
    right: auto;
}


body {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;

    padding: 0;
    margin: 0;
}
h1, h2, h3, h4 {
    font-family: "Oranienbaum";
}
h1 {
    font-size: 1.7rem;
}
h2 {
    margin-block: 0.3rem;
}
h3, h4, h5, h6 {
    margin-block: 2px;
}











.pcal67-toolbar {
    box-sizing: border-box;

    max-width: 100%;

    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 4px solid black;
    padding: 0.2rem 1rem 0.2rem 1rem;

    & > .side {
        display: flex;
        gap: 1rem;
        flex-wrap: nowrap;
        align-items: center;
    }

    & .musicroom-logo-wrapper {
        position: relative;

        & .musicroom-logo {
            width: 3rem;
            height: 3rem;
        }
    }

    & .pcal67-calendar-title {
        white-space: nowrap;
        margin: 0;
    }

    & > .right-side-items {
        margin-left: auto;

        & .pcal67-timezone-select-container {
            display: flex;
            flex-direction: column;

            & .pcal67-timezone-select {
                max-width: 10rem;
            }
        }

        & .pcal67-help-button > img {
            height: 2rem;
            width: auto;
        }

        & .login-info-container {
            display: flex;
            flex-direction: column;
        }
    }
}








.pcal67-calendar-container {

    box-sizing: border-box;

    min-width: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 0 2px 2px 2px;
    overflow-y: auto;

    /* &.grabbing {
            cursor: grabbing !important;
    } */
}

.pcal67-calendar {
    touch-action: pan-y;
    text-align: center;
    --hour-lines-length: 600px;

    .header-bar {

        position: sticky;
        top: 0px;
        box-sizing: border-box;

        min-height: 3rem;
        max-height: 3rem;
        min-width: 100%;
        max-width: 100%;

        display: flex;
        justify-content: right;
        
        background-color: white;
        z-index: 10;
    }

    .header-bar-button {
        min-width: var(--pcal67-header-bar-button-width);
        max-width: var(--pcal67-header-bar-button-width);
        position: relative;
        box-sizing: border-box;
        
        --pcal67-calendar-week-content-left: "0000\AW00";
        --pcal67-calendar-week-content-right: "9999\AW99";

    }
    .header-bar-button::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        min-width: var(--pcal67-header-bar-button-width);
        min-height: var(--pcal67-header-bar-button-width);

        background: url("img/marcato.svg") center / 50% no-repeat;
    }
    .header-bar-button.left::before {
        transform: translate(-50%, -50%) rotate(-90deg);
    }
    /* Contains the text showing the year and calendar week */
    .header-bar-button.left::after {
        content: var(--pcal67-calendar-week-content-left);
        position: absolute;
        z-index: -1;
        white-space: pre;

        top: 100%;
        left: 0;
        width: 100%;

        padding-top: 6px;
        padding-bottom: 2px;
        text-align: center;
        font-size: calc(100% / 0.8);

        background-color: var(--color-tertiary-light);
        border-radius: 0 0 0.5rem 0.5rem;
    }
    .header-bar-button.right::before {
        transform: translate(-50%, -50%) rotate(90deg);
    }
    /* Contains the text showing the year and calendar week */
    .header-bar-button.right::after {
        content: var(--pcal67-calendar-week-content-right);
        position: absolute;
        z-index: -1;
        white-space: pre;

        top: 100%;
        left: 0;
        width: 100%;

        padding-top: 6px;
        padding-bottom: 2px;
        text-align: center;
        font-size: calc(100% / 0.8);

        background-color: var(--color-tertiary-light);
        border-radius: 0 0 0.5rem 0.5rem;
    }

    .header-bar-button.left {
        margin-left: calc(var(--pcal67-time-column-width) - var(--pcal67-header-bar-button-width));
    }

    .header-bar-grid {

        flex: 1;

        display: grid;
        grid-template-columns: repeat(var(--pcal67-day-column-count), 1fr);
        align-content: center;
    }

    .day-column-header {
        box-sizing: border-box;
        border-right: 2px solid gray;
    }

    .day-column-header:last-child {
        border-right: none;
    }










    .body {
        padding-right: var(--pcal67-header-bar-button-width);

        display: grid;
        grid-template-columns: var(--pcal67-time-column-width) 1fr;
        /* --pcal67-body-width: 100%; */

        /* This value MUST use a simple number/unit pair*/
        --pcal67-hour-height: 3rem; /* use REM only (because of p67-cal.js) */
        --pcal67-hour-height-scale: 1;
        --pcal67-min-hour-height-scale: 0.5; /* for clamping hour-height-scale in javascript */
        --pcal67-max-hour-height-scale: 3; /* for clamping hour-height-scale in javascript */
        /* This calculation is also separately used in p67-cal-js */
        --pcal67-hour-height-scaled: calc(var(--pcal67-hour-height) * var(--pcal67-hour-height-scale)); 
    }

    .time-label-column {
        display: grid;
        padding-top: calc(var(--pcal67-off-limits-height) - var(--pcal67-hour-height-scaled) / 2);
        padding-bottom: calc(var(--pcal67-off-limits-height) - var(--pcal67-hour-height-scaled) / 2);
        grid-auto-rows: var(--pcal67-hour-height-scaled);
        align-items: center;
    }

    .hour-label {

        position: relative;

        padding: 0;
        margin: 0;

        font-size: max(calc(var(--pcal67-time-column-width) / 4), calc(100% / 1.5));

        white-space: nowrap;
    }

    .hour-label::after {
        pointer-events: none;

        position: absolute;

        left: 100%;
        top: calc(50% - 1px);
        content: "";
        border-top: 2px solid gray;
        width: var(--hour-lines-length);
    }

    .day-columns {
        display: grid;
        grid-template-columns: repeat(var(--pcal67-day-column-count), 1fr);

        user-select: none;
        -webkit-user-select: none;
    }

    .day-column {
        user-select: none;
        -webkit-user-select: none;

        position: relative;
        box-sizing: border-box;
        border-right: 2px solid gray;

        padding-top: var(--pcal67-off-limits-height);
        padding-bottom: var(--pcal67-off-limits-height);

        --upper-handle-drag-cross-day-charge: 0%;
        --lower-handle-drag-cross-day-charge: 0%;

        & * {
            user-select: auto;
            -webkit-user-select: auto;
        }

        & > * {
            position: absolute;
        }

        &:last-child {
            border-right: none;
        }

        &::before {
            content: "";
            
            box-sizing: border-box;
            position: absolute;
            top: 0;
            left: 0;
            background-color: var(--color-primary-light);
            height: var(--pcal67-off-limits-height);
            width: var(--upper-handle-drag-cross-day-charge);
        }
        &::after {
            content: "";

            box-sizing: border-box;
            position: absolute;
            bottom: 0;
            left: 0;
            background-color: var(--color-primary-light);
            height: var(--pcal67-off-limits-height);
            width: var(--lower-handle-drag-cross-day-charge);
        }
    }

    .current-time-indicator {
        position: absolute;
        width: 100%;
        height: 0;
        z-index: 1;
        
        border: 4px skyblue solid;
        
    }








    /* generic event style */ 
    .event-segment {

        box-sizing: border-box;
        container-type: size;

        --event-segment-border-width: 4px;
        --event-segment-padding-horizontal: 4px;

        min-width: calc(100% - 4px);
        max-width: calc(100% - 4px);
        padding-inline: var(--event-segment-padding-horizontal);
        padding-block: 2px;
        margin: 0px 2px 0px 2px;

        background-color: var(--color-primary-contrast);
        border: var(--event-segment-border-width) solid var(--color-primary);
        border-radius: 4px;

        font-size: 1.5rem;

        &:not(.selected-event-segment) {
            cursor: pointer;
        }

        & .preview {
            overflow: hidden;
            width: 100%;
            height: 100%;
        }

        & .title {
            font-weight: bold;
            text-align: center;
            font-family: "Oranienbaum";

            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;


            margin: clamp(-3px, calc(-1.4rem + 100cqh), 0px) auto 0 auto;
            --font-size-factor: 1.0;
            font-size: calc(
                min(
                    clamp(var(--pcal67-hour-height-scaled) / 4, 100cqh, 1.4rem),
                    clamp(var(--pcal67-hour-height-scaled) / 4, 100cqh, 1.4rem) * var(--font-size-factor))
                );
        }

        & .description {
            font-size: 1rem;
            text-align: left;
            font-width: condensed;
            font-stretch: condensed;

            overflow: hidden;
            overflow-wrap: anywhere;
            text-overflow: ellipsis;

            margin: auto 0 auto 0;
        }

        &[data-event-type="consultation hour"] {
            background-color: var(--color-tertiary);

            --event-segment-border-width: 0px;
        }

        &[data-event-type="closure"] {
            background: transparent;
            --event-segment-border-width: 0px;

            & .title, & .description {
                background-color: var(--color-secondary-light);
            }

            &::before {
                content: "";
                position: absolute;
                z-index: -1;
                inset: 0;
                width: 100%;
                height: 100%; 

                background-color: var(--color-secondary-light);
                mask: url("img/stripes.svg");
                mask-repeat: repeat;
                mask-size: 32px;
            }
        }

        &[data-event-type="special event"] {
            
            &::after {
                content: "";
                position: absolute;
                inset: 0;
                width: 100%;
                height: 100%;
                border-radius: inherit;
                background-color: transparent;
                border: inherit;
                filter: hue-rotate(-70deg);
                filter: blur(7px);
            }
        }
    }

    .overlay {

        box-sizing: border-box;
        width: 100%;
        padding: 0px;
        margin: 0px;
        pointer-events: none;

        &.out-of-timeframe-overlay {
            z-index: -3;
            
            background-color: var(--color-primary-very-light);
            mask: url("img/stripes.svg");
            mask-repeat: repeat;
            mask-size: 32px;

            &[data-is-out-of-viewing-timeframe="true"] {
                background-color: var(--color-primary-light);
                z-index: -1;
            }
        }

        &.closure-overlay {

            box-sizing: border-box;
            z-index: -2;

            background-color: var(--color-secondary-light);
            mask: url("img/stripes.svg");
            mask-repeat: repeat;
            mask-size: 32px;
        }
    }

    

    










    .handle-vertical {
        position: absolute;
        --handle-width: min(50%, calc(0.9 * var(--pcal67-hour-height-scaled)));
        width: var(--handle-width);
        inset: auto auto auto calc((100% - var(--handle-width)) / 2);

        z-index: 10;
        pointer-events: none;
        touch-action: none;

        & > svg:hover {
            cursor: grab;
        }

        &> * {
            pointer-events: visiblePainted;
            position: relative;
            width: 100%;
            height: auto;
        }

        &.upward {
            top: 0;
        }
        &.upward > * {
            translate: 0 -100%;
        }

        &.downward {
            bottom: 0;
        }
        &.downward > * {
            rotate: 180deg;
            translate: 0 calc(100% + 4px ); /* add the vertical padding to the 100% */
        }
    }

    .plus-indicator {
        pointer-events: none;
        --pointer-x: 0px;
        --pointer-y: 0px;
        --size: 3rem;

        position: fixed;
        z-index: 100;
        left: calc(var(--pointer-x) - var(--size) / 2);
        top: calc(var(--pointer-y) - var(--size) / 2 - 3rem);
        width: var(--size);
        height: auto;

        & svg {
            width: 100%;
            height: auto;
        }
    }
    .plus-fill {
        --fill-scale: 0%;

        position: absolute;
        inset: 50% auto auto 50%;
        translate: -50% -50%;

        width: var(--fill-scale);
        height: auto;

        & svg {
            width: 100%;
            height: auto;
        }
    }


    






    .event-popup {

        position-anchor: --selected-event-segment;
        /* These fallbacks work only for avoiding viewport out-of-bounds. Collisions with other event popups are resolved in p67-cal.js. */
        /* position-try-fallbacks: --segment-left, --segment-right, --segment-left-up, --segment-left-down, --segment-right-up, --segment-right-down; */
        inset: auto;
        right: anchor(left);
        top: anchor(center);
        bottom: anchor(center);

        display: flex;
        flex-direction: column;
        justify-content: center;

        &[data-popup-name="action-buttons"] {

            & .action-button {
            color: red;
            width: 3rem;
            height: 3rem;

                & > svg {
                    width: 100%;
                    height: 100%;
                }
            }
        }

        &[data-popup-name="budget"] {
            min-width: 4rem;
            min-height: 4rem;

            &:empty::after {
                content: var(--empty-popup-content, "");
                white-space: pre-wrap;
                color: var(--color-primary-light);
            }
        }

    }
    .hidden-popup {
        visibility: hidden;
        
    }
    
    .time-budget-card {
        &[data-is-within-budget="false"] {
            color: var(--color-secondary-light);

            & p, span {
                font-weight: bold;
            }
        }
    }



    #event-dialog {

        &:modal {
            display: flex;
            flex-direction: column;
        }

        max-height: 75vh;

        min-width: 30vw;
        max-width: 80vw;
        overflow-x: auto;
        overflow-y: hidden;
        
        & header {
            top: 0;
            position: sticky;
            flex: 0 0 auto;

            & > h1 {
                margin: 0;
            }
        }

        & form {

            flex: 1 1 auto;
            scrollbar-gutter: stable;
            overflow-y: auto;
            width: fit-content;
            min-height: 0;
            margin: 0 auto 0 auto;

            & .event-dialog-component {

                padding: 4px;
                margin: 2px;

                & .title {

                    &:empty {
                        display: none;
                    }
                }

                & p {
                    text-align: left;
                }

                & .description {
                    white-space: pre-wrap;
                    
                    &:empty {
                        display: none;
                    }
                }

                & label.title {
                    font-family: "Oranienbaum";
                    font-size: 1.5rem;
                    font-weight: 600;
                }

                & input {
                    width: 90%;
                }

                & textarea {
                    width: 90%;
                    min-height: 5rem;
                }

                &[data-component-type="color"] .input-element-view-only-representation {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    height: 4rem;
                    width: 90%;
                    margin: auto;
                    box-sizing: border-box;
                    border: 4px solid var(--color-primary);
                    --color: purple;
                    background-color: var(--color);
                
                    & span, p  {
                        color: var(--color);
                        filter: invert(1) drop-shadow(0px 0px 2px black);
                    }
                }

                &[data-component-type="information"] {

                    text-align: start;

                    .freestyle {
                        
                        text-align: left;
                    }
                }
            }
        }

        & .event-dialog-buttons {
            position: sticky;
            flex: 0 0 auto;
            margin-top: 2rem;
            bottom: 0;
        }

        & .validation-message {
            color: var(--color-secondary);
        }
    }

}

#pcal67-calendar-explanation::backdrop {
        background-color: #000000aa;
    }