/**
 * Akenveen Reserve Form - front-end styles.
 *
 * Styles every element of the reservation request form on the villa pages: fieldsets,
 * labels, text inputs, textarea, date inputs, number inputs, radios, checkboxes, the
 * submit button, the validation states and the thank-you line. Nothing is left on a
 * browser default.
 *
 * Every rule is scoped under `.arf-reserve-form`. That is not decoration: the theme
 * styles `input[type="text"]` and friends at specificity (0,1,1), which outranks a
 * single class, and an unscoped rule here loses to it.
 *
 * BEM, prefix `arf-`. The palette tokens below are the ACTIVE THEME's own values,
 * read out of casamia/css/__colors.css (field #efefef, field focus #1d2023, button
 * #ffffff on #ffa752, muted #767676), so the form reads as part of the page instead
 * of carrying a second design. Re-tune the look by editing the tokens, not the rules.
 *
 * Counterparts: includes/Form/RenderForm.php (the markup),
 * includes/Assets/LoadAssets.php (enqueue).
 *
 * Filename: assets/css/reserve-form.css
 *
 * @package AkenveenReserveForm
 * @since 0.1.0
 */

.arf-reserve-form {
    --arf-accent: #ffa752;
    --arf-accent-dark: #e8923d;
    --arf-ink: #1d2023;
    --arf-ink-soft: #343739;
    --arf-muted: #767676;
    --arf-field-bg: #efefef;
    --arf-field-border: #e5e5e5;
    --arf-surface: #ffffff;
    --arf-error: #c0392b;
    --arf-radius: 4px;

    /* Density tokens. The form sits in a villa page's sidebar column, where its
       overall height is the thing that matters most, so type size, line-height and
       field padding are tuned together from here. Every vertical margin and every
       top/bottom padding in the form is currently zero; --arf-gap is left as the
       horizontal gap between the two date fields. */
    --arf-gap: 0.8rem;
    --arf-font-size: 0.9375rem;
    --arf-line: 1.3;
    --arf-field-pad-y: 0.3rem;
    --arf-field-pad-x: 0.75rem;

    display: block;
    max-width: 48rem;
    color: var(--arf-ink-soft);
    font-size: var(--arf-font-size);
    line-height: var(--arf-line);
}

.arf-reserve-form *,
.arf-reserve-form *::before,
.arf-reserve-form *::after {
    box-sizing: border-box;
}

/* Loading state
   -------------------------------------------------------------------------
   Every async action scopes this to the form box - never a full-screen overlay -
   so the visitor always sees that the click registered (house rule: async
   feedback always shows a loader).
*/

.arf-reserve-form--loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.arf-reserve-form--loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.25rem;
    height: 2.25rem;
    margin: -1.125rem 0 0 -1.125rem;
    border: 3px solid var(--arf-accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: arf-spin 0.8s linear infinite;
}

@keyframes arf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Intro
   -------------------------------------------------------------------------
   The heading and text from the settings screen, shown above the form. Both are
   optional - see includes/Form/RenderForm.php.
*/

.arf-reserve-form .arf-intro {
    margin: 0 0 0.6rem;
}

/**
 * Every property is declared, not inherited: left to the theme this h2 comes out
 * small and letter-spaced, so the field labels below it read as the bigger heading.
 * The intro heading has to outrank them.
 */
/**
 * The !important is forced by the child theme: casamia-child/assets/css/frontend.css
 * sets `h2 { margin-top: 20px !important; margin-bottom: 10px !important }`, which no
 * amount of specificity can outrank.
 */
.arf-reserve-form .arf-intro__heading {
    margin: 0 0 0.4rem !important;
    color: var(--arf-ink);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
}

.arf-reserve-form .arf-intro__text p {
    margin: 0 0 0.9rem;
    line-height: 1.45;
}

/* Form shell
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form {
    margin: 0;
    padding: 0;
}

/* Shown only when scripting is off, where the form cannot submit at all. */
.arf-reserve-form .arf-form__noscript {
    margin: 0 0 0.6rem;
    padding: 0.5rem 0.85rem;
    border-left: 4px solid var(--arf-error);
    background-color: var(--arf-field-bg);
    color: var(--arf-ink);
    font-weight: 700;
}

/* The sum is a short field; a full-width box invites a long answer. */
.arf-reserve-form .arf-form__input--sum {
    appearance: textfield;
    -moz-appearance: textfield;
    max-width: 7rem;
}

