/* ---------- cs-calendar --------------------------------------------------
   A plan of a few weeks shown as a calendar that follows the reader.
   The board sits in the heading column and stays in view; the weeks are
   written out beside it. assets/js/cs-calendar.js opens the week being read,
   folds the others down to their bars and moves a playhead from Monday to
   Friday as that week's copy scrolls past.

   Base state is the whole calendar, every week open, above or beside the copy,
   so no-JS readers get the plan as a figure. Only .is-live folds anything. */

.main > .cs-cal {
    --cal-ink: var(--caseAccent, var(--frgd));
    --cal-quiet: color-mix(in srgb, var(--frgd) 16%, transparent);
    --cal-tint: color-mix(in srgb, var(--cal-ink) 10%, var(--bkgd));
    --cal-lane: 22px;
    --cal-lane-gap: 3px;
    --cal-open: calc(var(--cal-lane) * 3 + var(--cal-lane-gap) * 2);
    --cal-folded: 14px;
    clear: both;
    display: grid;
    grid-template-columns:
        calc(var(--heading-col) - var(--gap) / 2)
        calc(var(--content-col) - var(--gap) / 2);
    column-gap: var(--gap);
    align-items: start;
    box-sizing: border-box;
    width: 100%;
    margin: var(--space-6) 0 0;
    text-align: left;
}

/* --- the board ----------------------------------------------------------- */
.cs-cal__board {
    box-sizing: border-box;
    padding: 12px;
    border: 1.5px solid var(--frgd);
    border-radius: 8px;
    background: var(--bkgd);
    color: var(--frgd);
    font-family: var(--font-meta);
    font-size: var(--text-meta);
    line-height: 1.2;
    letter-spacing: 0;
    container-type: inline-size;
}
/* The heading column is narrow for five days. Where the page has room to the
   left of it, the board takes some. */
@media only screen and (min-width: 1200px) {
    .cs-cal__board {
        margin-left: -72px;
    }
}
.cs-cal.is-live .cs-cal__board {
    position: sticky;
    top: var(--space-5);
    z-index: 2;
}

.cs-cal__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 10px;
    text-transform: uppercase;
}
.cs-cal__now {
    color: var(--cal-ink);
    white-space: nowrap;
}

.cs-cal__days,
.cs-cal__dates {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.cs-cal__days {
    padding-bottom: 6px;
    border-bottom: 1.5px solid var(--frgd);
    text-transform: uppercase;
}
.cs-cal__days > span,
.cs-cal__dates > span {
    padding-left: 5px;
}

/* --- a week -------------------------------------------------------------- */
.cs-cal__row {
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--cal-quiet);
    transition: opacity 240ms ease;
}
.cs-cal__row:last-of-type {
    border-bottom: 0;
}

/* style.css gives every `article a` the soft-button skin unless it is on the
   exclusion list there. This one is a row label, so it is flattened. */
.cs-cal a.cs-cal__wk {
    display: flex !important;
    align-items: baseline;
    justify-content: space-between !important;
    gap: 8px;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 0 !important;
    margin: 0 0 6px !important;
    padding: 0 !important;
    border-radius: 2px !important;
    background: none !important;
    box-shadow: none !important;
    transform: none !important;
    transition: none !important;
    color: inherit !important;
    font: inherit !important;
    letter-spacing: 0 !important;
    text-transform: uppercase !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}
.cs-cal a.cs-cal__wk::before,
.cs-cal a.cs-cal__wk::after {
    content: none !important;
}
.cs-cal a.cs-cal__wk:focus-visible {
    outline: 2px solid var(--frgd);
    outline-offset: 3px;
}
.cs-cal__wk > b {
    font-weight: 400;
}
.cs-cal__wk > span {
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.7;
}
.cs-cal a.cs-cal__wk:hover > b {
    text-decoration: underline;
}

/* Dates and events share one frame, so the playhead can cross both. */
.cs-cal__track {
    position: relative;
    background-image: repeating-linear-gradient(
        to right,
        var(--cal-quiet) 0 1px,
        transparent 1px 20%
    );
}

.cs-cal__dates {
    height: 20px;
    overflow: hidden;
    transition: height 280ms ease, opacity 200ms ease;
}
.cs-cal__dates > span {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}
/* Every day has the daily sync; Wednesday also has the midweek one. */
.cs-cal__dates > span::after,
.cs-cal__key--daily::before {
    content: "";
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.55;
}
.cs-cal__dates > span:nth-child(3)::before,
.cs-cal__key--mid::before,
.cs-cal__ev--sync::before {
    content: "";
    flex: none;
    order: 2;
    width: 5px;
    height: 5px;
    background: var(--cal-ink);
    transform: rotate(45deg);
}
.cs-cal__dates > span::after {
    order: 3;
}
.cs-cal__dates > span.is-today {
    color: var(--cal-ink);
}
.cs-cal__dates > span.is-today > i {
    margin-left: -4px;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--cal-ink);
    color: var(--bkgd);
}
.cs-cal__dates i {
    font-style: normal;
}

.cs-cal__events {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(var(--lanes, 3), minmax(0, 1fr));
    gap: var(--cal-lane-gap) 0;
    height: var(--cal-open);
    transition: height 280ms ease;
}

