/**
 * The OTA form field: the pill every form on the site wears.
 *
 * Teamwork 49444942. Jade's two bullets on 27 Aug 2026 were "Add radius (same
 * as other parts of website)" and "Reduce height of boxes, maybe to 75% of
 * current height", asked about My Details. Bryce's call on the radius (3 Sep
 * 2026) was the pill the search field uses, since that is what most forms on
 * the site already look like.
 *
 * WHY THIS FILE EXISTS. These rules shipped inside ota-dashboard.css, scoped to
 * `body.theme-agend--account-is-dashboard`. That class is the theme's, set on
 * WooCommerce account pages and on pages carrying the `agendtheme_is_dashboard_page`
 * meta (Theme.php, set_body_classes), and the checkout is neither, so on 11 Sep
 * 2026 Jade reported the field format missing from /checkout. It was never
 * WooCommerce blocking anything: the theme embellishes checkout fields exactly
 * the way it embellishes dashboard ones, through `.woocommerce-input-wrapper
 * input` in embellish-form-inputs.js, and the wrapper that comes out is the
 * same `.agendtheme-form-input`. The rules simply had no way to match there.
 *
 * So the block moved out of the dashboard stylesheet into this one, which
 * Form_Fields loaded on the dashboard AND the checkout, every selector leading
 * with the dashboard body class and the checkout's `body.woocommerce-checkout`
 * beside it.
 *
 * SITE-WIDE SINCE 22 OCT 2026. OTA asked why the fields were not round
 * everywhere: Contact us, Become a member and the other page forms still wore
 * the theme's square 65px field. Form_Fields now loads this file on every
 * front-end page and puts its own `ota-form-fields` class on the body, and
 * every selector leads with that class instead. One class, as before, so every
 * specificity count worked out below still holds: `body` alone would be a
 * class short, and several `!important` rules here win only by that margin.
 * The whole treatment goes with the radius, height included: the inset, the
 * select rebuild and the placeholder rules below all exist because of the
 * pill or the shorter box, so a round field without them would bring back the
 * overlaps they fix.
 *
 * THE HEIGHT IS ONE VARIABLE. Every measurement of the theme's floating-label
 * field is derived from `--at-line-height-base`: the input line is 1.75 of it,
 * the gap the label floats into is half of that, the label's raised position,
 * the multi-select paddings and the text area's cap are all multiples of the
 * same product (see `.agendtheme-form-input` in the compiled skin-2020
 * bundle). The 1.75 is a Sass constant baked into every rule, so it cannot be
 * changed once; the base it multiplies can. Scoping the base to 75% of the
 * theme's 1.5rem inside each field scales the whole assembly together: a 65px
 * box becomes about 49px, the label still lands where the input text expects
 * it, and the dropdown arrow stays centred. Field text keeps its own size,
 * which comes from `--at-form-field-font-size`, not from this.
 *
 * THE RADIUS IS ONE VARIABLE TOO. The theme paints every field's corners from
 * `--at-input-border-radius`, which the 2020 skin sets to 0. The theme DOES
 * register it as a Customizer control, "Input Border Radius", filed under Agend
 * Theme > Other rather than Forms because its key matches none of the section
 * prefixes, and prints the saved value on `:root`. This file was scoped when
 * that control could not be, so the variable is overridden here on the body
 * instead, and it stays here now the scope is the whole site: the radius, the
 * height and the insets below have to change together, and only this file
 * changes all three. Setting it on the body means the `:root` value loses by
 * inheritance, no `!important` fight needed. The height has no control anywhere (the Forms panel offers labels,
 * font size, colours, border, border-bottom and outline), so it could only ever
 * land in a stylesheet.
 *
 * The 2px underline goes with it. On a square field it read as the design; on a
 * pill a straight line across the bottom clips along the curve. The Customizer
 * feeds `--at-form-field-border-bottom` and the theme applies it with
 * `!important`, but a custom property set on the body still wins for
 * descendants, since importance only competes on the same element.
 *
 * Text areas get a shallower curve: the pill radius on a box five lines tall
 * rounds the whole end off. The theme paints the textarea's radius from the
 * shared field rule, whose `textarea` selector is (0,1,1) WITH `!important`;
 * the doubled-class rule of its own only sets padding. So the `!important` on
 * the radius below is load bearing: it is what lets (0,3,1) compete at all, and
 * dropping it would hand the corners back to the 999px pill.
 *
 * The inset moves from 1rem to 1.5rem so the text sits inside the pill the way
 * it does in the search field. The theme's paddings and the label's left/right
 * are `!important` at (0,1,1); the body class plus `!important` here outranks
 * them. The one exception is the native single `<select>`, which the theme pads
 * through `select:not([multiple]):not([size])` at (0,3,1), each `:not()`
 * counting as a class. The generic rule below is only (0,2,2), so that select
 * gets its own rule at (0,4,1); without it the value would sit at 1rem under a
 * label that had moved to 1.5rem.
 *
 * THE CHECKOUT'S COUNTRY AND STATE DROPDOWNS ARE COVERED. They are native
 * selects the theme embellishes like any other, so the select rule below
 * reaches them, and it clears the label-over-value overlap they carry today:
 * the client's screenshot of the live checkout shows "Country/Region" sitting
 * on top of "Azerbaijan", which is the same imbalance 82b552c fixed on the
 * dashboard. Should WooCommerce's selectWoo ever be enabled on them it would
 * draw a `.select2-container` beside the native select, and the theme styles
 * only the two enhancers it knows, Chosen and Tom Select, so that would need
 * its own rule.
 *
 * @package Agend\OTA
 */

