/* ═══════════════════════════════════════════════════════════════════════════════
   Spotlight Search - Global "Search All" Modal
   Beautiful animated gradient border using mode colors
   ═══════════════════════════════════════════════════════════════════════════════ */

/* CSS Custom Property for animated gradient angle */
@property --spotlight-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Overlay / Backdrop
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.spotlight-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Container with Animated Gradient Border
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-container {
    --spotlight-angle: 0deg;
    position: relative;
    width: 100%;
    max-width: 64rem; /* max-w-5xl, matches detail modal */
    max-height: 92vh;
    border-radius: 1rem;
    
    /* Animated conic gradient as the "border" */
    background: conic-gradient(
        from var(--spotlight-angle),
        #3B82F6,  /* Kanji - Blue */
        #10B981,  /* Vocab - Green */
        #FACC15,  /* Grammar - Yellow */
        #EC4899,  /* Names - Pink */
        #2DD4BF,  /* Sentences - Teal */
        #C084FC,  /* Radicals - Purple */
        #3B82F6   /* Back to Blue for seamless loop */
    );
    padding: 2px;
    animation: spotlight-gradient-rotate 8s linear infinite;
    
    /* Entry animation */
    transform: scale(0.96) translateY(10px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.spotlight-overlay.open .spotlight-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

@keyframes spotlight-gradient-rotate {
    to {
        --spotlight-angle: 360deg;
    }
}

/* Fallback for browsers without @property support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .spotlight-container {
        background: linear-gradient(
            135deg,
            #3B82F6, #10B981, #FACC15, #EC4899, #2DD4BF, #C084FC
        );
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Inner Content Panel
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-inner {
    background: var(--color-bg-secondary, #1a1a1f);
    border-radius: calc(1rem - 2px);
    display: flex;
    flex-direction: column;
    max-height: calc(92vh - 4px);
    overflow: hidden;
}

/* Light theme */
.light .spotlight-inner {
    background: var(--color-bg-secondary, #ffffff);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Header / Search Input Area
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
}

.spotlight-search-icon {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-text-primary, #fff);
    caret-color: var(--color-accent, #3B82F6);
}

.spotlight-input::placeholder {
    color: var(--color-text-muted, #6b7280);
    font-weight: 400;
}

.spotlight-close-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.spotlight-close-btn:hover {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
    color: var(--color-text-primary, #fff);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Results Area
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    min-height: 200px;
    max-height: 60vh;
}

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

.spotlight-results::-webkit-scrollbar-track {
    background: transparent;
}

.spotlight-results::-webkit-scrollbar-thumb {
    background: var(--color-border, rgba(255, 255, 255, 0.15));
    border-radius: 4px;
}

.spotlight-results::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, rgba(255, 255, 255, 0.25));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Result Row
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-result {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s, border-color 0.1s;
}

.spotlight-result:hover {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.05));
}

.spotlight-result.selected {
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.08));
    border-left-color: var(--result-mode-color, var(--color-accent));
}

/* Unactivated/catalog items (not yet added to study list) */
.spotlight-result-unactivated {
    opacity: 0.7;
}

.spotlight-result-unactivated:hover,
.spotlight-result-unactivated.selected {
    opacity: 1;
}

.spotlight-result-unactivated .spotlight-result-icon {
    opacity: 0.8;
}

/* Mode icon badge */
.spotlight-result-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--result-mode-color, var(--color-accent));
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Display text (kanji/word) */
.spotlight-result-display {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary, #fff);
    min-width: 3rem;
}

