/*
 * ============================================================
 * HHY SERVICES CALENDAR
 * ============================================================
 */


/*
 * ============================================================
 * PAGE
 * ============================================================
 */

.hhy-calendar-page {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 30px 20px 50px;
    box-sizing: border-box;
}


.hhy-calendar-header {
    margin-bottom: 20px;
}


.hhy-calendar-header h1 {
    margin: 0 0 8px;
}


.hhy-calendar-intro {
    margin: 0;
}


/*
 * ============================================================
 * VIEW SWITCHER
 * ============================================================
 */

.hhy-calendar-view-switcher {
    display: flex;
    gap: 8px;
    margin: 0 0 18px;
}


.hhy-calendar-view-button {
    appearance: none;
    border: 1px solid #c8c8c8;
    background: #fff;
    color: #333;
    border-radius: 6px;
    padding: 9px 18px;
    min-height: 44px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}


.hhy-calendar-view-button:hover {
    background: #f5f5f5;
}


.hhy-calendar-view-button:focus {
    outline: 3px solid rgba(79, 154, 154, 0.25);
    outline-offset: 2px;
}


.hhy-calendar-view-button.is-active {
    background: #333;
    color: #fff;
    border-color: #333;
}


/*
 * ============================================================
 * NAVIGATION
 * ============================================================
 */

.hhy-calendar-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}


.hhy-calendar-navigation button {
    appearance: none;
    border: 1px solid #c8c8c8;
    background: #fff;
    color: #333;
    border-radius: 5px;
    padding: 8px 14px;
    min-height: 42px;
    cursor: pointer;
    font-size: 14px;
}


.hhy-calendar-navigation button:hover {
    background: #f5f5f5;
}


.hhy-calendar-navigation button:focus {
    outline: 3px solid rgba(79, 154, 154, 0.25);
    outline-offset: 2px;
}


.hhy-calendar-current-date {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 18px;
}


/*
 * ============================================================
 * FILTERS
 * ============================================================
 */

.hhy-calendar-filters {
    margin-bottom: 20px;
}


.hhy-calendar-service-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 12px;
}


.hhy-calendar-service-filters strong {
    margin-right: 4px;
}


.hhy-calendar-service-filters label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    white-space: nowrap;
}


.hhy-calendar-service-filters input,
.hhy-admission-options input {
    width: 17px;
    height: 17px;
    margin: 0;
}


.hhy-filter-icon {
    line-height: 1;
}


/*
 * ============================================================
 * ADMISSION FILTER
 * ============================================================
 */

.hhy-calendar-admission-filter {
    position: relative;
    max-width: 360px;
}


.hhy-admission-toggle {
    appearance: none;
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid #c8c8c8;
    border-radius: 5px;
    background: #fff;
    color: #333;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}


.hhy-admission-toggle:hover {
    background: #f7f7f7;
}


.hhy-admission-toggle:focus {
    outline: 3px solid rgba(79, 154, 154, 0.25);
    outline-offset: 2px;
}


.hhy-admission-count {
    margin-left: 4px;
    font-weight: 600;
}


.hhy-admission-arrow {
    float: right;
    font-size: 16px;
}


.hhy-admission-options {
    position: absolute;
    z-index: 100;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #fff;
    border: 1px solid #c8c8c8;
    border-radius: 5px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}


.hhy-admission-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    cursor: pointer;
}


.hhy-admission-options p {
    margin: 4px 0;
}


/*
 * ============================================================
 * SHARED CALENDAR VIEW
 * ============================================================
 */

.hhy-calendar-view[hidden] {
    display: none;
}


/*
 * ============================================================
 * TIMETABLE SURFACE
 * ============================================================
 *
 * IMPORTANT:
 *
 * This is the SINGLE horizontal scrolling container.
 *
 * The heading and timetable rows are both inside it, so their
 * horizontal coordinates remain locked together on mobile.
 */

.hhy-calendar-surface {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    box-sizing: border-box;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}


.hhy-calendar-surface::-webkit-scrollbar {
    height: 10px;
}


