/*
 * Flatpickr calendar skin — virgo-karma template.
 *
 * This is a COLOR / TYPOGRAPHY OVERRIDE LAYER, not a standalone theme. It loads
 * AFTER the shared airbnb layout theme (which supplies all positioning, sizing,
 * arrows). Every hard-coded color in that base is re-pointed here at the
 * template's design tokens, so the calendar inherits the Kelp Teal "Living
 * Archive" world and follows the visitor across all five color palettes, dark
 * mode, and the dynamic font-size scale.
 *
 * The contact-form pickers run in flatpickr static mode (static:true), so the
 * calendar renders inside a .flatpickr-wrapper around the field instead of
 * appended to <body>. The wrapper rule below makes it stretch to the field's
 * full width inside .contact-form-input-wrap; flatpickr's own
 * .flatpickr-calendar.static rule positions the calendar below the field.
 *
 * Token-first by rule: bare hex/rgb literals would lock the skin to one palette
 * and break under slate_indigo / clay_terracotta / iron_graphite / olive_archive
 * and dark mode. The only literals here are shadows (tinted off the ink token)
 * and a single translucent scrim used to mark the range midpoint.
 *
 * The airbnb base also ships element-prefixed selectors (span.flatpickr-day,
 * span.flatpickr-weekday) whose element+class specificity plain-class rules
 * cannot beat at any load order. The "Airbnb base parity" section re-declares
 * exactly those properties at matching specificity so the token values win.
 *
 * The calendar always renders LTR (flatpickr core direction), independent of
 * the page's RTL language direction, so month/day grids never mirror.
 */

/* ------------------------------------------------------------------ Static-mode wrapper
 * contact-form date pickers use flatpickr static mode, which wraps the field
 * in .flatpickr-wrapper (core gives it position:relative; display:inline-block).
 * Inside .contact-form-input-wrap (a block container) the wrapper must stretch
 * to the field's full width so the visible altInput keeps the same width as a
 * plain text field. The calendar itself is positioned by flatpickr's own
 * .flatpickr-calendar.static rule relative to this wrapper.
 */
.contact-form-input-wrap > .flatpickr-wrapper {
    display: block;
    width: 100%;
}

/* ------------------------------------------------------------------ Calendar shell
 * The raised card. The airbnb base draws a 1px ring via four directional box-
 * shadows + a soft drop shadow. We rebuild the ring from the token border color
 * so it reads on every palette, and keep the soft drop shadow (tinted, never
 * pure black) for the raised-card depth the airbnb language promises.
 */
.flatpickr-calendar {
    background: var(--card-bg);
    color: var(--text-color);
    /* offset ring (token border) + soft drop shadow (ink-tinted, not #000) */
    box-shadow:
        1px 0 0 var(--border-color),
        -1px 0 0 var(--border-color),
        0 1px 0 var(--border-color),
        0 -1px 0 var(--border-color),
        var(--shadow-lg);
    border-radius: var(--radius-lg);
}

/* The little pointer arrow that connects the calendar to its input. The airbnb
 * base builds it from two stacked transparent-border triangles; the inner color
 * must match the new card background, the outer the new ring color. */
.flatpickr-calendar.arrowTop:before {
    border-bottom-color: var(--border-color);
}
.flatpickr-calendar.arrowTop:after {
    border-bottom-color: var(--card-bg);
}
.flatpickr-calendar.arrowBottom:before {
    border-top-color: var(--border-color);
}
.flatpickr-calendar.arrowBottom:after {
    border-top-color: var(--card-bg);
}

/* ------------------------------------------------------------------ Month header
 * Month/year title row + prev/next navigation arrows.
 */
.flatpickr-months .flatpickr-month,
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--text-ink);
    fill: var(--text-muted); /* svg chevron fill */
}

/* The up-arrow chevrons are interactive — give them a clear hover affordance
 * tied to the accent (the secondary brand voice), not the primary, so they
 * don't compete with selected-day emphasis for attention. */
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: var(--accent-color);
    fill: var(--accent-color);
}

