/* Premium Vocabulary Search - Quick Jump System */

/* Search Container */
.vocab-search-container {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 1;
}

/* Search Input */
.vocab-search-input {
    width: 260px;
    padding: 10px 40px 10px 38px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    font-size: 0.95em;
    font-weight: 500;
    font-family: 'Inter', -apple-system, sans-serif;
    transition: border-color 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(44, 44, 44, 0.05);
}

.vocab-search-input::placeholder {
    color: #767676;
    font-weight: 400;
}

.vocab-search-input:focus {
    width: 320px;
    outline: none;
    border-color: var(--category-primary, #3D5A80);
    box-shadow:
        0 0 0 3px rgba(61, 90, 128, 0.09),
        0 4px 16px rgba(61, 90, 128, 0.12);
    background: rgba(255, 255, 255, 1);
}

/* Search Icon */
.vocab-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.vocab-search-input:focus + .vocab-search-icon {
    opacity: 0.8;
    color: var(--category-primary, #3D5A80);
}

/* Clear Button */
.vocab-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(44, 44, 44, 0.15);
    border: none;
    color: #4a5568;
    font-size: 0.85em;
    font-weight: 700;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
    opacity: 0;
}

.vocab-search-clear:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    transform: translateY(-50%) scale(1.15) rotate(90deg);
}

.vocab-search-clear:active {
    transform: translateY(-50%) scale(0.9);
}

/* Show clear button when input has text */
.vocab-sidebar .vocab-search-input:not(:placeholder-shown) ~ .vocab-search-clear {
    display: flex;
    opacity: 1;
}

/* Search Results Dropdown */
.vocab-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow:
        0 12px 40px rgba(44, 44, 44, 0.12),
        0 4px 12px rgba(44, 44, 44, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    z-index: 2700;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vocab-search-results.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Washi paper texture */
.vocab-search-results::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 4px),
        repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(44, 44, 44, 0.01) 3px, rgba(44, 44, 44, 0.01) 6px);
    opacity: 0.4;
    mix-blend-mode: overlay;
    pointer-events: none;
    border-radius: inherit;
    z-index: 1;
}

/* Category tint overlay */
.vocab-search-results::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--category-primary, #3D5A80);
    opacity: 0.06;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Results list */
.vocab-search-list {
    position: relative;
    z-index: 2;
    padding: 8px;
}

/* Individual result item */
.vocab-search-result {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    animation: resultFadeIn 0.3s ease forwards;
}

@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Staggered animation delay */
.vocab-search-result:nth-child(1) { animation-delay: 0ms; }
.vocab-search-result:nth-child(2) { animation-delay: 50ms; }
.vocab-search-result:nth-child(3) { animation-delay: 100ms; }
.vocab-search-result:nth-child(4) { animation-delay: 150ms; }
.vocab-search-result:nth-child(5) { animation-delay: 200ms; }
.vocab-search-result:nth-child(n+6) { animation-delay: 250ms; }

.vocab-search-result:hover,
.vocab-search-result.selected {
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--category-primary, #3D5A80);
    box-shadow: 0 4px 12px rgba(61, 90, 128, 0.15);
    transform: translateX(4px);
}

.vocab-search-result:active {
    transform: scale(0.98) translateX(4px);
}

/* Result content */
.result-main {
    flex: 1;
    min-width: 0;
}

.result-japanese {
    font-family: 'Klee One', 'Noto Sans JP', sans-serif;
    font-size: 1.3em;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.48);
}

/* Highlight matched characters */
.result-japanese mark,
.result-romanization mark,
.result-english mark {
    background: rgba(61, 90, 128, 0.3);
    color: inherit;
    border-radius: 4px;
    padding: 0 2px;
    font-weight: 700;
}

