/*
 * Advertise enquiry form (components/advertise/form.php).
 * Recreates the look of the form this replaced: a 480px column centred in a 768px left-aligned block, Open Sans,
 * square fields with a light border. Everything is scoped and reset defensively, since it sits inside article
 * content whose paragraph, list, input and button styles would otherwise leak in.
 */

/*
 * Country flags for the phone picker. Windows has no flag emoji and some Linux setups have no colour emoji font,
 * so flags come from this flag-only font on every platform. unicode-range limits it to the regional-indicator
 * characters, so the browser only downloads it once a flag is drawn and all other text keeps its usual font.
 * "Twemoji Country Flags" by TalkJS (MIT), artwork from Twemoji (CC-BY 4.0): fonts/TwemojiCountryFlags-LICENSE.md
 */
@font-face {
    font-family: "CP Country Flags";
    src: url("fonts/TwemojiCountryFlags.woff2") format("woff2");
    unicode-range: U+1F1E6-1F1FF;
    font-display: swap;
}
.cp-advertise-form {
    --cpaf-accent: #ddc596;
    --cpaf-accent-hover: #ead2a3;
    --cpaf-accent-active: #d0b889;
    --cpaf-text: #1f1f1f;
    --cpaf-muted: #65686f;
    --cpaf-border: #d1d1d1;
    --cpaf-border-hover: #c2c2c2;
    --cpaf-option-hover: #f7f7f7;
    --cpaf-link: #0d68c5;
    --cpaf-error: #b11506;
    --cpaf-shadow: 1px 1px 3px 0 rgba(0, 0, 0, .04);
    --cpaf-field-height: 36px;

    box-sizing: border-box;
    width: 100%;
    max-width: 768px;
    margin: 0;
    padding: 0 20px 32px;
    font-family: "Open Sans", sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--cpaf-text);
    text-align: left;
    -webkit-font-smoothing: antialiased;
}

.cp-advertise-form *,
.cp-advertise-form *::before,
.cp-advertise-form *::after {
    box-sizing: border-box;
}

.cp-advertise-form > * {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.cp-advertise-form p {
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    letter-spacing: normal;
}

.cp-advertise-form__form {
    margin: 0 auto;
    padding: 0;
}

.cp-advertise-form__intro {
    margin: 8px 0 16px !important;
    line-height: 18px !important;
}

.cp-advertise-form__field {
    margin: 0 0 16px;
}

.cp-advertise-form__label {
    display: inline-block;
    margin: 0 0 4px;
    padding: 0;
    font: inherit;
    line-height: 18px;
    font-weight: 400;
    color: var(--cpaf-text);
    text-transform: none;
    letter-spacing: normal;
}

.cp-advertise-form__optional {
    font: inherit;
    color: inherit;
}

/* Fields */
.cp-advertise-form .cp-advertise-form__input {
    display: block;
    width: 100%;
    height: var(--cpaf-field-height);
    margin: 0;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--cpaf-text);
    background: #fff;
    border: 1px solid var(--cpaf-border);
    border-radius: 0;
    box-shadow: var(--cpaf-shadow);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s ease;
}

.cp-advertise-form .cp-advertise-form__input:hover {
    border-color: var(--cpaf-border-hover);
}

.cp-advertise-form .cp-advertise-form__input:focus {
    outline: 2px solid var(--cpaf-link);
    outline-offset: -1px;
}

.cp-advertise-form .cp-advertise-form__textarea {
    height: auto;
    min-height: 96px;
    resize: vertical;
}

.cp-advertise-form [aria-invalid="true"] {
    border-color: var(--cpaf-error);
}

/* Select (state, budget) */
.cp-advertise-form__select {
    position: relative;
}

.cp-advertise-form__select select.cp-advertise-form__input {
    padding-right: 32px;
    cursor: pointer;
}

.cp-advertise-form__select .cp-advertise-form__chevron {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    pointer-events: none;
}

.cp-advertise-form__chevron {
    display: inline-flex;
    align-items: center;
    color: var(--cpaf-text);
    line-height: 0;
}

