/*
 * Booking widget styles — minimal, theme-driven (BOOK-07).
 * Every selector is scoped under .saphir-booking-form so it cannot leak
 * into the rest of the site. No colors, no !important, no imports.
 *
 * The invalid state is signalled with the user-interaction variant of the
 * pseudo-class where supported. The plain form matches a required-but-untouched
 * field on load, which would draw an error outline on a form nobody has touched
 * yet. No colour is authored here — currentColor inherits the theme's text
 * colour.
 *
 * `:user-invalid` is only available from Chrome/Edge 119, Firefox 88 and
 * Safari 16.5. There is no build step and no autoprefixer in this repo, so a
 * fallback cannot be generated: the plain `:invalid` rule below is authored by
 * hand as the floor. It is deliberately safe because every field is
 * `required`-free and prefilled — the server always renders today/tomorrow and
 * 1/1/0 — so an untouched form has no `:invalid` match on load anyway.
 * Browsers that understand `:user-invalid` take the second rule's signal; the
 * floor rule keeps older browsers from showing *no* error affordance at all.
 */
/*
 * Layout is the CozyStay theme's job. The field row, label placement, spacing
 * and control chrome come from the theme's `.cs-reservation-form` rules, so a
 * plugin-owned `display:flex` here would fight its grid. Two narrow exceptions
 * are documented where they appear below: the dropdown reveal floor and the
 * one-line guest pair.
 */
.saphir-booking-form .saphir-booking-form__submit {
    cursor: pointer;
}

/*
 * Fallback for the one-line guest pair. CozyStay halves `.form-field-col-1-2`
 * itself, so on the live theme this is redundant; it exists for a theme that
 * does not ship that rule. `float` (not display/grid) so it cannot fight the
 * theme's inline-block layout. Scoped to `.saphir-booking-form` as always.
 */
.saphir-booking-form .cs-form-field.form-field-col-1-2 {
 float: left;
 width: 50%;
}

.saphir-booking-form .cs-form-field.form-field-col-1-2.cs-children {
 float: right;
}

/*
 * Order-independent: children floats left when it renders first, so hiding
 * adults does not leave a half-width column with an empty slot beside it.
 */
.saphir-booking-form .cs-form-field.form-field-col-1-2.cs-children:first-of-type {
    float: left;
}

.saphir-booking-form::after {
 content: "";
 display: block;
 clear: both;
}

/*
 * Block layout: submit gap parity (1.2.4).
 *
 * The theme spaces every `.style-block` field with `padding-top:
 * var(--field-space)` — 30px on the live site, the visible gap between Check
 * In and Check Out. The submit field is meant to match that gap.
 *
 * The cause is not a theme override. The theme has exactly one submit-specific
 * spacing rule:
 *   `.cs-room-booking .cs-reservation-form.style-block
 *    .cs-form-field.cs-submit { padding-top: 35px }`
 * It is inert here. This widget never renders an ancestor carrying
 * `.cs-room-booking`, so that rule matches nothing on any page that shows the
 * form. Re-declaring `padding-top` alone therefore changes nothing visible.
 *
 * The real cause is the float layout above. `.form-field-col-1-2` (Adults and
 * Children) is floated by this sheet, which takes both fields out of normal
 * flow. `.cs-submit` is not cleared, so it is positioned from the bottom of the
 * last in-flow field and float-avoidance then pushes the button line box down
 * until it clears the two floats. That displacement is paid out of the field's
 * own `padding-top`, collapsing the gap between the guest row and the button.
 *
 * `clear: both` puts the submit's border box below the floats, so its
 * `padding-top` is measured from the guest row's bottom - the same origin every
 * other field measures from. The gap then equals `--field-space`, which is the
 * Check In / Check Out gap by construction.
 *
 * Specificity, verified against the theme stylesheet:
 *   theme, block gap   .cs-reservation-form.style-block
 *                      .cs-form-field:not(:first-child)       = 0-4-0
 *   this rule          .saphir-booking-form.cs-form-wrap
 *                      :not(.is-style-banner)
 *                      .cs-form-field.cs-submit               = 0-5-0
 *
 * The theme sets no `clear` on the submit field, so that half needs no
 * specificity headroom. Only `padding-top` competes, against the theme's 0-4-0
 * block-gap rule, and 0-5-0 wins on its own - no reliance on source order,
 * which matters because the plugin sheet is not guaranteed to load after the
 * theme. The selector stays anchored under `.saphir-booking-form` as the scope
 * analyzer (StylesheetScopeTest) requires.
 *
 * Restoring the token rather than repeating 30px is the point: the button then
 * follows the theme spacing it is meant to match, so it cannot drift again if
 * the theme changes `--field-space` or a page overrides it.
 *
 * Banner layout is excluded because it is one horizontal row of flex items,
 * where a vertical offset would knock the button out of line with the inputs
 * beside it.
 */