.cs-cal__ev {
    display: flex;
    align-items: flex-start;
    box-sizing: border-box;
    min-width: 0;
    margin: 0 2px 0 1px;
    padding: 4px 5px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--cal-tint);
    color: var(--cal-ink);
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Kickoff and the workshops: the days the three streams decided together. */
.cs-cal__ev--key {
    background: var(--cal-ink);
    color: var(--bkgd);
    white-space: normal;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 4px;
    text-transform: capitalize;
}
/* A one-day block is too narrow for its word on a small board: stand it up. */
@container (max-width: 330px) {
    .cs-cal__ev--key {
        writing-mode: vertical-rl;
        padding: 5px 4px;
        white-space: nowrap;
    }
    .cs-cal__wide {
        display: none;
    }
}
/* The midweek sync that mattered enough to name: a marker, not a block. */
.cs-cal__ev--sync {
    align-items: center;
    gap: 5px;
    overflow: visible;
    background: none;
    padding-left: 5px;
}
.cs-cal__ev--sync::before {
    order: 0;
}
/* A slot that was planned and then moved. */
.cs-cal__ev--moved {
    background: none;
    box-shadow: inset 0 0 0 1px var(--cal-ink);
    border-radius: 3px;
    opacity: 0.75;
    background-image: repeating-linear-gradient(
        135deg,
        transparent 0 4px,
        color-mix(in srgb, var(--cal-ink) 18%, transparent) 4px 5px
    );
}

.cs-cal__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- the playhead -------------------------------------------------------- */
.cs-cal__track::before,
.cs-cal__track::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
}
/* Time already spent this week. */
.cs-cal__track::before {
    width: calc(var(--p, 0) * 100%);
    background: color-mix(in srgb, var(--frgd) 7%, transparent);
}
.cs-cal__track::after {
    left: calc(var(--p, 0) * 100% - 1px);
    top: -3px;
    bottom: -3px;
    width: 2px;
    border-radius: 1px;
    background: var(--frgd);
}
.cs-cal.is-live .cs-cal__row.is-active .cs-cal__track::before,
.cs-cal.is-live .cs-cal__row.is-active .cs-cal__track::after {
    opacity: 1;
}

/* --- folded weeks -------------------------------------------------------- */
.cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__dates {
    height: 0;
    opacity: 0;
}
.cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__events {
    height: var(--cal-folded);
    gap: 2px 0;
}
.cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__ev {
    padding: 0;
    font-size: 0;
    border-radius: 1.5px;
}
.cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__ev--sync::before {
    content: none;
}
.cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__track {
    background-image: none;
}
/* Weeks still ahead wait quietly. */
.cs-cal.is-live .cs-cal__row:not(.is-active):not(.is-done) {
    opacity: 0.45;
}

/* --- legend -------------------------------------------------------------- */
.cs-cal__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    padding-top: 10px;
    border-top: 1.5px solid var(--frgd);
}
.cs-cal__key {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cs-cal__key--mid::before {
    order: 0;
}
.cs-cal__key--work::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--cal-ink);
}

/* --- the weeks as written ------------------------------------------------ */
.cs-cal__weeks {
    min-width: 0;
}
.cs-cal__week {
    scroll-margin-top: var(--space-5);
    padding-bottom: var(--space-6);
}
.cs-cal__week:last-child {
    padding-bottom: 0;
}
.main .cs-cal__week > h4.caseStudyLabel {
    display: block;
    margin: 0 0 var(--space-4);
    padding: 0;
    background: none;
    font-family: var(--font-display);
    font-size: var(--text-h4);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.005em;
    text-align: left;
}
.main .cs-cal__week > p,
.main .cs-cal__week > ul {
    box-sizing: border-box;
    width: auto;
    max-width: none;
    margin: var(--space-4) 0;
}
.main .cs-cal__week > ul {
    list-style-position: outside;
    padding-left: 1.25em;
}

/* --- stacked: the board becomes a bar stuck to the top ------------------- */
@media only screen and (max-width: 768px) {
    .main > .cs-cal {
        --cal-folded: 8px;
        grid-template-columns: minmax(0, 1fr);
        row-gap: var(--space-5);
    }
    .cs-cal.is-live .cs-cal__board {
        top: 0;
        margin: 0 -8px;
        container-type: normal;
        padding: 8px 8px 6px;
        border-width: 0 0 1.5px;
        border-radius: 0;
        box-shadow: 0 8px 16px -12px color-mix(in srgb, var(--frgd) 60%, transparent);
    }
    .cs-cal.is-live .cs-cal__head {
        padding-bottom: 6px;
    }
    .cs-cal.is-live .cs-cal__legend {
        display: none;
    }
    .cs-cal.is-live .cs-cal__row {
        padding: 4px 0;
        border-bottom: 0;
    }
    .cs-cal.is-live .cs-cal__row:not(.is-active) a.cs-cal__wk {
        display: none !important;
    }
    .cs-cal.is-live .cs-cal__row.is-active {
        padding: 6px 0 8px;
    }
    /* The board covers the top of the screen, so a week lands below it. */
    .cs-cal.is-live .cs-cal__week {
        scroll-margin-top: calc(var(--cs-cal-board, 220px) + 16px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .cs-cal__row,
    .cs-cal__dates,
    .cs-cal__events,
    .cs-cal__track::before,
    .cs-cal__track::after {
        transition: none;
    }
}

@media print {
    .cs-cal.is-live .cs-cal__board {
        position: static;
    }
    .cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__dates {
        height: 20px;
        opacity: 1;
    }
    .cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__events {
        height: var(--cal-open);
    }
    .cs-cal.is-live .cs-cal__row:not(.is-active) .cs-cal__ev {
        padding: 4px 5px;
        font-size: inherit;
    }
    .cs-cal.is-live .cs-cal__row:not(.is-active):not(.is-done) {
        opacity: 1;
    }
    .cs-cal__now,
    .cs-cal__track::before,
    .cs-cal__track::after {
        display: none;
    }
}
