/*
 * tvt-calendar 1.0.0: the styles of public/js/tvt-calendar.js. Plain CSS, loaded by URL (not processed by Vite).
 * Every colour and size is a custom property on .tvt-cal: a theme, a page or one calendar overrides them with a
 * more specific selector, e.g.  .my-theme .tvt-cal { --tvt-cal-brand: #0369a1; }
 * The rules are not in a cascade layer, so Tailwind's preflight (which is) never overrides them.
 */

/* tokens */
.tvt-cal {
    --tvt-cal-brand: var(--color-tvt-brand);  /* resources/css/tvt-theme.css */
    --tvt-cal-on-brand: #fff;
    --tvt-cal-range-bg: var(--tvt-cal-brand);
    --tvt-cal-range-text: var(--tvt-cal-on-brand);
    --tvt-cal-preview-bg: color-mix(in srgb, var(--tvt-cal-brand) 14%, var(--tvt-cal-bg));  /* opaque: see the band */
    --tvt-cal-text: #1e293b;          /* slate-800 */
    --tvt-cal-title: #0f172a;         /* slate-900 */
    --tvt-cal-muted: #64748b;         /* slate-500: weekdays */
    --tvt-cal-disabled: #cbd5e1;      /* slate-300 */
    --tvt-cal-hover-bg: #f1f5f9;      /* slate-100 */
    --tvt-cal-nav: #475569;           /* slate-600 */
    --tvt-cal-line: #cbd5e1;          /* slate-300: the selects */
    --tvt-cal-field-bg: #fff;
    --tvt-cal-focus: #1e293b;         /* the keyboard ring, visible on the brand colour too */
    --tvt-cal-today-bg: #f1f5f9;      /* slate-100 */
    --tvt-cal-weekdays-bg: #f1f5f9;   /* slate-100: the weekdays row, between the header and the days */
    --tvt-cal-price: var(--tvt-cal-brand);
    --tvt-cal-price-hover-bg: var(--tvt-cal-preview-bg);  /* the light brand colour of the range preview */
    --tvt-cal-link: #0284c7;          /* sky-600: a day that is a link ("check price") */
    --tvt-cal-link-hover: #075985;    /* sky-800 */
    --tvt-cal-link-hover-bg: #f0f9ff; /* sky-50 */
    --tvt-cal-marker: #f59e0b;        /* amber-500: a marked day (special offer), seen on the brand colour too */
    --tvt-cal-marker-size: clamp(0.875rem, 24cqi, 1.5rem);  /* cqi: of the day (14px up to 24px) */
    --tvt-cal-bg: #fff;               /* the frame */
    --tvt-cal-frame: #e2e8f0;         /* slate-200 */
    --tvt-cal-frame-radius: 0.75rem;
    --tvt-cal-padding: 1rem;
    --tvt-cal-radius: 0.25rem;
    --tvt-cal-day-height: 2.5rem;     /* auto + --tvt-cal-day-aspect: 1 for square days (full width) */
    --tvt-cal-day-aspect: auto;
    /* wide columns (full width): a day stays at most 1.2 times as wide as it is tall, in the middle of its column;
       with --tvt-cal-day-height: auto there is no cap unless one is set here */
    --tvt-cal-day-max-width: calc(var(--tvt-cal-day-height) * 1.2);
    /* the day's text grows with the day's width (a container): the min in a day up to ~60px wide (the price label:
       ~78px), the max from 100px (square price days at full width) */
    --tvt-cal-day-font-size: 0.875rem;
    --tvt-cal-day-font-size-max: 1.125rem;
    --tvt-cal-label-font-size: 0.6875rem;   /* the price, "check price" */
    --tvt-cal-label-font-size-max: 0.8125rem;
    --tvt-cal-day-gap: 2px;          /* between the weeks, and between the days except in a range (one band) */
    --tvt-cal-month-width: 20.5rem;   /* a month, unless fullWidth */
    --tvt-cal-header-height: 2.5rem;
    --tvt-cal-months-gap: 2rem;
    --tvt-cal-duration: 150ms;
}

/* bigger touch targets on phones */
@media (max-width: 767.98px) {
    .tvt-cal {
        --tvt-cal-day-height: 2.75rem;
    }
}