.hhy-calendar-surface::-webkit-scrollbar-track {
    background: #eeeeee;
}


.hhy-calendar-surface::-webkit-scrollbar-thumb {
    background: #aaaaaa;
    border-radius: 5px;
}


/*
 * ============================================================
 * TIME HEADER
 * ============================================================
 */

.hhy-calendar-day-heading {
    display: flex;
    width: max-content;
    min-width: 100%;
    height: 42px;
    box-sizing: border-box;
    border-bottom: 1px solid #cfcfcf;
    overflow: visible;
}


.hhy-calendar-heading-day-spacer {
    flex: 0 0 100px;
    width: 100px;
    min-width: 100px;
    box-sizing: border-box;
}


.hhy-calendar-time-axis {
    position: relative;
    flex: 1 0 1260px;
    min-width: 1260px;
    height: 42px;
}


.hhy-calendar-time-marker {
    position: absolute;
    top: 0;
    height: 42px;
    padding-left: 5px;
    box-sizing: border-box;
    border-left: 1px solid #dedede;
    color: #666;
    font-size: 12px;
    line-height: 40px;
    white-space: nowrap;
}


/*
 * ============================================================
 * WEEK
 * ============================================================
 */

.hhy-calendar-week {
    position: relative;
    width: max-content;
    min-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}


.hhy-calendar-day-row {
    display: flex;
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid #dedede;
}


/*
 * ============================================================
 * DAY LABEL
 * ============================================================
 */

.hhy-calendar-day-label {
    flex: 0 0 100px;
    width: 100px;
    min-width: 100px;
    box-sizing: border-box;
    padding: 8px 7px;
    background: #fafafa;
    border-right: 1px solid #d8d8d8;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}


.hhy-calendar-day-label strong {
    font-size: 14px;
    line-height: 1.25;
}


.hhy-calendar-day-label span {
    margin-top: 3px;
    color: #777;
    font-size: 12px;
}


/*
 * ============================================================
 * DAY TIMELINE
 * ============================================================
 */

.hhy-calendar-day-timeline {
    position: relative;
    flex: 1 0 1260px;
    min-width: 1260px;
    box-sizing: border-box;
    background: #fff;
}


.hhy-calendar-hour-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #eeeeee;
    pointer-events: none;
}


/*
 * ============================================================
 * EVENTS
 * ============================================================
 */

.hhy-calendar-event {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    min-width: 28px;
    box-sizing: border-box;
    padding: 4px 7px;
    border-radius: 5px;
    overflow: hidden;
    text-decoration: none;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    z-index: 5;
}


.hhy-calendar-event:hover {
    text-decoration: none;
    filter: brightness(0.96);
}


.hhy-calendar-event:focus {
    outline: 3px solid rgba(0, 0, 0, 0.25);
    outline-offset: 1px;
}


.hhy-calendar-event-icon {
    flex: 0 0 auto;
    line-height: 1;
}


.hhy-calendar-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}


.hhy-calendar-event-time {
    flex: 0 0 auto;
    margin-left: auto;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0.9;
}


/*
 * ============================================================
 * SERVICE COLOURS
 * ============================================================
 */

.hhy-service-shelter {
    background: #5B7FA3;
}


.hhy-service-food-and-drink {
    background: #C58A3A;
}


.hhy-service-washing-facilities {
    background: #4F9A9A;
}


.hhy-service-health {
    background: #C96B6B;
}


.hhy-service-talk {
    background: #8067A8;
}


.hhy-service-advice {
    background: #8067A8;
}


.hhy-service-recovery {
    background: #5F9568;
}


.hhy-service-emergency-services {
    background: #B94A48;
}


.hhy-service-activities {
    background: #BEA046;
}


/*
 * ============================================================
 * OPEN NOW
 * ============================================================
 */

.hhy-calendar-event-open-now {
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.9),
        0 0 0 4px rgba(50, 120, 70, 0.45);
    z-index: 10;
}