/* Month/year numerals — the strongest type in the header, treated as ink. */
.flatpickr-current-month {
    color: var(--text-ink);
    font-weight: 600;
}
.flatpickr-current-month input.cur-year {
    color: var(--text-ink);
}
.flatpickr-current-month input.cur-year:focus {
    /* Focus ring matches the form-field focus language elsewhere in the template */
    box-shadow: 0 0 0 1px var(--accent-color);
}

/* The year dropdown <select> rendered inside the month title. */
.flatpickr-monthDropdown-months,
.flatpickr-monthDropdown-month:focus,
.flatpickr-monthDropdown-month:hover {
    color: var(--text-ink);
    background-color: var(--card-bg);
}
.flatpickr-monthDropdown-option {
    color: var(--text-color);
    background-color: var(--card-bg);
}
.flatpickr-monthDropdown-option:focus,
.flatpickr-monthDropdown-option:hover {
    background-color: var(--primary-tint);
    color: var(--text-ink);
}

/* ------------------------------------------------------------------ Weekday labels
 * Su Mo Tu We Th Fr Sa — muted, small. These orient but must stay quiet so the
 * day grid reads first. The selector is span-prefixed because the airbnb base
 * writes the weekday as span.flatpickr-weekday with a near-black rgba color
 * and font-weight bolder — a plain class rule cannot override either, and the
 * base color sinks into invisibility on the dark palettes.
 */
span.flatpickr-weekday {
    color: var(--text-muted);
    font-weight: 600;
}

/* ------------------------------------------------------------------ Day cells
 * The heart of the skin. Four states carry meaning:
 *   default   — selectable day, body-text color, transparent ground
 *   hover     — the visitor is considering this day; a soft tint lift
 *   today     — a single dot/outline so "now" is findable without shouting
 *   selected  — the committed day; solid primary fill, on-primary foreground
 *   inRange   — the muted corridor between two selected days in a range pick
 */
.flatpickr-day {
    color: var(--text-color);
}

/* Hover — the airbnb language uses a soft circle, not a border. Tint from the
 * primary family so hover and selected read as one gesture (lighter → heavier). */
.flatpickr-day:hover,
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover,
.flatpickr-day:focus,
.flatpickr-day.prevMonthDay:focus,
.flatpickr-day.nextMonthDay:focus {
    background: var(--primary-tint);
    border-color: var(--primary-tint);
    color: var(--text-ink);
}

/* Days belonging to the adjacent month — dimmed, still hoverable. The airbnb
 * base fades them; we keep that fade by tinting toward muted. */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted);
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: var(--text-muted);
    background: transparent;
    border-color: transparent;
}

/* Today — a quiet outline in the accent voice, not a fill (the fill belongs to
 * "selected"). Styled in the "Airbnb base parity" section below: the base
 * guards its today underline with span-prefixed selectors that outrank any
 * plain-class rule, so the accent ring is declared at matching specificity. */

/* Selected — the committed day. Solid primary fill, on-primary foreground, and
 * a slightly deeper primary on hover so the selection still feels alive. */
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange:focus,
.flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.selected.nextMonthDay {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-primary);
}
.flatpickr-day.selected.startRange + .flatpickr-day.endRange:not(:nth-child(7n+1)) {
    /* airbnb's overlap-seam rule — keep the token fill, drop the inherited ring */
    box-shadow: -10px 0 0 var(--primary-color);
}

/* Range corridor — the muted midpoint between a startRange and endRange. Reads
 * as "these days are in play" without claiming the weight of a selected day. */
.flatpickr-day.inRange {
    background: var(--primary-tint);
    border-color: var(--primary-tint);
    color: var(--text-ink);
    /* a translucent ink scrim deepens the corridor just enough to separate it
     * from the plain hover lift, without going solid. */
    box-shadow: -5px 0 0 var(--primary-tint), 5px 0 0 var(--primary-tint);
}
.flatpickr-day.week.selected {
    /* week-select variant: extend the selected fill across the row seam */
    box-shadow: -5px 0 0 var(--primary-color), 5px 0 0 var(--primary-color);
}

