/*
 * ============================================================
 *  ParsCoders Theme — Custom CSS Overrides
 * ============================================================
 *
 *  This file contains hand-written CSS that cannot be achieved
 *  with Tailwind utility classes alone.
 *
 *  Sections:
 *    1. Admin Bar Fix
 *    2. Sticky Header
 *    3. Mega Menu (Desktop)
 *    4. Mobile Offcanvas Menu
 *    5. Search Overlay
 *    6. Navigation Active States
 *    7. WordPress Core Overrides
 *    8. Gutenberg / Prose Overrides
 *    9. Comments
 *   10. Widgets
 *   11. Pagination
 *   12. Elementor Compatibility
 *   13. Accessibility
 *   14. Transitions & Animations
 *   15. Print
 *
 * ============================================================
 */

/* ─────────────────────────────────────────────────────────────
   1. ADMIN BAR FIX
   ─────────────────────────────────────────────────────────────
   WordPress admin bar is 32px on desktop, 46px on mobile.
   We must offset our sticky header so it doesn't hide behind it.
   ───────────────────────────────────────────────────────────── */

/* Desktop admin bar: 32px */
.admin-bar #site-header {
    top: 32px;
}

/* Mobile admin bar: 46px */
@media screen and (max-width: 782px) {
    .admin-bar #site-header {
        top: 46px;
    }
}

/* When admin bar is present, also offset fixed overlays */
.admin-bar #search-overlay,
.admin-bar #mobile-menu,
.admin-bar #mobile-menu-overlay {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar #search-overlay,
    .admin-bar #mobile-menu,
    .admin-bar #mobile-menu-overlay {
        top: 46px;
    }
}

/* Fix mobile menu height when admin bar is present */
.admin-bar #mobile-menu {
    height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar #mobile-menu {
        height: calc(100vh - 46px);
    }
}

/* ─────────────────────────────────────────────────────────────
   2. STICKY HEADER
   ───────────────────────────────────────────────────────────── */

#site-header {
    position: sticky;
    z-index: 50;
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

#site-header.scrolled {
    box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.1);
}

.dark #site-header.scrolled {
    box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.4);
}

/* ─────────────────────────────────────────────────────────────
   3. MEGA MENU (Desktop)
   ─────────────────────────────────────────────────────────────
   The mega menu panel is positioned FIXED relative to viewport,
   spanning full width under the header. This prevents the
   left-shift issue when using absolute positioning.
   ───────────────────────────────────────────────────────────── */

/* Parent item */
.mega-menu-parent {
    position: static;
}

/* Trigger button active state */
.mega-menu-parent:hover > button,
.mega-menu-parent.is-open > button {
    color: #6c3fff;
    background-color: rgba(108, 63, 255, 0.06);
    border-radius: 0.5rem;
}

.dark .mega-menu-parent:hover > button,
.dark .mega-menu-parent.is-open > button {
    color: #a594ff;
    background-color: rgba(108, 63, 255, 0.15);
}

/* Chevron rotation */
.mega-menu-parent:hover > button svg,
.mega-menu-parent.is-open > button svg {
    transform: rotate(180deg);
}

/* The dropdown panel */
.mega-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    padding-top: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    pointer-events: none;
    z-index: 50;
}

/* Show on hover */
.mega-menu-parent:hover > .mega-menu-dropdown,
.mega-menu-parent.is-open > .mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Inner container */
.mega-menu-inner {
    background: #ffffff;
    border-top: 2px solid rgba(108, 63, 255, 0.1);
    border-radius: 0 0 1rem 1rem;
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.15);
    padding: 2rem;
}

.dark .mega-menu-inner {
    background: #1f2937;
    border-top-color: rgba(108, 63, 255, 0.2);
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.5);
}

/* Mega menu column header */
.mega-menu-col-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

.dark .mega-menu-col-title {
    color: #f9fafb;
    border-bottom-color: #374151;
}

.mega-menu-col-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Mega menu link item */
.mega-menu-link {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.mega-menu-link:hover {
    background: rgba(108, 63, 255, 0.06);
}

.dark .mega-menu-link:hover {
    background: rgba(108, 63, 255, 0.12);
}

.mega-menu-link-arrow {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: #9ca3af;
    transition: color 0.2s ease, transform 0.2s ease;
}

.mega-menu-link:hover .mega-menu-link-arrow {
    color: #6c3fff;
    transform: translateX(-3px);
}

[dir="rtl"] .mega-menu-link:hover .mega-menu-link-arrow {
    transform: translateX(3px);
}

.mega-menu-link-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    transition: color 0.2s ease;
}

.dark .mega-menu-link-title {
    color: #f9fafb;
}

.mega-menu-link:hover .mega-menu-link-title {
    color: #6c3fff;
}

.dark .mega-menu-link:hover .mega-menu-link-title {
    color: #a594ff;
}

.mega-menu-link-desc {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.125rem;
    line-height: 1.4;
}

.dark .mega-menu-link-desc {
    color: #9ca3af;
}

