/* Event calendar (Views/Shared/_EventCalendar.cshtml), used in the admin and on the public site.
   Each event is coloured by its department: --c is the colour, --t the text colour on it. */

.cal {
    --cal-border: #e6e8ec;
    --cal-muted: #6b7280;
    --cal-text: #111827;
    --cal-surface: #fff;
    --cal-soft: #f7f8fa;
    --cal-accent: var(--brand-navy, var(--brand-primary, #2a2068));
    --cal-radius: .875rem;
    color: var(--cal-text);
}

/* ----- Toolbar ----- */
.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.cal-title {
    min-width: 11rem;
    margin: 0;
    font-size: 1.375rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -.01em;
}

.cal-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--cal-text);
    text-decoration: none;
    background: var(--cal-surface);
    border: 1px solid var(--cal-border);
    border-radius: 50%;
    transition: background .15s ease;
}

.cal-nav-btn:hover,
.cal-nav-btn:focus-visible {
    background: var(--cal-soft);
}

.cal-today {
    margin-left: .35rem;
    padding: .4rem .9rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--cal-accent);
    text-decoration: none;
    border: 1px solid var(--cal-border);
    border-radius: 999px;
}

.cal-today:hover {
    background: var(--cal-soft);
}

.cal-actions {
    display: flex;
    gap: .5rem;
}

/* ----- Department chips (legend + filter) ----- */
.cal-filters {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    padding-bottom: .25rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.cal-chip {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: .45rem;
    min-height: 2.375rem;
    padding: .35rem .8rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--cal-text);
    text-decoration: none;
    white-space: nowrap;
    background: var(--cal-surface);
    border: 1px solid var(--cal-border);
    border-radius: 999px;
    transition: background .15s ease, border-color .15s ease;
}

.cal-chip:hover {
    border-color: color-mix(in srgb, var(--c, #6b7280) 50%, var(--cal-border));
}

.cal-chip-dot {
    width: .7rem;
    height: .7rem;
    background: var(--c);
    border-radius: 50%;
}

.cal-chip-count {
    min-width: 1.4rem;
    padding: 0 .4rem;
    font-size: .75rem;
    line-height: 1.4rem;
    color: var(--cal-muted);
    text-align: center;
    background: var(--cal-soft);
    border-radius: 999px;
}

/* Selected department: filled with its colour. */
.cal-chip.is-on {
    color: var(--t);
    background: var(--c);
    border-color: var(--c);
}

.cal-chip.is-on .cal-chip-dot {
    background: var(--t);
}

.cal-chip.is-on .cal-chip-count {
    color: var(--t);
    background: rgba(255, 255, 255, .22);
}

.cal-chip-all.is-on {
    color: #fff;
    background: var(--cal-accent);
    border-color: var(--cal-accent);
}

.cal-chip-dots {
    display: inline-flex;
}

.cal-chip-dots span {
    width: .6rem;
    height: .6rem;
    margin-left: -.2rem;
    border: 1.5px solid var(--cal-surface);
    border-radius: 50%;
}

.cal-chip-dots span:first-child {
    margin-left: 0;
}

.cal-chip-all.is-on .cal-chip-dots span {
    border-color: var(--cal-accent);
}

/* ----- Grid ----- */
.cal-grid {
    overflow: hidden;
    background: var(--cal-surface);
    border: 1px solid var(--cal-border);
    border-radius: var(--cal-radius);
}

.cal-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-row + .cal-row {
    border-top: 1px solid var(--cal-border);
}

.cal-weekday {
    padding: .6rem .5rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--cal-muted);
    background: var(--cal-soft);
}

.cal-wd-short {
    display: none;
}

.cal-day {
    position: relative;
    min-width: 0;
    min-height: 7.5rem;
    padding: .35rem .35rem .5rem;
}

.cal-day + .cal-day {
    border-left: 1px solid var(--cal-border);
}

.cal-day.is-out {
    background: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(17, 24, 39, .018) 6px 12px), var(--cal-soft);
}

.cal-day.is-out .cal-date {
    color: #b0b5be;
}

.cal-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .25rem;
}

.cal-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.85rem;
    height: 1.85rem;
    padding: 0 .3rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--cal-text);
    text-decoration: none;
    border-radius: 999px;
}

a.cal-date:hover {
    background: var(--cal-soft);
}

.cal-day.is-today .cal-date {
    color: #fff;
    background: var(--cal-accent);
}

.cal-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    font-size: 1.1rem;
    color: var(--cal-muted);
    text-decoration: none;
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s ease;
}

.cal-day:hover .cal-add,
.cal-add:focus-visible {
    opacity: 1;
}

.cal-add:hover {
    color: var(--cal-accent);
    background: var(--cal-soft);
}

.cal-events {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A timed event: coloured dot-bar on the left, light tint. */
.cal-pill {
    display: flex;
    align-items: baseline;
    gap: .3rem;
    min-width: 0;
    padding: .15rem .4rem;
    font-size: .75rem;
    line-height: 1.35;
    color: var(--cal-text);
    text-decoration: none;
    background: color-mix(in srgb, var(--c) 12%, transparent);
    border-left: 3px solid var(--c);
    border-radius: .35rem;
    transition: background .15s ease;
}

.cal-pill:hover,
.cal-pill:focus-visible {
    background: color-mix(in srgb, var(--c) 22%, transparent);
}

.cal-pill-time {
    flex: none;
    font-weight: 700;
    color: color-mix(in srgb, var(--c) 75%, #000);
}

.cal-pill-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* All-day and multi-day events: solid bars that run across days. */
.cal-pill.is-bar {
    font-weight: 600;
    color: var(--t);
    background: var(--c);
    border-left-color: var(--c);
}

.cal-pill.is-bar:hover {
    filter: brightness(1.08);
}

.cal-pill.is-cont {
    margin-left: -.36rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-pill.is-more {
    margin-right: -.36rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-pill.is-draft {
    background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--c) 10%, transparent) 0 5px, transparent 5px 10px);
    border: 1px dashed var(--c);
    border-left-width: 3px;
}

.cal-pill.is-draft.is-bar {
    color: var(--cal-text);
}

.cal-pill.is-cancelled .cal-pill-title {
    text-decoration: line-through;
    opacity: .7;
}

.cal-more {
    display: inline-block;
    padding: .1rem .4rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--cal-muted);
    text-decoration: none;
    border-radius: .35rem;
}

