/*
==============================================
 AJAX Load More - Enhanced Styles (v3.3.0)
 完整後台設定支援版本
==============================================
*/

/* --- CSS 變數定義（預設為一般模式，深色模式由 PHP 動態覆蓋） --- */
:root {
--alm-primary: #2c3e50;
--alm-primary-hover: #34495e;
--alm-accent: #3498db;
--alm-text-dark: #2c3e50;
--alm-text-light: #7f8c8d;
--alm-border: #ecf0f1;
--alm-bg-light: #ffffff;
--alm-shadow: 0 2px 8px rgba(0,0,0,0.08);
--alm-shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
--alm-radius: 12px;
--alm-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 整體容器 --- */
.alm-section-wrapper {
margin: 0px auto;
padding: 40px 0px; /* 預設值，會被動態 CSS 覆蓋 */
max-width: 1400px;
width: min(100%, 1400px);
box-sizing: border-box;
/*background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);*/
border-radius: var(--alm-radius);
}

.alm-section-wrapper[hidden],
.alm-section-wrapper--empty {
display: none !important;
}

/*.alm-section-title {
text-align: center;
font-size: clamp(24px, 4vw, 32px);
font-weight: 700;
color: var(--alm-text-dark);
margin-bottom: 40px;
position: relative;
padding-bottom: 15px;
}

.alm-section-title::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 60px;
height: 4px;
background: linear-gradient(90deg, var(--alm-accent), #9b59b6);
border-radius: 2px;
}*/

.alm-section-title {
text-align: center;
font-size: 1.4rem;
color: var(--alm-text-dark);
margin: 20px 0 0;
position: relative;
clear: both;
font-weight: 900;
line-height: 1.4;
letter-spacing: 0.01em;
}

.alm-section-title a {
color: inherit;
text-decoration: none;
}

.alm-section-title a:hover,
.alm-section-title a:focus-visible {
color: inherit;
text-decoration: none;
}

.alm-section-title--style-classic-line {
padding: 10px 9px 10px 0;
border-bottom: 2px solid #e1e1e1;
}

.alm-section-title--style-accent-bar {
padding: 10px 18px;
border-left: 5px solid var(--alm-primary);
border-radius: 0 16px 16px 0;
background: linear-gradient(90deg, rgba(44, 62, 80, 0.08) 0%, rgba(44, 62, 80, 0.01) 100%);
}

.alm-section-title--style-soft-pill {
display: block;
width: fit-content;
max-width: 100%;
padding: 10px 18px;
border: 1px solid rgba(44, 62, 80, 0.14);
border-radius: 999px;
background: rgba(255, 255, 255, 0.92);
box-shadow: 0 8px 24px rgba(44, 62, 80, 0.08);
}

.alm-section-title--style-minimal {
padding: 0;
border: none;
background: transparent;
}

/* 左對齊時調整裝飾線位置 */
.alm-section-title--align-left {
text-align: left;
}

.alm-section-title--align-center {
text-align: center;
}

.alm-section-title--align-right {
text-align: right;
}

.alm-section-title--style-soft-pill.alm-section-title--align-left {
margin-right: auto;
}

.alm-section-title--style-soft-pill.alm-section-title--align-center {
margin-left: auto;
margin-right: auto;
}

.alm-section-title--style-soft-pill.alm-section-title--align-right {
margin-left: auto;
}

/* 修改後 */
.alm-posts-container {
margin-bottom: 15px;
min-height: 200px;
/* display: grid; 已移除 */
/* gap: 30px; 已移除，由 PHP 動態控制 */
margin-top: 20px;
}

/* --- 載入按鈕 --- */
.alm-button-wrapper {
text-align: center;
padding: 20px 0;
}

.alm-button {
background: linear-gradient(135deg, var(--alm-primary) 0%, var(--alm-primary-hover) 100%);
color: #fff;
border: none;
padding: 14px 36px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
border-radius: 50px;
box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
transition: var(--alm-transition);
position: relative;
overflow: hidden;
}

/*.alm-button::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
transform: translate(-50%, -50%);
transition: width 0.6s, height 0.6s;
}*/

.alm-button:hover::before {
width: 300px;
height: 300px;
}

.alm-button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(44, 62, 80, 0.3);
}

.alm-button:active {
transform: translateY(0);
}

.alm-button:disabled {
background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
cursor: not-allowed;
transform: none;
box-shadow: none;
}