/* Mega menu CTA card */
.mega-menu-cta {
    background: linear-gradient(135deg, #f0eeff 0%, #e8e0ff 100%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dark .mega-menu-cta {
    background: linear-gradient(135deg, #2d1270 0%, #3b1993 100%);
}

/* ─────────────────────────────────────────────────────────────
   4. MOBILE OFFCANVAS MENU
   ───────────────────────────────────────────────────────────── */

#mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20rem;
    max-width: 85vw;
    z-index: 100;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobile-menu.is-open {
    transform: translateX(0);
}

/* Overlay */
#mobile-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

#mobile-menu-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Mobile menu items */
.mobile-nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-nav-menu li {
    margin-bottom: 0.25rem;
}

.mobile-nav-menu > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    color: #374151;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: 0.75rem;
    transition: all 0.25s ease;
    text-decoration: none;
}

.dark .mobile-nav-menu > li > a {
    color: #d1d5db;
}

.mobile-nav-menu > li > a:hover,
.mobile-nav-menu > li > a:focus {
    background: rgba(108, 63, 255, 0.08);
    color: #6c3fff;
    padding-right: 1.25rem;
}

.dark .mobile-nav-menu > li > a:hover,
.dark .mobile-nav-menu > li > a:focus {
    background: rgba(108, 63, 255, 0.15);
    color: #a594ff;
}

/* Mobile sub-menu */
.mobile-nav-menu .sub-menu {
    list-style: none;
    padding: 0 1rem 0 0;
    margin: 0.25rem 0 0.5rem 0;
    border-right: 2px solid rgba(108, 63, 255, 0.15);
}

.dark .mobile-nav-menu .sub-menu {
    border-right-color: rgba(108, 63, 255, 0.25);
}

.mobile-nav-menu .sub-menu li a {
    display: block;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    border-radius: 0.5rem;
    transition: all 0.25s ease;
    text-decoration: none;
}

.dark .mobile-nav-menu .sub-menu li a {
    color: #9ca3af;
}

.mobile-nav-menu .sub-menu li a:hover {
    color: #6c3fff;
    background: rgba(108, 63, 255, 0.06);
    padding-right: 1.25rem;
}

.dark .mobile-nav-menu .sub-menu li a:hover {
    color: #a594ff;
    background: rgba(108, 63, 255, 0.12);
}

/* Mobile menu scrollbar */
#mobile-menu::-webkit-scrollbar {
    width: 4px;
}

#mobile-menu::-webkit-scrollbar-track {
    background: transparent;
}

#mobile-menu::-webkit-scrollbar-thumb {
    background: rgba(108, 63, 255, 0.2);
    border-radius: 2px;
}

#mobile-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 63, 255, 0.4);
}

/* ─────────────────────────────────────────────────────────────
   5. SEARCH OVERLAY
   ───────────────────────────────────────────────────────────── */

#search-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s;
}

#search-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

#search-overlay input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* ─────────────────────────────────────────────────────────────
   6. NAVIGATION ACTIVE STATES
   ───────────────────────────────────────────────────────────── */

/* Desktop nav: active/current page */
.current-menu-item > a,
.current_page_item > a {
    color: #6c3fff !important;
    position: relative;
}

.dark .current-menu-item > a,
.dark .current_page_item > a {
    color: #a594ff !important;
}

/* Underline indicator for active desktop menu item */
.desktop-nav .current-menu-item > a::after,
.desktop-nav .current_page_item > a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(to left, #6c3fff, #a594ff);
    border-radius: 1px;
}

/* Mobile nav: active */
.mobile-nav-menu .current-menu-item > a,
.mobile-nav-menu .current_page_item > a {
    background: rgba(108, 63, 255, 0.08);
    color: #6c3fff;
}

.dark .mobile-nav-menu .current-menu-item > a,
.dark .mobile-nav-menu .current_page_item > a {
    background: rgba(108, 63, 255, 0.15);
    color: #a594ff;
}

/* ─────────────────────────────────────────────────────────────
   7. WORDPRESS CORE OVERRIDES
   ───────────────────────────────────────────────────────────── */

/* Alignwide & alignfull for Gutenberg */
.alignwide {
    margin-left: -2rem;
    margin-right: -2rem;
    max-width: calc(100% + 4rem);
    width: calc(100% + 4rem);
}

.alignfull {
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    max-width: 100vw;
    width: 100vw;
}

/* WordPress image captions */
.wp-caption {
    max-width: 100%;
}

.wp-caption-text {
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
    margin-top: 0.5rem;
}

.dark .wp-caption-text {
    color: #9ca3af;
}

/* Gallery */
.wp-block-gallery {
    margin: 2rem 0;
}

/* Screen reader text */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    clip-path: none;
    color: #21759b;
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* ─────────────────────────────────────────────────────────────
   8. GUTENBERG / PROSE OVERRIDES
   ───────────────────────────────────────────────────────────── */

/* RTL blockquote fix */
[dir="rtl"] .prose blockquote {
    border-right-width: 4px;
    border-right-color: #6c3fff;
    border-left-width: 0;
    padding-right: 1.5rem;
    padding-left: 0;
}