.cal-more:hover {
    color: var(--cal-accent);
    background: var(--cal-soft);
}

.cal-dots {
    display: none;
}

/* ----- Agenda (the month as a list) ----- */
.cal-agenda {
    margin-top: 1.75rem;
}

.cal-agenda-title {
    margin: 0 0 .75rem;
    font-size: 1rem;
    font-weight: 700;
}

.cal-agenda-day {
    display: flex;
    gap: .9rem;
    padding: .75rem 0;
    scroll-margin-top: 7rem;
    border-top: 1px solid var(--cal-border);
}

.cal-agenda-day:target {
    animation: cal-flash 1.6s ease;
}

@keyframes cal-flash {
    0%, 30% { background: color-mix(in srgb, var(--cal-accent) 10%, transparent); }
    100% { background: transparent; }
}

.cal-agenda-date {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    width: 3rem;
    line-height: 1.1;
}

.cal-agenda-date span {
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--cal-muted);
}

.cal-agenda-date strong {
    font-size: 1.5rem;
}

.cal-agenda-day.is-today .cal-agenda-date strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    margin-top: .1rem;
    font-size: 1.15rem;
    color: #fff;
    background: var(--cal-accent);
    border-radius: 50%;
}

.cal-agenda-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: .5rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cal-agenda-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .8rem .65rem .65rem;
    color: var(--cal-text);
    text-decoration: none;
    background: var(--cal-surface);
    border: 1px solid var(--cal-border);
    border-radius: .75rem;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.cal-agenda-item:hover,
.cal-agenda-item:focus-visible {
    border-color: color-mix(in srgb, var(--c) 45%, var(--cal-border));
    box-shadow: 0 4px 14px rgba(17, 24, 39, .07);
}

.cal-agenda-bar {
    flex: none;
    align-self: stretch;
    width: 4px;
    background: var(--c);
    border-radius: 2px;
}

.cal-agenda-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.cal-agenda-name {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-agenda-item.is-cancelled .cal-agenda-name {
    text-decoration: line-through;
    opacity: .7;
}

.cal-agenda-meta {
    font-size: .8125rem;
    color: var(--cal-muted);
}

.cal-agenda-tags {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .3rem;
}

.cal-tag {
    padding: .15rem .55rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--t);
    white-space: nowrap;
    background: var(--c);
    border-radius: 999px;
}

.cal-state {
    padding: .15rem .55rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 999px;
}

.cal-state-draft { color: #8a5a00; background: #fff4e0; }
.cal-state-scheduled { color: #1d4ed8; background: #e8f0ff; }
.cal-state-cancelled { color: #c62828; background: #fdecec; }

.cal-empty {
    padding: 2.5rem 1rem;
    color: var(--cal-muted);
    text-align: center;
    border: 2px dashed var(--cal-border);
    border-radius: var(--cal-radius);
}

.cal-empty > i {
    font-size: 2rem;
}

/* ----- Phones: compact grid with dots; the list carries the details ----- */
@media (max-width: 767.98px) {
    .cal-toolbar {
        justify-content: center;
    }

    .cal-nav {
        width: 100%;
        justify-content: space-between;
    }

    .cal-title {
        min-width: 0;
        font-size: 1.2rem;
    }

    .cal-nav .cal-title {
        flex: 1;
    }

    .cal-today {
        order: 1;
        margin-left: 0;
        padding: .3rem .7rem;
        font-size: .8125rem;
    }

    .cal-actions:empty {
        display: none;
    }

    .cal-filters {
        /* Swipeable row; fades at the edge to hint there's more. */
        mask-image: linear-gradient(90deg, #000 85%, transparent);
    }

    .cal-weekday {
        padding: .45rem 0;
        font-size: .6875rem;
        text-align: center;
    }

    .cal-wd-long {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .cal-wd-short {
        display: inline;
    }

    .cal-filters {
        scrollbar-width: none;
    }

    .cal-filters::-webkit-scrollbar {
        display: none;
    }

    .cal-day {
        display: flex;
        flex-direction: column;
        align-items: center;
        min-height: 3.6rem;
        padding: .3rem 0;
    }

    .cal-day-head {
        justify-content: center;
        margin: 0;
    }

    .cal-add,
    .cal-events {
        display: none;
    }

    .cal-date {
        min-width: 2.1rem;
        height: 2.1rem;
        font-size: .9375rem;
    }

    .cal-day.has-events:not(.is-out) .cal-date {
        font-weight: 700;
    }

    .cal-dots {
        display: flex;
        gap: 3px;
        margin-top: .2rem;
    }

    .cal-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
    }

    .cal-agenda-item {
        flex-wrap: wrap;
    }

    .cal-agenda-tags {
        justify-content: flex-start;
        width: 100%;
        padding-left: calc(4px + .75rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cal-agenda-day:target {
        animation: none;
    }
}
