/**
 * Custom CSS for Elegance Theme
 *
 * Additional styling beyond Tailwind CSS classes
 */

/**
 * Typography Enhancements
 */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 0;
}

/* Consistent vertical rhythm */
p, ul, ol, dl, blockquote {
    margin-bottom: 1.5rem;
}

/* Make links more accessible */
a {
    transition: color 0.2s ease-in-out;
    text-underline-offset: 0.15em;
}

a:hover {
    text-decoration-thickness: 0.1em;
}

/**
 * Header Styles
 */
.site-header {
    transition: all 0.3s ease;
}

.site-header.sticky-header-scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
}

.dark .site-header.sticky-header-scrolled {
    background-color: rgba(17, 24, 39, 0.9);
}

.site-header.sticky-header-scrolled .site-branding img {
    max-height: 40px;
}

/* Animate primary menu interactions */
.main-navigation a {
    position: relative;
    padding: 0.5rem 0;
    font-weight: 500;
}

.main-navigation a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.main-navigation a:hover::after,
.main-navigation .current-menu-item > a::after {
    width: 100%;
}

.dark .main-navigation a::after {
    background-color: #60a5fa;
}

/**
 * Reading Progress Bar Enhancement
 */
.reading-progress-container {
    height: 4px;
    background-color: transparent;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
}

.reading-progress {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.1s ease;
}

/**
 * Post Content Enhancements
 */

/* Improved Blockquotes */
.entry-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    font-style: italic;
    margin: 1.5rem 0;
    border-radius: 0.25rem;
}

.dark .entry-content blockquote {
    background-color: #1e293b;
    border-left-color: #60a5fa;
}

/* Code Blocks */
.entry-content pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.entry-content code {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;
    background-color: #f1f5f9;
    color: #475569;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.dark .entry-content code {
    background-color: #1e293b;
    color: #e2e8f0;
}

.entry-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

/* Table Styling */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.entry-content th {
    background-color: #f1f5f9;
    font-weight: 600;
    text-align: left;
    padding: 0.75rem;
}