/* Code blocks */
.prose pre code {
    background: transparent !important;
    padding: 0 !important;
    color: #e2e8f0;
}

/* Tables */
.prose table {
    border-collapse: collapse;
    width: 100%;
}

.prose th {
    background: #f8fafc;
    font-weight: 700;
    text-align: right;
}

.dark .prose th {
    background: #1e293b;
}

.prose td,
.prose th {
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
}

.dark .prose td,
.dark .prose th {
    border-color: #374151;
}

/* Gutenberg blocks spacing */
.entry-content > * + * {
    margin-top: 1.5rem;
}

/* ─────────────────────────────────────────────────────────────
   9. COMMENTS
   ───────────────────────────────────────────────────────────── */

.comment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment-list .children {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
    padding-right: 1.5rem;
    border-right: 2px solid rgba(108, 63, 255, 0.1);
}

@media (max-width: 640px) {
    .comment-list .children {
        padding-right: 0.75rem;
    }
}

.dark .comment-list .children {
    border-right-color: rgba(108, 63, 255, 0.2);
}

/* Comment form */
.comment-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.comment-respond .comment-reply-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────
   10. WIDGETS
   ───────────────────────────────────────────────────────────── */

.widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget ul li {
    padding: 0.625rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.dark .widget ul li {
    border-bottom-color: #374151;
}

.widget ul li:last-child {
    border-bottom: none;
}

.widget ul li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #6b7280;
    font-size: 0.875rem;
    transition: all 0.25s ease;
    text-decoration: none;
}

.dark .widget ul li a {
    color: #9ca3af;
}

.widget ul li a:hover {
    color: #6c3fff;
    padding-right: 0.5rem;
}

.dark .widget ul li a:hover {
    color: #a594ff;
}

/* Footer widget titles */
.footer-widget-column h4,
.footer-widget-column .widget-title {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    position: relative;
}

.footer-widget-column h4::after,
.footer-widget-column .widget-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 3rem;
    height: 2px;
    background: linear-gradient(to left, #6c3fff, #a594ff);
    border-radius: 1px;
}

.footer-widget-column ul li a {
    color: #9ca3af;
}

.footer-widget-column ul li a:hover {
    color: #a594ff;
}

.footer-widget-column ul li {
    border-bottom-color: #374151;
}

/* ─────────────────────────────────────────────────────────────
   11. PAGINATION
   ───────────────────────────────────────────────────────────── */

.pagination,
.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination .page-numbers,
.nav-links .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
    text-decoration: none;
}

.dark .pagination .page-numbers,
.dark .nav-links .page-numbers {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

.pagination .page-numbers:hover,
.nav-links .page-numbers:hover,
.pagination .page-numbers.current,
.nav-links .page-numbers.current {
    background: linear-gradient(135deg, #6c3fff 0%, #8b6fff 100%);
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(108, 63, 255, 0.35);
}

.pagination .prev,
.pagination .next,
.nav-links .prev,
.nav-links .next {
    min-width: auto;
    padding: 0 1rem;
    gap: 0.5rem;
}

.pagination .dots,
.nav-links .dots {
    background: transparent;
    border: none;
    cursor: default;
}

.pagination .dots:hover,
.nav-links .dots:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
    color: #6b7280;
}

/* ─────────────────────────────────────────────────────────────
   12. ELEMENTOR COMPATIBILITY
   ───────────────────────────────────────────────────────────── */

/* Prevent Elementor from breaking theme layout */
.elementor-page #page-wrapper {
    max-width: 100%;
    padding: 0;
}

.elementor-page .container {
    max-width: 100%;
    padding: 0;
}

/* Elementor section full width */
.elementor-section.elementor-section-boxed > .elementor-container {
    max-width: 1400px;
}

/* ─────────────────────────────────────────────────────────────
   13. ACCESSIBILITY
   ───────────────────────────────────────────────────────────── */

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #6c3fff;
    outline-offset: 2px;
    border-radius: 4px;
}

.dark a:focus-visible,
.dark button:focus-visible {
    outline-color: #a594ff;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ─────────────────────────────────────────────────────────────
   14. TRANSITIONS & ANIMATIONS
   ───────────────────────────────────────────────────────────── */

/* Smooth color transitions for dark mode */
body,
header,
footer,
main,
.card,
.widget {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Body scroll lock when overlay is open */
body.menu-open,
body.search-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Scroll to Top visibility */
#scroll-to-top {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}
#scroll-to-top.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ─────────────────────────────────────────────────────────────
   15. PRINT
   ───────────────────────────────────────────────────────────── */

@media print {
    #site-header,
    #mobile-menu,
    #mobile-menu-overlay,
    #search-overlay,
    #scroll-to-top,
    #cta-pre-footer,
    .share-buttons,
    .related-posts,
    .comment-form,
    .no-print {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt !important;
    }

    .prose {
        max-width: 100% !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline !important;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    h1, h2, h3, h4 {
        page-break-after: avoid;
    }
}
