/* 1024px 이하 공통 레이아웃 (사이드바 → 상단, 본문 1열 정렬 느낌으로) */
@media (max-width: 1024px) {
    /* 회사소개/사업분야/사업실적/자료실 공통 컨테이너 여백 정리 */
    .content-section .container {
        margin-left: 0;
        padding-left: 20px;
        padding-right: 20px;
        max-width: 100%;
    }

    /* 좌측 고정 사이드바는 숨기고, 본문만 전체 폭 사용 */
    .sidebar-nav {
        display: none;
        position: static;
        height: auto;
        box-shadow: none;
        border-right: none;
    }

    .business-main,
    .portfolio-main {
        margin-left: 0;
    }

    .business-with-sidebar .container,
    .portfolio-with-sidebar .container {
        display: block;
    }

    /* 사업분야(#evaluation 등): style.css의 ID 선택자 margin-left:-260px가
       그대로면 모바일/태블릿에서 본문이 왼쪽으로 밀려 잘림 → 동일 특이도로 초기화 */
    #evaluation .content-section .container,
    #location .content-section .container,
    #supervision .content-section .container,
    #manufacturing .content-section .container,
    #relay .content-section .container {
        margin-left: 0;
        padding-left: 20px;
        padding-right: 20px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .portfolio-main {
        margin-left: 0;
    }

    /* 입지선정 등: PC용 음수 마진 레이아웃 → 좁은 화면에서 가로 스크롤 방지 */
    .evaluation-sub-images-2-1 {
        margin-left: 0 !important;
    }

    .evaluation-sub-images-2-1 .evaluation-sub-images-row:last-child img {
        margin-left: 0 !important;
    }

    .evaluation-sub-images-2-1 .evaluation-sub-images-row-2 img:first-child {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }

    .evaluation-sub-images-2-1 .evaluation-sub-images-row-2 img:last-child {
        margin-left: 0 !important;
    }

    /* 사업분야 흰 박스 안쪽 여백 (좁은 화면) */
    .evaluation-box .business-content {
        padding: 24px 18px;
    }

    /* 하위 탭: 한 줄에 6개flex 시 과도하게 눌림 방지 */
    .evaluation-sub-tabs {
        gap: 6px 4px;
        justify-content: flex-start;
    }

    .evaluation-sub-tab-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        font-size: clamp(0.88rem, 2.2vw, 1.15rem);
        padding: 10px 10px;
    }

    #relay .relay-equipment-tabs .evaluation-sub-tab-btn {
        flex: 1 1 calc(50% - 6px);
        font-size: clamp(0.72rem, 2.8vw, 0.95rem);
    }

    /* 브로슈어·본문 이미지: 고정 픽셀 높이 해제로 세로 비율 유지 */
    .evaluation-sub-images img {
        height: auto;
        max-height: min(70vh, 520px);
        width: 100%;
        object-fit: contain;
    }

    #relay .relay-brochure-page {
        max-width: 100%;
        width: 100%;
        height: auto;
    }
}

/* 태블릿 스타일 */
@media (max-width: 768px) {
    .hero-logo {
        left: 20px;
        padding: 15px;
    }
    
    .hero-logo-img {
        height: 80px;
        max-width: 150px;
    }
    
    .hero-title {
        font-size: 36px;
    }
    
    .hero-subtitle {
        font-size: 18px;
    }
    
    .navbar-logo {
        padding-right: 15px;
    }
    
    .navbar-logo-img {
        height: 40px;
        max-width: 150px;
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        height: 100vh;
        background: var(--white);
        flex-direction: column;
        padding: 80px 30px;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s;
        z-index: 999;
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    .hamburger {
        display: flex;
        z-index: 1001;
    }
    
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .mega-menu-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--white);
        opacity: 0;
        visibility: hidden;
        transform: none;
        padding: 80px 20px 20px;
        grid-template-columns: 1fr;
        gap: 20px;
        overflow-y: auto;
        z-index: 998;
    }
    
    .mega-menu-column {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 20px;
        margin-bottom: 20px;
    }
    
    .mega-menu-column:last-child {
        border-bottom: none;
    }
    
    .services-grid,
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .business-detail,
    .product-detail {
        grid-template-columns: 1fr;
    }
    
    .business-detail.reverse,
    .product-detail.reverse {
        direction: ltr;
    }
    
    .location-content {
        grid-template-columns: 1fr;
    }
    
    .contact-wrapper {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .org-level {
        flex-direction: column;
    }
    
    .timeline-item {
        flex-direction: column;
    }
    
    .timeline-item::before {
        display: none;
    }
}

/* 모바일 스타일 */
@media (max-width: 480px) {
    .hero {
        min-height: 200px;
    }
    
    .hero-slider {
        padding: 32px 16px;
    }
    
    .hero-logo {
        left: 10px;
        top: 20px;
        transform: none;
        padding: 10px;
    }
    
    .hero-logo-img {
        height: 60px;
        max-width: 120px;
    }
    
    .navbar-logo {
        padding-right: 10px;
    }
    
    .navbar-logo-img {
        height: 35px;
        max-width: 120px;
    }
    
    .hero-title {
        font-size: 28px;
    }
    
    .section-title {
        font-size: 28px;
    }
    
    section {
        padding: 50px 0;
    }
    
    .content-section {
        padding: 40px 0;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
    }
    
    .page-header h1 {
        font-size: 28px;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    .performance-table {
        font-size: 12.15px; /* 기존 13.5px에서 10% 추가 축소 */
    }
    .performance-table th,
    .performance-table td {
        padding: 14px 18px;
    }
    .performance-table .col-period {
        width: 11.352%; /* 기존 9.46%에서 20% 증가 */
        min-width: 60px;
    }
    .performance-table .col-client {
        width: 15.34%;
        min-width: 60px;
    }
    
    .awards-grid {
        grid-template-columns: 1fr;
    }
    
    .logo-section {
        grid-template-columns: 1fr;
    }
    
    .materials-grid {
        grid-template-columns: 1fr;
    }
    
    .talent-grid {
        grid-template-columns: 1fr;
    }
    
    .welfare-grid {
        grid-template-columns: 1fr;
    }

    /* 사업분야 본문: 세로 쌓기로 가독성·비율 유지 */
    .evaluation-sub-images {
        flex-direction: column;
        align-items: stretch;
    }

    .evaluation-sub-images img {
        max-height: none;
        width: 100%;
    }

    #relay .relay-equipment-tabs .evaluation-sub-tab-btn {
        flex: 1 1 100%;
    }
}

/* 모바일 공통 안전장치: 가로 깨짐/텍스트 이탈 방지 */
@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    img,
    svg,
    video,
    iframe {
        max-width: 100%;
        height: auto;
    }

    .container,
    .content-section .container {
        width: 100%;
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
    }

    h1, h2, h3, h4, h5, h6, p, li, a, span, td, th {
        overflow-wrap: anywhere;
        word-break: keep-all;
    }

    .org-box,
    .org-box-description {
        width: 100%;
        min-width: 0;
    }

    .org-box-description.eng3-desc ul li.org-item-nowrap-tight {
        white-space: normal;
        letter-spacing: normal;
    }

    .table-wrap,
    .performance-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        width: 100%;
    }
}
