/* ============================================================================
   Change country or region — the region picker page (SSR from the configurator
   API via includes/regions-lib.php). Dark theme; the wrapper carries .theme-dark
   so the shared header/footer sit on the same near-black canvas.
   ========================================================================== */

.change-region {
    /* A muted grey that still clears WCAG AA contrast on the near-black bg
       (--color-text-muted #6B6B80 only reaches 3.96:1 and fails). */
    --cr-muted: #9A9AB0;
    background: var(--color-bg);
    color: var(--color-text);
    /* The site header is position:fixed, so content flows under it — this top
       gap clears it so the nav never touches the content. Every new top-level
       page needs a header-clearing top gap like this. */
    padding: calc(var(--space-6xl) + var(--space-lg)) 0 var(--space-6xl);
    min-height: 70vh;
}

/* ── Header card: title + subtitle on the left, search on the right ───────── */
.cr-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xl) var(--space-2xl);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-4xl);
    padding: var(--space-2xl);
}

.cr-head__text { flex: 1 1 380px; min-width: 0; }

.cr-title {
    margin: 0;
    font-size: var(--text-4xl);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.cr-sub {
    margin: var(--space-sm) 0 0;
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    line-height: 1.5;
    max-width: 60ch;
}

/* ── Search box ───────────────────────────────────────────────────────────── */
.cr-search {
    position: relative;
    flex: 0 1 420px;
    min-width: 260px;
}

.cr-search__icon {
    position: absolute;
    left: var(--space-lg);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--cr-muted);
    pointer-events: none;
}

.cr-search__input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.9rem 1.25rem 0.9rem 3.1rem;
    font-family: var(--font-family);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.cr-search__input::placeholder { color: var(--cr-muted); }

.cr-search__input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255, 121, 27, 0.18);
}

/* Kill the native search "x" so it doesn't clash with the custom look. */
.cr-search__input::-webkit-search-decoration,
.cr-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ── Groups ───────────────────────────────────────────────────────────────── */
.cr-groups { margin-top: var(--space-3xl); }

/* Neutralise the global `section {}` gradient/border/padding (layout.css) — the
   picker's groups are flat rows, not the site's full-width gradient bands. */
.cr-group {
    padding: 0;
    background: none;
    border-top: 0;
}

.cr-group + .cr-group { margin-top: var(--space-2xl); }

.cr-group__title {
    margin: 0 0 var(--space-md);
    color: var(--cr-muted);
    font-size: var(--text-xl);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.cr-group__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-xs) var(--space-md);
}

/* ── Region cell ──────────────────────────────────────────────────────────── */
.cr-region {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-2xl);
    color: var(--color-text);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

a.cr-region { cursor: pointer; }

a.cr-region:hover,
a.cr-region:focus-visible { background: var(--color-surface); }

a.cr-region:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.cr-region.is-active { background: var(--color-surface); }

.cr-region__flag {
    width: 28px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.09);
    background: var(--color-surface);
}

/* The World-Wide globe is square (1:1) — render it uncropped, not squeezed
   into the flag rectangle (object-fit:cover was cropping its top/bottom). */
.cr-region__flag--globe {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 50%;
    box-shadow: none;
    background: none;
}

.cr-region__name {
    font-size: var(--text-lg);
    font-weight: 500;
    line-height: 1.2;
}

/* Coming-soon — inert, muted, with a "Soon" pill. */
.cr-region--soon { cursor: default; }
.cr-region--soon .cr-region__name { color: var(--cr-muted); }
.cr-region--soon .cr-region__flag { opacity: 0.75; }

.cr-region__pill {
    margin-left: 2px;
    padding: 3px 10px;
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

/* Search filtering (change-region.js toggles the [hidden] attribute). An explicit
   `display` on a flex item overrides the UA `[hidden] { display:none }`, so a hidden
   region cell would stay visible unless we re-assert display:none here. */
.cr-region[hidden],
[data-cr-group][hidden] { display: none !important; }

/* Empty search state. */
.cr-empty {
    margin: var(--space-3xl) 0 0;
    text-align: center;
    color: var(--cr-muted);
    font-size: var(--text-lg);
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .change-region { padding: calc(var(--space-4xl) + var(--space-md)) 0 var(--space-4xl); }
    .cr-head { padding: var(--space-xl); }
    .cr-title { font-size: var(--text-3xl); }
    .cr-search { flex-basis: 100%; }
    .cr-group__grid { grid-template-columns: 1fr; }
    .cr-groups { margin-top: var(--space-2xl); }
}
