/* /css/header.css */

/* NEW: Top Announcement Bar Styles (REVISED) */
.top-announcement-bar {
    background-color: #E2E8F0; /* A very light gray, close to border-color but distinct */
    color: var(--text-light-color); /* Light text color for contrast */
    text-align: center;
    padding: 0.3rem 2%; /* More compact vertical padding */
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2; /* Tighter line height for single line */
    position: fixed; /* FIXED so it always stays at the top */
    top: 0;
    left: 0;
    width: 100%; /* Ensure it spans full width */
    z-index: 1001; /* Above main header */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Subtle shadow */
    display: flex; /* Use flexbox for centering content */
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Hide overflow if text is too long */
    white-space: nowrap; /* Keep text on a single line */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
    margin-bottom: 0; /* ENSURE no margin below top bar */
    border-bottom: none;
}

/* Adjust padding for the paragraph inside if needed */
.top-announcement-bar p {
    margin: 0; /* ENSURE no margin on the paragraph */
    padding: 0;
    max-width: 100%; /* Allow it to shrink on small screens */
    flex-shrink: 1; /* Allow it to shrink if needed */
}

.site-header {
    padding: 0 5%; /* Adjusted padding, internal elements will control actual height */
    display: flex;
    flex-direction: column; /* Stack top-row, tagline, nav vertically */
    align-items: center; /* Center items horizontally within the column */
    position: fixed;
    top: calc(var(--top-announcement-bar-height) - 2px);
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    z-index: 1000;
    transition: background-color 0.3s ease, border-bottom 0.3s ease, box-shadow 0.3s ease;
    border-top: none;
    padding-top: 0.75rem; /* Top padding for the header content */
    padding-bottom: 0; /* No explicit bottom padding here, nav will provide its own */
}

/* This is the new "scrolled" state */
.site-header.scrolled {
    border-bottom: 1px solid var(--border-color); /* */
    box-shadow: 0 2px 4px var(--shadow-color); /* */
}

/* NEW: Header Top Row to contain desktop trigger, logo, and mobile trigger */
.header-top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* Allows absolute positioning of children within this row */
    /* REMOVED padding-bottom here, tagline below will have its own margin */
}

/* --- Updated Logo Styles --- */
.logo {
    display: flex;
    align-items: center;
    margin: 0 auto; /* Center logo in the middle of header-top-row */
    /* On mobile, this will cause the logo to be centered initially,
       but when header-top-row is flex (row), it will be on the left due to content */
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.2s ease;
}

.logo-link:hover {
    color: var(--secondary-color);
}

.logo-link .logo-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.logo-text-wrapper {
    display: flex;
    flex-direction: column; /* Stacks Samrakshaka and tagline vertically */
    align-items: flex-start; /* Aligns text to the left within its column */
    line-height: 1; /* Tighter line height for the block */
}

.logo-text-wrapper span:first-child {
    font-family: 'Oxanium', sans-serif; /* Changed font to Oxanium */
    font-size: 1.6rem; /* Increased from 1.5rem to 1.6rem for slightly more height */
    font-weight: 700; /* Kept bold for prominence */
    letter-spacing: -0.5px;
    line-height: 1;
}

.logo-tagline { /* NOW INSIDE .logo-text-wrapper */
    font-family: 'Dancing Script', cursive;
    font-size: 0.75rem;
    color: var(--text-light-color);
    margin-top: 0.1rem; /* Small gap from main text */
    line-height: 1;
    letter-spacing: 0.2px;
    white-space: nowrap;
    text-align: left; /* Align tagline with "Samrakshaka" text */
    /* REMOVED display: block; or any mobile-specific overrides from here */
}

/* NEW: Desktop Menu/Search Trigger (positioned absolutely within header-top-row) */
.desktop-menu-search-trigger {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.2s ease, transform 0.2s ease;
    position: absolute; /* Position absolutely relative to .header-top-row */
    top: 50%; /* Center vertically */
    left: 0; /* Align to the left edge of .header-top-row */
    transform: translateY(-50%); /* Adjust for vertical centering */
    z-index: 1010; /* Ensure it's above other header elements */
}

