/**
 * Calendar (M-011): site/calendar/* and components/calendar/*. Built on the media kit (page band, tabs, chips,
 * rails, poster cards, empty state); only tokens, so it follows the Cinema theme.
 */

/* ================== BAND AND TOOLBAR ================== */
.calendar-band .page-band-row {
    align-items: flex-end;
}

.calendar-views {
    align-self: flex-end;
    gap: 22px;
    padding-bottom: 4px;
}

.calendar-views .media-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.calendar-views .media-tab i {
    font-size: 13px;
}

.calendar-zone {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 20px;
    color: var(--text-2);
}

.calendar-zone i {
    color: var(--accent);
}

.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    padding-top: 24px;
    padding-bottom: 4px;
}

.calendar-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.calendar-chips .module-dot {
    width: 8px;
    height: 8px;
}

/* "Premieres and finales only" and "Only my library" */
.calendar-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.calendar-main {
    padding-top: 28px;
}

/* A list being asked again (filters, time zone, another month) stays in place, faded, until the answer arrives */
[data-calendar-agenda][aria-busy="true"] > *,
[data-calendar-rail][aria-busy="true"] > *,
[data-calendar-undated][aria-busy="true"] > * {
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

/* ================== AGENDA ================== */
.calendar-agenda {
    max-width: 980px;
}

.calendar-day + .calendar-day {
    margin-top: 32px;
}

.calendar-day-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 30px;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--text-1);
}

.calendar-day-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.calendar-day.is-today .calendar-day-title {
    color: var(--accent);
}

.calendar-day.is-today .calendar-day-title::after {
    background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.calendar-events {
    margin: 0;
    padding: 0;
    list-style: none;
}

.calendar-events > li + li {
    border-top: 1px solid var(--line);
}

.calendar-event {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px 12px 12px 8px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
}

.calendar-event:hover,
.calendar-event:focus-within {
    background: var(--surface-1);
}

.calendar-event-cover {
    width: 48px;
    box-shadow: none;
}

.calendar-event-cover .poster-fallback-title {
    font-size: 22cqi;
}

.calendar-event-body {
    min-width: 0;
}

.calendar-event-title {
    margin: 0;
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-1);
}

.calendar-event-link {
    color: inherit;
    text-decoration: none;
}

/* The whole line opens the title */
.calendar-event-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-sm);
}

.calendar-event-link:hover {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.calendar-event-link:focus-visible {
    outline: none;
}

.calendar-event-link:focus-visible::after {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.calendar-event-detail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 7px;
    margin: 3px 0 0;
    font-size: 13px;
    line-height: 20px;
    color: var(--text-2);
}

.calendar-event-code {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-1);
}

.calendar-event-name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.calendar-event-module {
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-2);
}

/* Where it will be (M-033), after its own separator, so a line never ends in a dot */
.calendar-event-where-sep {
    margin-right: 7px;
}

.calendar-event-where-more {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.calendar-event-marks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 7px 0 0;
}

.calendar-mark {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border: 1px solid color-mix(in srgb, var(--module) 55%, transparent);
    border-radius: 11px;
    background: color-mix(in srgb, var(--module) 14%, transparent);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
    color: color-mix(in srgb, var(--module) 70%, var(--text-1));
}

.calendar-mark.is-season-finale {
    border-style: dashed;
}

.calendar-event-time {
    padding-top: 2px;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 28px;
    line-height: 1;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text-1);
}

.calendar-day.is-today .calendar-event-time {
    color: var(--accent);
}

.calendar-more {
    margin-top: 28px;
}

/* A long day (11 lines or more) shows its first 8 and "Show more" (calendar.js, DAY_LONG and DAY_SHOWN) */
.calendar-day:not(.is-expanded) .calendar-events:has(> li:nth-child(11)) > li:nth-child(n + 9) {
    display: none;
}

.calendar-day-more {
    margin-top: 6px;
}

.calendar-day-more-count {
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.calendar-empty {
    max-width: 760px;
}

/* ================== MONTH ================== */
.calendar-month-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 18px;
}

.calendar-month-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 38px;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--text-1);
}

.calendar-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calendar-grid {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
    background: var(--surface-1);
}

.calendar-weekdays span {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-2);
}

.calendar-cells {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--line);
}

.calendar-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 136px;
    padding: 8px;
    background: var(--surface-0);
}

.calendar-cell.is-outside {
    background: color-mix(in srgb, var(--surface-0) 70%, var(--surface-1));
}

.calendar-cell.is-outside .calendar-cell-day,
.calendar-cell.is-outside .calendar-cell-events {
    opacity: 0.45;
}

.calendar-cell.is-selected {
    background: var(--surface-1);
}

.calendar-cell.is-today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-cell-day {
    align-self: flex-start;
    min-width: 34px;
    height: 30px;
    margin: 0;
    padding: 2px 8px 0;
    border: 0;
    border-radius: 15px;
    background: none;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 22px;
    line-height: 28px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    cursor: pointer;
}

.calendar-cell-day:hover {
    color: var(--text-1);
    background: var(--surface-2);
}