/* dark mode: .dark on <html>, as on the site; .tvt-cal--light (theme: 'light') keeps a calendar light */
.dark .tvt-cal:not(.tvt-cal--light) {
    --tvt-cal-preview-bg: color-mix(in srgb, var(--tvt-cal-brand) 30%, var(--tvt-cal-bg));
    --tvt-cal-text: #f1f5f9;          /* slate-100 */
    --tvt-cal-title: #fff;
    --tvt-cal-muted: #94a3b8;         /* slate-400 */
    --tvt-cal-disabled: #475569;      /* slate-600 */
    --tvt-cal-hover-bg: #334155;      /* slate-700 */
    --tvt-cal-nav: #cbd5e1;           /* slate-300 */
    --tvt-cal-line: #475569;          /* slate-600 */
    --tvt-cal-field-bg: #1e293b;      /* slate-800 */
    --tvt-cal-focus: #f1f5f9;
    --tvt-cal-today-bg: #334155;      /* slate-700 */
    --tvt-cal-weekdays-bg: #334155;   /* slate-700 */
    --tvt-cal-price: color-mix(in srgb, var(--tvt-cal-brand) 45%, #fff);  /* the brand colour is too dark on slate-800 */
    --tvt-cal-link: #38bdf8;          /* sky-400 */
    --tvt-cal-link-hover: #7dd3fc;    /* sky-300 */
    --tvt-cal-link-hover-bg: color-mix(in srgb, #0ea5e9 15%, transparent);
    --tvt-cal-bg: #1e293b;            /* slate-800 */
    --tvt-cal-frame: #334155;         /* slate-700 */
}
/* /tokens */

/*
 * calendar: framed by default; .tvt-cal--borderless (border: false) when the host is the frame (a modal).
 * Its own width by default: --tvt-cal-month-width per month, narrower when its container is (max-width: 100%), so it
 * also sizes a container that takes the width of its content (a dropdown). .tvt-cal--full-width (fullWidth: true)
 * fills the container instead: the days get wider, their height stays --tvt-cal-day-height.
 */
.tvt-cal {
    position: relative;
    width: max-content;
    max-width: 100%;
    padding: var(--tvt-cal-padding);
    font-family: inherit;
    color: var(--tvt-cal-text);
    background-color: var(--tvt-cal-bg);
    border: 1px solid var(--tvt-cal-frame);
    border-radius: var(--tvt-cal-frame-radius);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.tvt-cal--borderless {
    --tvt-cal-padding: 0;
    background-color: transparent;
    border: 0;
    border-radius: 0;
}
.tvt-cal,
.tvt-cal *,
.tvt-cal *::before,
.tvt-cal *::after {
    box-sizing: border-box;
}

.tvt-cal__months {
    display: grid;
    grid-template-columns: minmax(0, var(--tvt-cal-month-width));
    gap: var(--tvt-cal-months-gap);
}
.tvt-cal--months-2 .tvt-cal__months {
    grid-template-columns: repeat(2, minmax(0, var(--tvt-cal-month-width)));
}

.tvt-cal--full-width {
    width: auto;
}
.tvt-cal--full-width .tvt-cal__months {
    grid-template-columns: minmax(0, 1fr);
}
.tvt-cal--full-width.tvt-cal--months-2 .tvt-cal__months {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tvt-cal__month {
    min-width: 0;
}

/* read, not seen: the announcement of the month, the full date of a day */
.tvt-cal__status,
.tvt-cal__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
/* /calendar */

/* header: the month title (or the month / year selects) between the arrows */
.tvt-cal__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: var(--tvt-cal-header-height);
    margin: 0 0 0.5rem;
    padding: 0 calc(var(--tvt-cal-header-height) + 0.25rem);
}

.tvt-cal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5rem;
    color: var(--tvt-cal-title);
    white-space: nowrap;
}

.tvt-cal__nav {
    position: absolute;
    top: var(--tvt-cal-padding);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tvt-cal-header-height);
    height: var(--tvt-cal-header-height);
    margin: 0;
    padding: 0;
    color: var(--tvt-cal-nav);
    background-color: transparent;
    border: 0;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color var(--tvt-cal-duration), color var(--tvt-cal-duration);
}
.tvt-cal__nav--prev {
    left: var(--tvt-cal-padding);
}
.tvt-cal__nav--next {
    right: var(--tvt-cal-padding);
}
.tvt-cal__nav:hover {
    color: var(--tvt-cal-brand);
    background-color: var(--tvt-cal-hover-bg);
}
.tvt-cal__nav[aria-disabled="true"] {
    color: var(--tvt-cal-disabled);
    background-color: transparent;
    cursor: default;
}
.tvt-cal__nav:focus {
    outline: none;
}
.tvt-cal__nav:focus-visible {
    outline: 2px solid var(--tvt-cal-focus);
    outline-offset: 1px;
}
.tvt-cal__nav svg {
    display: block;
}

.tvt-cal__select {
    -webkit-appearance: none;
    appearance: none;
    height: 2rem;
    margin: 0;
    padding: 0 1.75rem 0 0.625rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    color: var(--tvt-cal-title);
    background-color: var(--tvt-cal-field-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 7.5 10 12.5l5-5' fill='none' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.875rem;
    border: 1px solid var(--tvt-cal-line);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: border-color var(--tvt-cal-duration);
}
.tvt-cal__select:hover {
    border-color: var(--tvt-cal-muted);
}
.tvt-cal__select:focus {
    outline: none;
}
.tvt-cal__select:focus-visible {
    outline: 2px solid var(--tvt-cal-focus);
    outline-offset: 1px;
}
/* /header */

/* grid: the weekdays, then six weeks of seven cells; the same gap both ways, none between the days of a range (one band) */
.tvt-cal__week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    column-gap: var(--tvt-cal-day-gap);
}
.tvt-cal--range .tvt-cal__week {
    column-gap: 0;
}
.tvt-cal__week + .tvt-cal__week {
    margin-top: var(--tvt-cal-day-gap);
}
.tvt-cal__weekdays {
    margin-bottom: 0.5rem;
    background-color: var(--tvt-cal-weekdays-bg);
    border-radius: var(--tvt-cal-radius);
}

.tvt-cal__weekday {
    display: block;
    padding: 0.375rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1rem;
    text-align: center;
    color: var(--tvt-cal-muted);
}

/* a day capped by --tvt-cal-day-max-width sits in the middle of its column */
.tvt-cal__cell {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
}
/* /grid */

/* day: the states, in this order (a later one wins): hover, price, today, link, disabled, preview, range, selected */
.tvt-cal__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: var(--tvt-cal-day-max-width);
    height: var(--tvt-cal-day-height);
    aspect-ratio: var(--tvt-cal-day-aspect);
    margin: 0;
    padding: 0;
    font: inherit;
    font-size: var(--tvt-cal-day-font-size);
    font-weight: 600;
    line-height: 1;
    color: var(--tvt-cal-text);
    text-decoration: none;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--tvt-cal-radius);
    cursor: pointer;
    transition: background-color var(--tvt-cal-duration), border-color var(--tvt-cal-duration), color var(--tvt-cal-duration);
    /* its text is sized on its width (cqi) */
    container-type: inline-size;
}
.tvt-cal__day:hover {
    background-color: var(--tvt-cal-hover-bg);
}
.tvt-cal__day:focus {
    outline: none;
}
.tvt-cal__day:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--tvt-cal-focus);
    outline-offset: 1px;
}