.saphir-booking-form.cs-form-wrap:not(.is-style-banner) .cs-form-field.cs-submit {
  clear: both;
  padding-top: var(--field-space, 30px);
}

/*
 * Banner layout: one row.
 *
 * The theme ships its own banner rules, qualified
 * `.cs-reservation-form.style-banner .cs-form-wrap ...`. They reach this widget
 * only because the renderer puts `style-banner` on the wrapper div in banner
 * mode (`$is_banner ? 'style-banner' : 'style-block'`). The token on the <form>
 * below is `is-style-banner` - the plugin's own, a different class on a
 * different element - so it is NOT what activates the theme.
 *
 * History worth keeping: before 1.2.5 the wrapper hardcoded `style-block`, so
 * that family never matched, the theme stacked the fields, and the banner
 * rendered as the standard form. Three earlier revisions of this comment
 * computed specificity against those dead rules and concluded "a tie, won by
 * load order". There was never a tie - there was a wrong class on the wrapper.
 * See .planning/solutions/ui-bugs/documented-dead-selector-was-the-bug-2026-10-28.md.
 *
 * The rules below therefore do not out-rank the theme; they cooperate with it,
 * and the width model is the plugin's contribution on top:
 *
 * Widths (1.2.5). The previous version sized every field with a zero flex basis
 * plus `min-width: 0`. A zero basis makes flexbox ignore each field's content
 * width, so a date field could be handed less room than the date it has to
 * show; the value then spilled out of the box and collided with the field's
 * own text. Shrinking a field below its content is never survivable - the
 * label and the value are siblings inside the same box.
 *
 * The split below is by content, not by arithmetic:
 * - date fields are content-sized and never shrink (a zero flex-shrink with a
 *   `max-content` floor), so DD-MM-YYYY always fits and any slack is free to
 *   grow into;
 * - quantity fields keep `flex: 1 1 auto`, so they take the slack the date
 *   fields leave behind. The flexbox line-breaking algorithm may only consume
 *   free space, so it cannot push a later item below its floor and steal room
 *   from an earlier one - which is what makes "Check In ends up the narrow
 *   field" a shape this rule cannot produce.
 *
 * Hero positioning. These rules are keyed on `.is-style-banner.cs-form-wrap`
 * because the renderer always emits both classes (see
 * class-booking-widget.php, the `<form class="cs-form-wrap ...">` line). That
 * merge is what lets one block own the row AND keeps the hero stacking
 * context - `position`/`z-index` must stay here, or the form painted over a
 * hero image loses its stacking context and can sink behind the overlay.
 */
.saphir-booking-form.is-style-banner.cs-form-wrap {
 position: relative;
 z-index: 1;
 flex-wrap: nowrap;
 align-items: flex-end;
}

.saphir-booking-form.is-style-banner.cs-form-wrap .cs-form-field {
 display: block;
 width: auto;
 flex: 1 1 auto;
 min-width: 0;
 margin-top: 0;
 padding: 0 calc(var(--field-space, 30px) / 2);
}

.saphir-booking-form.is-style-banner.cs-form-wrap .cs-form-field.saphir-field {
 flex: 1 0 auto;
 min-width: max-content;
}

.saphir-booking-form.is-style-banner.cs-form-wrap .cs-form-field.cs-submit {
 flex: 0 0 auto;
 width: auto;
}