.result-details {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.9em;
    color: #4a5568;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.result-romanization {
    font-style: italic;
    color: var(--category-primary, #3D5A80);
    font-weight: 500;
}

.result-separator {
    opacity: 0.4;
}

.result-english {
    color: #2d3748;
}

/* Result metadata */
.result-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.result-badge {
    padding: 3px 10px;
    background: rgba(61, 90, 128, 0.12);
    border: 1px solid rgba(61, 90, 128, 0.25);
    border-radius: 10px;
    font-size: 0.75em;
    font-weight: 600;
    color: #4a5568;
    text-transform: lowercase;
    white-space: nowrap;
}

.result-category {
    padding: 3px 10px;
    background: rgba(44, 44, 44, 0.05);
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 500;
    color: #718096;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status indicator (quiz-derived mastery) */
.result-progress {
    display: flex;
    align-items: center;
}

.status-indicator {
    font-size: 0.7em;
    line-height: 1;
}

.status-indicator.status-new {
    color: #9CA3AF;
}

.status-indicator.status-learning {
    color: rgba(194, 130, 114, 0.9);
}

.status-indicator.status-known {
    color: rgba(163, 177, 138, 0.9);
}

/* Legacy quiz-derived classes */
.status-indicator.status-practicing {
    color: rgba(194, 130, 114, 0.9);
}

.status-indicator.status-mastered {
    color: rgba(163, 177, 138, 0.9);
}

/* Empty state */
.vocab-search-empty {
    padding: 40px 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.vocab-search-empty-icon {
    font-size: 3em;
    margin-bottom: 12px;
    opacity: 0.4;
}

.vocab-search-empty-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.95em;
    color: #718096;
    line-height: 1.5;
}

/* Loading state */
.vocab-search-loading {
    padding: 30px 20px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.vocab-search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(61, 90, 128, 0.2);
    border-top-color: var(--category-primary, #3D5A80);
    border-radius: 50%;
    animation: searchSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

/* Keyboard hint */
.vocab-search-hint {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 0.75em;
    color: rgba(44, 44, 44, 0.4);
    background: rgba(44, 44, 44, 0.05);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(44, 44, 44, 0.1);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.vocab-search-input:focus ~ .vocab-search-hint {
    opacity: 0;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .vocab-search-input {
        width: 200px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .vocab-search-input:focus {
        width: 240px;
    }

    .vocab-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 24px 24px 0 0;
        max-height: 60vh;
    }

    .result-japanese {
        font-size: 1.2em;
    }

    .result-details {
        font-size: 0.85em;
    }

    .vocab-search-hint {
        display: none;
    }
}

/* Focus mode specific */
body.focus-mode .vocab-search-container {
    display: none;
}

/* Video mode specific */
body.video-mode .vocab-search-container {
    display: none;
}

/* ========================================
   Recent searches (mobile bottom-sheet empty state)
   ======================================== */

.vocab-search-recent-label {
    font-family: var(--font-ui, 'Inter', sans-serif);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-faint, #948E85);
    padding: 14px 18px 8px;
}

.vocab-search-recent-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 18px;
    cursor: pointer;
    border-bottom: 1px solid rgba(44, 44, 44, 0.04);
    -webkit-tap-highlight-color: transparent;
    transition: background var(--duration-fast, 200ms) ease;
}

.vocab-search-recent-item:active {
    background: rgba(44, 44, 44, 0.03);
}

.vocab-search-recent-item .result-japanese {
    font-family: var(--font-jp, 'Klee One', serif);
    font-size: 18px;
    color: var(--color-ink, #2C2C2C);
}

.vocab-search-recent-item .result-details {
    font-family: var(--font-ui, 'Inter', sans-serif);
    font-size: 13px;
    color: var(--color-faint, #948E85);
}

.vocab-search-recent-item .result-separator {
    margin: 0 6px;
    opacity: 0.6;
}

.vocab-search-recent-empty {
    padding: 32px 20px;
    text-align: center;
    font-family: var(--font-ui, 'Inter', sans-serif);
    font-size: 13px;
    color: var(--color-faint, #948E85);
    line-height: 1.5;
}

/* Scrollbar styling */
.vocab-search-results::-webkit-scrollbar {
    width: 8px;
}

.vocab-search-results::-webkit-scrollbar-track {
    background: rgba(44, 44, 44, 0.05);
    border-radius: 8px;
}

.vocab-search-results::-webkit-scrollbar-thumb {
    background: rgba(61, 90, 128, 0.3);
    border-radius: 8px;
}

.vocab-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(61, 90, 128, 0.5);
}