/* Fields
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form__field {
    margin: 0 0 0.5rem;
}

/* A label is a label, not a heading: pinned to body size so it sits below the
   intro heading and the fieldset legends in the hierarchy. */
.arf-reserve-form .arf-form__label {
    display: block;
    margin: 0 0 0.2rem;
    color: var(--arf-ink);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
}

.arf-reserve-form .arf-form__input {
    display: block;
    width: 100%;
    margin: 0;
    padding: var(--arf-field-pad-y) var(--arf-field-pad-x);
    border: 1px solid var(--arf-field-border);
    border-radius: var(--arf-radius);
    background-color: var(--arf-field-bg);
    color: var(--arf-ink);
    font: inherit;
    line-height: var(--arf-line);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.arf-reserve-form .arf-form__input::placeholder {
    color: var(--arf-muted);
    opacity: 1;
}

.arf-reserve-form .arf-form__input:hover {
    border-color: var(--arf-muted);
}

.arf-reserve-form .arf-form__input:focus {
    border-color: var(--arf-ink);
    background-color: var(--arf-surface);
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.arf-reserve-form .arf-form__input:focus-visible {
    outline-color: var(--arf-accent);
}

.arf-reserve-form textarea.arf-form__input {
    min-height: 2.25rem;
    resize: vertical;
}

/* Date inputs. The native control is kept - its own picker navigates months and
   years, which is what the brief asks for - but its chrome is brought in line
   with the other fields. */

.arf-reserve-form .arf-form__input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    min-height: 2.2rem;
}

.arf-reserve-form .arf-form__input[type="date"]::-webkit-calendar-picker-indicator {
    padding: 0.15rem 0.2rem;
    border-radius: var(--arf-radius);
    cursor: pointer;
    opacity: 0.65;
}

.arf-reserve-form .arf-form__input[type="date"]::-webkit-calendar-picker-indicator:hover {
    background-color: var(--arf-surface);
    opacity: 1;
}

/* Groups
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form__group {
    margin: 0 0 0.6rem;
    padding: 0.5rem 0.85rem 0.45rem;
    border: 1px solid var(--arf-field-border);
    border-radius: var(--arf-radius);
    background-color: var(--arf-surface);
}

/**
 * The theme pulls every legend out of the flow - `fieldset legend { position:
 * absolute; top: -0.6em; left: 1.5em; font-style: italic }` in casamia/style.css -
 * which drops the label above the border instead of centring it on the line. The
 * first four declarations below put it back in the normal legend flow; the
 * background keeps the border from running through the text.
 */
.arf-reserve-form .arf-form__legend {
    position: static;
    top: auto;
    left: auto;
    float: none;
    width: auto;
    margin: 0;
    padding: 0 0.5rem;
    background-color: var(--arf-surface);
    color: var(--arf-ink);
    font-size: 0.9375rem;
    font-style: normal;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

/* The period group puts the two dates side by side from the small-tablet width up. */

.arf-reserve-form .arf-form__group .arf-form__field:last-of-type {
    margin-bottom: 0.35rem;
}

@media (min-width: 30rem) {
    .arf-reserve-form .arf-form__group--period {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 var(--arf-gap);
    }

    .arf-reserve-form .arf-form__group--period .arf-form__legend {
        grid-column: 1 / -1;
    }
}

/* Radios and checkboxes
   -------------------------------------------------------------------------
   Drawn by hand: the native controls cannot be coloured consistently across
   browsers, and these have to match the fields next to them.
*/

.arf-reserve-form .arf-form__choice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0 0 0.3rem;
    padding: 0.1rem 0;
    color: var(--arf-ink-soft);
    line-height: var(--arf-line);
    cursor: pointer;
}

.arf-reserve-form .arf-form__choice input[type="radio"],
.arf-reserve-form .arf-form__choice input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin: 0.12rem 0 0;
    border: 1px solid var(--arf-muted);
    background-color: var(--arf-surface);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.arf-reserve-form .arf-form__choice input[type="radio"] {
    border-radius: 50%;
}

.arf-reserve-form .arf-form__choice input[type="checkbox"] {
    border-radius: var(--arf-radius);
}

.arf-reserve-form .arf-form__choice:hover input[type="radio"],
.arf-reserve-form .arf-form__choice:hover input[type="checkbox"] {
    border-color: var(--arf-ink);
}

.arf-reserve-form .arf-form__choice input[type="radio"]:checked,
.arf-reserve-form .arf-form__choice input[type="checkbox"]:checked {
    border-color: var(--arf-accent);
    background-color: var(--arf-accent);
}

/* The radio's dot. */
.arf-reserve-form .arf-form__choice input[type="radio"]:checked::after {
    content: "";
    display: block;
    width: 0.4rem;
    height: 0.4rem;
    margin: 0.25rem auto 0;
    border-radius: 50%;
    background-color: var(--arf-surface);
}

/* The checkbox's tick, drawn with a rotated border so no image is needed. */
.arf-reserve-form .arf-form__choice input[type="checkbox"]:checked::after {
    content: "";
    display: block;
    width: 0.28rem;
    height: 0.52rem;
    margin: 0.07rem auto 0;
    border: solid var(--arf-surface);
    border-width: 0 2px 2px 0;
    transform: rotate(40deg);
}

.arf-reserve-form .arf-form__choice input[type="radio"]:focus-visible,
.arf-reserve-form .arf-form__choice input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--arf-accent);
    outline-offset: 2px;
}