.desktop-menu-search-trigger:hover {
    color: var(--secondary-color);
    transform: translateY(-50%) scale(1.1);
}

.desktop-menu-search-trigger .menu-search-icon {
    width: 28px;
    height: 28px;
}

/* --- Mobile Header Action Buttons (Combined Menu/Search icon) --- */
.mobile-header-actions {
    display: none; /* Hidden on desktop, shown on mobile via media query */
    align-items: center;
    gap: 0.75rem;
    position: absolute; /* Position absolutely relative to .header-top-row */
    top: 50%; /* Center vertically */
    right: 0; /* Align to the right edge of .header-top-row */
    transform: translateY(-50%); /* Adjust for vertical centering */
    z-index: 1010; /* Ensure it's above other header elements */
}

.mobile-action-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.mobile-action-btn:hover {
    color: var(--secondary-color);
    transform: scale(1.1);
}

.mobile-action-btn .menu-search-icon {
    width: 36px;
    height: 36px;
    margin-top: 3.5rem;
}

/* NEW: Desktop Main Navigation (brought back and styled) */
.main-nav {
    display: flex;
    gap: 1.5rem;
    justify-content: center; /* Center nav links */
    width: 100%; /* Take full width of header */
    margin-top: 0.75rem; /* Space below tagline */
    padding-bottom: 0.75rem; /* Padding below nav links */
    position: relative; /* For mega-menu positioning */
    z-index: 998; /* Ensure nav links are below header, but above content */
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 0;
    color: var(--text-light-color);
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative; 
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.nav-link:hover {
    color: var(--secondary-color);
}

.nav-link.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
    font-weight: 600;
}

/* Arrow icon for nav-links with mega-menus */
.nav-link[data-category]:not([data-category="favorites"])::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-light-color); /* Down arrow */
    margin-top: 2px;
    transition: transform 0.2s ease, border-top-color 0.2s ease;
}

.nav-link[data-category]:not([data-category="favorites"]):hover::after {
    transform: rotate(180deg);
    border-top-color: var(--secondary-color);
}

/* --- NEW: Desktop Menu/Search Overlay (now with reduced width and slide-in) --- */
.fullscreen-menu-search-overlay {
    position: fixed;
    top: 0;
    left: 0; /* Aligned to the left */
    width: 350px; /* Approximately 1/4 to 1/3 of typical desktop screen */
    height: 100%;
    background-color: var(--surface-color);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1); /* Shadow on the right side */
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-100%); /* Slide in from left */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.fullscreen-menu-search-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0); /* Slide into view */
}

.overlay-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 4%; /* Adjusted padding to match mobile header */
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent header from shrinking */
    background-color: var(--surface-color); /* Ensure it has a background */
}

.overlay-header .social-links {
    display: flex;
    gap: 0.75rem; /* Reduced gap */
}

.overlay-header .social-links a {
    color: var(--primary-color);
    transition: color 0.2s ease, transform 0.2s ease;
}

.overlay-header .social-links a:hover {
    color: var(--secondary-color);
    transform: scale(1.1);
}

.overlay-header .social-links svg {
    width: 24px; /* Slightly smaller icons */
    height: 24px;
}

.close-overlay-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-light-color);
    transition: color 0.2s ease;
}

.close-overlay-btn:hover {
    color: var(--primary-color);
}

.close-overlay-btn svg {
    width: 28px; /* Adjusted size */
    height: 28px;
}

.overlay-content {
    width: 100%;
    padding: 2rem 5%; /* Adjusted padding for narrower overlay to match mobile */
    overflow-y: auto;
    flex-grow: 1;
    display: block; /* Ensure content flows naturally */
}

.subscribe-link {
    display: block;
    text-align: center;
    padding: 0.8rem 1.5rem; /* Adjusted padding for narrower panel */
    background-color: var(--secondary-color);
    color: white; /* Changed text color to white for contrast */
    font-weight: 600;
    border-radius: 30px;
    margin-bottom: 1.5rem; /* Adjusted margin */
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.subscribe-link:hover {
    background-color: #dd9b4d;
    transform: translateY(-2px);
}

.overlay-separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0; /* Adjusted margin for narrower panel */
}

