/*
 Theme Name:   iwenai Theme
 Theme URI:    https://iwenai.com
 Description:  AI Agent-friendly WordPress theme for structured knowledge. Child theme of GeneratePress.
 Author:       iwenai
 Author URI:   https://iwenai.com
 Template:     generatepress
 Version:      1.1.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain:  iwenai
 Tags:         ai, structured-data, json-feed, seo, fast
*/

/* === Variables === */
:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --code-bg: #f3f4f6;
    --tag-bg: #eff6ff;
    --tag-color: #1d4ed8;
    --radius: 8px;
}

/* === Reset === */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background: var(--bg-color);
    margin: 0;
    padding: 0;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1.25rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* === Layout === */
.site-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.site-main-wrapper {
    max-width: 860px;
    margin: 0 auto;
}

/* === Header === */
.site-header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-branding {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
}

.site-title a {
    color: var(--text-color);
}

.site-title a:hover {
    text-decoration: none;
    color: var(--primary-color);
}

.site-description {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

/* === Navigation === */
.main-navigation {
    display: flex;
    gap: 1.5rem;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
}

.main-navigation a {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
}

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

/* === Section Title === */
.section-title {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: none;
    padding-bottom: 0;
}

/* === Latest Highlight (Homepage) === */
.latest-highlight {
    margin-bottom: 2.5rem;
}

.highlight-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.highlight-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.375rem;
}

.highlight-card h3 a {
    color: var(--text-color);
}

.highlight-card h3 a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.highlight-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.highlight-excerpt {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.read-more {
    font-weight: 600;
    font-size: 0.875rem;
}

/* === Category Sections (Homepage) === */
.category-sections {
    margin-bottom: 2.5rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.category-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.category-title {
    font-size: 1rem;
    margin: 0 0 0.75rem;
    border-bottom: none;
    padding-bottom: 0;
}

.category-title a {
    color: var(--text-color);
}

.category-posts {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
}

.category-posts li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.category-posts li:last-child {
    border-bottom: none;
}

.category-posts a {
    color: var(--text-color);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.5rem;
}

.category-posts .post-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.more-link {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* === Trending Section (Homepage) === */
.trending-section {
    margin-bottom: 2.5rem;
}

.trending-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.trending-tags a {
    background: var(--tag-bg);
    color: var(--tag-color);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.trending-tags a:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
}

/* === AI Agent Info Box === */
.ai-agent-info {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}

.ai-agent-info h3 {
    color: var(--primary-color);
    font-size: 1rem;
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.ai-agent-info ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-agent-info li {
    padding: 0.375rem 0;
    font-size: 0.9375rem;
}

.ai-agent-info code {
    background: white;
    padding: 0.125rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8125rem;
}

/* === Latest Posts === */
.latest-posts {
    margin-top: 2rem;
}

/* === Article === */
article.post {
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
}

article.post:last-child {
    border-bottom: none;
}

.entry-header {
    margin-bottom: 1.5rem;
}

.entry-title {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.entry-title a {
    color: var(--text-color);
}

.entry-title a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.entry-meta a {
    color: var(--text-muted);
}

.entry-meta a:hover {
    color: var(--primary-color);
}

/* === Tags === */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.post-tags a {
    background: var(--tag-bg);
    color: var(--tag-color);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.post-tags a:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
}

/* === Content === */
.entry-content {
    font-size: 1.0625rem;
}

.entry-content ul,
.entry-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.entry-content li {
    margin-bottom: 0.5rem;
}

.entry-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.entry-content code {
    background: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
}

.entry-content pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.entry-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

/* === FAQ Section === */
.faq-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 2rem 0;
}

.faq-section h2 {
    border-bottom: none;
    font-size: 1.125rem;
    margin-top: 0;
    padding-bottom: 0;
}

.faq-item {
    margin-bottom: 1.5rem;
}

.faq-item:last-child {
    margin-bottom: 0;
}

.faq-question {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.faq-answer {
    color: var(--text-muted);
}

/* === Source Attribution === */
.source-attribution {
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 2rem 0;
}

.source-attribution a {
    color: var(--primary-color);
}

/* === Related Posts === */
.related-posts {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.related-posts h2 {
    font-size: 1.125rem;
    border-bottom: none;
    padding-bottom: 0;
}

.related-posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.related-post-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    display: block;
}

.related-post-item:hover {
    text-decoration: none;
    background: #f0f4f8;
}

.related-post-item h3 {
    font-size: 0.9375rem;
    margin: 0 0 0.5rem;
    color: var(--text-color);
}

.related-post-item p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

/* === Breadcrumb === */
.breadcrumb {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb span {
    margin: 0 0.25rem;
}

/* === Post Navigation === */
.post-navigation {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.nav-links {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.nav-prev,
.nav-next {
    font-size: 0.875rem;
    font-weight: 500;
}

/* === Pagination === */
.pagination {
    margin: 2rem 0;
    text-align: center;
}

.pagination .nav-links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.pagination .page-numbers {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.pagination .page-numbers:hover:not(.current) {
    background: var(--bg-secondary);
    text-decoration: none;
}

/* === Archive === */
.archive-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.archive-header .page-title {
    font-size: 1.75rem;
    margin: 0;
}

.archive-description {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.archive-posts article.post {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
}

/* === Search === */
.search-header {
    margin-bottom: 2rem;
}

.search-header .page-title {
    font-size: 1.5rem;
    margin: 0;
}

.search-header span {
    color: var(--primary-color);
}

.search-results article.post {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
}

.no-results {
    text-align: center;
    padding: 3rem 1rem;
}

/* === 404 === */
.error-404 {
    text-align: center;
    padding: 3rem 1rem;
}

.error-404 h1 {
    font-size: 4rem;
    color: var(--primary-color);
    margin: 0;
}

.error-404 h2 {
    border-bottom: none;
    padding-bottom: 0;
}

.helpful-links {
    margin-top: 2rem;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.helpful-links h3 {
    border-bottom: none;
    padding-bottom: 0;
}

.helpful-links ul {
    list-style: none;
    padding: 0;
}

.helpful-links li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

/* === Sidebar === */
.sidebar {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.widget {
    margin-bottom: 2rem;
}

.widget:last-child {
    margin-bottom: 0;
}

.widget-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

/* === Footer === */
.site-footer {
    background: var(--bg-secondary);
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.footer-widgets {
    margin-bottom: 1.5rem;
}

.site-info p {
    margin-bottom: 0.75rem;
}

.site-footer a {
    color: var(--text-muted);
    margin: 0 0.5rem;
}

.site-footer a:hover {
    color: var(--primary-color);
}

.footer-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-navigation a {
    font-size: 0.8125rem;
}

.footer-links {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.footer-links a {
    margin: 0 0.75rem;
    font-size: 0.8125rem;
}

/* === Skip Link === */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
}

/* === Responsive === */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    .entry-title { font-size: 1.375rem; }
    
    .site-branding {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .main-navigation ul {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .related-posts-list {
        grid-template-columns: 1fr;
    }
    
    .nav-links {
        flex-direction: column;
    }
    
    .site-content {
        padding: 1.5rem 1rem;
    }
}

/* === Print === */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .related-posts,
    .post-navigation,
    .ai-agent-info,
    .pagination {
        display: none;
    }
    
    .site-content {
        max-width: 100%;
    }
}