/* --- The pill ---------------------------------------------------------------- */

body.ota-form-fields {
	--at-input-border-radius: 999px;
	--at-form-field-border-bottom: none;
}

body.ota-form-fields .agendtheme-form-input {
	--at-line-height-base: 1.125rem;
}

body.ota-form-fields .agendtheme-form-input input,
body.ota-form-fields .agendtheme-form-input select,
body.ota-form-fields .agendtheme-form-input .ts-wrapper .ts-control {
	padding-inline: 1.5rem !important;
}

/*
 * THE NATIVE DROPDOWN NEEDS ITS INSIDES REBUILT, NOT JUST ITS INSET. Teamwork
 * 49444942, reopened 8 Sep 2026: Jade's screenshot of Connections Magazine
 * Format on Marketing Preferences shows the floated label sitting on top of
 * the value, "Connections Magazine Format" overlapping "Digital".
 *
 * The claim above that scaling `--at-line-height-base` scales the whole
 * assembly together holds for the text input and NOT for the native single
 * select, because the theme builds the two differently. Writing L for the
 * base, the label is the same in both: absolutely positioned across the field
 * from `top: 0` to `bottom: L * 0.875`, its text centred in that box, so its
 * centre is at L * 0.875. The value is not:
 *
 *   input   padding-top L * 0.875, line-height L * 1.75
 *           -> value centre at L * 1.75, so a gap of L * 0.875
 *   select  no padding at all, line-height L * 2.625, value centred in it
 *           -> value centre at L * 1.3125, so a gap of L * 0.4375
 *
 * The dropdown's gap is exactly half the input's at any size. At the theme's
 * 1.5rem that is 10.5px, which clears a 12.8px label and a 15px value by a
 * hair; at the 1.125rem above it is 7.9px and they overlap. So the shrink did
 * not create the imbalance, it just used up the last of the headroom the
 * dropdown had.
 *
 * Giving the select the input's construction fixes it at the source and, since
 * L * 0.875 + L * 1.75 is the same L * 2.625 the line-height alone came to,
 * WITHOUT CHANGING THE HEIGHT OF THE BOX: measured on Marketing Preferences,
 * 47.3px before and after, the label unmoved at 15.8px, the gap 7.8px -> 15.7px
 * and so identical to the text fields. Every dashboard dropdown now sits on the
 * same grid as every dashboard input.
 *
 * The theme's own reason for centring selects instead was most likely that
 * browsers used to ignore vertical padding on a `<select>`. Current ones do
 * not, and the padding is only doing what the theme already asks of the
 * `.ts-control` that Enhanced UI swaps in, which is padded exactly this way a
 * few rules above.
 *
 * Specificity is already won: the theme's rule is (0,3,1) with `!important`
 * and the body class takes this to (0,4,1). The shorthand carries the 1.5rem
 * inset that was the whole of this rule before.
 */
body.ota-form-fields .agendtheme-form-input select:not([multiple]):not([size]) {
	line-height: calc(var(--at-line-height-base) * 1.75) !important;
	padding: calc(calc(var(--at-line-height-base) * 1.75) * 0.5) 1.5rem 0 !important;
}

body.ota-form-fields .agendtheme-form-input .agend-st-field-label,
body.ota-form-fields .agendtheme-form-input label {
	left: 1.5rem !important;
	right: 1.5rem !important;
}

body.ota-form-fields .agendtheme-form-input.agendtheme-form-input textarea {
	border-radius: 24px !important;
	padding-inline: 1.5rem;
}

/* --- One placeholder, not two -------------------------------------------- */

