/*
 * utilities.css — 共通ユーティリティクラス
 * 全ページで使用される汎用ヘルパークラスを一元管理します。
 */

/* Visually hidden (display: none) */
.hidden {
    display: none !important;
}

/* Screen reader only (visually hidden but accessible) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
 * Touch devices: enforce 44px minimum touch targets (WCAG 2.5.8)
 * Only applies when pointer is coarse (touch screens)
 * ============================================================ */
@media (pointer: coarse) {
    .filter-chip,
    .color-chip,
    .view-btn,
    .btn-sm,
    .action-btn,
    .widget-action-btn,
    .nav-link,
    .nav-theme-toggle,
    .nav-logout-btn,
    .tool-btn,
    .btn-icon,
    .timestamp-jump-btn,
    .chart-toggle,
    .nav-hamburger,
    .nav-login-link,
    .nav-brand {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Color chips: expand from 32px to 44px while maintaining circular shape */
    .color-chip {
        width: 44px;
        height: 44px;
    }

    /* Filter chips: increase padding for touch comfort */
    .filter-chip {
        padding: 10px 16px;
    }
}

/* ============================================================
 * Touch device: hover-dependent elements always visible
 * ============================================================ */
@media (hover: none) {
    /* Archive: timestamp link on cards */
    .card-timestamp-link {
        opacity: 0.7;
    }

    /* Dashboard: widget remove button */
    .widget-remove-btn {
        opacity: 0.7;
    }

    /* Disable hover transforms on touch */
    .stream-thumbnail:hover {
        transform: none;
    }
    .archive-card:hover {
        transform: none;
    }
    .donation-card:hover {
        transform: none;
    }
}

/* ============================================================
 * M4-25: iOS Safari dynamic viewport height
 * Page CSS files use 100dvh directly. This fallback catches
 * older browsers that don't support dvh.
 * ============================================================ */
@supports not (min-height: 100dvh) {
    body {
        min-height: 100vh !important;
    }
}

/* Prevent overscroll bounce on internal scroll containers */
.table-wrap,
.channel-sidebar,
.widget-timeline,
.widget-body {
    overscroll-behavior: contain;
}

/* ============================================================
 * M4-24: Mobile performance — disable backdrop-filter
 * backdrop-filter is GPU-intensive on low-end mobile devices
 * ============================================================ */
@media (max-width: 768px) {
    .filter-section,
    .stats-content,
    .modal,
    .cd-overlay {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* ============================================================
 * M4-21: prefers-reduced-motion — disable animations globally
 * WCAG 2.3.3 compliance for vestibular disorder users
 * ============================================================ */
@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;
    }
}
