/* 모바일 전용 CSS - 링크 가독성 및 디자인 개선 */

/* 모바일 기본 설정 */
@media screen and (max-width: 768px) {
    /* 모바일 헤더 인증 버튼 개선 */
    #user-auth-buttons {
        flex-direction: column;
        gap: 4px;
        align-items: flex-end;
    }
    
    #auth-login-buttons {
        gap: 4px;
    }
    
    #auth-login-buttons .btn {
        padding: 4px 8px;
        font-size: 0.75rem;
        border-radius: 4px;
    }
    
    #auth-user-menu .dropdown-toggle {
        padding: 4px 8px;
        font-size: 0.75rem;
        border-radius: 4px;
    }
    
    #auth-user-menu .dropdown-menu {
        min-width: 160px;
        right: 0;
        left: auto;
    }
    
    /* 모바일 네비게이션 개선 */
    .header-nav {
        padding: 6px 0 !important;
        background: linear-gradient(135deg, #000000 0%, #2d2d2d 100%);
    }
    
    .header-nav .container-fluid {
        padding: 0 8px !important;
        max-width: 100% !important;
    }
    
    /* 모바일 네비게이션 그리드 */
    .mobile-nav-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2px !important;
        padding: 4px 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* 모바일 네비게이션 버튼 */
    .mobile-nav-btn {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        padding: 4px 2px !important;
        border-radius: 6px !important;
        font-size: 0.6rem !important;
        font-weight: 600 !important;
        color: #ffffff !important;
        text-align: center !important;
        line-height: 1.0 !important;
        min-height: 32px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
        transition: all 0.2s ease !important;
        box-sizing: border-box !important;
    }
    
    .mobile-nav-btn:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
        text-decoration: none !important;
        color: #ffffff !important;
    }
    
    .mobile-nav-btn:active {
        transform: translateY(0) !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* 더보기 버튼 */
    .mobile-nav-more {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 4px 2px !important;
        border-radius: 6px !important;
        font-size: 0.6rem !important;
        font-weight: 600 !important;
        color: #ffffff !important;
        text-align: center !important;
        line-height: 1.0 !important;
        min-height: 32px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        background: rgba(0, 0, 0, 0.7) !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        box-sizing: border-box !important;
    }
    
    .mobile-nav-more:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }
    
    /* 숨겨진 메뉴 */
    #mobile-hidden-menu {
        display: none !important;
        margin-top: 4px !important;
        padding: 4px !important;
        background: rgba(0, 0, 0, 0.8) !important;
        border-radius: 6px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        box-sizing: border-box !important;
    }
    
    #mobile-hidden-menu .mobile-nav-btn {
        min-height: 28px !important;
        font-size: 0.55rem !important;
        padding: 6px 8px !important;
        border-radius: 4px !important;
    }
}

/* 더 작은 모바일 화면 (360px 이하) */
@media (max-width: 360px) {
    .category-nav-container {
        gap: 0.5px !important;
    }
    
    .category-nav-btn {
        flex: 0 0 calc(33.333% - 0.5px) !important;
        max-width: calc(33.333% - 0.5px) !important;
        width: calc(33.333% - 0.5px) !important;
        font-size: 0.3rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 18px !important;
        max-height: 18px !important;
    }
    
    .category-nav-btn .category-nav-text {
        font-size: 0.3rem !important;
        line-height: 0.8 !important;
    }
    
    .category-nav-btn[href*="http"] {
        font-size: 0.25rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 16px !important;
        max-height: 16px !important;
    }
    
    .category-nav-btn[href*="http"] .category-nav-text {
        font-size: 0.25rem !important;
        line-height: 0.7 !important;
    }
}

/* 매우 작은 모바일 화면 (320px 이하) */
@media (max-width: 320px) {
    .category-nav-container {
        gap: 0.5px !important;
        padding: 0 1px !important;
    }
    
    .category-nav-btn {
        flex: 0 0 calc(33.333% - 0.5px) !important;
        max-width: calc(33.333% - 0.5px) !important;
        width: calc(33.333% - 0.5px) !important;
        font-size: 0.25rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 14px !important;
        max-height: 14px !important;
        margin-bottom: 0.5px !important;
        border-radius: 2px !important;
    }
    
    .category-nav-btn .category-nav-text {
        font-size: 0.25rem !important;
        line-height: 0.7 !important;
    }
    
    .category-nav-btn[href*="http"] {
        font-size: 0.2rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 12px !important;
        max-height: 12px !important;
    }
    
    .category-nav-btn[href*="http"] .category-nav-text {
        font-size: 0.2rem !important;
        line-height: 0.6 !important;
    }
    
    .header-nav {
        padding: 2px 0 !important;
    }
}

/* 초소형 모바일 화면 (280px 이하) */
@media (max-width: 280px) {
    .category-nav-container {
        gap: 0.5px !important;
        padding: 0 0.5px !important;
    }
    
    .category-nav-btn {
        flex: 0 0 calc(33.333% - 0.5px) !important;
        max-width: calc(33.333% - 0.5px) !important;
        width: calc(33.333% - 0.5px) !important;
        font-size: 0.2rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 12px !important;
        max-height: 12px !important;
        margin-bottom: 0.5px !important;
        border-radius: 1px !important;
    }
    
    .category-nav-btn .category-nav-text {
        font-size: 0.2rem !important;
        line-height: 0.6 !important;
    }
    
    .category-nav-btn[href*="http"] {
        font-size: 0.18rem !important;
        padding: 0.5px 0.5px !important;
        min-height: 10px !important;
        max-height: 10px !important;
    }
    
    .category-nav-btn[href*="http"] .category-nav-text {
        font-size: 0.18rem !important;
        line-height: 0.5 !important;
    }
    
    .header-nav {
        padding: 1px 0 !important;
    }
}