/*
 * ============================================================
 * CURRENT TIME LINE
 * ============================================================
 */

.hhy-calendar-current-time-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #c0392b;
    z-index: 50;
    pointer-events: none;
}


.hhy-calendar-current-time-line span {
    position: absolute;
    top: -22px;
    left: -18px;
    padding: 2px 5px;
    border-radius: 3px;
    background: #c0392b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
}


/*
 * ============================================================
 * SCHEDULE VIEW
 * ============================================================
 */

.hhy-calendar-schedule {
    width: 100%;
    max-width: 1000px;
}


.hhy-schedule-day {
    margin-bottom: 24px;
}


.hhy-schedule-day-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 8px;
    padding: 8px 10px;
    border-bottom: 2px solid #d6d6d6;
    font-size: 20px;
}


.hhy-schedule-day-heading span {
    font-weight: 700;
}


.hhy-schedule-day-heading small {
    color: #777;
    font-size: 14px;
    font-weight: 400;
}


.hhy-schedule-event-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.hhy-schedule-event {
    display: grid;
    grid-template-columns: 105px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 8px 12px;
    box-sizing: border-box;
    border-left: 5px solid #999;
    border-radius: 5px;
    background: #f7f7f7;
    color: #333;
    text-decoration: none;
}


.hhy-schedule-event:hover {
    background: #eeeeee;
    text-decoration: none;
}


.hhy-schedule-event:focus {
    outline: 3px solid rgba(79, 154, 154, 0.25);
    outline-offset: 2px;
}


.hhy-schedule-time {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}


.hhy-schedule-service {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}


.hhy-schedule-icon {
    flex: 0 0 auto;
    font-size: 21px;
    line-height: 1;
}


.hhy-schedule-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}


.hhy-schedule-details strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}


.hhy-schedule-category {
    margin-top: 2px;
    color: #777;
    font-size: 12px;
}


.hhy-schedule-status {
    min-width: 78px;
    text-align: right;
    color: #39734a;
    font-size: 11px;
    font-weight: 700;
}


.hhy-schedule-event-open-now {
    background: #f1f8f2;
    box-shadow:
        inset 4px 0 0 #39734a;
}


.hhy-schedule-empty {
    margin: 0;
    padding: 12px 14px;
    color: #777;
    font-size: 14px;
    background: #fafafa;
    border-radius: 5px;
}


/*
 * Schedule service colours
 *
 * These deliberately use the same colours as the timetable.
 */

.hhy-schedule-event.hhy-service-shelter {
    border-left-color: #5B7FA3;
}


.hhy-schedule-event.hhy-service-food-and-drink {
    border-left-color: #C58A3A;
}


.hhy-schedule-event.hhy-service-washing-facilities {
    border-left-color: #4F9A9A;
}


.hhy-schedule-event.hhy-service-health {
    border-left-color: #C96B6B;
}


.hhy-schedule-event.hhy-service-talk {
    border-left-color: #8067A8;
}


.hhy-schedule-event.hhy-service-advice {
    border-left-color: #8067A8;
}


.hhy-schedule-event.hhy-service-recovery {
    border-left-color: #5F9568;
}


.hhy-schedule-event.hhy-service-emergency-services {
    border-left-color: #B94A48;
}


.hhy-schedule-event.hhy-service-activities {
    border-left-color: #BEA046;
}


/*
 * ============================================================
 * TABLET
 * ============================================================
 */

@media (max-width: 900px) {

    .hhy-calendar-page {
        padding-left: 15px;
        padding-right: 15px;
    }

    .hhy-calendar-service-filters {
        gap: 8px 12px;
    }

}


/*
 * ============================================================
 * MOBILE
 * ============================================================
 */

