/*
Theme Name: AI Meta Knowledges for All
Theme URI: https://allmetaknow.com
Author: meta_know
Author URI: https://allmetaknow.com
Description: V2 Rebuild of All Meta Know - A premium AI knowledge hub theme using FSE.
Requires at least: 6.4
Tested up to: 6.4
Requires PHP: 7.4
Version: 2.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: allmetaknow-v2
Tags: full-site-editing, block-theme, education, news, ai
*/

/* 
 * NOTE: This theme uses theme.json for all styling. 
 * Do not add CSS here unless absolutely necessary for third-party plugin compatibility 
 * or complex animations that Block Styles cannot handle.
 */

body {
    padding-top: 80px !important;
    /* Compensate for fixed header height */
}

/* Layout Toggle Controls */
.layout-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.layout-btn {
    background: none;
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--wp--preset--color--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.layout-btn:hover {
    background-color: var(--wp--preset--color--background);
    color: var(--wp--preset--color--primary);
}

.layout-btn.active {
    background-color: var(--wp--preset--color--primary);
    color: white;
    border-color: var(--wp--preset--color--primary);
}

/* List View Styles */
.is-view-list .wp-block-post-template {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
}

.is-view-list .wp-block-post .wp-block-group {
    display: block !important;
    padding: 1rem;
    border-bottom: 1px solid var(--wp--preset--color--border);
    margin-bottom: 0 !important;
}

.is-view-list .wp-block-post-featured-image,
.is-view-list .wp-block-post-excerpt,
.is-view-list .wp-block-post-date,
.is-view-list .wp-block-post-author {
    display: none !important;
}

.is-view-list .wp-block-post-title {
    margin-bottom: 0 !important;
    font-size: var(--wp--preset--font-size--lg) !important;
}

.is-view-list .wp-block-post-title a {
    text-decoration: none;
    color: var(--wp--preset--color--text-main);
}

.is-view-list .wp-block-post-title a:hover {
    color: var(--wp--preset--color--primary);
}

/* Featured Card Hover Effects */
.featured-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.featured-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.featured-card a {
    transition: color 0.2s ease;
}

.featured-card:hover h3 a {
    color: var(--wp--preset--color--primary);
}

/* Navigation Enhancements */

/* Smart Sticky Header */
.is-style-sticky-header {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: top 0.3s ease-in-out;
}

.nav-up {
    top: -100px !important;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--wp--preset--color--primary);
    color: white;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
    text-decoration: none;
}

.back-to-top:hover {
    background-color: var(--wp--preset--color--accent);
    transform: translateY(-5px);
    color: white;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 
 * AI News Modern Magazine Grid (Bento Style)
 * Applied when .is-style-news-bento class is present
 */

/* Grid Layout Definition */
.is-style-news-bento:not(.is-view-list) .wp-block-post-template {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(300px, auto);
    gap: 1.5rem;
}

/* Hero Card (First Post) */
.is-style-news-bento:not(.is-view-list) .wp-block-post:nth-child(1) {
    grid-column: span 2;
    grid-row: span 2;
}

/* Hero Card Styling */
.is-style-news-bento:not(.is-view-list) .wp-block-post:nth-child(1) .wp-block-post-title {
    font-size: 2rem !important;
    font-weight: 800;
    margin-bottom: 1rem;
}

.is-style-news-bento:not(.is-view-list) .wp-block-post:nth-child(1) .wp-block-post-excerpt {
    display: block !important;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--wp--preset--color--text-muted);
    margin-bottom: 1rem;
}

/* Standard Cards (Rest of the posts) */
.is-style-news-bento:not(.is-view-list) .wp-block-post:not(:nth-child(1)) .wp-block-post-title {
    font-size: 1.1rem !important;
    font-weight: 600;
}