@media screen and (max-width: 768px) {
    /* 카테고리 카드 전체 개선 */
    .category-card {
        margin-bottom: 20px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
    }
    
    /* 카테고리 제목 부분 - 흰색 글씨로 변경 */
    .category-card-title {
        color: #ffffff !important;
        font-weight: 700;
        font-size: 1.1rem;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .category-card-title span:first-child {
        font-size: 1.3rem;
    }
    
    /* 더보기 버튼 스타일 개선 */
    .category-more-btn {
        color: #ffffff !important;
        background: rgba(255, 255, 255, 0.2);
        padding: 6px 12px;
        border-radius: 20px;
        text-decoration: none;
        font-size: 0.9rem;
        font-weight: 600;
        transition: all 0.3s ease;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    .category-more-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    
    /* 카테고리 헤더 배경 */
    .category-card-header {
        background: transparent;
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    /* 카테고리 바디 배경 */
    .category-card-body {
        background: #ffffff;
        padding: 0;
        margin: 0;
    }
    
    /* 링크 아이템 전체 개선 - 가득차게 */
    .category-link {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px !important;
        margin: 0 !important;
        width: 100% !important;
        min-height: 60px;
        text-decoration: none !important;
        color: #333 !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
        position: relative;
        background: #ffffff;
    }
    
    .category-link:hover {
        background: linear-gradient(135deg, #f8f9ff 0%, #e8f2ff 100%) !important;
        color: #2563eb !important;
        transform: translateX(4px);
        box-shadow: inset 4px 0 0 #2563eb;
    }
    
    .category-link:active {
        transform: translateX(2px);
        background: #e0f2fe !important;
    }
    
    /* 순위 표시 개선 */
    .category-rank {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 32px;
        height: 32px;
        border-radius: 50%;
        font-weight: 700;
        font-size: 0.9rem;
        margin-right: 16px;
        flex-shrink: 0;
    }
    
    .category-rank.top3 {
        background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
        color: #ffffff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    }
    
    .category-rank.other {
        background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
        color: #475569;
        font-weight: 600;
    }
    
    /* 사이트명 개선 */
    .category-site-name {
        flex: 1;
        font-weight: 600;
        font-size: 1rem;
        color: #1e293b;
        line-height: 1.4;
        margin-right: 12px;
    }
    
    /* 왕관 아이콘 개선 */
    .category-crown {
        color: #fbbf24;
        font-size: 1.2rem;
        margin-left: 8px;
        filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.4));
        animation: crown-glow 2s ease-in-out infinite alternate;
    }
    
    @keyframes crown-glow {
        0% { filter: drop-shadow(0 2px 4px rgba(251, 191, 36, 0.4)); }
        100% { filter: drop-shadow(0 2px 8px rgba(251, 191, 36, 0.8)); }
    }
    
    /* 터치 피드백 개선 */
    .category-link::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: radial-gradient(circle at center, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .category-link:active::before {
        opacity: 1;
    }
    
    /* 카테고리 그리드 간격 조정 */
    .category-grid-component .row {
        margin: 0 -8px;
    }
    
    .category-grid-component .col-6 {
        padding: 0 8px;
        margin-bottom: 16px;
    }
    
    /* 전체 컨테이너 패딩 조정 */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* 카드 그림자 및 테두리 개선 */
    .category-card {
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
    }
    
    /* 스크롤 성능 개선 */
    .category-card-body {
        -webkit-overflow-scrolling: touch;
        transform: translateZ(0);
    }
    
    /* 접근성 개선 */
    .category-link:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
        background: #e0f2fe !important;
    }
    
    /* 로딩 상태 개선 */
    .category-card.loading {
        opacity: 0.7;
        pointer-events: none;
    }
    
    .category-card.loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        border: 2px solid #ffffff;
        border-top: 2px solid transparent;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        transform: translate(-50%, -50%);
    }
    
    @keyframes spin {
        0% { transform: translate(-50%, -50%) rotate(0deg); }
        100% { transform: translate(-50%, -50%) rotate(360deg); }
    }
}

/* 매우 작은 화면 (480px 이하) 추가 최적화 */
@media screen and (max-width: 480px) {
    .category-card-title {
        font-size: 1rem;
    }
    
    .category-site-name {
        font-size: 0.95rem;
    }
    
    .category-link {
        padding: 14px 16px !important;
        min-height: 56px;
    }
    
    .category-rank {
        min-width: 28px;
        height: 28px;
        font-size: 0.85rem;
        margin-right: 12px;
    }
    
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .category-grid-component .row {
        margin: 0 -4px;
    }
    
    .category-grid-component .col-6 {
        padding: 0 4px;
        margin-bottom: 12px;
    }
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .category-card-body {
        background: #1e293b;
    }
    
    .category-link {
        background: #1e293b;
        color: #e2e8f0 !important;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .category-link:hover {
        background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
        color: #60a5fa !important;
    }
    
    .category-site-name {
        color: #e2e8f0;
    }
    
    .category-rank.other {
        background: linear-gradient(135deg, #475569 0%, #64748b 100%);
        color: #e2e8f0;
    }
}

/* 고해상도 디스플레이 최적화 */
@media (-webkit-min-device-pixel-ratio: 2) and (max-width: 768px) {
    .category-card {
        border-width: 0.5px;
    }
    
    .category-link {
        border-bottom-width: 0.5px;
    }
}

/* 가로 모드 최적화 */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .category-link {
        min-height: 50px;
        padding: 12px 20px !important;
    }
    
    .category-rank {
        min-width: 30px;
        height: 30px;
    }
} 