@media (max-width: 600px) {

    .hhy-calendar-page {
        padding: 20px 10px 40px;
    }


    .hhy-calendar-header h1 {
        font-size: 25px;
    }


    .hhy-calendar-view-switcher {
        width: 100%;
    }


    .hhy-calendar-view-button {
        flex: 0 0 auto;
        padding-left: 12px;
        padding-right: 12px;
    }


    .hhy-calendar-navigation {
        flex-wrap: wrap;
    }


    .hhy-calendar-navigation button {
        flex: 1;
        min-width: 0;
    }


    .hhy-calendar-current-date {
        font-size: 14px;
    }


    .hhy-calendar-service-filters {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }


    .hhy-calendar-service-filters label {
        min-height: 32px;
    }


    .hhy-calendar-admission-filter {
        max-width: none;
    }

    
    /*
     * IMPORTANT:
     *
     * Keep the day label at 100px.
     *
     * The JavaScript uses exactly the same coordinate width.
     * The entire timetable scrolls inside .hhy-calendar-surface.
     */

    .hhy-calendar-day-label,
    .hhy-calendar-heading-day-spacer {
        flex-basis: 100px;
        width: 100px;
        min-width: 100px;
    }


    .hhy-calendar-time-marker {
        font-size: 11px;
    }


    .hhy-calendar-event {
        padding-left: 5px;
        padding-right: 5px;
        font-size: 11px;
    }


    .hhy-calendar-event-icon {
        display: none;
    }


    .hhy-calendar-event-time {
        font-size: 10px;
    }


    /*
     * Schedule view becomes a simple mobile list.
     */

    .hhy-schedule-day-heading {
        font-size: 18px;
    }


    .hhy-schedule-event {
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 8px;
        padding: 9px 10px;
    }


    .hhy-schedule-status {
        display: block;
        grid-column: 2;
        min-width: 0;
        text-align: left;
        margin-top: -5px;
    }


    .hhy-schedule-time {
        align-self: start;
        font-size: 13px;
    }


    .hhy-schedule-icon {
        font-size: 19px;
    }


    .hhy-schedule-details strong {
        font-size: 14px;
    }

}


/*
 * ============================================================
 * PRINT CONTROLS
 * ============================================================
 */

.hhy-calendar-print-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#hhy-calendar-export-schedule {
    min-height: 38px;
    box-sizing: border-box;
    line-height: 1.2;
}

.hhy-calendar-print-day-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hhy-calendar-print-day-controls label {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.hhy-calendar-print-day-select {
    min-height: 38px;
    min-width: 180px;
    padding: 6px 30px 6px 10px;
    box-sizing: border-box;
}

#hhy-calendar-print-selected-day {
    min-width: 180px;
    padding-left: 16px;
    padding-right: 16px;
}


/*
 * ============================================================
 * PRINT
 * ============================================================
 *
 * Provides clean A4 printing for the filtered Schedule view.
 */