.entry-content td {
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.dark .entry-content th {
    background-color: #1e293b;
}

.dark .entry-content td {
    border-top-color: #334155;
}

/* Table of Contents */
.toc-container {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.toc-header {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.toc-list {
    padding: 1rem;
}

.dark .toc-container {
    border-color: #334155;
}

.dark .toc-header {
    border-bottom-color: #334155;
}

.toc-list a {
    color: #64748b;
    text-decoration: none;
    font-size: 0.95rem;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.dark .toc-list a {
    color: #94a3b8;
}

.toc-list a:hover,
.toc-list a.active {
    color: var(--primary-color);
}

.dark .toc-list a:hover,
.dark .toc-list a.active {
    color: #60a5fa;
}

/* Images and Captions */
.wp-caption {
    max-width: 100%;
    margin-bottom: 1.5rem;
}

.wp-caption img {
    border-radius: 0.5rem;
    overflow: hidden;
}

.wp-caption-text {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
    font-style: italic;
}

.dark .wp-caption-text {
    color: #94a3b8;
}

/* Featured Image */
.featured-image {
    margin-bottom: 2rem;
    border-radius: 0.5rem;
    overflow: hidden;
}

.featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/**
 * Card Animations
 */
.post-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-card:hover {
    transform: translateY(-5px);
}

/**
 * Comment Styling
 */
.comment-list {
    list-style: none;
    padding-left: 0;
}

.comment-list ol {
    list-style: none;
    padding-left: 2rem;
}

.comment-author .avatar {
    border-radius: 50%;
}

.comment-metadata {
    font-size: 0.875rem;
    color: #64748b;
}

.dark .comment-metadata {
    color: #94a3b8;
}

.comment-respond {
    margin-top: 2rem;
}

#reply-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.comment-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background-color: #f8fafc;
    margin-bottom: 1rem;
}

.dark .comment-form input[type="text"],
.dark .comment-form input[type="email"],
.dark .comment-form input[type="url"],
.dark .comment-form textarea {
    border-color: #334155;
    background-color: #1e293b;
    color: #f8fafc;
}

.comment-form input[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.comment-form input[type="submit"]:hover {
    background-color: #1d4ed8;
}

/**
 * Newsletter Form
 */
.newsletter-form {
    margin-bottom: 1rem;
}

.newsletter-form input[type="email"] {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background-color: #f8fafc;
}

.dark .newsletter-form input[type="email"] {
    border-color: #334155;
    background-color: #1e293b;
    color: #f8fafc;
}

.newsletter-form button {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.newsletter-form button:hover {
    background-color: #1d4ed8;
}

/**
 * Social Share Buttons
 */
.social-sharing a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.social-sharing a:hover {
    transform: translateY(-2px);
}

/**
 * Author Bio Section
 */
.author-bio {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 0.5rem;
    background-color: #f8fafc;
}

.dark .author-bio {
    background-color: #1e293b;
}

.author-bio img {
    border-radius: 50%;
}

/**
 * Pagination
 */
.pagination,
.page-links,
.nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
}

.pagination .page-numbers,
.page-links a,
.page-links span,
.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    margin: 0 0.25rem;
    border-radius: 0.375rem;
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dark .pagination .page-numbers,
.dark .page-links a,
.dark .page-links span,
.dark .nav-links a {
    background-color: #1e293b;
    color: #94a3b8;
}

.pagination .page-numbers.current,
.page-links span.current {
    background-color: var(--primary-color);
    color: white;
}

.pagination a.page-numbers:hover,
.page-links a:hover,
.nav-links a:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.dark .pagination a.page-numbers:hover,
.dark .page-links a:hover,
.dark .nav-links a:hover {
    background-color: #334155;
    color: #f8fafc;
}

/**
 * Page Header Styling
 */
.page-header {
    margin-bottom: 2rem;
    text-align: center;
}

.page-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.archive-description {
    color: #64748b;
    max-width: 42rem;
    margin: 0 auto;
}

.dark .archive-description {
    color: #94a3b8;
}

/**
 * Search Modal
 */
.search-form {
    position: relative;
}

.search-form input[type="search"] {
    width: 100%;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background-color: #f8fafc;
}

.dark .search-form input[type="search"] {
    border-color: #334155;
    background-color: #1e293b;
    color: #f8fafc;
}

/**
 * Skip Links
 */
.skip-link {
    background-color: #f8fafc;
    color: #0f172a;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 0.375rem;
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-100%);
    transition: transform 0.2s ease;
}

.skip-link:focus {
    transform: translateY(0);
    z-index: 100;
}

.dark .skip-link {
    background-color: #1e293b;
    color: #f8fafc;
}

/**
 * WooCommerce Specific Styles
 */
.woocommerce span.onsale {
    background-color: var(--primary-color);
    color: white;
}

.woocommerce div.product .woocommerce-tabs ul.tabs li.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.woocommerce .button.alt {
    background-color: var(--primary-color) !important;
}

.woocommerce .button.alt:hover {
    background-color: #1d4ed8 !important;
}

/**
 * Animations and Micro-interactions
 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.slide-in-up {
    animation: slideInUp 0.4s ease forwards;
}

.single .entry-content > * {
    animation: fadeIn 0.5s ease forwards;
}

/**
 * Dark Mode Toggle Effect
 */
.dark-mode-toggle {
    position: relative;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dark-mode-toggle:hover {
    transform: rotate(10deg);
}

/**
 * Additional theme-specific styles
 */
.breadcrumbs {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.site-footer {
    font-size: 0.875rem;
}

.site-footer .widget-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Navigation Menus */
.footer-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-nav li {
    margin-bottom: 0.5rem;
}

.footer-nav a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.dark .footer-nav a {
    color: #94a3b8;
}

.dark .footer-nav a:hover {
    color: #60a5fa;
}

/* Category List in Footer */
.footer-categories li {
    margin-bottom: 0.5rem;
}

.footer-categories a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-categories a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.dark .footer-categories a {
    color: #94a3b8;
}

.dark .footer-categories a:hover {
    color: #60a5fa;
}

/* Related Posts */
.related-post {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.related-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* Main Navigation Styling */
#primary-menu,
#primary-menu-mobile {
    list-style: none;
    margin: 0;
    padding: 0;
}

#primary-menu li,
#primary-menu-mobile li {
    position: relative;
}

#primary-menu > li {
    display: inline-block;
    margin-right: 1.5rem;
}

#primary-menu-mobile li {
    margin-bottom: 0.75rem;
}

#primary-menu a,
#primary-menu-mobile a {
    color: #1f2937;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.dark #primary-menu a,
.dark #primary-menu-mobile a {
    color: #f9fafb;
}

#primary-menu a:hover,
#primary-menu-mobile a:hover {
    color: var(--primary-color);
}