.is-style-news-bento:not(.is-view-list) .wp-block-post:not(:nth-child(1)) .wp-block-post-excerpt {
    display: none;
    /* Hide excerpt for compact cards */
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .is-style-news-bento:not(.is-view-list) .wp-block-post-template {
        grid-template-columns: repeat(2, 1fr);
    }

    /* On tablet, hero spans full width */
    .is-style-news-bento:not(.is-view-list) .wp-block-post:nth-child(1) {
        grid-column: span 2;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .is-style-news-bento:not(.is-view-list) .wp-block-post-template {
        grid-template-columns: 1fr;
    }

    .is-style-news-bento:not(.is-view-list) .wp-block-post:nth-child(1) {
        grid-column: span 1;
    }
}

/* Tag Chips Styling */
.is-style-allmetaknow-tag-chip a {
    display: inline-block;
    background-color: var(--wp--preset--color--tertiary, #f3f4f6);
    color: var(--wp--preset--color--primary, #4f46e5);
    padding: 0.3rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.is-style-allmetaknow-tag-chip a:hover {
    background-color: var(--wp--preset--color--primary, #4f46e5);
    color: white;
    transform: translateY(-2px);
}

/* Search Trigger Button */
.search-trigger-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0.5rem;
    margin-left: 1rem;
    transition: color 0.2s ease;
}

.search-trigger-btn:hover {
    color: var(--wp--preset--color--primary);
}

/* Full Screen Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    padding-top: 0; /* Closed state: no padding */
    background-color: #4f46e5; /* Primary Brand Color */
    z-index: 9999;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Animate all properties including padding */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search-overlay.open {
    height: 100vh;
    padding-top: 10vh; /* Open state: add padding */
}

/* Search Close Button */
.search-close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.search-close-btn:hover {
    opacity: 1;
}

/* Search Container */
.search-container {
    width: 100%;
    max-width: 800px;
    padding: 0 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease 0.1s, transform 0.4s ease 0.1s;
}

.search-overlay.open .search-container {
    opacity: 1;
    transform: translateY(0);
}

.search-title {
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
}

/* Custom Search Form */
.search-form-custom {
    width: 100%;
    margin-bottom: 2rem;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 9999px;
    padding: 0.5rem 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.search-icon {
    color: #6b7280;
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
}

.search-field-custom {
    flex: 1;
    border: none;
    background: none;
    padding: 1rem 0.5rem;
    font-size: 1.25rem;
    outline: none;
    color: #111827;
}

.search-submit-btn {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    color: #4f46e5;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.search-submit-btn:hover {
    background-color: #f3f4f6;
    color: #4338ca;
}

/* Search Tags Cloud */
.search-tags {
    text-align: center;
}

.is-style-search-tags .wp-block-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.is-style-search-tags a {
    display: inline-block;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    text-decoration: none;
    font-size: 0.95rem !important;
    transition: all 0.2s ease;
}

.is-style-search-tags a:hover {
    background-color: white;
    color: #4f46e5;
    transform: translateY(-2px);
}

/* Post Navigation Cards */
.post-navigation-container {
    width: 100%;
    gap: 1.5rem;
}

.is-style-post-nav-card {
    flex: 1 1 300px; /* Responsive flex basis */
    display: flex;
    flex-direction: column;
    text-decoration: none;
}

/* Apply styles whether the class is on a wrapper or the anchor itself */
.is-style-post-nav-card a,
a.is-style-post-nav-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background-color: #fff;
    border: 1px solid var(--wp--preset--color--border);
    border-radius: 12px;
    text-decoration: none !important;
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    width: 100%; /* Ensure full width */
    box-sizing: border-box;
}

.is-style-post-nav-card a:hover,
a.is-style-post-nav-card:hover {
    border-color: var(--wp--preset--color--primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

/* Navigation Label (Previous/Next) */
.is-style-post-nav-card .wp-block-post-navigation-link__label,
a.is-style-post-nav-card .wp-block-post-navigation-link__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wp--preset--color--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

/* Post Title */
.is-style-post-nav-card .wp-block-post-navigation-link__content,
a.is-style-post-nav-card .wp-block-post-navigation-link__content {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wp--preset--color--text-main);
    line-height: 1.4;
    transition: color 0.2s ease;
}

.is-style-post-nav-card a:hover .wp-block-post-navigation-link__content,
a.is-style-post-nav-card:hover .wp-block-post-navigation-link__content {
    color: var(--wp--preset--color--primary);
}

/* Direction Arrows */
.is-style-post-nav-card.prev-post a::before,
a.is-style-post-nav-card.prev-post::before {
    content: "←";
    font-family: sans-serif;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--wp--preset--color--primary);
    transition: transform 0.2s ease;
    display: block;
}

.is-style-post-nav-card.prev-post a:hover::before,
a.is-style-post-nav-card.prev-post:hover::before {
    transform: translateX(-4px);
}

.is-style-post-nav-card.next-post a,
a.is-style-post-nav-card.next-post {
    text-align: right;
    align-items: flex-end;
}

.is-style-post-nav-card.next-post a::before,
a.is-style-post-nav-card.next-post::before {
    content: "→";
    font-family: sans-serif;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--wp--preset--color--primary);
    transition: transform 0.2s ease;
    display: block;
    order: -1;
}

.is-style-post-nav-card.next-post a:hover::before,
a.is-style-post-nav-card.next-post:hover::before {
    transform: translateX(4px);
}

/* Query Pagination Styling */
.is-style-allmetaknow-pagination {
    margin-top: 3rem;
}

.is-style-allmetaknow-pagination .wp-block-query-pagination-numbers {
    display: flex;
    gap: 0.5rem;
}

.is-style-allmetaknow-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--wp--preset--color--border);
    color: var(--wp--preset--color--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    background-color: white;
}

.is-style-allmetaknow-pagination .page-numbers:hover:not(.current) {
    border-color: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--primary);
}

.is-style-allmetaknow-pagination .page-numbers.current {
    background-color: var(--wp--preset--color--primary);
    color: white;
    border-color: var(--wp--preset--color--primary);
}

.is-style-allmetaknow-pagination .wp-block-query-pagination-previous,
.is-style-allmetaknow-pagination .wp-block-query-pagination-next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--wp--preset--color--border);
    color: var(--wp--preset--color--text-main);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    background-color: white;
}