.calendar-cell-day:focus-visible,
.calendar-cell-more:focus-visible,
.calendar-cell-poster:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.calendar-cell.has-events .calendar-cell-day {
    color: var(--text-1);
}

.calendar-cell.is-today .calendar-cell-day {
    color: var(--accent);
}

.calendar-cell.is-selected .calendar-cell-day {
    background: var(--accent);
    color: var(--on-accent);
}

.calendar-cell-events {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

/* Where the events will go while they are on their way */
.calendar-cell-ghost {
    display: block;
    width: 46%;
    height: 6px;
    margin-top: 4px;
    border-radius: 3px;
    opacity: 0.7;
}

.calendar-cell-posters {
    align-self: stretch;
    display: flex;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.calendar-cell-posters li {
    flex: 0 1 30%;
    min-width: 0;
}

.calendar-cell-poster {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface-2);
    box-shadow: inset 0 -2px 0 var(--module, var(--line));
}

.calendar-cell-poster img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.calendar-cell-poster.is-marked {
    outline: 1px solid color-mix(in srgb, var(--module) 70%, transparent);
    outline-offset: 1px;
}

.calendar-cell-poster .poster-fallback-title {
    font-size: 20cqi;
    -webkit-line-clamp: 3;
}

/* "+N" in the last place of a busier day, the size of a poster: opens the whole day under the grid */
.calendar-cell-more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 2 / 3;
    margin: 0;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-1));
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 22px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    cursor: pointer;
}

.calendar-cell-more:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
}

/* ================== HOVER CARD ================== */
/* A poster of the month on hover or focus: what its agenda line says (calendar.js fills and places it) */
.calendar-tip {
    position: absolute;
    z-index: 1080;
    width: max-content;
    max-width: 280px;
    padding: 10px 12px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface-3);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    line-height: 18px;
    color: var(--text-1);
}

.calendar-tip[hidden] {
    display: none;
}

/* The arrow pointing at the poster */
.calendar-tip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--tip-arrow, 50%);
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
    background: var(--surface-3);
    transform: rotate(45deg);
}

.calendar-tip.is-below::after {
    top: auto;
    bottom: 100%;
    margin: 0 0 -5px -5px;
    border: 0;
    border-top: 1px solid var(--line-strong);
    border-left: 1px solid var(--line-strong);
}

.calendar-tip-module {
    margin: 0;
    font-size: 11px;
    color: var(--text-2);
}

.calendar-tip-title {
    margin: 4px 0 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 19px;
}

.calendar-tip-detail {
    margin: 2px 0 0;
    color: var(--text-2);
}

.calendar-tip-marks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0 0;
}

.calendar-tip-note {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-2);
}

.calendar-tip-note i {
    width: 14px;
    text-align: center;
    color: var(--text-2);
}

/* Every name, which may take two lines: the icon stays on the first */
.calendar-tip-where {
    align-items: baseline;
}

.calendar-tip-where i {
    flex: none;
}

.calendar-month-days {
    margin-top: 28px;
}

.calendar-day-empty,
.calendar-month-none {
    margin: 0;
    font-size: 14px;
    color: var(--text-2);
}

/* Only the month listed as an agenda (a phone) says the month has nothing; the grid shows it already */
.calendar-month-none {
    display: none;
}

.calendar-days-loading {
    display: grid;
    gap: 12px;
    max-width: 980px;
}

.calendar-days-loading span {
    display: block;
    height: 64px;
    border-radius: var(--radius-sm);
}

.calendar-days-loading span:first-child {
    width: 240px;
    height: 28px;
}

/* Short, over the grid, where the arrows were used: the days stay on screen */
.calendar-error {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0 0 16px;
    padding: 10px 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    font-size: 14px;
    line-height: 20px;
    color: var(--text-1);
}

.calendar-error[hidden] {
    display: none;
}

.calendar-error > i {
    color: var(--danger);
}

/* The month's "No set day" strip, after the chosen day (calendar.js): the releases known only by their month,
   quarter or year */
.calendar-undated-slot {
    margin-top: 44px;
}

.calendar-undated-slot[hidden] {
    display: none;
}

.calendar-undated-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
    margin-bottom: 14px;
}

.calendar-undated-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 30px;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--text-1);
}

.calendar-undated-count {
    align-self: center;
    padding: 2px 9px 1px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}

.calendar-undated-sub {
    flex-basis: 100%;
    margin: 0;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-2);
}

/* The rail stays inside the page's margins, under the grid */
.calendar-undated .calendar-rail {
    --rail-inset: 0px;
    --cover-w: 136px;
    --rail-gap: 16px;
}

.calendar-undated .calendar-countdown.is-period {
    font-size: 22px;
}

/* The period is already over the cover */
.calendar-undated .poster-card-title + .poster-card-meta {
    display: none;
}

/* Without the page's margin beside it, an arrow with nowhere to go would only cover a poster */
.calendar-undated .media-rail-arrow:disabled {
    visibility: hidden;
}

.calendar-undated-more {
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 18px;
    color: var(--text-2);
}