/*
 * TWO PLACEHOLDERS ON TOP OF EACH OTHER. Teamwork 49444942, Jade's screenshots
 * of 13 and 15 Sep 2026: "State" sitting on "Select an option..." on the
 * checkout once Australia is picked as the country, and "Organisation Name"
 * sitting on "Please select" on Find an OT. Neither field has a value. What is
 * showing is the control's OWN placeholder text, drawn at the value position
 * while the theme's label is doing the same job from the label position.
 *
 * The theme already knows about this and handles it at page load: its
 * embellish script strips the `placeholder` attribute from every text input
 * and blanks the text of the empty option in every native select, so the label
 * is the one placeholder. Two dropdowns get past it:
 *
 *   - The WooCommerce state field. It starts as a text input, and choosing a
 *     country with states makes WooCommerce swap in a `<select>` whose first
 *     option reads "Select an option...". The theme re-runs its embellish on
 *     the swapped element, but that routine looks for the label BEFORE the
 *     input and this wrapper has it after, so it returns before blanking
 *     anything. The option text stays.
 *
 *   - The Organisation Name field on Find an OT, a Gravity Forms select the
 *     Advanced Select perk turns into a Tom Select control (populated from the
 *     CRM by ota-accounts-select.js). Tom Select draws its own placeholder as
 *     the `placeholder` attribute of the `<input>` inside `.ts-control`, taken
 *     from the field's Gravity Forms placeholder setting. The theme blanks the
 *     native option, which Tom Select has hidden anyway, and never touches
 *     this input. That one is handled in the next block, differently.
 *
 * For the native select the fix is to hide the placeholder text while the
 * select's chosen option is the placeholder one: WooCommerce's is
 * `<option value="">` (country-select.js) and Gravity Forms' placeholder
 * option is too, so `:has(option:checked[value=""])` matches exactly the
 * valueless state. The text goes transparent until something is chosen, since
 * the only text a valueless select shows is its placeholder option, and the
 * moment an option with a value is selected the match drops and the text
 * returns. The options list the browser opens is painted in the select's
 * colour in Chromium, so it is set back explicitly, in the same variable the
 * theme's form-input mixin paints the select with, so the two follow one
 * Customizer setting. Multi-selects and list boxes are excluded: they show
 * their options as their content.
 *
 * NOT gated on the theme's `.not-empty` class, although every other rule in
 * this file trusts it. That class is toggled by a change listener the theme
 * attaches in embellishGenericInput(), and on the swapped-in state select that
 * routine returns early (see above), so no listener is ever attached and the
 * class never lands. A rule keyed to `:not(.not-empty)` would then paint a
 * CHOSEN state transparent for good on that path. It is reachable on OTA: a
 * member whose saved address is in a country without states (New Zealand, the
 * UK), or anyone who picks such a country and then Australia, gets the
 * input-to-select swap rather than the select-to-select refill that keeps the
 * listener. The label still fails to lift on that path, which is the theme
 * routine's problem and predates this file; the value is at least visible.
 *
 * CSS rather than a script deliberately: the swap happens on WooCommerce's
 * timetable, and a stylesheet rule is in force whenever it does.
 *
 * `!important` because the theme paints the select's text that way: its
 * form-input mixin writes `color: var(--at-form-field-text-color) !important`
 * on every select inside the wrapper, and a flagged declaration beats any
 * unflagged one whatever the selector weighs. Measured on the checkout state
 * field: without the flag the text stayed #303030.
 */
body.ota-form-fields .agendtheme-form-input select:not([multiple]):not([size]):has(option:checked[value=""]) {
	color: transparent !important;
}

