/* Image Error Handling */
img {
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    display: block;
    max-width: 100%;
    height: auto;
}

/* Loading state */
img:not(.loaded) {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    min-height: 200px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Successfully loaded */
img.loaded {
    animation: fadeIn 0.3s ease-in;
    background: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Failed to load - แสดง broken image icon */
img.error,
img[data-error="true"] {
    position: relative;
    min-height: 200px;
    background: #f5f5f5;
    border: 1px dashed #ddd;
}

img.error::before,
img[data-error="true"]::before {
    content: "📷";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

img.error::after,
img[data-error="true"]::after {
    content: "Image not available";
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #999;
}

/* Breadcrumb Styles */
.breadcrumb {
    padding: 15px 0;
    margin-bottom: 20px;
    background: transparent;
    font-size: 14px;
}

.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: "›";
    padding: 0 8px;
    color: #999;
    font-size: 16px;
}

.breadcrumb li:last-child {
    color: #666;
}

.breadcrumb a {
    color: #0066cc;
    text-decoration: none;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: #004499;
    text-decoration: underline;
}

/* Research Post Type Styles */
.research-meta {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-left: 4px solid #0066cc;
}

.research-meta .citation-info {
    font-size: 13px;
    line-height: 1.6;
    color: #333;
}

.research-meta .pdf-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: #0066cc;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.research-meta .pdf-link:hover {
    background: #004499;
}

/* Responsive Breadcrumb */
@media (max-width: 768px) {
    .breadcrumb {
        font-size: 13px;
    }
    
    .breadcrumb li:not(:last-child)::after {
        padding: 0 5px;
    }
}

/* Schema.org hidden elements */
[itemscope] meta,
[itemscope] link {
    display: none;
}

/* Loading optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Performance: Prevent layout shift */
img {
    max-width: 100%;
    height: auto;
}

/* Research archive grid */
.post-type-archive-research .site-main {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    padding: 20px 0;
}

.post-type-archive-research article {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.post-type-archive-research article:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.post-type-archive-research .entry-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.post-type-archive-research .entry-content {
    padding: 20px;
}

.post-type-archive-research .entry-title {
    font-size: 18px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.post-type-archive-research .entry-meta {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

/* Responsive Research Grid */
@media (max-width: 768px) {
    .post-type-archive-research .site-main {
        grid-template-columns: 1fr;
    }
}