/* a day with a price (.is-price, set by renderDay): brand border, the light brand colour on hover */
.tvt-cal__day.is-price {
    border-color: var(--tvt-cal-brand);
}
.tvt-cal__day.is-price:not(.is-disabled):not(.is-selected):not(.is-in-range):hover {
    background-color: var(--tvt-cal-price-hover-bg);
}

/* today: brand border on grey; filled with the brand colour on hover (with a price too: it comes after) */
.tvt-cal__day.is-today {
    background-color: var(--tvt-cal-today-bg);
    border-color: var(--tvt-cal-brand);
}
.tvt-cal__day.is-today:not(.is-disabled):not(.is-link):hover {
    color: var(--tvt-cal-on-brand);
    background-color: var(--tvt-cal-brand);
}

/* a day that is a link (dayHref), e.g. "check price": sky, darker with a light background on hover */
.tvt-cal__day.is-link {
    color: var(--tvt-cal-link);
    background-color: transparent;
    border-color: var(--tvt-cal-link);
}
.tvt-cal__day.is-link:hover {
    color: var(--tvt-cal-link-hover);
    background-color: var(--tvt-cal-link-hover-bg);
    border-color: var(--tvt-cal-link-hover);
}

/* cannot be picked: no border, faded */
.tvt-cal__day.is-disabled {
    color: var(--tvt-cal-disabled);
    background-color: transparent;
    border-color: transparent;
    cursor: default;
}

