/* =====================================================
   Custom Search Shortcode — Stylesheet
   ===================================================== */

/* ---------- Layout wrapper ---------- */
.css-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    position: relative;
}

/* ---------- Toggle button ---------- */
.css-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: inherit;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
    z-index: 2;
}

.css-toggle:hover {
    background: rgba(0, 0, 0, 0.07);
}

.css-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---------- Icons ---------- */
.css-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.15s ease, transform 0.2s ease;
    position: absolute;
}

/* Default state: show magnifier, hide ×  */
.css-icon--search {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.css-icon--close {
    opacity: 0;
    transform: scale(0.6) rotate(-45deg);
}

/* Active state (toggled via JS class) */
.css-wrapper.is-open .css-icon--search {
    opacity: 0;
    transform: scale(0.6) rotate(45deg);
}

.css-wrapper.is-open .css-icon--close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ---------- Search box ---------- */
.css-box {
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transition:
        max-width  0.35s cubic-bezier(0.4, 0, 0.2, 1),
        opacity    0.25s ease;
}

/* Remove the browser "hidden" after JS removes the attribute,
   so the CSS transition can run */
.css-box[hidden] {
    display: block !important; /* override hidden — visibility managed by max-width */
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}

.css-wrapper.is-open .css-box {
    max-width: 320px;
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Form ---------- */
.css-form {
    display: flex;
    align-items: center;
    border: 1.5px solid currentColor;
    border-radius: 999px;
    overflow: hidden;
    background: transparent;
    padding: 0 6px 0 14px;
    margin-left: 6px;
    white-space: nowrap;
}

/* ---------- Input ---------- */
.css-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.95rem;
    color: inherit;
    min-width: 160px;
    outline: none;
    font-family: inherit;
}

.css-input::placeholder {
    opacity: 0.55;
}

/* Remove browser's built-in clear (×) button */
.css-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

/* ---------- Submit button inside form ---------- */
.css-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: inherit;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.css-submit:hover {
    background: rgba(0, 0, 0, 0.07);
}

.css-submit:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.css-submit svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* ---------- Reduced-motion override ---------- */
@media (prefers-reduced-motion: reduce) {
    .css-toggle,
    .css-icon,
    .css-box {
        transition: none;
    }
}