/* Extras
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form__extra {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0 0 0.3rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--arf-radius);
    transition: background-color 0.15s ease;
}

.arf-reserve-form .arf-form__extra:hover {
    background-color: var(--arf-field-bg);
}

.arf-reserve-form .arf-form__extra .arf-form__choice {
    flex: 1 1 auto;
    margin: 0;
}

.arf-reserve-form .arf-form__amount {
    appearance: textfield;
    -moz-appearance: textfield;
    flex: 0 0 4rem;
    width: 4rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--arf-field-border);
    border-radius: var(--arf-radius);
    background-color: var(--arf-field-bg);
    color: var(--arf-ink);
    font: inherit;
    text-align: center;
}

.arf-reserve-form .arf-form__amount:focus {
    border-color: var(--arf-ink);
    background-color: var(--arf-surface);
    outline: 2px solid var(--arf-accent);
    outline-offset: 1px;
}

/* Disabled until its extra is ticked - the box must read as inert, not broken. */
.arf-reserve-form .arf-form__amount:disabled {
    border-color: var(--arf-field-bg);
    color: var(--arf-muted);
    cursor: not-allowed;
    opacity: 0.65;
}

/* Submit
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form__submit {
    display: inline-block;
    margin: 0.3rem 0 0;
    padding: 0.55rem 1.75rem;
    border: 0;
    border-radius: var(--arf-radius);
    background-color: var(--arf-accent);
    color: var(--arf-surface);
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.arf-reserve-form .arf-form__submit:hover,
.arf-reserve-form .arf-form__submit:focus {
    background-color: var(--arf-accent-dark);
    color: var(--arf-surface);
}

.arf-reserve-form .arf-form__submit:focus-visible {
    outline: 2px solid var(--arf-ink);
    outline-offset: 2px;
}

.arf-reserve-form .arf-form__submit:active {
    transform: translateY(1px);
}

.arf-reserve-form .arf-form__submit:disabled {
    background-color: var(--arf-muted);
    cursor: not-allowed;
}

/* Validation and feedback
   ------------------------------------------------------------------------- */

.arf-reserve-form .arf-form__error {
    display: block;
    margin: 0;
    color: var(--arf-error);
    font-size: 0.8125rem;
    line-height: 1.25;
}

.arf-reserve-form .arf-form__field--error .arf-form__input,
.arf-reserve-form .arf-form__field--error .arf-form__amount {
    border-color: var(--arf-error);
    background-color: var(--arf-surface);
}

.arf-reserve-form .arf-form__group.arf-form__field--error {
    border-color: var(--arf-error);
}

.arf-reserve-form .arf-form__feedback {
    margin: 0.5rem 0 0;
    min-height: 1.15em;
    color: var(--arf-error);
    font-weight: 600;
}

.arf-reserve-form .arf-form__feedback:empty {
    margin: 0;
    min-height: 0;
}

/* The thank-you line, which replaces the whole form once the request is away. */

.arf-reserve-form .arf-form__thanks {
    margin: 0;
    padding: 0.8rem 1.1rem;
    border: 1px solid var(--arf-accent);
    border-left-width: 4px;
    border-radius: 0 var(--arf-radius) var(--arf-radius) 0;
    background-color: var(--arf-field-bg);
    color: var(--arf-ink);
    font-weight: 700;
    line-height: 1.5;
}
