/* ==========================
   Month calendar (components/calendar.html) - on the home page and the
   Calendar (/events). calendar.js switches months.
   ========================== */

.calendar {
    max-width: 78rem;
    margin: 0 auto;

    background: #fff;
    border: 1px solid #e6ebef;
    border-radius: 12px;

    box-shadow:
        0 4px 8px rgba(17, 52, 86, 0.06),
        0 10px 24px rgba(17, 52, 86, 0.05);

    overflow: hidden;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 1.25rem 1.5rem;

    background: var(--color-secondary);
}

.calendar-header h3 {
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 2.25rem;
    height: 2.25rem;

    color: #fff;
    border-radius: 50%;

    transition: background .2s ease;
}

.calendar-nav:hover {
    background: rgb(255 255 255 / 12%);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);

    padding: 0.75rem 0.5rem 0;

    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;

    padding: 0.5rem;
}

.calendar-day {
    /* Grid items don't shrink below their content's natural width by
       default - a long, unbreakable event title (see .calendar-event's
       white-space: nowrap) was forcing its whole column wider instead
       of truncating inside it. This lets the column shrink to the
       track's actual size so the child's overflow/ellipsis rules
       actually get a chance to kick in. */
    min-width: 0;
    min-height: 5.5rem;
    padding: 0.4rem;

    border-radius: 6px;

    transition: background .2s ease;
}

.calendar-day-number {
    display: inline-block;
    margin-bottom: 0.3rem;

    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-secondary);
}

.calendar-day-outside {
    background: #fafbfc;
}

/* Days from the months either side - still readable (AA contrast), but
   lighter-weight than this month's. */
.calendar-day-outside .calendar-day-number {
    color: #64748b;
    font-weight: 400;
}

.calendar-day-today {
    background: color-mix(in srgb, #3b82f6 14%, white);
}

.calendar-day-today .calendar-day-number {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 1.5rem;
    height: 1.5rem;

    background: var(--color-primary);
    border-radius: 50%;

    color: #fff;
}

.calendar-event {
    display: block;
    overflow: hidden;

    margin-bottom: 0.2rem;
    padding: 0.15rem 0.4rem;

    background: var(--color-secondary);
    border-radius: 4px;

    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;

    transition: background .2s ease;
}

/* Meetings keep the navy; every other type is teal with a light stripe
   down its left edge - the stripe so the two read apart without relying
   on color alone (the Calendar's legend shows both). :where() keeps
   this at .calendar-event's specificity, so hover and cancelled below
   still override the color. */
.calendar-event:where(:not(.calendar-event-meeting)) {
    background: #0f766e;
    border-left: 3px solid #99f6e4;
}

/* Phones only (see the media query below). */
.calendar-day-panel {
    display: none;
}

.calendar-event:hover {
    background: var(--color-primary);
}

/* Called off - still on the calendar, but plainly not happening. */
.calendar-event-cancelled {
    background: #e2e8f0;
    color: #475569;
    text-decoration: line-through;
}

.calendar-event-cancelled:hover {
    background: #cbd5e1;
}

@media (max-width: 640px) {
    .calendar-day {
        min-height: 3.5rem;
    }

    .calendar-weekdays span {
        font-size: 0;
    }

    .calendar-weekdays span::first-letter {
        font-size: 0.7rem;
    }

    .calendar-grid {
        padding: 0.25rem;
    }

    .calendar-day {
        padding: 0.2rem 0.1rem;
    }

    /* As much of each title as fits on one line, cut off at the cell's
       edge (as Outlook does) - tapping the day lists them in full in
       .calendar-day-panel below. */
    .calendar-event {
        padding: 0.1rem 0.2rem;

        font-size: 0.625rem;
        font-weight: 500;
        letter-spacing: -0.01em;
        text-overflow: clip;
    }

    .calendar-day {
        cursor: pointer;
    }

    .calendar-day-selected {
        box-shadow: inset 0 0 0 2px var(--color-secondary);
    }

    .calendar-day-panel:not([hidden]) {
        display: block;

        padding: 0.75rem 1rem 1rem;

        border-top: 1px solid #e6ebef;
    }

    .calendar-day-panel-date {
        margin-bottom: 0.5rem;

        color: var(--color-secondary);
        font-size: 0.95rem;
        font-weight: 700;
    }

    .calendar-day-panel-list {
        list-style: none;
    }

    .calendar-day-panel-list li + li {
        border-top: 1px solid #f1f5f9;
    }

    .calendar-day-panel-item {
        display: flex;
        gap: 0.75rem;

        padding: 0.55rem 0.25rem;

        color: inherit;
        text-decoration: none;
    }

    .calendar-day-panel-time {
        flex-shrink: 0;
        width: 4.25rem;

        color: var(--color-secondary);
        font-size: 0.8rem;
        font-weight: 700;
    }

    .calendar-day-panel-details {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .calendar-day-panel-title {
        color: var(--color-secondary);
        font-size: 0.9rem;
        font-weight: 600;
    }

    .calendar-day-panel-location {
        color: #64748b;
        font-size: 0.8rem;
    }

    .calendar-day-panel-badge {
        /* Inline-block so the cancelled title's line-through skips it. */
        display: inline-block;
        margin-right: 0.35rem;
        padding: 0.05rem 0.35rem;

        background: #e2e8f0;
        border-radius: 4px;

        color: #475569;
        font-size: 0.7rem;
        font-weight: 600;
        text-decoration: none;
    }

    /* Called off - matches the grid's grey, struck-through chip. */
    .calendar-day-panel-cancelled .calendar-day-panel-title,
    .calendar-day-panel-cancelled .calendar-day-panel-time {
        color: #475569;
        text-decoration: line-through;
    }

    .calendar-day-panel-empty {
        color: #64748b;
        font-size: 0.85rem;
    }
}
