/* Header search: the magnifier button and the desktop dropdown panel. Values follow the design (panel 1272px wide at 1512px). */

.main-bar {
    position: relative;
}

.nm-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 3.5rem;
    height: 3rem;
    margin: 0 1.5rem 0 0.5rem;
    padding: 0;
    border: 1px solid #f6f6f6;
    border-radius: 3rem;
    background: transparent;
    cursor: pointer;
}

/* Below 1400px the header row has no room for the design size: a 48px circle with tighter spacing */
@media (min-width: 992px) and (max-width: 1399.98px) {
    .nm-search-trigger {
        width: 3rem;
        margin: 0 1rem 0 0;
    }
}

/* Narrow desktops (992px to 1199px): tighter spacing around the search button */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .nm-search-trigger {
        margin: 0 0.5rem 0 0;
    }
}

/* From 992px to 1399px the header row is too tight for the number: the button reads "Llámenos" (the number stays in the HTML) */
@media (min-width: 992px) and (max-width: 1399.98px) {
    .nm-call-number {
        display: none;
    }
}

.nm-search-trigger img {
    display: block;
}

/* The magnifier turns into a close icon while the panel is open */
.nm-search-trigger .nm-search-icon-close,
.nm-search-trigger[aria-expanded="true"] .nm-search-icon-open {
    display: none;
}

.nm-search-trigger[aria-expanded="true"] .nm-search-icon-close {
    display: block;
}

.nm-search-trigger:focus-visible {
    outline: 2px solid var(--green-500);
    outline-offset: 4px;
}

/* The layer spans the header width but lets the clicks through; only the panel takes them */
.nm-search-layer {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 1032;
    pointer-events: none;
}

.nm-sp {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 0.5rem;
    padding: 2.5rem;
    border-radius: 1.5rem;
    background-color: #d4e5e8;
    box-shadow: 0 2px 24px 0 rgba(0, 15, 35, 0.24);
    pointer-events: auto;
}

