/* Custom styles for Agentic Madness */

/* Sidebar contact link */
.sidebar-contact a:hover {
    opacity: 1 !important;
}

/* Sidebar social icons */
.sidebar-social a:hover {
    opacity: 1 !important;
}

/* Search button styling */
#libdoc-sidebar-item-search button[type="submit"]:hover {
    opacity: 1 !important;
}

/* Search input - always show right border */
#libdoc-search-box {
    border-right: 1px dashed var(--sg-color-primary-alt, #ccc) !important;
}

/* Search input clear button styling */
#libdoc-search-box::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 16px;
    width: 16px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>') center/contain no-repeat;
    cursor: pointer;
    margin-right: 28px;
}

#libdoc-search-box::-webkit-search-cancel-button:hover {
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>') center/contain no-repeat;
}

/* Firefox clear button */
#libdoc-search-box::-moz-search-cancel-button {
    cursor: pointer;
}

/* Latest post indicator */
.latest-indicator {
    background: var(--sg-color-primary-edge, #f5f5f5);
    padding: 0.3em 0.6em;
    border-radius: 0.25em;
    font-weight: bold;
    display: inline-block;
}

/* Full width metadata container */
.post-meta-full-width {
    width: 100%;
}

/* Post preview alignment */
.latest-post,
.latest-post .post-preview {
    text-align: left;
    margin-left: 0;
    margin-right: 0;
}

/* Post metadata inline layout */
.post-meta-inline {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    line-height: 1.2;
    gap: 0.5em;
    text-align: left;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.post-meta-inline > * {
    flex-shrink: 0;
}

/* Post preview styles */
.latest-post .post-preview {
    margin-bottom: 2rem;
}

.post-meta {
    color: var(--sg-color-primary-alt, #666);
    font-size: 0.9em;
    margin-bottom: 1rem;
}

.post-category,
a.post-category {
    background: var(--sg-color-primary-edge, #f5f5f5);
    padding: 0.2em 0.5em;
    border-radius: 0.25em;
    font-size: 0.8em;
    margin-right: 0.5em;
    display: inline-block;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

a.post-category:hover {
    background: var(--sg-color-primary-alt, #647688);
    color: var(--sg-color-primary-max, #fff);
}

.post-tags {
    margin-top: 0.5rem;
}

.tag,
a.tag {
    color: var(--sg-color-primary-alt, #666);
    font-size: 0.7em;
    margin-right: 0.15em;
    display: inline;
    text-decoration: none;
    white-space: nowrap;
    font-style: italic;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

a.tag:hover {
    color: var(--sg-color-primary, #333);
    text-decoration: underline;
}

/* Post list styles */
.post-list-item {
    border-bottom: 1px dashed var(--sg-color-primary-edge, #ddd);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.post-list-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.post-list-item h4 {
    margin-bottom: 0.5rem;
}

.post-list-item h4 a {
    color: var(--sg-color-primary, #333);
    text-decoration: none;
}

.post-list-item h4 a:hover {
    text-decoration: underline;
}

/* Post content styles */
.post-content {
    line-height: 1.6;
    text-align: left;
    margin-left: 0;
    margin-right: 0;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content h1:first-child,
.post-content h2:first-child,
.post-content h3:first-child {
    margin-top: 0;
}

.post-content p {
    margin-bottom: 1rem;
}

.post-content blockquote {
    border-left: 4px solid var(--sg-color-primary-edge, #ddd);
    padding-left: 1rem;
    margin-left: 0;
    font-style: italic;
    color: var(--sg-color-primary-alt, #666);
}

/* Post navigation */
.post-navigation {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.post-navigation a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px dashed var(--sg-color-primary-edge, #ddd);
    border-radius: 0.25rem;
    background: var(--sg-color-primary-max, #fff);
    color: var(--sg-color-primary, #333);
    transition: all 0.2s ease;
}

.post-navigation a:hover {
    background: var(--sg-color-primary-edge, #f5f5f5);
    border-style: solid;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .post-navigation {
        flex-direction: column;
    }
    
    .post-navigation a {
        text-align: center;
    }
}

/* Code highlighting improvements */
.post-content pre {
    background: var(--sg-color-primary-edge, #f5f5f5);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.post-content code {
    background: var(--sg-color-primary-edge, #f5f5f5);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.post-content pre code {
    background: none;
    padding: 0;
}

/* Mobile responsiveness improvements */

/* Small phones: 0-480px */
@media (max-width: 480px) {
    /* Extra small font sizes for tiny screens */
    body {
        font-size: 14px !important;
    }
    
    h1 {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 20px !important;
        line-height: 1.2 !important;
    }
    
    h3 {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }
    
    h4, h5, h6 {
        font-size: 16px !important;
        line-height: 1.3 !important;
    }
    
    .u-fs-lg {
        font-size: 18px !important;
    }
    
    .post-meta {
        font-size: 12px !important;
    }
    
    /* Tighter spacing for small screens */
    .post-meta-inline {
        gap: 0.25em !important;
    }
    
    .post-tags {
        gap: 0.2rem !important;
    }
}

/* Phones and small tablets: 481-768px */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        font-size: 16px !important;
    }
    
    h1 {
        font-size: 28px !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }
    
    h3 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }
    
    h4, h5, h6 {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }
    
    .u-fs-lg {
        font-size: 20px !important;
    }
    
    .post-meta {
        font-size: 14px !important;
    }
}

/* All mobile devices (up to 768px) - shared styles */
@media (max-width: 768px) {
    /* Fix tags wrapping on main page */
    .post-meta-inline {
        flex-wrap: wrap !important;
    }
    
    .post-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        margin-top: 0.5rem;
    }
    
    /* Fix hamburger menu positioning */
    #libdoc-sidebar button.c-btn {
        z-index: 1001 !important;
        pointer-events: auto !important;
        background-color: var(--sg-color-primary-max, #fff) !important;
    }
    
    /* Ensure hamburger menu doesn't overlap page content */
    @media (max-width: 1200px) {
        #libdoc-sidebar button.c-btn {
            position: fixed !important;
            transform: none !important;
        }
        
        /* Add top padding to page header to prevent overlap with hamburger menu */
        #libdoc-page-title {
            padding-top: 50px !important;
        }
    }
    
    /* Fix sidebar height to take full screen */
    #libdoc-sidebar {
        height: 100vh !important;
        min-height: 100vh !important;
    }
    
    #libdoc-sidebar-menu {
        max-height: 100vh !important;
    }
    
    /* Fix content width - ensure full screen usage */
    #libdoc-content {
        max-width: 100vw !important;
        overflow-x: hidden;
    }
    
    main {
        max-width: 100vw !important;
        overflow-x: hidden;
    }
    
    .post-content,
    .post-preview {
        max-width: 100% !important;
        overflow-x: hidden;
    }
}

/* Tablets in portrait mode: 769-1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Slightly reduced font sizes for tablets */
    body {
        font-size: 17px !important;
    }
    
    h1 {
        font-size: 36px !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 30px !important;
        line-height: 1.2 !important;
    }
    
    h3 {
        font-size: 22px !important;
        line-height: 1.3 !important;
    }
    
    /* Ensure tags wrap on tablets too */
    .post-meta-inline {
        flex-wrap: wrap !important;
    }
    
    .post-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    
    /* Optimize content width for tablets */
    #libdoc-content {
        max-width: 95vw !important;
    }
}

/* Force light mode for comments on all devices */
.giscus,
.giscus-frame {
    color-scheme: light !important;
}

.comments-section {
    background-color: #ffffff !important;
    color: #000000 !important;
}