/* On larger screens the grid shows the month and the list only the chosen day */
@media (min-width: 768px) {
    .calendar-month-days .calendar-day:not(.is-selected) {
        display: none;
    }

    .calendar-month-days .calendar-day + .calendar-day {
        margin-top: 0;
    }

    .calendar-month-days .calendar-more {
        display: none;
    }
}

/* ================== RELEASES ================== */
.calendar-releases-sub {
    margin: -8px 0 18px;
    font-size: 14px;
    line-height: 20px;
    color: var(--text-2);
}

.calendar-rail {
    --cover-w: 176px;
    --rail-gap: 22px;
    --rail-arrow-y: calc(var(--cover-w) * 0.75);
}

/* The countdown takes the bottom of the cover: a typographic cover puts the title under the module chip */
.calendar-card-cover .poster-fallback {
    justify-content: flex-start;
    padding-top: 48px;
}

.calendar-card-cover::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 52%;
    background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--surface-0) 82%, transparent) 70%, color-mix(in srgb, var(--surface-0) 94%, transparent) 100%);
    pointer-events: none;
}

.calendar-countdown {
    position: absolute;
    left: 12px;
    bottom: 10px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    color: var(--text-1);
}

.calendar-countdown-number {
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 58px;
    line-height: 0.85;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
}

.calendar-countdown-unit {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-2);
}

.calendar-countdown.is-today {
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 40px;
    line-height: 0.9;
    letter-spacing: 0.02em;
    color: var(--accent);
}

.calendar-countdown.is-period {
    right: 12px;
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 26px;
    line-height: 0.95;
    letter-spacing: 0.02em;
}

.calendar-rank {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    padding: 4px 8px 1px;
    border-radius: 6px;
    background: var(--accent);
    font-family: var(--font-display);
    font-weight: var(--font-display-weight);
    font-size: 24px;
    line-height: 24px;
    letter-spacing: 0.02em;
    color: var(--on-accent);
}

.calendar-card .poster-card-meta {
    white-space: normal;
}

.calendar-card-note {
    margin-top: 2px;
    font-size: 12.5px;
}

/* One line under the date: the names that do not fit end in an ellipsis */
.calendar-card .calendar-card-where {
    margin-top: 2px;
    font-size: 12.5px;
    white-space: nowrap;
}

.calendar-card-where-names {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-card-people i {
    color: var(--accent);
}

.calendar-rail-empty {
    padding-bottom: 8px;
}

/* ================== PHONES AND TABLETS ================== */
@media (max-width: 991.98px) {
    .calendar-band .page-band-row {
        align-items: flex-start;
    }

    .calendar-views {
        align-self: flex-start;
    }

    .calendar-toggles {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .calendar-toolbar {
        flex-wrap: nowrap;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 18px;
    }

    /* The chips scroll sideways instead of taking several lines */
    .calendar-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-inline: calc(var(--page-inset) * -1);
        padding-inline: var(--page-inset);
        scrollbar-width: none;
    }

    .calendar-chips::-webkit-scrollbar {
        display: none;
    }

    .calendar-chips .kit-chip,
    .calendar-toggles .kit-chip {
        flex: none;
        height: 36px;
        padding: 0 14px;
        font-size: 13.5px;
    }

    .calendar-main {
        padding-top: 22px;
    }

    .calendar-day + .calendar-day {
        margin-top: 26px;
    }

    .calendar-day-title {
        font-size: 26px;
    }

    .calendar-event {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 12px;
        padding: 10px 4px;
    }

    .calendar-event-cover {
        width: 44px;
    }

    .calendar-event-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    /* Where it will be takes a line of its own instead of wrapping after a separator */
    .calendar-event-where {
        flex-basis: 100%;
    }

    .calendar-event-where-sep {
        display: none;
    }

    .calendar-event-time {
        font-size: 24px;
    }

    /* The grid gives way to the month as an agenda */
    .calendar-grid {
        display: none;
    }

    .calendar-month-title {
        font-size: 32px;
    }

    .calendar-month-days {
        margin-top: 8px;
    }

    .calendar-undated-slot {
        margin-top: 4px;
        margin-bottom: 28px;
    }

    .calendar-undated-title {
        font-size: 26px;
    }

    .calendar-undated .calendar-rail {
        --cover-w: 118px;
        --rail-gap: 12px;
    }

    .calendar-undated .calendar-countdown.is-period {
        font-size: 19px;
    }

    /* The whole month is listed: no chosen day to report as empty, and no days of the months around */
    .calendar-day-empty,
    .calendar-month-days .calendar-day.is-outside {
        display: none;
    }

    .calendar-month-days .calendar-day.is-outside + .calendar-day:not(.is-outside) {
        margin-top: 0;
    }

    .calendar-month-none {
        display: block;
    }

    .calendar-rail {
        --cover-w: 140px;
        --rail-gap: 14px;
    }

    .calendar-countdown-number {
        font-size: 48px;
    }

    .calendar-countdown.is-period {
        font-size: 22px;
    }

    .calendar-rank {
        font-size: 20px;
        line-height: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .calendar-event,
    [data-calendar-agenda][aria-busy="true"] > *,
    [data-calendar-rail][aria-busy="true"] > *,
    [data-calendar-undated][aria-busy="true"] > * {
        transition: none;
    }
}