.overlay-search-container {
    margin-bottom: 1.5rem; /* Adjusted margin for narrower panel */
    position: relative;
}

.overlay-search-container input {
    width: 100%;
    padding: 0.8rem 1rem; /* Adjusted padding for smaller input */
     border-radius: 4px; /* Changed from 20px to 4px for a square look */
    border: 1px solid var(--border-color); /* Adjusted border */
    font-size: 1rem; /* Adjusted font size */
    text-align: left; /* Align placeholder to left again */
    transition: all 0.3s ease;
}

.overlay-search-container input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(209, 158, 93, 0.2); /* Adjusted shadow */
}

.search-results-dropdown {
    position: absolute; /* Revert to absolute positioning for search results */
    top: calc(100% + 5px); /* Position below the search input, add small gap */
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 16px var(--shadow-color);
    z-index: 999; /* Ensure it's above other content but below overlay header */
    max-height: 200px; /* Limit height */
    overflow-y: auto;
    display: none; /* Hidden by default */
}

.search-results-dropdown.visible {
    display: block;
}

.result-item {
    display: block;
    padding: 0.75rem 1rem; /* Adjusted padding */
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover {
    background-color: var(--background-color);
    color: var(--secondary-color);
}

.result-item .category {
    font-size: 0.7rem; /* Adjusted font size */
    text-transform: uppercase;
    color: var(--text-light-color);
    margin-left: 0.5rem;
}

.empty-search-results {
    padding: 1rem; /* Adjusted padding */
    text-align: center;
    color: var(--text-light-color);
    font-style: italic;
    font-size: 0.9rem;
}

/* Sort select within the overlay */
.overlay-search-container .sort-container {
    margin-top: 1rem;
    position: relative; /* For sort select styling */
}
.overlay-search-container #desktopOverlaySortSelect {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    font-size: 0.9rem;
    color: var(--text-color);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    cursor: pointer;
}


/* NEW: Desktop Overlay Navigation Content (to mimic mobile-main-nav and sub-menus) */
.overlay-nav-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0; /* Handled by .overlay-content parent */
    align-items: flex-start;
}

/* Style for direct navigation links within desktop overlay (Home, Favorites) */
.overlay-nav-link {
    display: block;
    width: 100%;
    padding: 1rem 0; /* Match mobile-nav-link padding */
    color: var(--text-color);
    font-size: 1.3rem; /* Match mobile font size */
    font-weight: 500;
    text-decoration: none;
    text-align: left;
    transition: all 0.2s ease, background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.overlay-nav-link:last-child {
    border-bottom: none;
}

.overlay-nav-link:hover {
    background-color: var(--background-color);
    color: var(--secondary-color);
}

/* Styles for category sections within the desktop overlay (mimicking mobile sub-menus) */
.overlay-nav-category-section {
    width: 100%;
    padding-top: 1rem; /* Match mobile sub-menu padding */
    padding-bottom: 1rem; /* Match mobile sub-menu padding */
    margin-top: 0;
    border-bottom: 1px solid var(--border-color); /* Add border for separation */
}

.overlay-nav-category-section:last-of-type {
    border-bottom: none; /* No border for the last section */
}

.overlay-nav-category-title {
    font-family: var(--font-body); /* Match mobile sub-menu title font */
    font-size: 1.3rem; /* Match mobile sub-menu title font size */
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 1rem; /* Space below title */
    padding-bottom: 0.5rem; /* Match mobile sub-menu title padding */
    border-bottom: 1px solid var(--border-color); /* Match mobile sub-menu title border */
    display: block; /* Ensure it takes full width */
}

/* Tag grid within overlay sections (mimics mobile-tag-grid) */
.overlay-tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Responsive tag grid */
    gap: 0.75rem 0.5rem; /* Match mobile tag grid gap */
    padding: 0;
    margin-bottom: 1.5rem; /* Space below tags */
}

