
:root {
    --mw-blue: #13265c;
    --mw-accent: #3b82f6;
    --mw-orange: #ef5b25; /* Merriam-Webster style orange */
    --text-main: #1e293b;
    --text-muted: #64748b;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text-main);
    background-color: white;
}

.serif { 
    font-family: 'Playfair Display', Georgia, serif; 
}

/* Navbar - HIGHEST LEVEL */
#top-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    box-shadow: 0 1px 12px rgba(0,0,0,0.03);
    border-bottom: 1px solid #f1f5f9;
    transition: padding 0.3s ease, background 0.3s ease;
    z-index: 2000; /* Absolut øverst */
}

/* Navbar Logo visibility */
#top-nav .serif {
    color: var(--mw-blue);
}

#top-nav #logo-nav {
    opacity: 1; /* Always visible */
    pointer-events: auto;
    transform: translateY(0);
}

/* Header Section - HIGH LEVEL (Contains Search & Autocomplete) */
#main-header {
    position: relative;
    /* Level 500 ensures it sits well above main content (level 10) */
    z-index: 500; 
    transition: padding 0.7s ease-in-out, background 0.7s ease-in-out, min-height 0.7s ease-in-out;
}

#main-header.hero-mode {
    /* Height is now handled by padding in HTML to accommodate wave */
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Hero mode needs overflow hidden to clip the wave SVG */
    overflow: hidden;
}

#main-header:not(.hero-mode) {
    /* Compact header for results */
    padding: 100px 0 20px; 
    border-bottom: 1px solid #f1f5f9;
    background: #13265c; /* Keep blue background even in results */
    min-height: auto;
    /* Result mode needs overflow visible so autocomplete dropdown can go over the section below */
    overflow: visible;
}

/* Hide the wave in results mode to save space */
#main-header:not(.hero-mode) svg, 
#main-header:not(.hero-mode) #popular-tags,
#main-header:not(.hero-mode) h1.logo {
    display: none;
}

/* SEARCH WRAPPER & FORM */
.search-wrapper {
    position: relative;
    z-index: 100; /* Local priority inside header */
}

#search-form {
    position: relative;
    z-index: 100;
}

.search-container-inner {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    z-index: 100;
}

.search-input {
    width: 100%;
    height: 76px;
    padding: 0 140px 0 32px; 
    border: none;
    border-radius: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--mw-blue);
    outline: none;
    transition: all 0.3s;
    background: white;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

#main-header:not(.hero-mode) .search-input {
    height: 62px;
    font-size: 1.05rem;
    padding-right: 140px;
    border-radius: 12px;
}

.search-submit {
    position: absolute;
    right: 8px;
    top: 8px;
    bottom: 8px;
    background: var(--mw-orange); /* Orange button like Thesaurus */
    color: white;
    font-weight: 800;
    padding: 0 32px;
    min-width: 120px;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    white-space: nowrap;
    z-index: 110; /* On top of input */
}

#main-header:not(.hero-mode) .search-submit {
    top: 6px;
    bottom: 6px;
    right: 6px;
    padding: 0 20px;
    min-width: 100px;
    border-radius: 8px;
}

.search-submit:hover {
    background: #d84612;
    transform: translateY(-1px);
}

/* Autocomplete dropdown - MAXIMUM PRIORITY */
#autocomplete-list {
    max-height: 350px;
    overflow-y: auto;
    z-index: 9999; /* Float over EVERYTHING */
    position: absolute;
    width: 100%;
    /* Stronger shadow to separate from content below */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
}
#autocomplete-list .autocomplete-item {
    padding: 14px 24px;
    cursor: pointer;
    font-weight: 600;
    color: var(--mw-blue);
    display: flex;
    align-items: center;
    gap: 12px;
}
#autocomplete-list .autocomplete-item:hover,
#autocomplete-list .autocomplete-active {
    background-color: #f8fafc;
    color: var(--mw-orange); /* Highlight text color slightly */
}

/* Main Content - LOWER PRIORITY */
#main-content {
    position: relative;
    z-index: 10; /* Must be significantly lower than header's 500 */
}

