:root {
    --color-background: #fff;
    --color-graytext: #ccc;
    --color-hover: #ececec;
    --color-selected: #007bff;

    --calendar-day-height: calc(100vh / 8);
    --calendar-day-width: calc(100vw / 7);
    --calendar-inner-padding: 4px;
}

body {
    cursor: default;
    font-family: system-ui;
    margin: 0;
}

[aria-labelledby] {
    bottom: 0;
    height: calc(100vh - var(--calendar-day-height));
    left: 0;
    position: absolute;
    text-align: center;
    width: 100%;

    &[aria-hidden="true"] {
        visibility: hidden;
    }
}

header {
    display: block;
    height: var(--calendar-day-height);
    line-height: var(--calendar-day-height);
    overflow: hidden;
    text-align: center;
}

[role="button"] {
    text-align: center;
    transition: transform 75ms ease-in;
    width: var(--calendar-day-width);

    &[rel="prev"] {
        float: left;

        &:active {
            transform: translateX(-2px);
        }
    }

    &[rel="next"] {
        float: right;

        &:active {
            transform: translateX(2px);
        }
    }

    & svg {
        pointer-events: none;
        width: 16px;
        height: 100%;
    }

    @media (hover: hover) {
        &:hover {
            transform: scale(1.2);
        }
    }
}

[aria-live="polite"] {
    border: 1px dotted transparent;
    color: var(--color-selected);
    font-weight: bold;
    margin: auto 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;

    @media (hover: hover) {
        &:hover {
            border-bottom-color: inherit;
        }
    }
}

table {
    border-spacing: 0;
    table-layout: fixed;
}

th {
    box-sizing: border-box;
    height: var(--calendar-day-height);
    padding-bottom: calc(2 * var(--calendar-inner-padding));
    vertical-align: middle;
}

td {
    border-radius: var(--border-radius);
    padding: 0;

    &:not([aria-selected]) {
        color: var(--color-graytext);
    }

    &[aria-current="date"] {
        font-weight: bold;
    }

    &[aria-disabled="true"] {
        background-color: var(--color-hover);
        border-radius: 0;
        color: var(--color-graytext);
        cursor: not-allowed;
    }
}

#months, #years {
    box-sizing: border-box;
    float: left;
    height: 100%;
    line-height: calc((100vh - var(--calendar-day-height)) / 12);
    list-style: none;
    margin: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    padding: 0 var(--calendar-inner-padding);
    width: 50%;
}

[data-date], [data-month], [data-year] {
    @media (hover: hover) {
        &:hover {
            background-color: var(--color-hover);
        }
    }

    &[aria-selected="true"] {
        background-color: var(--color-selected);
        color: var(--color-background);
    }
}
