/* Community house weekly booking calendar ([ld-community-calendar]) */
.ld-ccal { --ld-ccal-hour: 64px; /* keep in sync with HOUR_HEIGHT in JS */ --ld-ccal-gutter: 56px; --ld-ccal-line: #e8e8e8; --ld-ccal-text: #222; --ld-ccal-muted: #666; --ld-ccal-accent: #2f80ed; --ld-ccal-today: #f5f9ff; margin: 0 0 32px; color: var(--ld-ccal-text); font-size: 14px; }

/* Reserve space until the first render so the page below doesn't jump */
.ld-ccal:not(.is-ready) { min-height: 480px; }
.ld-ccal *, .ld-ccal *::before, .ld-ccal *::after { box-sizing: border-box; }
.ld-ccal [hidden] { display: none !important; }
.ld-ccal__status, .ld-ccal__empty { margin: 16px 0 0; color: var(--ld-ccal-muted); }

/* Toolbar */
.ld-ccal__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 16px; }
.ld-ccal__title { margin: 0; font-size: 26px; font-weight: 400; line-height: 1.2; }

/* Hall switch (one hall at a time, native radio buttons) */
.ld-ccal__switch { display: inline-flex; border: 1px solid #ccc; border-radius: 4px; background: #fff; overflow: hidden; }
.ld-ccal__switch-option { position: relative; display: flex; }
.ld-ccal__switch-option + .ld-ccal__switch-option { border-left: 1px solid #ccc; }
.ld-ccal__switch-input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ld-ccal__switch-label { display: flex; flex: 1 1 auto; align-items: center; justify-content: center; gap: 8px; height: 40px; margin: 0; padding: 0 18px; color: var(--ld-ccal-muted); font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; transition: background-color .15s, color .15s, box-shadow .15s; }
.ld-ccal__switch-label:hover { background: #f7f7f7; color: var(--ld-ccal-text); }
.ld-ccal__switch-dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--ld-ccal-event); }
.ld-ccal__switch-input:checked + .ld-ccal__switch-label { background: var(--ld-ccal-event-bg); color: var(--ld-ccal-event-text); box-shadow: inset 0 -3px 0 var(--ld-ccal-event); cursor: default; }
.ld-ccal__switch-input:focus-visible + .ld-ccal__switch-label { outline: 2px solid var(--ld-ccal-accent); outline-offset: -2px; }
.ld-ccal__nav { display: flex; margin-left: auto; border-radius: 4px; overflow: hidden; background: #eee; }
.ld-ccal__nav-btn, .ld-ccal__nav-date { height: 40px; border: 0; background: #eee; color: var(--ld-ccal-text); font: inherit; cursor: pointer; }
.ld-ccal__nav-btn { position: relative; flex: 0 0 48px; width: 48px; }
.ld-ccal__nav-btn::before { content: ""; position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border: solid currentColor; border-width: 2px 2px 0 0; }
.ld-ccal__nav-btn--prev::before { transform: translate(-30%, -50%) rotate(-135deg); }
.ld-ccal__nav-btn--next::before { transform: translate(-70%, -50%) rotate(45deg); }
.ld-ccal__nav-date { min-width: 120px; padding: 0 12px; border-left: 1px solid #fff; border-right: 1px solid #fff; color: var(--ld-ccal-muted); }
.ld-ccal__nav-btn:hover:not(:disabled), .ld-ccal__nav-date:hover { background: #e0e0e0; }
.ld-ccal__nav-btn:disabled { opacity: .35; cursor: default; }
.ld-ccal__nav-btn:focus-visible, .ld-ccal__nav-date:focus-visible { outline: 2px solid var(--ld-ccal-accent); outline-offset: 2px; }

/* Week grid */
.ld-ccal__grid { border-top: 1px solid var(--ld-ccal-line); border-bottom: 1px solid var(--ld-ccal-line); }
.ld-ccal__head, .ld-ccal__body { display: grid; grid-template-columns: var(--ld-ccal-gutter) repeat(7, minmax(0, 1fr)) var(--ld-ccal-gutter); }
.ld-ccal__body { border-top: 1px solid var(--ld-ccal-line); }
.ld-ccal__day-head { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px 10px 12px; border-left: 1px solid var(--ld-ccal-line); }
.ld-ccal__head > .ld-ccal__gutter:last-child, .ld-ccal__times--right { border-left: 1px solid var(--ld-ccal-line); }
.ld-ccal__weekday { overflow: hidden; color: var(--ld-ccal-muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.ld-ccal__daynum { font-size: 22px; line-height: 1; }
.ld-ccal__day-head.is-today .ld-ccal__daynum { color: var(--ld-ccal-accent); font-weight: 700; }
.ld-ccal__times { color: var(--ld-ccal-muted); font-size: 12px; }
.ld-ccal__time { height: var(--ld-ccal-hour); padding: 6px 8px 0; border-top: 1px solid var(--ld-ccal-line); box-sizing: border-box; }
.ld-ccal__time:first-child { border-top: 0; }
.ld-ccal__times--left .ld-ccal__time { text-align: left; }
.ld-ccal__times--right .ld-ccal__time { text-align: right; }
.ld-ccal__day { position: relative; min-width: 0; border-left: 1px solid var(--ld-ccal-line); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--ld-ccal-hour) - 1px), var(--ld-ccal-line) calc(var(--ld-ccal-hour) - 1px), var(--ld-ccal-line) var(--ld-ccal-hour)); }
.ld-ccal__day.is-today { background-color: var(--ld-ccal-today); }

/* Booking colours (shared by grid blocks, agenda items, the hall switch and the dialog) */
.ld-ccal__event, .ld-ccal__agenda-item, .ld-ccal__switch-option, .ld-ccal__dialog { --ld-ccal-event: #4fc3f7; --ld-ccal-event-bg: #eaf4fb; --ld-ccal-event-text: #3a87ad; }
.ld-ccal__event--dance { --ld-ccal-event: #b39ddb; --ld-ccal-event-bg: #f3effa; --ld-ccal-event-text: #6a4fa3; }
.ld-ccal__event--terrace { --ld-ccal-event: #81c784; --ld-ccal-event-bg: #eef7ef; --ld-ccal-event-text: #3d7a40; }
.ld-ccal__event--booked { --ld-ccal-event: #d6d6d6; --ld-ccal-event-bg: #f5f5f5; --ld-ccal-event-text: #666666; }

/* Grid blocks */
.ld-ccal__event { position: absolute; z-index: 1; display: flex; flex-direction: column; gap: 2px; margin-top: 1px; padding: 5px 5px 5px 7px; overflow: hidden; border: 1px solid var(--ld-ccal-event); border-left-width: 4px; border-radius: 3px; background: var(--ld-ccal-event-bg); color: var(--ld-ccal-event-text); font-size: 11px; line-height: 1.35; box-sizing: border-box; container-type: inline-size; }

/* Bookings are buttons (they open the details dialog) */
.ld-ccal__event, .ld-ccal__agenda-item { margin: 0; font-family: inherit; text-align: left; cursor: pointer; -webkit-appearance: none; appearance: none; }
.ld-ccal__event:hover, .ld-ccal__event:focus-visible { z-index: 2; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.ld-ccal__event:focus-visible, .ld-ccal__agenda-item:focus-visible { outline: 2px solid var(--ld-ccal-accent); outline-offset: 1px; }
.ld-ccal__event-time { white-space: nowrap; opacity: .85; }
.ld-ccal__event-title { font-weight: 700; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.ld-ccal__event-room { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .75; }

/* Narrow blocks (several bookings side by side): start time only, no hall line */
@container (max-width: 80px) {
    .ld-ccal__event-end, .ld-ccal__event-room { display: none; }
    .ld-ccal__event-title { font-size: 10px; }
    /* Grey "Booked" blocks have no popup, so keep the hall name visible */
    .ld-ccal__event--booked:not(.is-compact) .ld-ccal__event-room { display: block; font-size: 10px; }
}

/* Very narrow blocks: title only (full details in the hover tooltip) */
@container (max-width: 44px) {
    .ld-ccal__event-time { display: none; }
}

/* Under one hour: no hall line; very short: time and title on one line */
.ld-ccal__event.is-compact .ld-ccal__event-room { display: none; }
.ld-ccal__event.is-short { flex-direction: row; flex-wrap: wrap; column-gap: 6px; padding-top: 2px; padding-bottom: 2px; }
.ld-ccal__now { position: absolute; left: 0; right: 0; z-index: 3; height: 2px; background: #e53935; pointer-events: none; }
.ld-ccal__now::before { content: ""; position: absolute; top: -4px; left: -5px; width: 10px; height: 10px; border-radius: 50%; background: #e53935; }

/* Agenda (phones and portrait tablets, breakpoint set in JS) */
.ld-ccal__agenda-day { padding: 14px 0; border-top: 1px solid var(--ld-ccal-line); }
.ld-ccal__agenda-day:last-child { border-bottom: 1px solid var(--ld-ccal-line); }
.ld-ccal__agenda-date { margin: 0 0 10px; font-size: 15px; font-weight: 700; line-height: 1.3; }
.ld-ccal__agenda-date::first-letter { text-transform: uppercase; }
.ld-ccal__agenda-day.is-today .ld-ccal__agenda-date { color: var(--ld-ccal-accent); }
.ld-ccal__agenda-none { margin: 0; color: var(--ld-ccal-muted); font-size: 13px; }
.ld-ccal__agenda-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ld-ccal__agenda-entry { margin: 0; padding: 0; }
.ld-ccal__agenda-entry::before { content: none; /* override theme list bullets */ }
.ld-ccal__agenda-item { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; width: 100%; padding: 8px 10px; border: 1px solid var(--ld-ccal-event); border-left-width: 4px; border-radius: 3px; background: var(--ld-ccal-event-bg); color: var(--ld-ccal-event-text); font-size: 13px; line-height: 1.4; }
.ld-ccal__agenda-item:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
/* Grey "Booked" blocks (school time) are not clickable */
.ld-ccal__event.ld-ccal__event--booked, .ld-ccal__agenda-item.ld-ccal__event--booked { cursor: default; }
.ld-ccal__event.ld-ccal__event--booked:hover, .ld-ccal__agenda-item.ld-ccal__event--booked:hover { z-index: 1; box-shadow: none; }
.ld-ccal__agenda-item .ld-ccal__event-time { grid-row: span 2; opacity: 1; }
.ld-ccal__agenda-item .ld-ccal__event-room { grid-column: 2; }

/* Booking details dialog */
html.ld-ccal-dialog-open { overflow: hidden; /* no page scroll behind the dialog */ }
.ld-ccal__dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); margin: auto; padding: 0; overflow: auto; border: 0; border-top: 6px solid var(--ld-ccal-event); border-radius: 8px; background: #fff; color: var(--ld-ccal-text); box-shadow: 0 24px 64px rgba(15, 23, 42, .25); }
.ld-ccal__dialog[open] { animation: ld-ccal-dialog-in .18s ease-out; }
.ld-ccal__dialog::backdrop { background: rgba(15, 23, 42, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@keyframes ld-ccal-dialog-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ld-ccal__dialog[open] { animation: none; }
}
.ld-ccal__dialog-inner { position: relative; padding: 28px 32px 24px; }
.ld-ccal__dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ld-ccal-muted); cursor: pointer; transition: background-color .15s, color .15s; }
.ld-ccal__dialog-close::before, .ld-ccal__dialog-close::after { content: ""; position: absolute; top: 50%; left: 50%; width: 16px; height: 2px; border-radius: 1px; background: currentColor; transform: translate(-50%, -50%) rotate(45deg); }
.ld-ccal__dialog-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.ld-ccal__dialog-close:hover { background: #f1f1f1; color: var(--ld-ccal-text); }
.ld-ccal__dialog-title { margin: 0 40px 24px 0; color: var(--ld-ccal-text); font-size: 24px !important; font-weight: 400; line-height: 1.3; overflow-wrap: break-word; }
.ld-ccal__dialog-details { margin: 0; border-top: 1px solid var(--ld-ccal-line); }
.ld-ccal__dialog-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--ld-ccal-line); }
.ld-ccal__dialog-row dt { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.ld-ccal__dialog-row dd { margin: 0; font-size: 15px; }
.ld-ccal__dialog-room { display: flex; align-items: center; gap: 8px; }
.ld-ccal__dialog-room::before { content: ""; flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--ld-ccal-event); }
.ld-ccal__dialog-footer { display: flex; justify-content: flex-end; margin-top: 24px; }
.ld-ccal__dialog-done { min-width: 110px; height: 40px; padding: 0 20px; border: 1px solid var(--ld-ccal-accent); border-radius: 4px; background: var(--ld-ccal-accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; transition: background-color .15s; }
.ld-ccal__dialog-done:hover { background: #1f6fdc; }
.ld-ccal__dialog-close:focus-visible, .ld-ccal__dialog-done:focus-visible { outline: 2px solid var(--ld-ccal-accent); outline-offset: 2px; }
@media (max-width: 479px) {
    .ld-ccal__dialog-inner { padding: 24px 20px 20px; }
    .ld-ccal__dialog-title { font-size: 20px !important; }
    .ld-ccal__dialog-row { grid-template-columns: 105px minmax(0, 1fr); }
    .ld-ccal__dialog-done { width: 100%; }
}

/* Smaller desktops / landscape tablets: drop the right-hand time column to give the days more room */
@media (max-width: 1199px) {
    .ld-ccal__head, .ld-ccal__body { grid-template-columns: var(--ld-ccal-gutter) repeat(7, minmax(0, 1fr)); }
    .ld-ccal__head > .ld-ccal__gutter:last-child, .ld-ccal__times--right { display: none; }
    .ld-ccal__grid { border-right: 1px solid var(--ld-ccal-line); }
    .ld-ccal__day-head { padding: 12px 6px 10px; }
    .ld-ccal__weekday { font-size: 10px; letter-spacing: 0; }
}

/* Phones: stacked toolbar */
@media (max-width: 767px) {
    .ld-ccal__title { width: 100%; font-size: 22px; }
    .ld-ccal__filter, .ld-ccal__nav { width: 100%; }
    .ld-ccal__switch { display: flex; }
    .ld-ccal__switch-option { flex: 1 1 0; }
    .ld-ccal__nav { margin-left: 0; }
    .ld-ccal__nav-date { flex: 1 1 auto; }
}