@media print {

    @page {
        size: A4 portrait;
        margin: 14mm 12mm 14mm 12mm;
    }


    /*
     * Hide everything inside the calendar page except
     * the Schedule view.
     */

    .hhy-calendar-page > * {
        display: none !important;
    }

    .hhy-calendar-page > .hhy-calendar-schedule-view {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }


    /*
     * Hide the normal WordPress/Astra site chrome.
     */

    header,
    footer,
    nav,
    .site-header,
    .site-footer {
        display: none !important;
    }


    /*
     * Hide the print controls themselves.
     */

    .hhy-calendar-print-controls {
        display: none !important;
    }

    .hhy-schedule-day.hhy-print-hide-day {
    display: none !important;
}

    /*
     * Print heading.
     */

     /*
     * Schedule.
     */

    .hhy-calendar-schedule {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
    }


    /*
     * Individual days.
     */

    .hhy-schedule-day {
        margin-bottom: 16px;
        break-inside: auto;
        page-break-inside: auto;
    }


    /*
     * PRINT PAGINATION
     *
     * Allow a long day's list to continue naturally onto
     * the next page, while keeping individual service rows
     * together.
     */

    .hhy-schedule-event-list {
        break-inside: auto;
        page-break-inside: auto;
    }


    .hhy-schedule-event {
        break-inside: avoid;
        page-break-inside: avoid;
    }


    .hhy-schedule-day-heading {
        margin: 0 0 6px;
        padding: 5px 7px;
        border-bottom: 1.5px solid #555;
        font-size: 16px;
        break-after: avoid;
        page-break-after: avoid;
    }


    .hhy-schedule-day-heading small {
        font-size: 12px;
    }


    /*
     * Events.
     */

    .hhy-schedule-event-list {
        gap: 3px;
    }


    .hhy-schedule-event {
        min-height: 0;
        padding: 5px 7px;
        grid-template-columns: 90px minmax(0, 1fr) auto;
        gap: 8px;

        border-left-width: 4px;
        border-radius: 0;

        background: #fff !important;
        color: #222 !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    .hhy-schedule-event:hover {
        background: #fff !important;
    }


    .hhy-schedule-time {
        font-size: 11px;
    }


    .hhy-schedule-icon {
        font-size: 16px;
    }


    .hhy-schedule-details strong {
        font-size: 12px;
    }


    .hhy-schedule-category {
        margin-top: 1px;
        font-size: 10px;
    }


    .hhy-schedule-status {
        min-width: 60px;
        font-size: 9px;
    }


    /*
     * OPEN NOW.
     */

    .hhy-schedule-event-open-now {
        background: #f4f8f4 !important;
    }


    /*
     * Links.
     */

    .hhy-schedule-event,
    .hhy-schedule-event:visited {
        color: #222 !important;
        text-decoration: none;
    }


    /*
     * Empty days.
     */

    .hhy-schedule-empty {
        padding: 6px 8px;
        font-size: 11px;
    }

}


/*
 * ============================================================
 * CALENDAR CONTROL BUTTON FIX
 * ============================================================
 *
 * Keep the calendar controls compact and prevent the theme's
 * general button styling from making them oversized.
 */


/* View buttons */

.hhy-calendar-view-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}


.hhy-calendar-view-button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 42px !important;
    height: auto !important;
    padding: 8px 16px !important;
    margin: 0 !important;
    border-radius: 5px !important;
    font-size: 15px !important;
    line-height: 1.2 !important;
}


/* Previous / Today / Next */

.hhy-calendar-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}


.hhy-calendar-navigation button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 42px !important;
    height: auto !important;
    padding: 8px 16px !important;
    margin: 0 !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
}


/* Service filters */

.hhy-calendar-service-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
}


.hhy-calendar-service-filters label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 2px 0;
    white-space: nowrap;
}


/* Admission button */

.hhy-admission-toggle {
    width: auto !important;
    min-width: 260px;
    min-height: 42px !important;
    height: auto !important;
    padding: 8px 14px !important;
    margin: 0 !important;
    border-radius: 5px !important;
    line-height: 1.2 !important;
}


/*
 * ============================================================
 * CALENDAR FULL-WIDTH DESKTOP FIX
 * ============================================================
 */

.hhy-calendar-page,
.hhy-calendar-wrapper,
.hhy-calendar-surface {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}


.hhy-calendar-surface {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}


/*
 * The timetable content itself can be wider than the viewport
 * when horizontal scrolling is required.
 */

.hhy-calendar-week,
.hhy-calendar-day-heading {
    width: max-content;
    min-width: 100%;
    max-width: none;
}


/*
 * ============================================================
 * DESKTOP CALENDAR VIEWPORT
 * ============================================================
 *
 * The timetable is intentionally 1380px wide:
 *
 * 100px day labels
 * + 1260px timetable (14 hours x 90px)
 *
 * On desktop we allow the calendar page to use the full
 * browser width rather than Astra's narrower content column.
 *
 * This leaves the timetable coordinates unchanged.
 */

@media (min-width: 901px) {

    .hhy-calendar-page {
        width: calc(100vw - 40px);
        max-width: none;
        margin-left: calc(50% - 50vw + 20px);
        margin-right: calc(50% - 50vw + 20px);
        box-sizing: border-box;
    }


    .hhy-calendar-surface {
        width: 100%;
        max-width: none;
    }

}