/* Homepage extra visibility */
body:not(.hero-active) #home-extra-content {
    display: none;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #main-header .logo { font-size: 2.5rem; line-height: 1.1; padding: 0 10px; }
    
    .search-input { 
        height: 60px; 
        padding: 0 60px 0 20px !important; 
        font-size: 1rem; 
        border-radius: 12px; 
    }
    
    /* On mobile, use icon to save space */
    .search-submit {
        width: 44px !important;
        min-width: 44px !important;
        right: 8px !important;
        top: 8px !important;
        bottom: 8px !important;
        padding: 0 !important;
        border-radius: 8px !important;
    }
    .btn-text { display: none !important; }
    .mobile-icon { display: block !important; }

    #query-word { font-size: 3rem !important; }
}

/* Loader Animation */
.loader-visual {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spinner {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 5px solid #f1f5f9;
    border-top-color: var(--mw-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Entries & Synonyms - MERRIAM WEBSTER STYLE */
.mw-entry { border-bottom: 1px solid #f1f5f9; }
.mw-entry:last-child { border-bottom: none; }

.mw-syn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 8px; /* Slightly squarer than before to match MW */
    font-weight: 800; /* Bolder text */
    font-size: 1.125rem;
    line-height: 1.2;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    letter-spacing: 0.01em;
}

/* Best matches - High Contrast Orange */
.tag-best { 
    background-color: var(--mw-orange); 
    color: white; 
    box-shadow: 0 3px 0 #c2410b; /* 3D depth */
    margin-bottom: 4px; /* Space for shadow */
}
.tag-best:hover {
    background-color: #d84612;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #c2410b;
}
.tag-best:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #c2410b;
}

/* Related matches - Lighter/Softer */
.tag-related { 
    background-color: #fff1eb; /* Very light orange tint */
    color: #c2410b; 
    border: 1px solid #fdba74;
    font-weight: 700;
}
.tag-related:hover {
    background-color: #ffedd5;
    border-color: #fb923c;
}

/* Weak matches */
.tag-weak { 
    background-color: white; 
    color: #64748b; 
    border: 1px solid #e2e8f0; 
    font-weight: 600;
    font-size: 1rem;
}
.tag-weak:hover {
    border-color: #cbd5e1;
    color: #475569;
}

/* Compact Feedback Buttons - ENHANCED */
.feedback-compact-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px; /* Pill shape */
    background-color: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.feedback-compact-btn svg {
    transition: transform 0.2s;
}

.feedback-compact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: #94a3b8;
    color: #1e293b;
}

.feedback-compact-btn:active {
    transform: translateY(0);
}

/* Active Up - Solid Green for clear success state */
.feedback-compact-btn.active-up {
    background-color: #22c55e;
    border-color: #16a34a;
    color: white;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
    pointer-events: none; /* Prevent double voting */
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Active Down - Solid Red/Orange for clear distinct state */
.feedback-compact-btn.active-down {
    background-color: #ef5b25; /* Using brand orange/red */
    border-color: #ea580c;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 91, 37, 0.35);
    pointer-events: none;
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.animate-fade-in { animation: fadeIn 0.5s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* SHARE BUTTON - STEALTH MODE */
.share-btn {
    background: transparent;
    border: none;
    color: #e2e8f0; /* Nearly invisible default */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 6px;
    border-radius: 50%;
    /* Flex alignment fix */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Reveal when parent container (the header) is hovered */
#results-header:hover .share-btn {
    color: #cbd5e1; /* Visible light gray on parent hover */
}

/* Distinct hover state for button itself */
.share-btn:hover {
    background: #eff6ff;
    color: var(--mw-accent) !important; /* Force blue on direct hover */
    transform: scale(1.1);
}

.share-tooltip {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 3000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.share-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ABOUT MODAL ANIMATIONS */
#about-modal.hidden {
    display: none;
}

/* Backdrop Fade */
#about-modal:not(.hidden) #about-backdrop {
    opacity: 1;
}

/* Content Slide */
#about-modal:not(.hidden) #about-content {
    transform: translateX(0);
}