.dark #primary-menu a:hover,
.dark #primary-menu-mobile a:hover {
    color: #60a5fa;
}

/* Sub-menus */
#primary-menu .sub-menu,
#primary-menu-mobile .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background-color: white;
    padding: 0.75rem 0;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.dark #primary-menu .sub-menu,
.dark #primary-menu-mobile .sub-menu {
    background-color: #1f2937;
}

#primary-menu .sub-menu li,
#primary-menu-mobile .sub-menu li {
    padding: 0.5rem 1rem;
}

#primary-menu li:hover > .sub-menu {
    display: block;
}

#primary-menu-mobile .sub-menu {
    position: static;
    background-color: transparent;
    box-shadow: none;
    padding-left: 1rem;
    margin-top: 0.5rem;
}

/* Social Menu Icons */
.social-links {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    color: #64748b;
    transition: all 0.2s ease;
}

.social-links a:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

.dark .social-links a {
    color: #94a3b8;
}

.dark .social-links a:hover {
    color: #60a5fa;
}

/* Post Formats */
.format-quote blockquote {
    font-size: 1.25rem;
    line-height: 1.5;
    position: relative;
    padding-top: 3rem;
}

.format-quote blockquote::before {
    content: '"';
    font-size: 5rem;
    color: var(--primary-color);
    opacity: 0.2;
    position: absolute;
    top: -1rem;
    left: -1rem;
    font-family: serif;
}

.dark .format-quote blockquote::before {
    color: #60a5fa;
}

/* Comment Navigation */
.comment-navigation {
    display: flex;
    justify-content: space-between;
    margin: 1.5rem 0;
}

.comment-navigation .nav-previous,
.comment-navigation .nav-next {
    max-width: 48%;
}

.comment-navigation a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.comment-navigation a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.dark .comment-navigation a {
    color: #94a3b8;
}

.dark .comment-navigation a:hover {
    color: #60a5fa;
}

/* Print Styles */
@media print {
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
    
    .site-header,
    .site-footer,
    .social-sharing,
    .newsletter-signup,
    .related-posts,
    .comments-area,
    .post-navigation {
        display: none;
    }
}

/*--------------------------------------------------------------
# Header Fixes
--------------------------------------------------------------*/

/* Prevent Dashboard styles from stretching desktop header menu */
@media (min-width: 768px) { /* Apply only to desktop view */
    #masthead #site-navigation {
        flex-grow: 0 !important;   /* Prevent nav container from growing */
        flex-shrink: 0 !important; /* Prevent nav container from shrinking unduly */
        width: max-content !important; /* Force width based on content */
    }
    #masthead #site-navigation ul#primary-menu {
        justify-content: flex-start !important; /* Override justify-content conflicts */
        width: auto !important;                 /* Override width conflicts */
    }
}

/*--------------------------------------------------------------
# Mobile Menu Styles
--------------------------------------------------------------*/

.mobile-menu-container {
    background-color: #f8f7f4; /* Light beige background like image */
    color: #333; /* Dark text color */
    padding-top: 1rem;
    padding-bottom: 2rem;
}

.dark .mobile-menu-container {
    background-color: #1a1a1a; /* Dark background for dark mode */
    color: #e0e0e0; /* Light text color for dark mode */
}

.mobile-menu-logo img {
    max-height: 30px; /* Adjust logo size as needed */
    width: auto;
}

.mobile-navigation .mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-navigation .mobile-menu-list li {
    border-bottom: 1px solid #e5e5e5; /* Thin line separator */
    position: relative;
}

.dark .mobile-navigation .mobile-menu-list li {
    border-bottom-color: #333;
}

.mobile-navigation .mobile-menu-list li:last-child {
    border-bottom: none;
}