/* ------------------------------------------------------------------ Airbnb base parity
 * The airbnb layout base draws its day grid and today mark with element-
 * prefixed selectors (span.flatpickr-day, span.flatpickr-day.today:not(...)).
 * Element+class specificity outranks every plain-class rule above regardless
 * of load order, so the base's hard-coded #e9e9e9 grid, #f64747 today
 * underline and #4f99ff range edges were punching through the tokens —
 * loudest on the dark palettes, where a light gray grid sits on a dark card.
 * Each rule below mirrors the base selector exactly; this file loads after
 * the base, so parity wins by source order.
 */
span.flatpickr-day,
span.flatpickr-day.prevMonthDay,
span.flatpickr-day.nextMonthDay {
    /* The spreadsheet grid fades out entirely in this world: days float on the
     * card and hover/selection are carried by the tint fills above. The
     * !important is unavoidable — the base locks its square corners with one,
     * and only an !important of our own can restore the skin's radius. */
    border-color: transparent;
    border-radius: var(--radius-md) !important;
}

/* "Now" — the accent ring on every side, replacing the base's red underline
 * (and its full red ring on hover/focus, which also overrode keyboard focus). */
span.flatpickr-day.today:not(.selected),
span.flatpickr-day.prevMonthDay.today:not(.selected),
span.flatpickr-day.nextMonthDay.today:not(.selected) {
    border-color: var(--accent-color);
}
span.flatpickr-day.today:not(.selected):hover,
span.flatpickr-day.prevMonthDay.today:not(.selected):hover,
span.flatpickr-day.nextMonthDay.today:not(.selected):hover,
span.flatpickr-day.today:not(.selected):focus,
span.flatpickr-day.prevMonthDay.today:not(.selected):focus,
span.flatpickr-day.nextMonthDay.today:not(.selected):focus {
    border-color: var(--accent-color);
    background: var(--primary-tint);
    color: var(--accent-color);
}

/* Range edges — the base hard-codes #4f99ff. No frontend picker runs range
 * mode today; this keeps the geometry on-palette if one ever does. */
span.flatpickr-day.startRange,
span.flatpickr-day.prevMonthDay.startRange,
span.flatpickr-day.nextMonthDay.startRange,
span.flatpickr-day.endRange,
span.flatpickr-day.prevMonthDay.endRange,
span.flatpickr-day.nextMonthDay.endRange {
    border-color: var(--primary-color);
}

/* ------------------------------------------------------------------ Time row
 * The hour / minute / am-pm inputs shown when enableTime is on.
 */
.flatpickr-calendar.hasTime .flatpickr-time {
    border-top-color: var(--border-color);
    height: 44px; /* slightly more breathing room than the airbnb 40px */
}
.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm,
.flatpickr-time .numInputWrapper span {
    color: var(--text-color);
}
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:focus,
.flatpickr-time input:hover,
.flatpickr-time .flatpickr-am-pm:hover {
    background: var(--surface-hover);
    color: var(--text-ink);
}
.flatpickr-time .flatInputWrapper,
.flatpickr-time .flatpickr-am-pm {
    /* the up/down spinners fade the edges of the number — keep them muted */
    color: var(--text-muted);
}
.flatpickr-time .numInputWrapper span:hover {
    color: var(--accent-color);
}
.flatpickr-time .numInputWrapper span.arrowUp:after {
    border-bottom-color: var(--text-muted);
}
.flatpickr-time .numInputWrapper span.arrowDown:after {
    border-top-color: var(--text-muted);
}

/* ------------------------------------------------------------------ Time separator + am/pm
 * The blinking colon between hh and mm reads as ink so it doesn't disappear on
 * the raised card.
 */
.flatpickr-time .flatpickr-time-separator,
.flatpickr-time input::placeholder {
    color: var(--text-muted);
}

/* ------------------------------------------------------------------ Mobile (inline) calendar
 * When flatpickr opens inline on small screens it adds .inline; the card should
 * sit on the page ground, not float. Shadow is enough depth — no ring needed.
 */
.flatpickr-calendar.inline {
    box-shadow: var(--shadow);
}
