/* ========================================
   Premium Vocabulary Panel - Left Slide-In
   ======================================== */

/* Backdrop (very subtle, allows card visibility) */
.vocab-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    z-index: 1499;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.vocab-panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Main Panel Container - Light Gray Frosted Glass */
.vocab-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    background: linear-gradient(
        180deg,
        rgba(245, 245, 247, 0.92) 0%,
        rgba(240, 240, 242, 0.90) 100%
    );
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
    z-index: 1500;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    color: #1d1d1f;
}

.vocab-panel.open {
    transform: translateX(0);
}

/* ========================================
   Panel Header with Search
   ======================================== */
.panel-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.4);
}

.panel-search {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.panel-search:focus-within {
    border-color: #6366f1;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.panel-search-icon {
    font-size: 1.2rem;
    color: #86868b;
}

.panel-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #1d1d1f;
    font-size: 1.1rem;
    font-weight: 500;
    outline: none;
    font-family: inherit;
}

.panel-search-input::placeholder {
    color: #86868b;
}

.panel-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #86868b;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.panel-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ========================================
   Panel Content (Scrollable Results)
   ======================================== */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ========================================
   Result Items - Refined Light Theme
   ======================================== */
.vocab-panel .vocab-search-result,
.panel-result {
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.025);
    border: 1px solid rgba(0, 0, 0, 0.03);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    animation: panelResultFadeIn 0.25s ease forwards;
}

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

/* Staggered animation */
.vocab-panel .vocab-search-result:nth-child(1) { animation-delay: 0ms; }
.vocab-panel .vocab-search-result:nth-child(2) { animation-delay: 30ms; }
.vocab-panel .vocab-search-result:nth-child(3) { animation-delay: 60ms; }
.vocab-panel .vocab-search-result:nth-child(4) { animation-delay: 90ms; }
.vocab-panel .vocab-search-result:nth-child(5) { animation-delay: 120ms; }
.vocab-panel .vocab-search-result:nth-child(n+6) { animation-delay: 150ms; }

.vocab-panel .vocab-search-result:hover,
.vocab-panel .vocab-search-result.selected {
    background: rgba(0, 0, 0, 0.045);
    border-color: rgba(0, 0, 0, 0.06);
    transform: translateX(3px);
}

/* Previewing state - subtle accent tint */
.vocab-panel .vocab-search-result.previewing {
    border-left: 3px solid #6366f1;
    background: rgba(99, 102, 241, 0.06);
    padding-left: 13px; /* Compensate for border */
}

.vocab-panel .vocab-search-result:active {
    transform: scale(0.99) translateX(3px);
    background: rgba(0, 0, 0, 0.06);
}

/* Text Hierarchy - Refined Light Theme
   Japanese: Primary (black) - the word to learn
   Romanization: Accent (indigo) - pronunciation aid
   English: Secondary (dark gray) - the meaning
   Meta: Tertiary (medium gray) - supplementary info
*/
.vocab-panel .result-japanese {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1.4em;
    font-weight: 600;
    color: #000000;
    margin-bottom: 5px;
    letter-spacing: 0.01em;
}

.vocab-panel .result-details {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.88em;
    color: #6e6e73;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.vocab-panel .result-romanization {
    font-style: italic;
    color: #6366f1;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.vocab-panel .result-separator {
    color: #c7c7cc;
    font-weight: 300;
}

.vocab-panel .result-english {
    color: #3a3a3c;
    font-weight: 450;
}

/* Highlight matches - subtle indigo underline effect */
.vocab-panel .result-japanese mark,
.vocab-panel .result-romanization mark,
.vocab-panel .result-english mark {
    background: rgba(99, 102, 241, 0.12);
    color: inherit;
    border-radius: 3px;
    padding: 1px 4px;
    margin: 0 -1px;
}

/* Part of speech badge - refined pill */
.vocab-panel .result-badge {
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.08);
    border: none;
    border-radius: 6px;
    font-size: 0.72em;
    font-weight: 600;
    color: #6366f1;
    text-transform: lowercase;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Category tag - muted neutral */
.vocab-panel .result-category {
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.035);
    border-radius: 6px;
    font-size: 0.68em;
    font-weight: 500;
    color: #8e8e93;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

/* Progress dots */
.vocab-panel .progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.12);
}

.vocab-panel .progress-dot.known {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.vocab-panel .progress-dot.learning {
    background: #f97316;
    box-shadow: 0 0 4px rgba(249, 115, 22, 0.4);
}

/* ========================================
   Empty & Loading States
   ======================================== */
.vocab-panel .vocab-search-empty,
.vocab-panel .vocab-search-loading {
    padding: 40px 20px;
    text-align: center;
}

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

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

.vocab-panel .vocab-search-empty-text strong {
    color: #1d1d1f;
}

.vocab-panel .vocab-search-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(99, 102, 241, 0.12);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: panelSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* ========================================
   Panel Footer (Keyboard Hints)
   ======================================== */
.panel-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.5);
}

.panel-hint {
    font-size: 0.75rem;
    color: #86868b;
    font-weight: 500;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* ========================================
   Card Preview Mode Styling
   Clean preview - no border or badge, just smooth content swap
   ======================================== */
.flashcard.preview-mode {
    /* No visual indicators - seamless preview */
    transition: none;
}

/* ========================================
   Mobile: Bottom Sheet
   ======================================== */
@media (max-width: 768px) {
    .vocab-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border-right: none;
        border-top: none;
        transform: translateY(100%);
        box-shadow: none;
        /* Safe area padding for notched phones */
        padding-top: env(safe-area-inset-top, 0);
    }

    .vocab-panel.open {
        transform: translateY(0);
    }

    /* Header adjustments for full-screen */
    .vocab-panel .panel-header {
        padding: 16px 20px;
        padding-top: calc(16px + env(safe-area-inset-top, 0));
    }

    /* No drag handle needed for full-screen */
    .panel-header::before {
        display: none;
    }

    .panel-search-input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .panel-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    /* Larger touch targets for results */
    .vocab-panel .vocab-search-result {
        padding: 16px 18px;
    }
}

/* ========================================
   Hide in Video Mode Only (Focus Mode Allowed)
   ======================================== */
body.video-mode .vocab-panel,
body.video-mode .vocab-panel-backdrop {
    display: none !important;
}

/* ========================================
   Slide Branding Out When Panel Opens
   ======================================== */
body.vocab-panel-open .app-branding-topleft {
    transform: translateX(-120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
}

/* Hide old search modal elements when panel is active */
body:has(.vocab-panel) .search-modal,
body:has(.vocab-panel) .search-modal-overlay {
    display: none !important;
}