/* --- 文章卡片基本樣式 --- */
.ajax-post-card {
background: var(--alm-bg-light);
border-radius: var(--alm-radius);
overflow: hidden;
box-shadow: var(--alm-shadow);
transition: var(--alm-transition);
display: flex;
flex-direction: column;
height: 100%;
}

.ajax-post-card:hover {
transform: translateY(-4px);
box-shadow: var(--alm-shadow-hover);
}

/* --- 圖片容器 (修正版 v4.1.1) --- */
.ajax-post-thumbnail {
position: relative;
display: block; /* 確保容器是區塊元素 */
overflow: hidden;
background: #f0f0f0; /* 使用設定的佔位顏色 */
transition: background-color 0.3s ease;

/* 
 * 【核心修正】使用 aspect-ratio 屬性，這是現代瀏覽器的最佳實踐。
 * 它會自動維持 16 / 10 的長寬比。
 */
aspect-ratio: 16 / 10;
}

/* 當圖片載入完成後，移除容器背景色 */
.ajax-post-thumbnail.img-loaded {
    background-color: transparent !important;
}

.ajax-post-thumbnail.img-error {
    background: #f8fafc;
}

/* --- 【新版樣式】增強效果 (v4.4.0) --- */

/* 1. 卡片層次與提升感 */
.alm-premium-on .ajax-post-card {
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.03);
}

.alm-premium-on .ajax-post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

/* 2. 縮圖懸浮縮放效果 */
.alm-premium-on .ajax-post-thumbnail img,
.alm-premium-on .ajax-post-thumbnail-img {
    transition: transform 0.8s cubic-bezier(0.2, 1, 0.3, 1);
}

.alm-premium-on .ajax-post-card:hover .ajax-post-thumbnail img,
.alm-premium-on .ajax-post-card:hover .ajax-post-thumbnail-img {
    transform: none;
}

/* 3. 分類標籤精緻化 (毛玻璃效果) */
.alm-premium-on .ajax-post-thumbnail .ajax-post-category {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 700;
    letter-spacing: 1px;
    padding: 7px 14px;
    border-radius: 8px;
}

/* 4. 標題與文字精緻化 */
.alm-premium-on .ajax-post-title {
    font-weight: 700;
    color: #1a1a1a;
    transition: color 0.3s ease;
}

/* 5. 按鈕優化 (漸層與反應) */
.alm-premium-on .alm-button {
    background: linear-gradient(135deg, #454552 0%, #2c2c31 100%);
    letter-spacing: 0.5px;
}

.alm-premium-on .alm-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}