/* Separator */
.spotlight-result-sep {
    color: var(--color-text-muted, #6b7280);
    font-size: 0.875rem;
}

/* Meaning text */
.spotlight-result-meaning {
    font-size: 0.9375rem;
    color: var(--color-text-secondary, #9ca3af);
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Kana reading - flows naturally after meaning */
.spotlight-result-reading {
    flex-shrink: 0;
    font-size: 0.875rem;
    color: var(--color-text-muted, #6b7280);
    opacity: 0.7;
}

/* Separator between primary and variant readings */
.spotlight-reading-sep {
    margin: 0 0.25rem;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Pitch Accent Display (in reading)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Container for pitch-annotated reading */
.spotlight-pitch {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    padding-top: 4px; /* space for overline */
}

/* Individual mora */
.spotlight-pitch .sp-m {
    position: relative;
    color: var(--color-text-muted, #6b7280);
}

/* High pitch mora - green overline indicator */
.spotlight-pitch .sp-m.h {
    color: var(--color-text-secondary, #9ca3af);
}

.spotlight-pitch .sp-m.h::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 2px;
    background: #22c55e; /* green-500 */
    border-radius: 1px;
}

/* Downstep marker (ꜜ) - orange accent */
.spotlight-pitch .sp-d {
    color: #f97316; /* orange-500 */
    font-size: 0.7em;
    font-weight: 700;
    margin: 0 1px;
    line-height: 1;
    vertical-align: middle;
}

/* Accent number badge */
.spotlight-pitch .sp-n {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.6rem;
    font-weight: 600;
    color: #f97316; /* orange-500 */
    background: rgba(249, 115, 22, 0.15);
    padding: 0.0625rem 0.25rem;
    border-radius: 3px;
    margin-left: 0.375rem;
    vertical-align: middle;
}

/* Light theme adjustments for pitch accent */
.light .spotlight-pitch .sp-m.h::after {
    background: #16a34a; /* green-600 for better contrast */
}

.light .spotlight-pitch .sp-d {
    color: #ea580c; /* orange-600 */
}

.light .spotlight-pitch .sp-n {
    color: #ea580c; /* orange-600 */
    background: rgba(234, 88, 12, 0.12);
}

/* Mode label - pushed to far right */
.spotlight-result-mode {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--result-mode-color, var(--color-accent));
    opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Empty / Initial State
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    opacity: 0.7;
}

.spotlight-empty-icon svg {
    width: 100%;
    height: 100%;
}

/* Animated shine sweep on search icon lens */
.spotlight-empty-icon .search-shine {
    opacity: 0;
    animation: search-shine-sweep 3s ease-in-out infinite;
    animation-delay: 1s;
}

@keyframes search-shine-sweep {
    0%, 100% {
        transform: translateX(-20px) translateY(-20px);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        transform: translateX(20px) translateY(20px);
        opacity: 0;
    }
    51%, 99% {
        opacity: 0;
    }
}

.spotlight-empty-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--color-text-secondary, #9ca3af);
}

.spotlight-empty-subtitle {
    font-size: 0.875rem;
}

/* Wildcard example chips */
.spotlight-examples {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.875rem;
}

.spotlight-example {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    font-family: inherit;
    color: var(--color-text-muted, #9ca3af);
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
    border-radius: 9999px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    user-select: none;
}

.spotlight-example:hover,
.spotlight-example:focus-visible {
    color: var(--color-text-secondary, #d1d5db);
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Footer / Keyboard Hints
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
}

.spotlight-hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.spotlight-hint kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
    font-family: inherit;
    font-weight: 500;
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
    border-radius: 0.25rem;
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.15));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Search Bar Actions Wrapper (Clear + Pill)
   Contains the clear button and spotlight pill together
   ═══════════════════════════════════════════════════════════════════════════════ */

.search-actions-wrapper {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted, #6b7280);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s, color 0.15s, background 0.15s;
}

.search-clear-btn.visible {
    opacity: 1;
    visibility: visible;
}

.search-clear-btn:hover {
    color: var(--color-text-primary, #fff);
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.1));
}

.search-clear-btn svg {
    width: 0.75rem;
    height: 0.75rem;
}

/* Light theme */
.light .search-clear-btn:hover {
    color: var(--color-text-primary, #111);
    background: var(--color-bg-tertiary, rgba(0, 0, 0, 0.08));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Search Bar Hint Pill (in main search input)
   Animated gradient border matching the spotlight modal exactly
   ═══════════════════════════════════════════════════════════════════════════════ */

/* CSS Custom Property for pill gradient animation */
@property --pill-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* Outer wrapper - the gradient IS the background (like .spotlight-container) */
.spotlight-trigger-pill {
    --pill-angle: 0deg;
    position: relative;
    isolation: isolate; /* Contain z-index stacking context for ::before */
    display: flex;
    align-items: center;
    /* Padding includes 1px for border + content spacing */
    padding: calc(0.25rem + 1px) calc(0.625rem + 1px);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted, #6b7280);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    
    /* Animated conic gradient as the "border" - exactly like spotlight */
    background: conic-gradient(
        from var(--pill-angle),
        #3B82F6,  /* Kanji - Blue */
        #10B981,  /* Vocab - Green */
        #FACC15,  /* Grammar - Yellow */
        #EC4899,  /* Names - Pink */
        #2DD4BF,  /* Sentences - Teal */
        #C084FC,  /* Radicals - Purple */
        #3B82F6   /* Back to Blue for seamless loop */
    );
    animation: pill-gradient-rotate 6s linear infinite;
}

/* Inner solid background - covers the gradient, leaving 1px border visible */
/* Using ::after to avoid any conflicts with other ::before rules */
.spotlight-trigger-pill::after {
    content: '' !important;
    position: absolute !important;
    inset: 1px !important;
    background: #1a1a1f !important;
    border-radius: calc(0.375rem - 1px) !important;
    z-index: 1 !important;
    transition: background 0.15s !important;
    pointer-events: none !important;
}

/* Content wrapper must be above ::after */
.spotlight-pill-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

@keyframes pill-gradient-rotate {
    to {
        --pill-angle: 360deg;
    }
}

/* Fallback for browsers without @property support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .spotlight-trigger-pill {
        background: linear-gradient(
            135deg,
            #3B82F6, #10B981, #FACC15, #EC4899, #2DD4BF, #C084FC
        );
    }
}

.spotlight-trigger-pill:hover {
    color: var(--color-text-secondary, #9ca3af);
}

.spotlight-trigger-pill:hover::after {
    background: #252529 !important;
}

.spotlight-trigger-pill kbd {
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.25rem;
    background: var(--color-bg-primary, rgba(0, 0, 0, 0.3));
    border-radius: 0.1875rem;
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
}

/* Light theme adjustments */
.light .spotlight-trigger-pill::after {
    background: #ffffff !important;
}

.light .spotlight-trigger-pill:hover::after {
    background: #f5f5f5 !important;
}

.light .spotlight-trigger-pill kbd {
    background: var(--color-bg-primary, rgba(0, 0, 0, 0.08));
    border-color: var(--color-border, rgba(0, 0, 0, 0.1));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Results Count
   ═══════════════════════════════════════════════════════════════════════════════ */

.spotlight-results-count {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted, #6b7280);
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.05));
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .spotlight-overlay {
        padding: 0.5rem;
    }
    
    .spotlight-container {
        max-height: 95vh;
    }
    
    .spotlight-inner {
        max-height: calc(95vh - 4px);
    }
    
    .spotlight-header {
        padding: 1rem;
    }
    
    .spotlight-input {
        font-size: 1.125rem;
    }
    
    .spotlight-results {
        max-height: 55vh;
    }
    
    .spotlight-result {
        padding: 0.625rem 0.75rem;
        gap: 0.625rem;
    }
    
    .spotlight-result-display {
        font-size: 1.125rem;
    }
    
    .spotlight-footer {
        gap: 1rem;
        padding: 0.625rem 1rem;
    }
    
    .spotlight-hint:not(:first-child) {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Fortress Search - Section Headers & Loading States
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Section headers for "Your Library" and "Dictionary" */
.spotlight-section-header {
    padding: 0.5rem 1rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted, #6b7280);
    background: var(--color-bg-tertiary, rgba(255, 255, 255, 0.03));
    border-bottom: 1px solid var(--color-border, rgba(255, 255, 255, 0.05));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Dictionary section has a purple accent */
.spotlight-section-fortress {
    color: #A78BFA;
}

/* Loading spinner in section header */
.spotlight-section-loading {
    display: flex;
    align-items: center;
}

.spotlight-spinner-small {
    width: 0.875rem;
    height: 0.875rem;
    color: #A78BFA;
    animation: spotlight-spin 1s linear infinite;
}

/* Fortress results have a slightly different style */
.spotlight-result-fortress {
    opacity: 0.9;
}

/* Push dictionary label to right (no meaning span to flex-push it) */
.spotlight-result-fortress .spotlight-result-mode {
    margin-left: auto;
}

.spotlight-result-fortress:hover {
    opacity: 1;
}

/* Large loading spinner for empty state */
.spotlight-loading-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spotlight-spinner {
    width: 3rem;
    height: 3rem;
    color: #A78BFA;
    animation: spotlight-spin 1s linear infinite;
}

@keyframes spotlight-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Light theme adjustments for fortress */
.light .spotlight-section-header {
    background: var(--color-bg-tertiary, rgba(0, 0, 0, 0.03));
}

.light .spotlight-section-fortress {
    color: #7C3AED;
}

.light .spotlight-spinner,
.light .spotlight-spinner-small {
    color: #7C3AED;
}