/* range preview: from the picked start to the day under the pointer */
.tvt-cal__day.is-preview {
    background-color: var(--tvt-cal-preview-bg);
    border-color: transparent;
}
.tvt-cal__day.is-preview-end {
    background-color: var(--tvt-cal-preview-bg);
    border-color: var(--tvt-cal-brand);
}

/* range: the days between the ends */
.tvt-cal__day.is-in-range {
    color: var(--tvt-cal-range-text);
    background-color: var(--tvt-cal-range-bg);
    border-color: var(--tvt-cal-range-bg);
}

/* selected: the single date, or the ends of a range */
.tvt-cal__day.is-selected {
    color: var(--tvt-cal-on-brand);
    background-color: var(--tvt-cal-brand);
    border-color: var(--tvt-cal-brand);
}

/*
 * the band of a range (or of its preview) lies on the cells, which are as wide as their column: the days keep their
 * rounded corners and their max width, and the band joins them. Whole under a day inside the band, half under its
 * first and last day of a week (.is-band-head: the right half, .is-band-tail: the left half), none under a day alone
 * in its week. The colours are opaque, so a day on its band shows no overlap.
 */
.tvt-cal__cell {
    --tvt-cal-band: var(--tvt-cal-range-bg);
}
.tvt-cal__cell.is-band-preview {
    --tvt-cal-band: var(--tvt-cal-preview-bg);
}
.tvt-cal__cell.is-band {
    background-color: var(--tvt-cal-band);
}
.tvt-cal__cell.is-band-head {
    background-image: linear-gradient(to right, transparent 50%, var(--tvt-cal-band) 50%);
}
.tvt-cal__cell.is-band-tail {
    background-image: linear-gradient(to left, transparent 50%, var(--tvt-cal-band) 50%);
}

.tvt-cal__day-num {
    display: block;
    font-size: var(--tvt-cal-day-font-size);
    font-size: clamp(var(--tvt-cal-day-font-size), 0.5rem + 10cqi, var(--tvt-cal-day-font-size-max));
}

/* the text under the number (renderDay): a price in the brand colour, or the link text ("check price") */
.tvt-cal__day-label {
    display: block;
    max-width: 100%;
    margin-top: 0.3125rem;
    margin-top: clamp(0.3125rem, 5cqi, 0.5rem);
    padding: 0 0.125rem;
    font-size: var(--tvt-cal-label-font-size);
    font-size: clamp(var(--tvt-cal-label-font-size), 0.25rem + 9cqi, var(--tvt-cal-label-font-size-max));
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
}
.tvt-cal__day.is-price .tvt-cal__day-label {
    color: var(--tvt-cal-price);
}
.tvt-cal__day.is-today:not(.is-disabled):hover .tvt-cal__day-label,
.tvt-cal__day.is-selected .tvt-cal__day-label,
.tvt-cal__day.is-in-range .tvt-cal__day-label {
    color: inherit;
}

/*
 * a marked day (dayMarker), e.g. a special offer: a triangle over its top right corner, border included
 * (.tvt-cal--marker-left: the left one), rounded like the day; it grows with the day (cqi) and stays on in every state.
 * Colour: --tvt-cal-marker (markerColor sets it on one calendar)
 */
.tvt-cal__day.is-marked {
    position: relative;
}
.tvt-cal__day.is-marked::after {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: var(--tvt-cal-marker-size);
    height: var(--tvt-cal-marker-size);
    background-color: var(--tvt-cal-marker);
    border-top-right-radius: var(--tvt-cal-radius);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    pointer-events: none;
}
.tvt-cal--marker-left .tvt-cal__day.is-marked::after {
    right: auto;
    left: -1px;
    border-top-right-radius: 0;
    border-top-left-radius: var(--tvt-cal-radius);
    clip-path: polygon(0 0, 100% 0, 0 100%);
}
/* /day */