/*==========================================
  Desiwood — international phone field (sign-up)
  Mirrors .signup-section .form-control: 58px, #2a1739, 8px radius,
  #ff7a00 hover/focus with a 4px ring. See public/frontend/js/dw-phone-input.js.
==========================================*/

/* Flag glyphs only (regional indicators), so flags look the same on Windows,
   which ships no flag emoji. Twemoji Country Flags, CC-BY 4.0 (Twitter, Inc.),
   via country-flag-emoji-polyfill. Downloaded only when a flag is drawn. */
@font-face {
    font-family: "Twemoji Country Flags";
    unicode-range: U+1F1E6-1F1FF;
    src: url("../fonts/TwemojiCountryFlags.woff2") format("woff2");
    font-display: swap;
}

.dw-phone {
    --dw-phone-bg: #2a1739;
    --dw-phone-border: rgba(255, 255, 255, .08);
    --dw-phone-accent: #ff7a00;
    --dw-phone-invalid: var(--bs-form-invalid-border-color, #dc3545);
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    height: 58px;
    background: var(--dw-phone-bg);
    border: 1px solid var(--dw-phone-border);
    border-radius: 8px;
    transition: border-color .25s ease, box-shadow .25s ease;
}

.dw-phone:hover {
    border-color: var(--dw-phone-accent);
}

.dw-phone:focus-within,
.dw-phone.is-open {
    border-color: var(--dw-phone-accent);
    box-shadow: 0 0 0 4px rgba(255, 122, 0, .12);
}

.dw-phone.is-invalid {
    border-color: var(--dw-phone-invalid);
}

.dw-phone.is-invalid:focus-within {
    box-shadow: 0 0 0 4px rgba(220, 53, 69, .2);
}

.dw-phone__flag {
    font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 20px;
    line-height: 1;
    flex: none;
}

/* Country button */
.dw-phone__country {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    margin: 0;
    padding: 0 14px 0 16px;
    background: transparent;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, .1);
    border-radius: 8px 0 0 8px;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s ease;
}

.dw-phone__country:hover,
.dw-phone.is-open .dw-phone__country {
    background: rgba(255, 255, 255, .04);
}

.dw-phone__country:focus {
    outline: none;
}

.dw-phone__country:focus-visible {
    outline: 2px solid var(--dw-phone-accent);
    outline-offset: -3px;
}

.dw-phone__dial {
    min-width: 2.6em;
    font-variant-numeric: tabular-nums;
}

.dw-phone__caret {
    width: 16px;
    height: 16px;
    fill: #8c8598;
    transition: transform .25s ease, fill .2s ease;
}

.dw-phone.is-open .dw-phone__caret {
    transform: rotate(180deg);
    fill: var(--dw-phone-accent);
}

/* Number input */
.dw-phone__input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0 18px 0 14px;
    background: transparent;
    border: 0;
    border-radius: 0 8px 8px 0;
    color: #fff;
    font: inherit;
    font-size: 15px;
    letter-spacing: .02em;
    outline: none;
    box-shadow: none;
}

.dw-phone__input::placeholder {
    color: #8c8598;
    letter-spacing: normal;
}

.dw-phone__input:-webkit-autofill {
    -webkit-text-fill-color: #fff;
    -webkit-box-shadow: 0 0 0 40px var(--dw-phone-bg) inset;
    caret-color: #fff;
}

.dw-phone-error {
    display: block;
    margin-top: 6px;
    color: var(--bs-form-invalid-color, #dc3545);
    font-size: .875em;
}

.dw-phone-error[hidden] {
    display: none;
}

/* Dropdown panel (appended to <body>, positioned by the script) */
.dw-phone-panel {
    position: fixed;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #241331;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
    color: #fff;
    font-family: var(--default-font, "Poppins", sans-serif);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease;
}

.dw-phone-panel.is-above {
    transform: translateY(6px);
}

.dw-phone-panel.is-visible {
    opacity: 1;
    transform: none;
}

.dw-phone-panel[hidden] {
    display: none;
}

.dw-phone-panel__search {
    position: relative;
    flex: none;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.dw-phone-panel__search svg {
    position: absolute;
    top: 50%;
    left: 24px;
    width: 18px;
    height: 18px;
    fill: #8c8598;
    transform: translateY(-50%);
    pointer-events: none;
}

.dw-phone-panel__query {
    display: block;
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 14px 0 42px;
    background: #311842;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    color: #fff;
    font: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming on focus */
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.dw-phone-panel__query::placeholder {
    color: #8c8598;
    font-size: 14px;
}

.dw-phone-panel__query:focus {
    border-color: #ff7a00;
    box-shadow: 0 0 0 3px rgba(255, 122, 0, .14);
}

.dw-phone-panel__list {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #4a2a63 transparent;
}

.dw-phone-panel__list::-webkit-scrollbar {
    width: 8px;
}

.dw-phone-panel__list::-webkit-scrollbar-thumb {
    background: #4a2a63;
    border-radius: 8px;
}

.dw-phone-panel__option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    margin: 0;
    padding: 8px 12px;
    border-radius: 6px;
    color: #e6def0;
    font-size: 14px;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.dw-phone-panel__option.is-active {
    background: #3d2052;
    color: #fff;
}

.dw-phone-panel__option.is-selected {
    color: #fff;
    font-weight: 500;
}

.dw-phone-panel__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dw-phone-panel__dial {
    flex: none;
    color: #a8a2b5;
    font-variant-numeric: tabular-nums;
}

.dw-phone-panel__option.is-selected .dw-phone-panel__dial {
    color: #ff8a00;
}

.dw-phone-panel__check {
    flex: none;
    width: 18px;
    height: 18px;
    fill: #ff8a00;
    visibility: hidden;
}

.dw-phone-panel__option.is-selected .dw-phone-panel__check {
    visibility: visible;
}

.dw-phone-panel__divider {
    height: 1px;
    margin: 6px 8px;
    background: rgba(255, 255, 255, .08);
}

.dw-phone-panel__empty {
    margin: 0;
    padding: 18px 16px 22px;
    color: #a8a2b5;
    font-size: 14px;
    text-align: center;
}

.dw-phone-panel__empty[hidden] {
    display: none;
}

.dw-phone-panel__status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Same breakpoint as `.signup-section .form-control { height: 54px }` in custom.css */
@media (max-width: 767px) {
    .dw-phone {
        height: 54px;
    }
}

@media (max-width: 575.98px) {
    .dw-phone__country {
        gap: 6px;
        padding: 0 10px 0 12px;
    }

    .dw-phone__input {
        padding-left: 12px;
        padding-right: 12px;
    }

    .dw-phone-panel__option {
        min-height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dw-phone,
    .dw-phone__caret,
    .dw-phone-panel,
    .dw-phone-panel__option {
        transition: none;
    }
}
