/*
 * CSS for the 53nord/kalender plugin (v3.0.0).
 * Calendar month view with CSS Grid spanning events,
 * plus "Upcoming Events" block timeline.
 */

/* ========================================
   Calendar Month View – Grid Layout
   ======================================== */

.calendar-month {
    background: #fff;
}

/* --- Weekday header row --- */

.calendar-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #ddd;
}

.calendar-header-row > div {
    padding: 8px 8px 8px 0;
    font-weight: 500;
    text-align: right;
    font-size: 0.9em;
    color: #999;
}





/* --- Week rows (each is its own grid) --- */

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-flow: dense;
    grid-auto-rows: auto;
    gap: 2px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e8e8e8;
    min-height: 140px;
    align-content: start;
    /* Column dividers + weekend shading defined below */
}

.calendar-week:last-child {
    border-bottom: none;
}

/* --- Day numbers (pinned to row 1) --- */

.calendar-day-num {
    grid-row: 1;
    padding: 8px 8px 4px 0;
    font-weight: 400;
    font-size: 0.95em;
    line-height: 1;
    color: #333;
    text-align: right;
}

/* Week number – small label inside Monday cell, left-aligned */
.calendar-week-num {
    float: left;
    font-size: 0.75em;
    font-weight: 400;
    color: #bbb;
    padding-left: 4px;
    line-height: 1.3;
}

/* Today circle */
.calendar-day-num.is-today {
    text-align: right;
    padding-top: 4px;
    padding-right: 3px;
}

.calendar-day-num.is-today > .today-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e8192c;
    color: #fff;
    font-weight: 600;
    font-size: 0.95em;
}

.calendar-day-num.is-other-month {
    color: #c5c5c5;
}

/* --- Weekend column shading (Sa + So = columns 6 + 7) --- */

.calendar-week {
    background-image:
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#e8e8e8, #e8e8e8),
        linear-gradient(#fcfdff, #fcfdff),
        linear-gradient(#fcfdff, #fcfdff);
    background-size:
        1px 100%,
        1px 100%,
        1px 100%,
        1px 100%,
        1px 100%,
        1px 100%,
        calc(100% / 7) 100%,
        calc(100% / 7) 100%;
    background-repeat: no-repeat;
    background-position:
        calc(100% / 7 * 1) 0,
        calc(100% / 7 * 2) 0,
        calc(100% / 7 * 3) 0,
        calc(100% / 7 * 4) 0,
        calc(100% / 7 * 5) 0,
        calc(100% / 7 * 6) 0,
        83.333% 0,
        100% 0;
}

/* --- Spanning event bars (Apple Calendar style) --- */

.calendar-event {
    background-color: color-mix(in srgb, var(--cat-color, #666) 25%, #f2f2f2);
    color: color-mix(in srgb, var(--cat-color, #666) 55%, #333);
    font-size: 0.75em;
    font-weight: 500;
    line-height: 1.4;
    padding: 3px 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 0;
    margin: 0;
    transition: background-color 0.15s;
}

.calendar-event:hover {
    background-color: color-mix(in srgb, var(--cat-color, #666) 35%, #f2f2f2);
}

/* Rounded corners indicate start/end of event */
.calendar-event.event-start {
    border-radius: 4px 0 0 4px;
    margin-left: 4px;
}

.calendar-event.event-end {
    border-radius: 0 4px 4px 0;
    margin-right: 4px;
}

.calendar-event.event-start.event-end {
    border-radius: 4px;
    margin-left: 4px;
    margin-right: 4px;
}

/* --- Timed events (single-day with start time): left border accent --- */

.calendar-event.event-timed.event-start.event-end {
    background-color: transparent;
    border-left: 3px solid var(--cat-color, #666);
    color: #333;
    border-radius: 2px;
    margin-left: 4px;
    margin-right: 4px;
}

.calendar-event.event-timed.event-start.event-end:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.calendar-event.event-timed .event-time {
    font-weight: 400;
    color: #666;
    margin-right: 3px;
}

/* --- Category legend --- */

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 10px 4px 0;
}

.calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: #777;
}

.calendar-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ========================================
   Navigation
   ======================================== */

.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-nav-title {
    font-size: 1.5em;
    font-weight: 400;
    margin: 0;
}

.calendar-nav-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.calendar-nav-today {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    font-size: 0.85em;
    font-weight: 500;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    margin-right: 8px;
    text-decoration: none;
    transition: background 0.15s;
}

.calendar-nav-today:hover {
    background: #f5f5f5;
    color: #333;
    text-decoration: none;
}

.calendar-nav-today.is-current {
    color: #bbb;
    cursor: default;
}

.calendar-nav-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #666;
    text-decoration: none;
    transition: background 0.15s;
}

.calendar-nav-arrow:hover {
    background: #f0f0f0;
    color: #333;
}

/* ========================================
   Upcoming Events Block (Timeline)
   ======================================== */

.events-timeline {
    position: relative;
    padding-left: 40px;
    border-left: 2px solid #e5e5e5;
}

.events-timeline-item {
    position: relative;
    padding-bottom: 4px;
}

.events-timeline-item:last-child {
    padding-bottom: 0;
}

.events-timeline-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px 8px 14px;
    margin-left: -14px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    text-decoration: none;
}

.events-timeline-item a:hover {
    background-color: #f5f5f5;
}

.events-timeline-item a [uk-icon] {
    color: #ccc;
    flex-shrink: 0;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.events-timeline-item a:hover [uk-icon] {
    opacity: 1;
}

.events-timeline-item .uk-text-meta {
    font-size: 0.9em;
    font-weight: 500;
    color: #888;
}

.events-timeline-item .uk-text-emphasis {
    font-weight: 500;
    font-size: 1.05em;
    line-height: 1.3;
}

.events-timeline-item::before {
    content: '';
    position: absolute;
    left: -49px;
    top: 30px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--category-color, #666);
    border: 2px solid #fff;
    transition: transform 0.15s ease;
}

.events-timeline-item:hover::before {
    transform: scale(1.15);
}

/* ========================================
   Responsive (mobile < 640px)
   ======================================== */

@media (max-width: 639px) {
    .calendar-nav-title {
        font-size: 1.15em;
    }

    .calendar-nav-today {
        padding: 4px 10px;
        font-size: 0.78em;
        margin-right: 4px;
    }

    .calendar-nav-arrow {
        width: 30px;
        height: 30px;
    }

    .calendar-header-row > div {
        padding: 5px 4px 5px 0;
        font-size: 0.75em;
    }

    .calendar-week {
        min-height: 80px;
        gap: 1px 0;
        padding-bottom: 3px;
    }

    .calendar-week-num {
        font-size: 0.65em;
        padding-left: 2px;
    }

    .calendar-day-num {
        font-size: 0.75em;
        padding: 4px 4px 2px 0;
    }

    .calendar-day-num.is-today > .today-circle {
        width: 22px;
        height: 22px;
        font-size: 0.7em;
    }

    .calendar-event {
        font-size: 0.6em;
        padding: 2px 3px;
        line-height: 1.2;
    }

    .calendar-event.event-start {
        margin-left: 2px;
    }

    .calendar-event.event-end {
        margin-right: 2px;
    }

    .calendar-event.event-timed {
        margin-left: 2px;
        margin-right: 2px;
        border-left-width: 2px;
    }

    .calendar-event.event-timed .event-time {
        display: none;
    }

    .events-timeline-item a [uk-icon] {
        opacity: 1;
    }
}