/* The desktop panel scrolls inside itself on short screens, because the sticky header does not let the page scroll to its end */
.nm-search-layer .nm-sp {
    max-height: calc(100vh - 12.5rem);
    max-height: calc(100dvh - 12.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nm-sp[hidden],
.nm-sp [hidden] {
    display: none;
}

.nm-sp-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem 0.75rem 1rem;
    border: 1px solid #267b8e;
    border-radius: 3rem;
    background-color: #d4e5e8;
}

.nm-sp-form img {
    flex-shrink: 0;
    display: block;
}

.nm-sp-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #07080d;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

.nm-sp-input::placeholder {
    color: #414141;
}

.nm-sp-input::-webkit-search-cancel-button {
    display: none;
}

.nm-sp-input:focus {
    outline: 0;
}

/* The input has no outline of its own: the focus ring goes around the whole field */
.nm-sp-form:focus-within {
    outline: 2px solid #267b8e;
    outline-offset: 2px;
}

.nm-sp-clear {
    flex-shrink: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

/* Spinner that takes the place of the clear button while results load */
.nm-sp-loading {
    display: none;
    flex-shrink: 0;
    color: #267b8e;
}

.nm-sp-form.is-loading .nm-sp-clear {
    display: none;
}

.nm-sp-form.is-loading .nm-sp-loading {
    display: block;
    animation: nm-search-spin 1.6s cubic-bezier(0.333, 0, 0.667, 1) infinite;
}

.nm-sp-loading circle {
    /* Static arc: what remains when the animation is off */
    stroke-dasharray: 70 200;
    animation: nm-search-arc 1.6s cubic-bezier(0.333, 0, 0.667, 1) infinite;
}

@keyframes nm-search-spin {
    from {
        transform: rotate(-90deg);
    }

    to {
        transform: rotate(270deg);
    }
}

@keyframes nm-search-arc {
    0% {
        stroke-dasharray: 0.01 200;
        stroke-dashoffset: 0;
    }

    30% {
        stroke-dasharray: 47 200;
        stroke-dashoffset: 0;
    }

    62.5% {
        stroke-dasharray: 55 200;
        stroke-dashoffset: -45;
    }

    100% {
        stroke-dasharray: 0.01 200;
        stroke-dashoffset: -100;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nm-sp-form.is-loading .nm-sp-loading,
    .nm-sp-loading circle {
        animation: none;
    }
}

/* Default state: service groups as buttons */
.nm-sp-services {
    display: flex;
    gap: 2.5rem;
}

.nm-sp-service-group {
    flex: 1 1 0;
}

.nm-sp-group-title {
    margin: 0 0 1.5rem;
    color: #07080d;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.5;
}

.nm-sp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

header[id$="-header"] .nm-sp-chip {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: 2.5rem;
    background-color: #b9d5da;
    color: #07080d;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
}

header[id$="-header"] .nm-sp-chip:hover,
header[id$="-header"] .nm-sp-chip:focus-visible {
    background-color: #267b8e;
    color: #f6f6f6;
}

/* Results */
.nm-sp-live {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nm-sp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.nm-sp-summary {
    margin: 0;
    color: #414141;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

.nm-sp-summary strong {
    color: #07080d;
    font-weight: 800;
}

header[id$="-header"] .nm-sp-all {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #0b252b;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.5;
}

header[id$="-header"] .nm-sp-all:hover {
    text-decoration: underline;
}

.nm-sp-columns {
    display: flex;
    gap: 2.5rem;
}

.nm-sp-group {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.nm-sp-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 1rem;
}

.nm-sp-group-header p {
    margin: 0;
    color: #07080d;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.5;
}

.nm-sp-group-header span {
    color: #414141;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
}

header[id$="-header"] .nm-sp-result {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    color: #07080d;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
}

header[id$="-header"] .nm-sp-result:hover,
header[id$="-header"] .nm-sp-result:focus-visible {
    background-color: #f6f6f6;
}

.nm-sp-result strong {
    font-weight: 800;
}

.nm-sp-result-meta {
    color: #414141;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* No results */
.nm-sp-empty-title {
    margin: 0 0 0.5rem;
    color: #07080d;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 2.5rem;
}

.nm-sp-empty-hint {
    margin: 0;
    color: #414141;
    font-size: 1rem;
    line-height: 1.5;
}

/* Call footer */
.nm-sp-divider {
    margin: 0 0 1.5rem;
    border: 0;
    border-top: 1px solid #267b8e;
    opacity: 0.4;
}

.nm-sp-call {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.nm-sp-call-text {
    margin: 0;
    color: #07080d;
    font-size: 1rem;
    line-height: 1.5;
}

.nm-sp-call-text strong {
    font-weight: 800;
}

.nm-sp-call-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 2rem;
    border: 0;
    border-radius: 2.5rem;
    background-color: #267b8e;
    color: #f6f6f6;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.5;
    white-space: nowrap;
}

.nm-sp-call-button:hover,
.nm-sp-call-button:focus {
    color: #f6f6f6;
}

/* Mobile: the field sits at the top of the menu panel; with focus or text the menu items give way to the suggestions */
.nm-sp-mobile:not(.is-active) .nm-sp-services {
    display: none;
}

@media (max-width: 991.98px) {
    .nm-sp-mobile {
        gap: 1.5rem;
        margin-top: 0;
        padding: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .nm-sp-mobile .nm-sp-form {
        padding: 0.625rem 1.5rem;
        border-color: #07080d;
        border-radius: 2.5rem;
        background: transparent;
    }

    .nm-sp-mobile .nm-sp-form img {
        width: 1rem;
        height: 1rem;
    }

    /* 16px minimum: iOS Safari zooms the page when a focused field has a smaller text */
    .nm-sp-mobile .nm-sp-input {
        font-size: 1rem;
        line-height: 1.25rem;
    }

    /* While the field is active the magnifier becomes a back arrow that returns to the menu */
    .nm-sp-back {
        display: none;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;
        width: 1rem;
        height: 1rem;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .nm-sp-mobile .nm-sp-back img {
        width: 0.6875rem;
        height: 0.6875rem;
    }

    .nm-sp-mobile.is-active .nm-sp-form-icon {
        display: none;
    }

    .nm-sp-mobile.is-active .nm-sp-back {
        display: inline-flex;
    }

    .nm-mobile-body.is-searching .nm-mobile-nav {
        display: none;
    }

    .nm-sp-mobile .nm-sp-services {
        flex-direction: column;
        gap: 1.5rem;
    }

    .nm-sp-mobile .nm-sp-group-title {
        margin-bottom: 1rem;
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-chips {
        gap: 1rem 0.5rem;
    }

    header[id$="-header"] .nm-sp-mobile .nm-sp-chip {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-head {
        display: contents;
    }

    .nm-sp-mobile .nm-sp-summary {
        order: 1;
        font-size: 1rem;
        line-height: 1.5;
    }

    .nm-sp-mobile .nm-sp-columns {
        order: 2;
        flex-direction: column;
        gap: 1.5rem;
    }

    .nm-sp-mobile .nm-sp-all {
        order: 3;
        align-self: flex-start;
    }

    header[id$="-header"] .nm-sp-mobile .nm-sp-all {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-group {
        gap: 1rem;
    }

    .nm-sp-mobile .nm-sp-group + .nm-sp-group {
        padding-top: 1.5rem;
        border-top: 1px solid rgba(38, 123, 142, 0.4);
    }

    .nm-sp-mobile .nm-sp-group-header {
        padding-left: 0;
    }

    .nm-sp-mobile .nm-sp-group-header p {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-group-header span {
        font-size: 0.625rem;
        line-height: 1rem;
    }

    header[id$="-header"] .nm-sp-mobile .nm-sp-result {
        padding: 0;
        border-radius: 0;
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    header[id$="-header"] .nm-sp-mobile .nm-sp-result:hover,
    header[id$="-header"] .nm-sp-mobile .nm-sp-result:focus-visible {
        background-color: transparent;
    }

    .nm-sp-mobile .nm-sp-result-meta {
        font-size: 0.625rem;
        line-height: 1rem;
    }

    .nm-sp-mobile .nm-sp-empty-title {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }

    .nm-sp-mobile .nm-sp-empty-hint {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-divider {
        margin-bottom: 1.5rem;
    }

    .nm-sp-mobile .nm-sp-call {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5rem;
    }

    .nm-sp-mobile .nm-sp-call-text {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-call-text strong {
        font-size: 1rem;
        line-height: 1.5;
    }

    .nm-sp-mobile .nm-sp-call-button {
        padding: 0.625rem 2rem;
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .nm-sp-mobile .nm-sp-call-button img {
        width: 1.25rem;
        height: 1.25rem;
    }
}