@media ( max-width: 560px ) {
 .saphir-booking-form.is-style-banner.cs-form-wrap {
 flex-direction: column;
 align-items: stretch;
 }

 .saphir-booking-form.is-style-banner.cs-form-wrap .cs-form-field {
 flex: 1 1 100%;
 width: 100%;
 }

 /*
 * A full-width field has all the room it needs, so the date floor is
 * redundant here - and a `max-content` floor would overflow a very narrow
 * phone instead of letting the value wrap inside the field.
 */
 .saphir-booking-form.is-style-banner.cs-form-wrap .cs-form-field.saphir-field {
 min-width: 0;
 }
}
/*
 * Field background token (`style_field` -> Field Background Color).
 *
 * The theme paints the field itself and ships no --field-bg, so the plugin must
 * not repaint it when the token is unset: `transparent` is a colour and would
 * erase the theme's own background. `inherit` keeps the computed value the
 * theme produced, so the default render is unchanged and only an operator who
 * picks a colour moves the dial.
 */
.saphir-booking-form .cs-form-field .field-input-wrap {
    background-color: var(--field-bg, inherit);
}

 /*
 * Quantity dropdown reveal. The `.csf-dropdown` panel is the editing surface;
 * the read-only summary in the field stays visible, so the form is still
 * submittable. `is-open` is the class the CozyStay theme itself toggles; `cs-open`
 * is the plugin fallback. Both are set by booking-widget.js, scoped as below.
 */
.saphir-booking-form .csf-dropdown {
    display: none;
}

.saphir-booking-form .cs-has-dropdown .csf-dropdown.is-open,
.saphir-booking-form .cs-has-dropdown.cs-open .csf-dropdown {
    display: block;
}

/*
 * The themed presentation (field chrome, spacing, the horizontal field row,
 * the dropdown panels, the submit button) is owned by the CozyStay theme via
 * the `cs-*` classes the renderer now emits alongside the `saphir-*` hooks.
 * This sheet therefore authors NO layout: it keeps only the two things the
 * theme must not own — the accessible invalid state and the operator colour
 * tokens. See docs/dom-contract.md (stable tier) for the `saphir-*` contract
 * that the theme classes are layered on top of.
 */

/*
 * Fallback floor for browsers without :user-invalid. The outline is paired with
 * a solid border colour so the error is not signalled by an outline alone —
 * an outline-only cue is easy to miss and can evade contrast checkers, which
 * do not evaluate `outline` reliably.
 */
.saphir-booking-form input:invalid {
    border-color: currentColor;
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/*
 * Preferred signal where supported: only flag a field the guest has actually
 * interacted with, so a freshly-loaded form never shows an error state.
 */
@supports selector( :user-invalid ) {
    .saphir-booking-form input:invalid {
        border-color: inherit;
        outline: none;
    }

    .saphir-booking-form input:user-invalid {
        border-color: currentColor;
        outline: 2px solid currentColor;
        outline-offset: 2px;
    }
}

/*
 * The 1.2.3-era duplicate banner block was removed in 1.2.5. It re-declared
 * the banner shell further down the sheet, keyed on `.is-style-banner` alone,
 * and put a hard 10rem floor on both `.saphir-field` and `.saphir-quantity` -
 * the floor that squeezed the date fields until their values collided with the
 * label. It had also drifted from the live rule above (`gap` instead of field
 * padding, a stacked column instead of wrapping). Because the later block won
 * on `min-width`, a fix applied to the block above could be silently undone by
 * it. One banner block, one owner - the one above.
 */

/*
 * Token colour consumption. Custom properties are set by Elementor's
 * per-post stylesheet via the STYLE tab COLOR controls; here we read them
 * with var() fallbacks so a site that sets nothing keeps the theme-driven
 * defaults (currentColor / transparent). No hex literals, no !important.
 */
.saphir-booking-form input,
.saphir-booking-form button {
    border-color: var(--saphir-field-border, currentColor);
}

.saphir-booking-form .saphir-booking-form__submit {
    background-color: var(--saphir-cta-bg, transparent);
    color: var(--saphir-cta-text, currentColor);
}
