/* ================================================================
   骨架載入 Skeleton
   - GPU 加速 shimmer（用 transform 不用 background-position）
   - 與既有 CSS 完全獨立，命名空間 .sk-*
   - 尊重 prefers-reduced-motion
   ================================================================ */

:root {
    --sk-base:      #e6e6e6;   /* 底色 */
    --sk-highlight: #f3f3f3;   /* shimmer 高亮色 */
    --sk-radius:    6px;
    --sk-radius-lg: 10px;
    --sk-radius-pill: 999px;
    --sk-duration:  1.6s;
}

/* 容器：包整個骨架；fade-in 用 */
.sk-container {
    opacity: 1;
    transition: opacity .2s ease-out;
}
.sk-container.is-fading-out {
    opacity: 0;
}

/* 基底元素：方塊、文字線、圖、圓形、按鈕… */
.sk {
    position: relative;
    overflow: hidden;
    background-color: var(--sk-base);
    border-radius: var(--sk-radius);
    /* shimmer 高亮帶 */
}
.sk::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(
        90deg,
        rgba(255,255,255,0) 0%,
        var(--sk-highlight) 50%,
        rgba(255,255,255,0) 100%
    );
    transform: translateX(-100%);
    animation: sk-shimmer var(--sk-duration) cubic-bezier(0.4, 0, 0.2, 1) infinite;
    will-change: transform;
}

@keyframes sk-shimmer {
    100% { transform: translateX(100%); }
}

/* 元素變化 */
.sk-block   { width: 100%; height: 40px; }
.sk-text    { width: 80%; height: 14px; margin: 6px 0; }
.sk-text--w50  { width: 50%; }
.sk-text--w30  { width: 30%; }
.sk-text--w70  { width: 70%; }
.sk-text--lg   { height: 18px; }
.sk-title   { width: 40%; height: 22px; margin-bottom: 12px; }
.sk-img     { width: 100%; aspect-ratio: 1 / 1; border-radius: var(--sk-radius-lg); }
.sk-thumb   { width: 80px; height: 80px; border-radius: var(--sk-radius-lg); flex-shrink: 0; }
.sk-thumb--sm { width: 60px; height: 60px; }
.sk-thumb--md { width: 130px; height: 130px; }
.sk-circle  { width: 48px; height: 48px; border-radius: 50%; }
.sk-btn     { width: 120px; height: 36px; border-radius: var(--sk-radius); }
.sk-btn--lg { height: 48px; width: 100%; border-radius: 8px; }
.sk-btn--pill { border-radius: var(--sk-radius-pill); }

/* 排版輔助 */
.sk-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f3f3f3;
}
.sk-row:last-child { border-bottom: none; }
.sk-row__main {
    flex: 1 1 auto;
    min-width: 0;
}
.sk-row__aside {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sk-section {
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    border: 1px solid #f0f0f0;
}

.sk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f3f3f3;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

/* 水平捲動（給 browseHistory widget 用） */
.sk-hscroll {
    display: flex;
    gap: 12px;
    overflow: hidden;
    padding: 4px 2px;
}
.sk-hcard {
    flex: 0 0 130px;
    width: 130px;
}
.sk-hcard .sk-thumb { width: 130px; height: 130px; }

/* 兩欄表單佈局（modal 用） */
.sk-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.sk-form-row__label { width: 80px; height: 14px; }
.sk-form-row__input { flex: 1; height: 38px; }

/* 響應式：手機列表骨架壓縮間距 */
@media (max-width: 576px) {
    .sk-thumb    { width: 64px; height: 64px; }
    .sk-thumb--md{ width: 100px; height: 100px; }
    .sk-hcard    { flex: 0 0 110px; width: 110px; }
    .sk-hcard .sk-thumb { width: 110px; height: 110px; }
    .sk-form-row { flex-wrap: wrap; }
    .sk-form-row__label { width: 60px; }
}

/* 尊重作業系統設定 */
@media (prefers-reduced-motion: reduce) {
    .sk::after {
        animation: none;
        background: var(--sk-highlight);
        opacity: 0.35;
        transform: none;
    }
    .sk-container { transition: none; }
}

/* 列印時不顯示骨架 */
@media print {
    .sk-container { display: none !important; }
}