/* Phone: country picker + number */
.cp-advertise-form__phone {
    position: relative;
    display: flex;
    gap: 8px;
}

.cp-advertise-form .cp-advertise-form__tel {
    flex: 1 1 auto;
    min-width: 0;
}

.cp-country-picker {
    flex: 0 0 auto;
}

.cp-advertise-form .cp-country-picker__button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
    min-width: 49px;
    white-space: nowrap;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}

.cp-country-picker__flag {
    font-family: "CP Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    line-height: 20px;
}

.cp-country-picker__dial:empty {
    display: none;
}

.cp-country-picker__chevron svg {
    transition: transform .15s ease;
}

.cp-country-picker__button[aria-expanded="true"] .cp-country-picker__chevron svg {
    transform: rotate(180deg);
}

.cp-country-picker__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    padding: 8px 0 8px 8px;
    background: #fff;
    border: 1px solid var(--cpaf-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

.cp-country-picker__panel[hidden] {
    display: none;
}

.cp-country-picker__search {
    padding: 0 8px 8px 0;
}

.cp-advertise-form .cp-country-picker__list {
    max-height: 166px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.cp-advertise-form .cp-country-picker__option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 10px;
    font: inherit;
    color: var(--cpaf-text);
    list-style: none;
    cursor: pointer;
}

.cp-advertise-form .cp-country-picker__option::before {
    content: none;
}

.cp-advertise-form .cp-country-picker__option[hidden],
.cp-advertise-form .cp-country-picker__empty[hidden] {
    display: none;
}

.cp-advertise-form .cp-country-picker__option.is-active,
.cp-advertise-form .cp-country-picker__option:hover {
    background: var(--cpaf-option-hover);
}

.cp-advertise-form .cp-country-picker__option[aria-selected="true"] {
    font-weight: 700;
}

.cp-country-picker__option-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-country-picker__option-dial {
    flex: 0 0 auto;
}

.cp-country-picker__empty {
    padding: 8px 10px;
    color: var(--cpaf-muted);
}

/* Errors */
.cp-advertise-form__error:empty {
    display: none;
}

.cp-advertise-form__error {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 16px;
    color: var(--cpaf-error);
}

.cp-advertise-form__error svg {
    flex: 0 0 auto;
}

.cp-advertise-form__error--form {
    margin: 0 0 8px;
}

/* Submit */
.cp-advertise-form .cp-advertise-form__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    margin: 24px 0 0;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 20px;
    color: #fff;
    text-transform: none;
    letter-spacing: normal;
    background: var(--cpaf-accent);
    border: 0;
    border-radius: 0;
    box-shadow: var(--cpaf-shadow);
    cursor: pointer;
    transition: background-color .15s ease;
}

.cp-advertise-form .cp-advertise-form__submit:hover {
    background: var(--cpaf-accent-hover);
}

.cp-advertise-form .cp-advertise-form__submit:active {
    background: var(--cpaf-accent-active);
}

.cp-advertise-form .cp-advertise-form__submit:focus-visible {
    outline: 2px solid var(--cpaf-link);
    outline-offset: 2px;
}

.cp-advertise-form .cp-advertise-form__submit[disabled] {
    cursor: progress;
    opacity: .7;
}

/* Success + footer notes */
.cp-advertise-form__success {
    padding: 16px 0 8px;
    outline: none;
}

.cp-advertise-form__success[hidden] {
    display: none;
}

.cp-advertise-form .cp-advertise-form__note {
    margin: 16px auto !important;
    line-height: 16px;
    color: var(--cpaf-muted);
}

.cp-advertise-form.is-sent .cp-advertise-form__note {
    display: none;
}

/* Reserved spam-check field: kept out of sight and out of the accessibility tree. */
.cp-advertise-form .cp-advertise-form__hp {
    position: absolute !important;
    left: -10000px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.cp-advertise-form .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 599px) {
    .cp-advertise-form {
        padding-left: 0;
        padding-right: 0;
    }
}