/* --- 【極簡模式】無陰影設定 --- */
.alm-minimal-on .ajax-post-card {
    box-shadow: none !important;
    border: 1px solid var(--alm-border, #ecf0f1);
}

.alm-minimal-on .ajax-post-card:hover {
    box-shadow: none !important;
    transform: none; /* 極簡模式預設不位移，若需位移可改為 translateY(-2px) */
    background: rgba(0,0,0,0.02);
}

.alm-minimal-on.alm-premium-on .ajax-post-card:hover {
    transform: translateY(-2px); /* 如果同時開啟極簡與增強，給予極輕微的回饋 */
}

/* 
 * 為了相容不支援 aspect-ratio 的舊瀏覽器，我們保留 padding-top 技巧。
 * @supports 語法會讓支援 aspect-ratio 的瀏覽器忽略這段。
 */
@supports not (aspect-ratio: 16 / 10) {
.ajax-post-thumbnail {
padding-top: 62.5%; /* 10 / 16 = 0.625 => 62.5% */
}
}

/* 
 * 無論是否有 <a> 標籤，圖片都相對於 .ajax-post-thumbnail 定位
 */
.ajax-post-thumbnail img,
.ajax-post-thumbnail-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover; /* 保持圖片填滿且不變形 */
    display: block;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ajax-post-thumbnail img.loaded,
.ajax-post-thumbnail img.lazy-loaded,
.ajax-post-thumbnail-img.loaded,
.ajax-post-thumbnail-img.lazy-loaded,
.ajax-post-thumbnail img[data-alm-image-state="loaded"],
.ajax-post-thumbnail img[data-alm-image-state="fallback"],
.ajax-post-thumbnail img[data-alm-image-state="placeholder"] {
    opacity: 1;
}

.ajax-post-thumbnail img.alm-image-error,
.ajax-post-thumbnail-img.alm-image-error {
    object-fit: contain;
    background: #f8fafc;
}

.ajax-post-thumbnail picture {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.ajax-post-thumbnail picture img,
.ajax-post-thumbnail picture .ajax-post-thumbnail-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* 
 * 如果存在 <a> 標籤 (非延伸連結模式)，讓它也填滿整個容器
 */
.ajax-post-thumbnail a {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}


/* --- 分類標籤（圖片上方） --- */
.ajax-post-thumbnail .ajax-post-category {
position: absolute;
z-index: 10;
background: rgba(0, 0, 0, 0.75);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
color: #fff;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
padding: 6px 12px;
border-radius: 6px;
text-decoration: none;
transition: var(--alm-transition);
box-shadow: 0 2px 8px rgba(0,0,0,0.2);

/* 確保這裡沒有 top, left, right, bottom 屬性 */
}

.ajax-post-thumbnail .ajax-post-category:hover {
background: var(--alm-accent);
color: #fff;
transform: translateY(-2px);
}

/* --- 內容區域 --- */
.ajax-post-content {
padding: 20px; /* 預設值，會被動態 CSS 覆蓋 */
flex: 1;
display: flex;
flex-direction: column;
}

.ajax-post-meta {
display: flex;
align-items: center;
gap: 12px;
font-size: 13px;
color: var(--alm-text-light);
margin-bottom: 0px;
flex-wrap: wrap;
}

.ajax-post-date {
display: inline-flex;
align-items: center;
gap: 4px;
}

.ajax-post-date::before {
content: '📅';
font-size: 14px;
}

.ajax-post-author {
display: inline-flex;
align-items: center;
gap: 4px;
}

.ajax-post-author::before {
content: '✍️';
font-size: 14px;
}

/* --- 標題樣式 --- */
/*.ajax-post-title {
font-size: 18px;
font-weight: 700;
line-height: 1.4;
margin: 0 0 12px 0;
color: var(--alm-text-dark);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-word;
hyphens: auto;
}*/

.ajax-post-title {
padding-left: 0;
padding-right: 0;
padding-top: 5px;
height: auto;
text-decoration: none;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
color: #1f1d1d;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 1.1rem;
line-height: 1.8em;
font-weight: 400;
}

.ajax-post-title a {
color: inherit;
text-decoration: none;
transition: color 0.3s;
}

.ajax-post-title a:hover {
color: var(--alm-accent);
}

/* --- 摘要樣式 --- */
.ajax-post-excerpt {
font-size: 14px;
line-height: 1.7;
color: var(--alm-text-light);
margin: 0;
flex: 1;

/* 多行省略處理 */
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}

/* --- 載入動畫 --- */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

.ajax-post-card {
animation: fadeInUp 0.5s ease-out;
}

/* 逐個延遲顯示 */
.ajax-post-card:nth-child(1) { animation-delay: 0.1s; }
.ajax-post-card:nth-child(2) { animation-delay: 0.2s; }
.ajax-post-card:nth-child(3) { animation-delay: 0.3s; }
.ajax-post-card:nth-child(4) { animation-delay: 0.4s; }
.ajax-post-card:nth-child(5) { animation-delay: 0.5s; }
.ajax-post-card:nth-child(6) { animation-delay: 0.6s; }

/* --- 特殊狀態 --- */
.alm-loading {
pointer-events: none;
opacity: 0.6;
}

.alm-no-posts {
text-align: center;
padding: 60px 20px;
color: var(--alm-text-light);
font-size: 16px;
}

/* --- 載入中的微調器動畫 --- */
@keyframes alm-spin {
to {
transform: rotate(360deg);
}
}

/* --- 減少動畫偏好 --- */
@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}

/* 
==============================================
 響應式設計基礎
 （詳細的版面設定由 PHP 動態生成）
==============================================
*/

@media (max-width: 767px) {
/* .alm-posts-container {
grid-template-columns: 1fr;  <-- 已刪除或註解掉此行
} */

.alm-section-wrapper {
padding-left: 16px;
padding-right: 16px;
overflow-x: clip;
}

.alm-posts-container,
.alm-posts-container > ul,
.ajax-post-card,
.ajax-post-content,
.ajax-post-title,
.ajax-post-excerpt {
min-width: 0;
overflow-wrap: anywhere;
}

.alm-section-title {
font-size: 24px;
margin-bottom: 30px;
}

/* 手機版按鈕 */
.alm-button {
padding: 12px 28px;
font-size: 15px;
}
}

/* 
==============================================
 列表樣式輔助類別
 （當後台選擇列表樣式時會套用）
==============================================
*/

/* 列表模式的基礎樣式 */
.alm-list-style .ajax-post-card {
display: flex;
flex-direction: row;
gap: 24px;
margin-bottom: 30px;
border-bottom: 2px solid var(--alm-border);
padding-bottom: 30px;
background: transparent;
box-shadow: none;
border-radius: 0;
}

.alm-list-style .ajax-post-card:last-child {
border-bottom: none;
padding-bottom: 0;
margin-bottom: 0;
}

.alm-list-style .ajax-post-card:hover {
transform: none;
box-shadow: none;
}

.alm-list-style .ajax-post-thumbnail {
flex: 0 0 280px;
height: 180px;
}

.alm-list-style .ajax-post-thumbnail a {
padding-top: 0;
height: 100%;
border-radius: var(--alm-radius);
}

.alm-list-style .ajax-post-content {
flex: 1;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
}

/* 列表模式手機版 */
@media (max-width: 768px) {
.alm-list-style .ajax-post-card {
flex-direction: column;
gap: 16px;
padding-bottom: 24px;
margin-bottom: 24px;
}

.alm-list-style .ajax-post-thumbnail {
flex: none;
height: 200px;
width: 100%;
}

.alm-list-style .ajax-post-content {
padding: 0;
}
}

/* 
==============================================
 修正：分類標籤不應佔滿圖片
 關鍵問題：分類標籤應該是「內容自適應寬度」而非「佔滿容器」
==============================================
*/

/* --- 通用分類標籤樣式（所有模式適用）--- */
.ajax-post-thumbnail .ajax-post-category {
/* 【核心修正 1】讓標籤寬度自適應內容 */
display: inline-block;  /* 改為 inline-block，寬度由內容決定 */
width: auto;/* 明確設定為 auto */
max-width: calc(100% - 24px); /* 最大不超過圖片寬度減去間距 */

/* 【核心修正 2】文字溢出處理 */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

/* 定位與層級 */
position: absolute;
z-index: 10;

/* 樣式 */
background: rgba(0, 0, 0, 0.75);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
color: #fff;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
padding: 6px 12px;
border-radius: 6px;
box-sizing: border-box;
transition: var(--alm-transition);
}

/* --- 手機列表模式特別處理 --- */
@media (max-width: 767px) {
/* 確保容器正確 */
.ajax-post-thumbnail { 
flex: 0 0 200px;
position: relative; /* 重要：讓分類標籤相對於圖片定位 */
}

/* 手機列表模式的分類標籤 */
.ajax-post-thumbnail .ajax-post-category {
display: inline-block; /* 保持內容自適應 */
width: auto;
max-width: calc(200px - 24px); /* 圖片寬度 - 左右間距 */
}
}

/* --- 平板/桌機列表模式 --- */
.alm-list-style .ajax-post-thumbnail {
flex: 0 0 280px;
height: 180px;
position: relative;
}

.alm-list-style .ajax-post-thumbnail .ajax-post-category {
display: inline-block;
width: auto;
max-width: calc(280px - 24px);
}

/* --- 經典宮格模式 --- */
.changeItem.grid .ajax-post-category {
display: inline-block; /* 保持內容自適應 */
width: auto;
max-width: calc(100% - 24px);
position: absolute;
top: 12px;
left: 12px;
z-index: 10;
}

/* --- 標準宮格模式 --- */
.ajax-post-card .ajax-post-thumbnail .ajax-post-category {
display: inline-block;
width: auto;
max-height: 30px;
}

/* --- 如果啟用延伸連結，確保分類標籤仍可點擊 --- */
.alm-stretched-link ~ .ajax-post-thumbnail .ajax-post-category {
position: relative;
z-index: 11; /* 比延伸連結層(z-index: 1)更高 */
pointer-events: auto;
}

/* 延伸連結模式下，整個縮圖容器的定位 */
.ajax-post-card.alm-stretched-link .ajax-post-thumbnail {
position: relative;
}

/* 
==============================================
 深色模式額外最佳化
==============================================
*/

/* 深色模式下的特殊調整（由 PHP 動態添加 class 或 style） */
.alm-dark-mode {
--alm-primary: #3498db;
--alm-primary-hover: #5dade2;
--alm-text-dark: #ecf0f1;
--alm-text-light: #bdc3c7;
--alm-border: #34495e;
--alm-bg-light: #2c3e50;
--alm-shadow: 0 2px 8px rgba(0,0,0,0.3);
--alm-shadow-hover: 0 8px 24px rgba(0,0,0,0.4);
}

.alm-dark-mode .alm-section-wrapper {
background: linear-gradient(180deg, #1a252f 0%, #2c3e50 100%);
}

.alm-dark-mode .ajax-post-card {
background: #34495e;
}

.alm-dark-mode .ajax-post-card:hover {
background: #3d5468;
}

/* 
==============================================
 列印樣式
==============================================
*/

@media print {
.alm-button-wrapper {
display: none;
}

.ajax-post-card {
break-inside: avoid;
box-shadow: none;
border: 1px solid #ddd;
margin-bottom: 20px;
}

.ajax-post-thumbnail img {
max-height: 200px;
object-fit: contain;
}
}

/* 
==============================================
 無障礙輔助
==============================================
*/

/* 鍵盤焦點樣式 */
.ajax-post-card a:focus {
outline: 2px solid var(--alm-accent);
outline-offset: 2px;
}

.alm-button:focus {
outline: 3px solid var(--alm-accent);
outline-offset: 3px;
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
.ajax-post-card {
border: 2px solid var(--alm-text-dark);
}

.ajax-post-thumbnail .ajax-post-category {
background: #000;
border: 1px solid #fff;
}
}

/* 
==============================================
 載入狀態與錯誤提示
==============================================
*/

.alm-error {
background: #e74c3c;
color: white;
padding: 15px 20px;
border-radius: 8px;
margin: 20px auto;
text-align: center;
max-width: 600px;
animation: shake 0.5s;
}

@keyframes shake {
0%, 100% { transform: translateX(0); }
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.alm-no-more {
text-align: center;
color: var(--alm-text-light);
font-size: 14px;
padding: 20px;
opacity: 0;
animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
to { opacity: 1; }
}

/* 
==============================================
 骨架屏載入效果（可選）
==============================================
*/

.alm-skeleton {
background: linear-gradient(
90deg,
var(--alm-border) 25%,
#f0f0f0 50%,
var(--alm-border) 75%
);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}

.alm-skeleton .ajax-post-thumbnail {
background: var(--alm-border);
min-height: 200px;
}

.alm-skeleton .ajax-post-title,
.alm-skeleton .ajax-post-excerpt {
background: var(--alm-border);
border-radius: 4px;
color: transparent;
}

/* 
==============================================
 自訂滾動條（僅 Webkit）
==============================================
*/

.alm-section-wrapper::-webkit-scrollbar {
width: 8px;
height: 8px;
}

.alm-section-wrapper::-webkit-scrollbar-track {
background: var(--alm-border);
border-radius: 4px;
}

.alm-section-wrapper::-webkit-scrollbar-thumb {
background: var(--alm-text-light);
border-radius: 4px;
}

.alm-section-wrapper::-webkit-scrollbar-thumb:hover {
background: var(--alm-primary);
}

/* 
==============================================
 實用工具類別
==============================================
*/

/* 隱藏特定元素 */
.alm-hide-category .ajax-post-category { display: none !important; }
.alm-hide-date .ajax-post-date { display: none !important; }
.alm-hide-excerpt .ajax-post-excerpt { display: none !important; }
.alm-hide-author .ajax-post-author { display: none !important; }

/* 對齊工具 */
.alm-text-left { text-align: left !important; }
.alm-text-center { text-align: center !important; }
.alm-text-right { text-align: right !important; }

/* 間距工具 */
.alm-spacing-sm { gap: 15px !important; }
.alm-spacing-md { gap: 30px !important; }
.alm-spacing-lg { gap: 45px !important; }

/* 
==============================================
 瀏覽器相容性修正
==============================================
*/

/* IE11 不支援 grid，回退到 flex */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.alm-posts-container {
display: flex;
flex-wrap: wrap;
}

.ajax-post-card {
flex: 0 0 calc(33.333% - 20px);
margin: 10px;
}
}

/* Safari 特定修正 */
@supports (-webkit-appearance: none) {
.ajax-post-thumbnail a {
will-change: transform;
}
}

/* Firefox 特定修正 */
@-moz-document url-prefix() {
.ajax-post-card {
image-rendering: -moz-crisp-edges;
}
}

/* 
==============================================
 效能最佳化
==============================================
*/

/* GPU 加速 */
.ajax-post-card,
.ajax-post-thumbnail img,
.alm-button {
will-change: transform;
transform: translateZ(0);
backface-visibility: hidden;
}

/* 圖片載入最佳化 */
.ajax-post-thumbnail img {
image-rendering: auto;
}


/* 
==============================================
 AJAX Load More - 擴充樣式 (v3.3.1)
 請將此檔案加入原有的 CSS 檔案中
==============================================
*/

/* --- 載入按鈕增強樣式 --- */
.alm-button {
position: relative;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 載入中的旋轉動畫 */
.alm-spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: #fff;
border-radius: 50%;
animation: alm-spin 0.6s linear infinite;
vertical-align: middle;
margin-right: 8px;
}

@keyframes alm-spin {
to { transform: rotate(360deg); }
}

/* 載入中狀態的按鈕 */
.alm-button.alm-loading {
pointer-events: none;
opacity: 0.7;
}

/* --- 錯誤訊息樣式 --- */
.alm-error {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
color: white;
padding: 16px 24px;
border-radius: 8px;
margin: 20px auto;
text-align: center;
max-width: 600px;
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
animation: alm-slide-down 0.3s ease-out;
}

@keyframes alm-slide-down {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

.alm-error-icon {
font-size: 20px;
flex-shrink: 0;
}

.alm-error-text {
flex: 1;
font-size: 14px;
font-weight: 500;
}

.alm-retry-btn {
background: rgba(255, 255, 255, 0.2);
color: white;
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 6px 14px;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
font-weight: 600;
transition: all 0.3s;
white-space: nowrap;
}

.alm-retry-btn:hover {
background: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.5);
}

/* --- 「沒有更多文章」訊息樣式 --- */
.alm-no-more {
text-align: center;
color: var(--alm-text-light, #7f8c8d);
font-size: 14px;
padding: 20px;
background: var(--alm-bg-light, #ffffff);
border-radius: 8px;
margin: 20px auto;
max-width: 400px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
animation: alm-fade-in 0.3s ease-out;
}

@keyframes alm-fade-in {
from { opacity: 0; }
to { opacity: 1; }
}

.alm-no-more::before {
content: '✓';
display: inline-block;
width: 24px;
height: 24px;
background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
color: white;
border-radius: 50%;
line-height: 24px;
margin-right: 8px;
font-weight: bold;
}

/* --- 文章淡入動畫最佳化 --- */
.ajax-post-card {
transform-origin: center top;
will-change: opacity, transform;
}

/* 骨架屏載入效果（可選） */
.ajax-post-card.alm-skeleton {
pointer-events: none;
}

.ajax-post-card.alm-skeleton .ajax-post-thumbnail {
background: linear-gradient(
90deg,
#f0f0f0 25%,
#e0e0e0 50%,
#f0f0f0 75%
);
background-size: 200% 100%;
animation: alm-shimmer 1.5s infinite;
}

.ajax-post-card.alm-skeleton .ajax-post-title,
.ajax-post-card.alm-skeleton .ajax-post-excerpt {
background: #f0f0f0;
color: transparent;
border-radius: 4px;
animation: alm-shimmer 1.5s infinite;
}

@keyframes alm-shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}

/* --- 按鈕焦點樣式（無障礙） --- */
.alm-button:focus-visible {
outline: 3px solid var(--alm-accent, #3498db);
outline-offset: 3px;
}

.alm-retry-btn:focus-visible {
outline: 2px solid rgba(255, 255, 255, 0.8);
outline-offset: 2px;
}

/* --- 深色模式適配 --- */
@media (prefers-color-scheme: dark) {
.alm-no-more {
background: #2c3e50;
color: #bdc3c7;
}

.alm-error {
box-shadow: 0 4px 12px rgba(231, 76, 60, 0.5);
}
}

/* --- 行動裝置最佳化 --- */
@media (max-width: 767px) {
.alm-error {
flex-direction: column;
padding: 14px 18px;
margin: 15px;
}

.alm-error-text {
text-align: center;
}

.alm-retry-btn {
width: 100%;
margin-top: 8px;
}

.alm-button {
/*width: 100%;*/
padding: 16px 24px;
}

}

/* --- 觸控裝置最佳化 --- */
@media (hover: none) and (pointer: coarse) {
.alm-button {
min-height: 48px; /* 符合 WCAG 觸控目標大小 */
}

.alm-retry-btn {
min-height: 44px;
}
}

/* --- 減少動畫偏好 --- */
@media (prefers-reduced-motion: reduce) {
.alm-spinner,
.ajax-post-card,
.alm-error,
.alm-no-more,
.ajax-post-card.alm-skeleton * {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}

/* --- 列印樣式 --- */
@media print {
.alm-button,
.alm-error,
.alm-no-more,
.alm-button-wrapper {
display: none !important;
}
}
