/*!
 * Engoory Gpost — city combobox, 3.0.1
 *
 * Loaded by checkout, the order editor and the settings screen, because one
 * widget serves all three. Colour, radius and motion come from tokens the host
 * context sets: Engoory Checkout's --ec-* on the storefront, the Engoory admin
 * scale in wp-admin. Both fall back to the same values, so the picker is never
 * unstyled and never guesses.
 */

.gpost-combo-shell,
.gpost-combo-list,
.gpost-error-message {
    --gp-surface: var(--ec-surface, #ffffff);
    --gp-text: var(--ec-text, #141414);
    --gp-muted: var(--ec-muted, #6e6e6e);
    --gp-border: var(--ec-border, #e4e8ef);
    --gp-accent: var(--ec-accent, #2563eb);
    --gp-accent-soft: var(--ec-accent-soft, rgba(37, 99, 235, .07));
    --gp-positive: var(--ec-positive, #0f7b4f);
    --gp-critical: var(--ec-critical, #b3261e);
    --gp-radius: var(--ec-input-radius, 10px);
    --gp-radius-lg: var(--ec-radius, 14px);
    --gp-ring: var(--ec-ring, rgba(37, 99, 235, .16));
    --gp-shadow: var(--ec-shadow, 0 1px 2px rgba(15, 23, 42, .05), 0 16px 40px -12px rgba(15, 23, 42, .22));
    --gp-fs-sm: var(--ec-fs-sm, 13px);
    --gp-fs-xs: var(--ec-fs-xs, 11.5px);
    --gp-dur: var(--ec-duration, .16s);
    --gp-ease: var(--ec-ease, cubic-bezier(.2, .6, .2, 1));
}

/* ==========================================================================
   Field
   ========================================================================== */

.gpost-combo-shell {
    position: relative;
    display: block;
    width: 100%;
}

.gpost-combo-shell .gpost-city-search {
    box-sizing: border-box;
    width: 100%;
    /* One gutter shared by the clear control and the confirmation tick, so the
       value never runs underneath whichever is currently shown. */
    padding-inline-end: 40px;
    transition: border-color var(--gp-dur) var(--gp-ease), box-shadow var(--gp-dur) var(--gp-ease);
}

.gpost-combo-affordance {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    box-shadow: none;
    color: var(--gp-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--gp-dur) var(--gp-ease), color var(--gp-dur) var(--gp-ease);
    pointer-events: none;
}

.gpost-combo-shell.has-value .gpost-combo-affordance,
.gpost-combo-shell.is-confirmed .gpost-combo-affordance {
    opacity: 1;
    pointer-events: auto;
}

.gpost-combo-shell.is-confirmed .gpost-combo-affordance {
    color: var(--gp-positive);
    cursor: default;
}

.gpost-combo-affordance:hover { color: var(--gp-text); }
.gpost-combo-shell.is-confirmed .gpost-combo-affordance:hover { color: var(--gp-positive); }
.gpost-combo-affordance:focus-visible { box-shadow: 0 0 0 3px var(--gp-ring); outline: none; }
.gpost-combo-affordance svg { display: block; }

.gpost-invalid-input {
    border-color: var(--gp-critical) !important; /* Beats theme field styling. */
    box-shadow: 0 0 0 3px rgba(179, 38, 30, .1) !important;
}

.gpost-error-message {
    clear: both;
    margin-top: 6px;
    color: var(--gp-critical);
    font-size: var(--gp-fs-xs);
    line-height: 1.4;
}

/* ==========================================================================
   Suggestion list
   ==========================================================================
   Appended to <body> and positioned against the viewport by script, so no
   themed overflow container and no admin table can trap it.
   ========================================================================== */

.gpost-combo-list {
    position: fixed;
    z-index: 2147483000;
    box-sizing: border-box;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--gp-border);
    border-radius: var(--gp-radius-lg);
    background: var(--gp-surface);
    box-shadow: var(--gp-shadow);
    color: var(--gp-text);
    font-size: var(--gp-fs-sm);
    line-height: 1.4;
    text-align: start;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    touch-action: pan-y;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity var(--gp-dur) var(--gp-ease), transform var(--gp-dur) var(--gp-ease);
    -webkit-overflow-scrolling: touch;
}

.gpost-combo-list.is-ready {
    opacity: 1;
    transform: none;
}

.gpost-city-option {
    display: flex;
    box-sizing: border-box;
    align-items: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--gp-radius);
    background: transparent;
    color: var(--gp-text);
    cursor: pointer;
    text-align: start;
    transition: background-color var(--gp-dur) var(--gp-ease);
    user-select: none;
}

.gpost-city-option:hover,
.gpost-city-option.is-active {
    background: var(--gp-accent-soft);
    outline: none;
}

.gpost-city-option__copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gpost-city-option__copy strong {
    color: var(--gp-text);
    font-size: var(--gp-fs-sm);
    font-weight: 550;
    line-height: 1.3;
}

.gpost-city-option__copy small {
    margin-top: 2px;
    color: var(--gp-muted);
    font-size: var(--gp-fs-xs);
    line-height: 1.3;
}

/* Underline rather than a highlight block: a yellow <mark> is the browser
   default and reads as a search-engine artefact inside a form. */
.gpost-city-option mark {
    padding: 0;
    background: none;
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gpost-combo-status {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 10px;
    color: var(--gp-muted);
    font-size: var(--gp-fs-sm);
    line-height: 1.35;
}

.gpost-combo-spinner {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border: 1.6px solid var(--gp-border);
    border-top-color: var(--gp-accent);
    border-radius: 50%;
    animation: gpost-spin .6s linear infinite;
}

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

/* The live region announces result counts to screen readers. Without this rule
   present in every context that loads the widget, it renders as visible text
   beside the field. */
.gpost-sr-only {
    position: absolute !important; /* Beats theme and wp-admin layout rules. */
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

@media (prefers-reduced-motion: reduce) {
    .gpost-combo-list,
    .gpost-city-option,
    .gpost-combo-affordance,
    .gpost-combo-shell .gpost-city-search {
        transition: none;
    }

    .gpost-combo-spinner { animation-duration: 1.4s; }
}