.mobile-navigation .mobile-menu-list a {
    display: block;
    padding: 1rem 0;
    text-decoration: none;
    color: inherit;
    font-size: 1.1rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mobile-navigation .mobile-menu-list a:hover {
    color: #007bff; /* Example hover color, adjust as needed */
}

.dark .mobile-navigation .mobile-menu-list a:hover {
    color: #60a5fa;
}

/* Current menu item */
.mobile-navigation .mobile-menu-list .current-menu-item > a,
.mobile-navigation .mobile-menu-list .current-menu-ancestor > a {
    font-weight: bold;
    color: #007bff; /* Example current item color */
}

.dark .mobile-navigation .mobile-menu-list .current-menu-item > a,
.dark .mobile-navigation .mobile-menu-list .current-menu-ancestor > a {
    color: #60a5fa;
}

/* Submenu Styles */
.mobile-navigation .mobile-menu-list .sub-menu {
    list-style: none;
    margin: 0;
    padding-left: 1rem;
    display: none; /* Hidden by default */
    background-color: rgba(0, 0, 0, 0.02);
    border-top: 1px solid #e5e5e5;
}

.dark .mobile-navigation .mobile-menu-list .sub-menu {
    background-color: rgba(255, 255, 255, 0.03);
    border-top-color: #333;
}

.mobile-navigation .mobile-menu-list .sub-menu.open {
    display: block;
}

.mobile-navigation .mobile-menu-list .sub-menu li {
    border: none;
}

.mobile-navigation .mobile-menu-list .sub-menu a {
    padding: 0.75rem 0;
    font-size: 1rem;
    font-weight: normal;
}

/* Submenu Toggle Button */
.mobile-navigation .submenu-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50px; /* Clickable area */
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    transition: transform 0.2s ease;
}

.dark .mobile-navigation .submenu-toggle {
    color: #666;
}

.mobile-navigation .submenu-toggle:hover {
    color: #333;
}

.dark .mobile-navigation .submenu-toggle:hover {
    color: #ccc;
}

.mobile-navigation .submenu-toggle svg {
    transition: transform 0.2s ease;
}

.mobile-navigation .submenu-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Hide desktop nav on small screens */
@media (max-width: 767px) {
    #site-navigation {
        display: none;
    }
}

/* Ensure mobile menu container is hidden initially if JS is slow */
[x-cloak] {
    display: none !important;
}

/*--------------------------------------------------------------
# Course Steps Navigation (single-course.php)
--------------------------------------------------------------*/

.course-sidebar {
    /* Make sidebar sticky within its container */
    /* top value should roughly match your header height + desired spacing */
    top: 6rem; 
}

.course-step-active {
    /* Style for the highlighted active step in the sidebar */
    /* Using yellow-200 and yellow-900 from Tailwind as an example */
}

.course-steps-container > * {
    /* Hide all direct children (paragraphs, images, lists etc.) by default */
    display: none;
}

.course-steps-container > h2 {
    /* Always keep the H2 step titles visible */
    display: block; 
}

/* 
Dynamically generated styles to show content for the active step.
Replace '#active-step-id' with the actual ID of the active step's H2 tag. 
This part needs to be handled by JS/Alpine by adding/removing a class or style attribute.
Alternatively, a more complex CSS sibling selector approach could be tried, 
but JS control is generally more reliable.

Example using a data attribute updated by AlpineJS:
.course-steps-container[data-active-step="step-1"] #step-1 ~ *:not(h2),
.course-steps-container[data-active-step="step-2"] #step-2 ~ *:not(h2) {
    display: block;
}

We will use AlpineJS to directly add a class to the content area 
that CSS can target more easily.
*/

/* Add classes for each potential step ID */
/* You might need a more dynamic approach if IDs are unpredictable */

/* Example - generated dynamically or use JS to apply display:block */
/* 
.course-steps-container.showing-step-id-1 #step-id-1 ~ *:not(h2) { display: block; }
.course-steps-container.showing-step-id-2 #step-id-2 ~ *:not(h2) { display: block; }
*/

/* Force 1/3 and 2/3 layout for course page */
@media (min-width: 768px) { /* Corresponds to Tailwind's md breakpoint */
    .course-layout-sidebar {
        flex-basis: 33.333333%;
        width: 33.333333%; /* Add width as fallback/reinforcement */
        max-width: 33.333333%; /* Prevent exceeding */
        flex-shrink: 0; /* Prevent shrinking */
        flex-grow: 0; /* Prevent growing */
    }

    .course-layout-content {
        flex-basis: 66.666667%;
        width: 66.666667%; /* Add width as fallback/reinforcement */
        max-width: 66.666667%; /* Prevent exceeding */
        flex-grow: 1; /* Allow growing if needed, though basis should dominate */
    }
}