/* Tag pill styles from content.css are universal and will apply */
.overlay-tags-grid .tag-pill {
    font-size: 0.8rem; /* Smaller font */
    padding: 0.3rem 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

/* Separator within category sections */
.overlay-sub-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 1rem 0; /* Match mobile sub-menu separator */
}

/* Articles list within overlay sections (mimics mobile-articles-list) */
.overlay-articles-list {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Match mobile articles list gap */
    padding: 0;
}

/* Overlay article card (mimics mobile-article-card) */
.overlay-article-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s ease;
    padding: 0.5rem;
    border-radius: 4px;
}

.overlay-article-card:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.overlay-article-card-image {
    width: 60px; /* Match mobile-article-card image size */
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.overlay-article-card-content {
    flex-grow: 1;
}

.overlay-article-card-title {
    font-family: var(--font-body);
    font-size: 0.9rem; /* Match mobile-article-card title font size */
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-article-card-date {
    font-size: 0.75rem; /* Match mobile-article-card date font size */
    color: var(--text-light-color);
}

/* --- Desktop Mega Menu Styles (Re-enabled and styled here) --- */
/* The .nav-link already has position: relative;  */

.mega-menu {
    display: none; /* Hidden by default */
    position: absolute; /* Position relative to the parent nav-link */
    left: 50%; /* Center relative to nav-link */
    transform: translateX(-50%); /* Adjust to truly center */
    top: calc(100% + 15px); /* Position below the nav link with a gap */
    
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem; /* Adjusted padding */
    z-index: 997; /* Below site-header (1000), above content */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, top 0.3s ease;
    
    display: grid;
    grid-template-columns: 1fr auto 1.5fr; /* Tags | Separator | Articles */
    gap: 1.5rem; /* Reduced gap between sections */
    align-items: flex-start;
    min-width: 1000px; /* Your preferred width */
}

/* Show mega-menu on hover of parent nav-link */
.nav-link:hover > .mega-menu {
    display: grid;
    opacity: 1;
    visibility: visible;
    top: calc(100% + 5px); /* Move closer on hover */
}

/* Mega-menu sections */
.mega-menu-section {
    display: flex;
    flex-direction: column;
}

.mega-menu-title {
    font-family: var(--font-heading);
    font-size: 1.1rem; /* Smaller title */
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem; /* Reduced margin */
    padding-bottom: 0.3rem; /* Reduced padding */
    border-bottom: 1px solid var(--border-color); /* Lighter border */
}

/* Mega-menu tag list */
.mega-menu-tags-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem; /* Reduced gap */
}

.mega-menu-tags-grid .tag-pill {
    font-size: 0.8rem; /* Smaller font */
    padding: 0.3rem 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mega-menu article list */
.mega-menu-articles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem; /* Reduced gap */
}

.mega-menu-article-card {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s ease, background-color 0.2s ease;
    padding: 0.5rem;
    border-radius: 4px;
}

.mega-menu-article-card:hover {
    color: var(--secondary-color);
    background-color: var(--background-color);
}

.mega-menu-article-card-image {
    width: 60px; /* Smaller image */
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.mega-menu-article-card-content {
    flex-grow: 1;
}

.mega-menu-article-card-title {
    font-family: var(--font-body);
    font-size: 0.9rem; /* Smaller title */
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mega-menu-article-card-date {
    font-size: 0.7rem; /* Smaller date */
    color: var(--text-light-color);
}

/* Pipe separator */
.mega-menu-separator {
    width: 1px;
    background-color: var(--border-color);
    align-self: stretch;
    margin: 0 1rem;
}

/* Hide desktop specific trigger on mobile */
@media (max-width: 992px) {
    .desktop-menu-search-trigger {
        display: none;
    }
}
/* Hide mobile specific trigger on desktop */
@media (min-width: 993px) {
    .mobile-header-actions {
        display: none !important;
    }
    .mobile-menu-overlay {
        display: none !important;
    }
}