@import './variables.css';
@import './animations.css';

/* Search bar wrapper */
.search-wrap {
    position: relative;
    width: min(760px, 92vw);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px;
    background: rgba(17, 24, 39, .6);
    border-radius: 999px;
    box-shadow: var(--shadow);
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease, filter .2s ease;
    isolation: isolate;

    /* Imported from animations.css */
    animation: 1s ease-out 0s 1 slideInFromBelow;
}

.search-wrap:hover {
    transform: translateY(-1px);
}

/* Disabled state */
.search-wrap.disabled {
    opacity: .6;
    filter: saturate(.7) grayscale(.1);
}

.search-input[disabled]::placeholder {
    opacity: .3;
}

.search-btn[disabled],
.search-input[disabled] {
    cursor: not-allowed;
}

/* Error pulse + shake */
.search-wrap.error {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, .5), var(--shadow);

    /* Imported from animations.css */
    /* Note: slideInFromBelow is also added to prevent triggering it again. */
    animation: slideInFromBelow 0s ease-in, shake .35s ease;
}

/* Fancy gradient border on hover using a pseudo-element */
.search-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 999px;
    padding: 2px;
    background: linear-gradient(120deg, #7c3aed, #22c55e, #06b6d4, #f59e0b, #ef4444, #7c3aed);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity .25s ease, filter 1s linear;
    filter: hue-rotate(0deg);
    z-index: -1;
}

.search-wrap:hover::before {
    opacity: 1;
    animation: hue 5s linear infinite;
}

@keyframes hue {
    to {
        filter: hue-rotate(360deg);
    }
}

/* Magnifying glass icon (left) */
.icon {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    opacity: .85;
}

/* Input */
.search-input {
    appearance: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    width: 100%;
    font-size: 18px;
    line-height: 20px;
    padding: 8px 4px;
    caret-color: #a78bfa;
}

.search-input::placeholder {
    color: #93a1b1;
    opacity: .5;
}

/* Magnifying glass + Circle search button (right) */
.search-wrap img {
    /* White */
    filter: brightness(0) saturate(100%) invert(96%) sepia(96%) saturate(1%) hue-rotate(60deg) brightness(104%) contrast(100%);
    user-select: none;
}

/* Focus styles */
.search-input:focus+.search-btn,
.search-btn:focus {
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .35);
}

@media (max-width: 480px) {
    .search-wrap {
        padding: 14px;
    }

    .search-btn {
        width: 42px;
        height: 42px;
    }
}

.search-btn {
    border: 0;
    outline: 0;
    cursor: pointer;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: radial-gradient(circle at 30% 30%, #7c3aed, #06b6d4);
    box-shadow: 0 8px 24px rgba(124, 58, 237, .35);
    transition: transform .15s ease, box-shadow .2s ease;
    display: grid;
    place-items: center;
    color: white;
}

.search-btn:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 28px rgba(6, 182, 212, .35);
    animation: spinGrad 3s linear infinite;
    background: conic-gradient(from 0deg, #7c3aed, #06b6d4, #22d3ee, #a78bfa, #7c3aed);
}

@keyframes spinGrad {
    to {
        filter: hue-rotate(360deg);
    }
}




/* Progress bar */
.progress {
    width: min(760px, 92vw);
    height: 6px;
    background: rgba(148, 163, 184, .15);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .08);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .25s ease, transform .25s ease;
}

.progress.show {
    opacity: 1;
    transform: translateY(0);
}

.progress .bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #06b6d4, #7c3aed, #ef4444, #22c55e, #06b6d4);
    background-size: 300% 100%;
    animation: slide 1.4s linear infinite;
}

@keyframes slide {
    to {
        background-position: 300% 0;
    }
}



/* Funny loading messages under progress */
.loading-text {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    min-height: 18px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .25s ease, transform .25s ease;
}

.loading-text.show {
    opacity: 1;
    transform: translateY(0);
}



/* Error text */
.error-text {
    font-size: 13px;
    color: #fca5a5;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .25s ease, transform .25s ease;
}

.error-text.show {
    opacity: 1;
    transform: translateY(0);
}

/* Example tooltip under search */
.hint {
    user-select: none;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    opacity: .9;

    /* Imported from animations.css */
    animation: 1s ease-out 0s 1 slideInFromBelow;
}

.hint code {
    display: inline-flex;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    background: rgba(148, 163, 184, .08);
    border: 1px solid rgba(148, 163, 184, .16);
    padding: 4px 8px;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.hint code:hover {
    cursor: pointer;
    transform: scale(1.01);
    background: rgba(26, 29, 34, 0.288);
}