/* ===== 平板設備 (768px - 1024px) ===== */
@media (max-width: 1024px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.2rem; }
    
    .container {
        padding: 0 var(--spacing-lg);
    }
    
    .video-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    .announcement-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* ===== 手機設備 (480px - 768px) ===== */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    p, li { font-size: 1.05rem; }
    
    .container {
        padding: 0 var(--spacing-md);
    }
    
    /* 導航列 */
    .nav-menu {
        display: none;
        position: absolute;
        top: 70px;
        left: 0;
        right: 0;
        flex-direction: column;
        background-color: white;
        box-shadow: var(--shadow-md);
        padding: var(--spacing-lg);
        gap: 0;
        z-index: 99;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu a {
        width: auto;
        min-height: auto;
        justify-content: flex-start;
        text-align: left;
        font-size: 1.1rem;
        border-radius: 8px;
        margin-bottom: 6px;
        padding: 12px 14px;
        border-bottom: none;
    }
    /* LINE Bot 專區在手機版恢復一般寬度 */
    .nav-menu li:nth-child(4) a { min-width: 0; }

    .hamburger {
        display: flex;
    }
    
    /* 英雄區 */
    .hero {
        height: 300px;
    }
    
    .hero-overlay h1 {
        font-size: 2rem;
    }
    
    .hero-overlay p {
        font-size: 1.1rem;
    }
    
    /* 卡片網格 */
    .card-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .info-cards {
        padding: var(--spacing-xl) 0;
    }
    
    /* 布告欄 */
    .announcement-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    /* 影片 */
    .video-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    /* 頁尾 */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    /* 間距調整 */
    .announcements,
    .health-education,
    .videos,
    .activity-intro,
    .line-section {
        padding: var(--spacing-xl) 0;
    }
    
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.95rem;
    }
}

/* ===== 小型手機 (320px - 480px) ===== */
@media (max-width: 480px) {
    html, body {
        font-size: 18px;
    }

    h1 { font-size: 1.9rem; }
    h2 { font-size: 1.45rem; }
    h3 { font-size: 1.2rem; }
    p, li { font-size: 1.05rem; }
    
    /* 導航 */
    .navbar .container {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    
    .nav-brand {
        gap: var(--spacing-sm);
    }
    
    .logo {
        height: 40px;
    }
    
    .logo-text {
        font-size: 0.9rem;
    }
    
    /* 英雄區 */
    .hero {
        height: 250px;
    }
    
    .hero-overlay h1 {
        font-size: 1.5rem;
    }
    
    .hero-overlay p {
        font-size: 1rem;
    }
    
    /* 卡片 */
    .info-card {
        padding: var(--spacing-lg);
    }
    
    .card-icon {
        font-size: 2.5rem;
    }
    
    /* 布告欄 */
    .announcement-item {
        padding: var(--spacing-md);
    }
    
    .announcement-icon {
        font-size: 2rem;
    }
    
    /* 輪播 */
    .carousel-prev,
    .carousel-next {
        padding: var(--spacing-sm);
        font-size: 1.2rem;
    }
    
    .carousel-prev {
        left: var(--spacing-sm);
    }
    
    .carousel-next {
        right: var(--spacing-sm);
    }
    
    /* 按鈕 */
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.9rem;
        display: block;
        width: 100%;
        max-width: 100%;
    }
    
    /* 表單 */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* 防止 iOS 自動縮放 */
    }
    
    /* 頁尾 */
    .footer {
        padding: var(--spacing-xl) 0 var(--spacing-md);
    }
    
    .footer-section h4 {
        font-size: 1rem;
    }
    
    .footer-section p,
    .footer-section a {
        font-size: 0.9rem;
    }
    
    /* 間距 */
    .mt-5, .mb-5 {
        margin-top: var(--spacing-xl) !important;
        margin-bottom: var(--spacing-xl) !important;
    }
}

/* ===== 表單響應式 ===== */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group {
        margin-bottom: var(--spacing-md);
    }
}

/* ===== 表格響應式 ===== */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
    }
    
    table {
        min-width: 100%;
        font-size: 0.9rem;
    }
    
    th, td {
        padding: var(--spacing-sm);
    }
}

/* ===== 列表響應式 ===== */
@media (max-width: 768px) {
    ul, ol {
        padding-left: var(--spacing-lg);
    }
    
    li {
        margin-bottom: var(--spacing-sm);
    }
}

/* ===== 圖片響應式 ===== */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .carousel-item img {
        max-height: 300px;
        object-fit: cover;
    }
}

/* ===== 特殊效果禁用（低功耗模式） ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== 深色模式：強制統一淺色（不隨手機深色模式變色） ===== */
/* 已停用深色覆寫，確保所有裝置顯示一致的淺色配色 */

/* ===== 列印樣式 ===== */
@media print {
    .navbar,
    .footer,
    .btn,
    .carousel-prev,
    .carousel-next {
        display: none;
    }
    
    body {
        background-color: white;
        color: black;
    }
    
    a {
        color: black;
    }
    
    .container {
        max-width: 100%;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    img {
        max-width: 100%;
    }
}

/* ===== 可訪問性 ===== */
@media (prefers-contrast: more) {
    :root {
        --border-color: #000000;
    }
    
    button,
    a {
        text-decoration: underline;
    }
}

/* ===== 觸控設備優化 ===== */
@media (hover: none) and (pointer: coarse) {
    a, button {
        padding: var(--spacing-md);
        min-height: 44px; /* Apple 推薦 */
        min-width: 44px;
    }
    
    .btn {
        padding: var(--spacing-md) var(--spacing-lg);
        min-height: 44px;
    }
}
