.fc-event {
    cursor: pointer;
}

.piecal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.piecal-wrapper :is(.fc-daygrid-body, .fc-timegrid-body, table) {
    width: 100% !important;
}

.piecal-wrapper #calendar {
    width: 100%;
}

.piecal-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
    position: relative;
}

.piecal-controls__skip-calendar {
    position: absolute;
    inset: 0 0 4px 0;
    min-height: 48px;
}

.piecal-controls__skip-calendar:not(:focus) {
    clip: rect(1px, 1px, 1px, 1px);
}

.piecal-popover {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.piecal-popover__inner {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 32px;
    gap: 16px;
    margin: 0 32px;
    max-width: 400px;
    width: 100%;
    max-height: 75%;
    overflow: auto;
}

.piecal-popover__title {
    font-size: 2rem;
    margin-block-start: 0;
    margin-block-end: 0;
}

.piecal-popover__meta {
    font-size: 14px;
    font-style: italic;
    display: grid;
    grid-template-columns: 50% 50%;
    grid-column-gap: 8px;
    grid-row-gap: 8px;
}

.piecal-popover__meta > p {
    margin-block-start: 0;
    margin-block-end: 0;
}

.piecal-popover__close-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    position: sticky;
    top: 0px;
    left: 100%;
    border: none;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(5px);
    border-radius: 100%;
    cursor: pointer;
    padding: 8px;
}

.piecal-popover__close-button::after {
    content: "";
    position: absolute;
    width: 2px;
    height: 80%;
    background: black;
    transform: rotate(45deg);
}

.piecal-popover__close-button::before {
    content: "";
    position: absolute;
    width: 2px;
    height: 80%;
    background: black;
    transform: rotate(-45deg);
}

/* Optional wrapping for event titles */
.piecal-wrapper.piecal-wrap-event-titles .fc-event {
    flex-direction: row;
    flex-wrap: wrap;
    white-space: normal;
}

/* Pie Calendar Footer */
.piecal-footer {
    text-align: center;
    font-size: 0.75rem;
}

/* Widget Mode - Both */
.piecal-wrapper:not([data-view='listDay']) .piecal-controls__back-to-month {
    display: none;
}

/* Responsive Widget Mode */
@media only screen and (min-width: 768px) {
    .piecal-wrapper:not(.piecal-wrapper--widget) .piecal-controls__back-to-month {
        display: none;
    }
}

/* Always Widget Mode */
.piecal-wrapper--widget .piecal-controls label {
    display: none;
}

.piecal-wrapper--widget .fc-header-toolbar.fc-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    grid-row-gap: 8px;
}

.piecal-wrapper--widget .fc-header-toolbar .fc-toolbar-title {
    text-align: center;
}

.piecal-wrapper--widget .fc-header-toolbar .fc-toolbar-chunk:last-child {
    display: grid;
    grid-row-gap: 8px;
}

.piecal-wrapper--widget .fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group {
    margin-left: 0;
}

.piecal-wrapper--widget .fc-col-header-cell a {
    font-size: 0.75rem;
    text-decoration: none;
}

.piecal-wrapper--widget .fc-daygrid-day-frame {
    aspect-ratio: 1 / 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.piecal-wrapper--widget .fc-daygrid-day-frame:has(.fc-daygrid-event-harness)::after {
    content: "";
    position: absolute;
    width: 32px;
    aspect-ratio: 1 / 1;
    border-radius: 100%;
    box-shadow: 0px 0px 0px 1px var(--fc-event-bg-color);
}

.piecal-wrapper--widget .fc-daygrid-day-top {
    font-size: 12px;
    margin-left: 6px;
}

.piecal-wrapper--widget .fc-daygrid-day-events .fc-daygrid-event-harness a {
    display: none;
}

.piecal-wrapper--widget[data-view="listDay"] .fc-today-button {
    display: none;
}

.piecal-wrapper--widget .fc-list-event {
    display: flex;
    flex-direction: column;
}

.piecal-wrapper--widget .fc-list-event > td {
    width: 100%;
}

.piecal-wrapper--widget .fc-list-event > td:first-child {
    padding-bottom: 0px;
    border-bottom: 0px;
}

.piecal-wrapper--widget .fc-list-event > td:last-child {
    padding-top: 0px;
    border-top: 0px;
}

.piecal-wrapper--widget .fc-list-event-graphic {
    display: none;
}

.piecal-wrapper--widget .fc-list-empty-cushion {
    margin-top: 0px;
    margin-bottom: 0px;
}

/* Responsive widget mode */
@media only screen and (max-width: 768px) {
    .piecal-wrapper--responsive-widget .piecal-controls label {
        display: none;
    }

    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-header-toolbar.fc-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        grid-row-gap: 8px;
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-header-toolbar .fc-toolbar-title {
        text-align: center;
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-header-toolbar .fc-toolbar-chunk:last-child {
        display: grid;
        grid-row-gap: 8px;
    }

    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group {
        margin-left: 0;
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-col-header-cell a {
        font-size: 0.75rem;
        text-decoration: none;
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-daygrid-day-frame {
        aspect-ratio: 1 / 1;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-daygrid-day-frame:has(.fc-daygrid-event-harness)::after {
        content: "";
        position: absolute;
        width: 32px;
        aspect-ratio: 1 / 1;
        border-radius: 100%;
        box-shadow: 0px 0px 0px 1px var(--fc-event-bg-color);
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-daygrid-day-top {
        font-size: 12px;
        margin-left: 6px;
    }
    
    .piecal-wrapper--responsive-widget[data-view="dayGridMonth"] .fc-daygrid-day-events .fc-daygrid-event-harness a {
        display: none;
    }

    .piecal-wrapper--responsive-widget[data-view="listDay"] .fc-today-button {
        display: none;
    }
}

/* Generic Responsive Styles */
@media only screen and (max-width: 768px) {
    .piecal-wrapper .fc-header-toolbar.fc-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        grid-row-gap: 8px;
    }
    
    .piecal-wrapper .fc-header-toolbar .fc-toolbar-title {
        text-align: center;
    }
    
    .piecal-wrapper .fc-header-toolbar .fc-toolbar-chunk:last-child {
        display: grid;
        grid-row-gap: 8px;
    }
    
    .piecal-wrapper .fc-header-toolbar .fc-toolbar-chunk:last-child .fc-button-group {
        margin-left: 0;
    }

    /* List view adjustments */
    .piecal-wrapper .fc-list-event {
        display: flex;
        flex-direction: column;
    }

    .piecal-wrapper .fc-list-event > td {
        width: 100%;
    }

    .piecal-wrapper .fc-list-event > td:first-child {
        padding-bottom: 0px;
        border-bottom: 0px;
    }

    .piecal-wrapper .fc-list-event > td:last-child {
        padding-top: 0px;
        border-top: 0px;
    }
    
    .piecal-wrapper .fc-list-event-graphic {
        display: none;
    }
}