.is-style-allmetaknow-pagination .wp-block-query-pagination-previous:hover,
.is-style-allmetaknow-pagination .wp-block-query-pagination-next:hover {
    border-color: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--primary);
}

/* Responsive Grid for Shortcode Lists */
.is-style-responsive-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile first */
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .is-style-responsive-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet */
    }
}

@media (min-width: 1024px) {
    .is-style-responsive-grid {
        grid-template-columns: repeat(3, 1fr); /* Desktop */
    }
}

/* Like Button Styles */
.meta-know-like-wrapper {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.meta-know-like-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: white;
    border: 1px solid var(--wp--preset--color--border, #e5e7eb);
    padding: 0.6rem 1.5rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--wp--preset--font-family--system-font, sans-serif);
    font-size: 1rem;
    color: var(--wp--preset--color--text-muted, #6b7280);
    line-height: 1;
}

.meta-know-like-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background-color: #fef2f2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.meta-know-like-btn.liked {
    background-color: #ef4444;
    border-color: #ef4444;
    color: white;
}

.meta-know-like-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.meta-know-like-btn .icon svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    vertical-align: middle;
}

.meta-know-like-btn:active .icon svg {
    transform: scale(1.3);
}

.meta-know-like-btn.liked .icon svg {
    fill: white;
}

.meta-know-like-btn .text {
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
}

.meta-know-like-btn .count {
    background-color: rgba(0,0,0,0.05);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
}

.meta-know-like-btn.liked .count {
    background-color: rgba(255,255,255,0.2);
    color: white;
}

.meta-know-like-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

.meta-know-like-note {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0;
    text-align: center;
}
