/**
 * A11y Carousel - 無障礙輪播元件樣式
 * 依據數位部無障礙規範 (accessibility.moda.gov.tw) 及 WCAG 2.1 AA 標準
 */

/* ==========================================
   共用基礎
   ========================================== */
.a11y-carousel {
    position: relative;
}

/* ==========================================
   淡入淡出輪播 (主視覺 Banner)
   ========================================== */
.a11y-carousel--fade {
    overflow: hidden;
}

.a11y-carousel--fade .a11y-carousel__track {
    position: relative;
    width: 100%;
    height: 100%;
}

/* 非作用中投影片：絕對定位疊於底層、不可見 */
.a11y-carousel--fade .a11y-carousel__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
    visibility: hidden;
}

/* 作用中投影片：相對定位，撐開容器高度 */
.a11y-carousel--fade .a11y-carousel__slide.is-active {
    position: relative;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* ==========================================
   多項目滑動輪播 (贊助 / 主題)
   ========================================== */
.a11y-carousel--multi {
    overflow: hidden;
}

.a11y-carousel--multi .a11y-carousel__track {
    display: flex;
    transition: transform 0.4s ease;
    will-change: transform;
}

.a11y-carousel--multi .a11y-carousel__slide {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
}

/* ==========================================
   控制按鈕 — 共用
   ========================================== */
.a11y-carousel__btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    transition: background-color 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    font-size: 1rem;
}

.a11y-carousel__btn:hover {
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* WCAG 2.1 SC 2.4.7：可見的鍵盤焦點 */
.a11y-carousel__btn:focus-visible {
    outline: 3px solid var(--primary, #667eea);
    outline-offset: 2px;
}

/* ==========================================
   淡入淡出輪播 — 前/後按鈕 (左右側)
   ========================================== */
.a11y-carousel--fade .a11y-carousel__btn--prev,
.a11y-carousel--fade .a11y-carousel__btn--next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.a11y-carousel--fade .a11y-carousel__btn--prev {
    left: 0.75rem;
}

.a11y-carousel--fade .a11y-carousel__btn--next {
    right: 0.75rem;
}

/* 暫停按鈕放右下角 */
.a11y-carousel--fade .a11y-carousel__btn--pause {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
}

/* ==========================================
   多項目輪播 — 導覽列 (下方置中)
   ========================================== */
.a11y-carousel__nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

/* ==========================================
   隱藏式即時區域 (Live Region for SR)
   WCAG 2.1 SC 4.1.3
   ========================================== */
.a11y-carousel__live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================
   動作減弱支援
   WCAG 2.1 SC 2.3.3 (AAA) / SC 1.4.13
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .a11y-carousel--fade .a11y-carousel__slide {
        transition: none;
    }

    .a11y-carousel--multi .a11y-carousel__track {
        transition: none;
    }
}