body.ota-form-fields .agendtheme-form-input select option {
	color: var(--at-form-field-text-color, #303030);
}


/*
 * THE SEARCH BOX KEEPS ITS LABEL UP AND SHOWS A PLACEHOLDER BENEATH IT. The
 * theme's label doubles as the placeholder and lifts on focus, driven by
 * `.focused`, which it toggles from focus and blur listeners on the field
 * itself. Those listeners sit on the original `<select>`, which Tom Select
 * hides and never focuses: the keyboard goes to its own `<input>` inside
 * `.ts-control`. So the class never lands, the label stays centred, and what
 * you type draws straight through it (Bryce, 18 Sep 2026, "abc" under
 * "Organisation Name").
 *
 * Lifting the label on `:focus-within` was tried first and read as janky: Tom
 * Select discards unsubmitted text on blur, so leaving the field made the
 * typed text vanish and the label drop back in the same instant, the whole box
 * jumping. This is the theme's other pattern instead, the one it already uses
 * for its Select2 and multi-select controls: the label sits small at the top
 * at all times and the control's own placeholder shows in the value slot, in
 * the label's grey so it reads as a hint and not as an entered value (Jade
 * took "Please select" for a filled field). Nothing moves on focus or blur; a
 * chosen organisation simply replaces the placeholder. The placeholder text
 * itself is the field's Gravity Forms placeholder setting, so the client can
 * word it ("Search for your organisation") without a deploy.
 *
 * The raised geometry is the theme's `.focused` rule: half the field's line
 * box up, 0.8em, measured identical to a focused text field on the same form.
 * `.single` so the theme's own rule for empty multi-select Tom Selects, which
 * keeps THEIR label large, is left alone.
 */
body.ota-form-fields .agendtheme-form-input .ts-wrapper.single ~ label {
	bottom: calc(var(--at-line-height-base) * 1.75 * 0.5) !important;
	font-size: 0.8em !important;
	line-height: 1.15em;
}

body.ota-form-fields .agendtheme-form-input .ts-control > input::placeholder {
	color: var(--at-form-field-label-color, #727c88);
	opacity: 1;
}

/*
 * The search box's own inset. The pill rule above pads every `input` in the
 * wrapper 1.5rem in from the edge, and Tom Select's `<input>` is an input in
 * the wrapper, but it sits INSIDE `.ts-control`, which the theme already pads
 * by the same 1.5rem (and this file re-insets). Both applied, the typed text
 * and the placeholder started 1.5rem to the right of the label above them,
 * which is also why "Please select" sat indented in Jade's screenshot. The
 * control carries the inset; the input inside it carries none. `!important`
 * to beat the pill rule's own flag.
 */
body.ota-form-fields .agendtheme-form-input .ts-control > input {
	padding-inline: 0 !important;
}

/* --- The time field ------------------------------------------------------- */

/*
 * THE TIME FIELD'S BOXES ARE TOO NARROW FOR THE PILL. OTA's screenshot of
 * Request an Event (form 20, Start time and Finish time, 30 Oct 2026) shows
 * "10" clipped to "1(" and the AM/PM arrow sitting low. Gravity Forms draws
 * the hour, the minute and AM/PM as three 76px boxes, and the theme
 * embellishes each like any other field, so they get the full treatment:
 *
 *   - the 1.5rem pill inset on both sides leaves 28px of a 76px box, and the
 *     number input's spin buttons take part of that, so two digits do not fit;
 *   - the top padding that makes room for a floated label, when the hour and
 *     minute labels are screen-reader-only, so the value sits low with nothing
 *     above it;
 *   - the colon is not in a field wrapper, so it keeps the theme's unscaled
 *     line height and Gravity Forms' own padding and lands below the boxes;
 *   - AM/PM is wrapped twice (the theme embellishes Gravity Forms' container
 *     and then the select inside it), and the outer wrapper, which draws the
 *     arrow, is taller than the select, so the arrow is placed for a field
 *     that is not there.
 *
 * The fix gives these three boxes a narrow inset, a centred value with no
 * label gap, the box's own height as the line height, no spin buttons, and
 * puts the colon and the arrow on the same line. The box is the same 2.625
 * multiple of the base the text fields come to (see the select rule above).
 */
body.ota-form-fields .gfield--type-time .ginput_complex {
	align-items: flex-start;
}

body.ota-form-fields .gfield--type-time .agendtheme-form-input.agendtheme-form-input input,
body.ota-form-fields .gfield--type-time .agendtheme-form-input.agendtheme-form-input select:not([multiple]):not([size]) {
	height: calc(var(--at-line-height-base) * 2.625) !important;
	line-height: calc(var(--at-line-height-base) * 2.625) !important;
	padding: 0 0.75rem !important;
}

body.ota-form-fields .gfield--type-time .agendtheme-form-input.agendtheme-form-input select:not([multiple]):not([size]) {
	padding-right: 1.75rem !important;
}

body.ota-form-fields .gfield--type-time .agendtheme-form-input input {
	text-align: center;
	-moz-appearance: textfield;
}

body.ota-form-fields .gfield--type-time input::-webkit-outer-spin-button,
body.ota-form-fields .gfield--type-time input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

body.ota-form-fields .gfield--type-time .hour_minute_colon {
	--at-line-height-base: 1.125rem;
	align-self: flex-start;
	height: auto !important;
	line-height: calc(var(--at-line-height-base) * 2.625) !important;
	padding: 0 0.5rem !important;
}

body.ota-form-fields .gfield--type-time .gfield_time_ampm {
	margin-inline-start: 0.5rem !important;
}

body.ota-form-fields .gfield--type-time .gfield_time_ampm.select-wrapper::after {
	top: calc(var(--at-line-height-base) * 2.625 * 0.5) !important;
	bottom: auto !important;
}
