/* PCI SSC Events — list meta, view switcher, and the month calendar grid.
   Uses the design-system variables from base.css so the section inherits the
   site's palette rather than restating colours of its own. */

/* ---- View switcher (Upcoming / Past / Calendar) ---- */

.events-views {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-4) 0 var(--space-6);
}

/* Heading and view switcher share a line on the calendar page: every line
   above the grid is a line the grid loses off the bottom of the screen. Only
   from tablet width up — at phone width the two do not fit side by side and
   the heading ends up underneath the buttons. */
@media (min-width: 768px) {
    .events-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-4);
    }

    .events-header h1 {
        margin: 0;
    }

    .events-header .events-views {
        margin: 0;
    }
}

.events-views a,
.events-views span {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    text-decoration: none;
}

.events-views a {
    color: var(--color-text-secondary);
    background: var(--color-surface);
}

.events-views a:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.events-views [aria-current="page"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.events-day-heading {
    margin-top: var(--space-8);
}

/* ---- Event cards ---- */

.event-meta {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.event-meta span + span::before {
    content: "·";
    margin: 0 var(--space-2);
    color: var(--color-text-muted);
}

/* ---- Detail page ---- */

.event-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-6);
    margin: var(--space-6) 0;
}

.event-facts dt {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.event-facts dd {
    margin: 0;
}

.event-speakers {
    margin: 0;
    padding-left: var(--space-4);
}

/* ---- Removed events ---- */

.event-gone-notice {
    padding: var(--space-3) var(--space-4);
    margin: var(--space-4) 0;
    border-left: 3px solid var(--color-rose-500);
    background: var(--color-rose-100);
    color: var(--color-rose-800);
    border-radius: var(--radius-sm);
}

.event-history {
    margin-top: var(--space-8);
}

.event-changes {
    list-style: none;
    padding: 0;
    margin: var(--space-4) 0 0;
}

.event-changes li {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--color-border-subtle);
}

.event-changes time {
    flex: 0 0 9rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ---- Month calendar ----
   Laid out to fit the screen rather than run off the bottom of it: the month
   is a flex column sized to the space left under the header, and its six week
   rows share that space equally. Below MIN-HEIGHT the page scrolls instead of
   squashing the weeks into unreadable slivers. */

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.calendar-nav-controls {
    display: flex;
    gap: var(--space-2);
}

.calendar-nav-arrow {
    /* Square, so the two arrows read as a pair of buttons rather than as two
       differently-sized pills. */
    width: 2rem;
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

.calendar-month {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.calendar-nav-link {
    white-space: nowrap;
    text-decoration: none;
    color: var(--color-text-secondary);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

.calendar-nav-link:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.calendar-today-link {
    margin: 0 0 var(--space-3);
    font-size: 0.875rem;
}

.cal {
    display: flex;
    flex-direction: column;
    /* Deliberately NOT pinned to the viewport with a dvh calculation. That
       approach has to guess the height of the chrome above it, and when the
       guess is too small the grid does not shrink — grid rows will not go below
       their content — so `overflow: hidden` silently eats a whole week instead.
       A hidden week is far worse than a short scroll. Compact rows keep the
       whole month inside a laptop screen on their own: ~2.5rem of header plus
       six weeks of 5rem is about 33rem, against the ~22rem of chrome above. */
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
}

.cal-weekday {
    padding: var(--space-2) var(--space-2);
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.cal-weekday abbr {
    text-decoration: none;
    border: 0;
}

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* Row 1 dates, then one row per lane, then the "+N" row. Sizing the lane
       rows explicitly rather than by content keeps every week the same height
       whether it holds three events or none, which is what makes the grid read
       as a calendar rather than as a table of variable-height cells. */
    /* The "+N" row is auto, not fixed: only a handful of weeks ever overflow,
       and reserving a row on every week for something almost never shown costs
       height on all six. */
    grid-template-rows: 1.375rem repeat(3, 1.0625rem) auto;
    row-gap: 2px;
    flex: 1 1 auto;
    padding-bottom: var(--space-1);
}

/* Background layer: spans every row of its column so the whole cell is shaded
   and bordered, with the bars drawn over it. */
.cal-cell {
    grid-row: 1 / -1;
    border-left: 1px solid var(--color-border-subtle);
    border-top: 1px solid var(--color-border-subtle);
}

.cal-week:first-of-type .cal-cell {
    border-top: 0;
}

.cal-cell:first-child {
    border-left: 0;
}

.cal-cell-outside {
    background: var(--color-bg-alt);
}

.cal-cell-today {
    background: var(--color-sky-100);
}

.cal-date {
    grid-row: 1;
    z-index: 1;
    padding: 0 var(--space-2);
    text-align: right;
}

.cal-daynum {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.cal-date-outside .cal-daynum {
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Today reads as a filled dot, the way a calendar app marks it, rather than an
   outline round the whole cell. */
.cal-daynum-today {
    background: var(--color-accent);
    color: var(--color-text-inverse);
    border-radius: var(--radius-full);
}

/* ---- Event bars ---- */

.cal-bar {
    z-index: 2;
    align-self: start;
    margin: 0 4px;
    padding: 1px var(--space-2);
    border-radius: var(--radius-full);
    background: var(--color-sky-100);
    color: var(--color-sky-800);
    font-size: 0.75rem;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.cal-bar-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-bar:hover {
    background: var(--color-cyan-500);
    color: var(--color-text-inverse);
}

/* An event PCI SSC has stopped listing: struck through rather than removed, so
   someone who saw it on the calendar last week can tell what became of it. */
.cal-bar-gone .cal-bar-text {
    text-decoration: line-through;
    opacity: 0.7;
}

/* A run cut by the week boundary is squared off at the cut and butts against
   the edge, so a bar only reads as starting or ending where it truly does. */
.cal-bar-from-earlier {
    margin-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-bar-continues {
    margin-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-more {
    z-index: 2;
    align-self: start;
    padding: 0 var(--space-2);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
}

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

/* Desktop: the bars are the links, so the whole-day target is not needed. */
.cal-daylink {
    display: none;
}

/* ---- Phone ----
   Seven columns cannot hold readable text, so the bars become coloured strips
   and the whole day becomes one tap target opening that day's list. */
@media (max-width: 640px) {
    .cal {
        height: auto;
        min-height: 0;
    }

    .cal-week {
        /* A little more room under the date than at desktop width, so the
           strips read as event markers rather than as underlining the number. */
        grid-template-rows: 1.625rem repeat(3, 0.375rem) auto;
    }

    .cal-date {
        padding: 2px;
        text-align: center;
    }

    .cal-daynum {
        min-width: 1.25rem;
        height: 1.25rem;
        font-size: 0.6875rem;
    }

    .cal-bar {
        margin: 0 2px;
        padding: 0;
        height: 4px;
        border-radius: 2px;
        background: var(--color-sky-500);
        /* The day link underneath is the tap target at this width. */
        pointer-events: none;
    }

    .cal-bar-text {
        display: none;
    }

    .cal-more {
        padding: 0;
        text-align: center;
        font-size: 0.625rem;
        pointer-events: none;
    }

    .cal-daylink {
        display: block;
        grid-row: 1 / -1;
        z-index: 3;
    }
}
