/* ==========================================================================
 * home.css — 메인 페이지(/) 전용 스타일
 *  · index.tsx 인라인 <style> 에서 분리 (정적 CSS)
 *  · commonGlobalCSSLink 의 변수(--primary-color 등)에 의존
 * ========================================================================== */

/* 메인 페이지 전용 body 오버라이드 */
body {
    overflow-x: hidden;
}

/* Hero Section
 * --------------------------------------------------------------
 * 기존 height:600px + overflow:hidden + align-items:center 조합은
 * 콘텐츠 높이 > 600px 일 때 위/아래가 잘리는 문제가 있었음.
 * 특히 좁고 긴(예: 19.5:9, 360px 폭) 화면에서 Korean wrap 으로
 * 라인 수가 증가하면 본문이 상단으로 밀려나며 잘림.
 *
 * 또한 Samsung Internet 등 일부 모바일 브라우저는 동일한 폰트가
 * 로드되기 전까지 fallback 폰트(SamsungSans / 시스템 한글)로
 * 렌더링 → 글자 폭이 달라져 wrap 라인 수가 더 늘어남.
 * 그 결과 같은 LG V50 기기라도 Brave 는 정상, Samsung Internet 만
 * 잘리는 현상이 발생.
 *
 * 해결책 (모든 브라우저 안전):
 *  1. height → min-height (콘텐츠가 더 길면 hero 가 늘어남)
 *  2. overflow:hidden 제거 → 잘림 방지
 *  3. 충분한 상/하 padding 으로 콘텐츠 보호
 *  4. word-break: keep-all 로 한국어 단어 단위 줄바꿈
 *  5. 매우 좁은 화면(≤420px) 에서 글자 크기 추가 축소
 * -------------------------------------------------------------- */
.hero {
    margin-top: 80px;
    min-height: 600px;
    padding: 80px 0;
    background: linear-gradient(rgba(26, 77, 124, 0.4), rgba(44, 107, 160, 0.4)), url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=1600&q=80') center/cover;
    position: relative;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 77, 124, 0.1);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

.hero-content {
    width:100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    position: relative;
    z-index: 2;
    color: var(--white);
    text-align: center;
}

.hero h1 {
    /* 서강대학교 폰트(SOGANGUNIVERSITYTTF.woff2) — /css/fonts-sogang.css 에서 등록됨 */
    font-family: 'Sogang University', 'Noto Serif KR', serif;
    font-size: 56px;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.3;
    animation: slideInLeft 1s ease;
}

.hero p {
    /* hero 메인 문구 통일성을 위해 부제도 서강대 폰트로 */
    font-family: 'Sogang University', 'Noto Sans KR', sans-serif;
    font-size: 20px;
    margin-bottom: 40px;
    opacity: 0.95;
    animation: slideInLeft 1s ease 0.2s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --------------------------------------------------------------
 * Hero h1/p 로테이터 (5초 주기: fade-in 1초 + 유지 3초 + fade-out 1초)
 * .hero 자체 레이아웃(min-height/flex/align-items)은 그대로 유지.
 * .hero-text 를 absolute 로 겹쳐 배치하고, 로테이터 영역의 높이는
 * (JS에서) 3개 문구 세트 중 가장 높은 세트에 맞춰 동적으로 계산하여
 * 어떤 세트가 표시되어도 아래 버튼과 겹치지 않도록 한다.
 * (min-height 는 JS 미실행 시를 대비한 안전망)
 * -------------------------------------------------------------- */
.hero-text-rotator {
    position: relative;
    width: 100%;
    min-height: 130px;
    /* 세트 전환 시 컨테이너 높이를 부드럽게 조절
     * (JS 가 현재 표시 중인 세트의 실제 높이로 height 를 갱신) */
    transition: height 0.6s ease;
    overflow: visible;
}

.hero-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    /* opacity 는 1초 fade, visibility 는 fade 종료 후 전환 */
    transition: opacity 1s ease, visibility 0s linear 1s;
}

.hero-text.active {
    opacity: 1;
    visibility: visible;
    /* 세트 전환 시 1초 동안 fade-in */
    transition: opacity 1s ease, visibility 0s linear 0s;
}

/* active 상태에서 fade-out 시작: opacity 만 0 으로, visibility 는 유지 */
.hero-text.fade-out {
    opacity: 0;
    visibility: visible;
    transition: opacity 1s ease;
}

/* 로테이터 내부 h1/p 는 기존 .hero h1 / .hero p 스타일을 그대로 상속.
 * 첫 세트 로딩 애니메이션(slideInLeft)은 유지되지만, 세트 전환 시
 * 반복 재생되지 않도록 active 전환에서는 opacity transition 만 사용. */

.cta-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    animation: slideInLeft 1s ease 0.4s both;
}

.btn {
    display: inline-block;
    padding: 18px 40px;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent-color);
    color: var(--white);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
}

.btn-primary:hover {
    background: #c19d2f;
    animation: bounce 0.6s;
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.5);
}

.btn-primary:active {
    animation: none;
    transform: scale(0.98);
}

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 2px solid var(--white);
}

.btn-secondary:hover {
    background: var(--white);
    color: var(--primary-color);
    animation: bounce 0.6s;
}

.btn-secondary:active {
    animation: none;
    transform: scale(0.98);
}

.btn-kakao:active,
.btn-naver:active,
.btn-email:active,
.feature-card:active {
    animation: none !important;
    transform: scale(0.98) !important;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-7px);
    }
}

/* 3D 입체 튀어나오는 효과 */
@keyframes popOut {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    }
    100% {
        transform: scale(1.08);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
    }
}

/* 카카오톡, 네이버, 메일 버튼 hover 효과 */
.btn-kakao,
.btn-naver,
.btn-email {
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-kakao:hover,
.btn-naver:hover,
.btn-email:hover {
    animation: popOut 0.4s ease forwards;
}

/* 모바일에서 버튼 hover 완전 비활성화 (터치 후 활성 상태 잔류 방지) */
@media (hover: none), (pointer: coarse) {
    .btn-kakao:hover,
    .btn-naver:hover,
    .btn-email:hover {
        animation: none !important;
        transform: none !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
    }
    .btn-primary:hover {
        animation: none !important;
        transform: none !important;
        box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4) !important;
    }
    .btn-secondary:hover {
        animation: none !important;
        background: transparent !important;
        color: var(--white) !important;
        transform: none !important;
    }
    .service-item:hover {
        border-color: transparent !important;
        transform: none !important;
        box-shadow: none !important;
    }
}

/* Features Section */
.features {
    padding: 100px 30px;
    background: var(--white);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    margin-bottom: 70px;
}

.section-title h2 {
    font-family: 'Noto Serif KR', serif;
    font-size: 42px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.section-title p {
    font-size: 18px;
    color: var(--text-light);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
}

.feature-card {
    background: var(--white);
    padding: 50px 40px;
    border-radius: 20px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.08);
    transition: all 0.4s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transition: transform 0.4s;
}

.feature-card:hover::before {
    transform: scaleX(1);
}

.feature-card:hover {
    animation: popOut 0.4s ease forwards;
    z-index: 10;
}

/* 모바일에서 hover 완전 비활성화 (터치 후 활성 상태 잔류 방지) */
@media (hover: none), (pointer: coarse) {
    .feature-card:hover::before {
        transform: scaleX(0);
    }
    .feature-card:hover {
        animation: none;
        transform: none;
        z-index: auto;
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    }
}

.feature-icon {
    font-size: 60px;
    color: var(--accent-color);
    margin-bottom: 25px;
    display: inline-block;
    transition: transform 0.4s;
}

/* 모바일 애니메이션 */
@media (max-width: 768px) {
    .feature-card.in-view {
        animation: gentle-bounce 1s ease-in-out;
    }

    @keyframes gentle-bounce {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-5px); }
    }
}

/*.feature-card:hover .feature-icon {
    transform: scale(1.1) rotateY(360deg);
}*/

.feature-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.feature-card p {
    color: var(--text-light);
    line-height: 1.8;
}

/* 모바일에서 클릭 가능성 표시 */
@media (max-width: 768px) {
    .feature-card {
        /* 항상 약간의 입체감 유지 */
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
        border: 2px solid transparent;
    }

    .feature-card::after {
        content: '자세히 보기 →';
        position: absolute;
        bottom: 20px;
        right: 20px;
        color: var(--primary-color);
        font-size: 14px;
        font-weight: 600;
        opacity: 0.7;
    }

    /* 스크롤 시 IntersectionObserver로 추가될 클래스 */
    .feature-card.in-view {
        animation: cardPulse 2s ease-in-out infinite;
    }

    @keyframes cardPulse {
        0%, 100% {
            box-shadow: 0 8px 20px rgba(44, 95, 158, 0.12);
            border-color: transparent;
        }
        50% {
            box-shadow: 0 12px 30px rgba(44, 95, 158, 0.25);
            border-color: rgba(44, 95, 158, 0.3);
        }
    }

    /* 터치 시 피드백 */
    .feature-card:active {
        transform: scale(0.95);
        box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    }
    /* 호버 상태 잔류 완전 방지 */
    .feature-card.touch-active {
        transform: scale(0.98);
    }
}

/* Services Section */
.services {
    padding: 100px 30px;
    background: var(--bg-light);
}

.service-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.service-item {
    background: var(--white);
    padding: 40px 30px;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.service-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.service-item i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.service-item h4 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-color);
}

/* CTA Section */
.cta-section {
    padding: 100px 30px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cta-section::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

.cta-section h2 {
    font-family: 'Noto Serif KR', serif;
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 20px;
    position: relative;
}

.cta-section p {
    font-size: 20px;
    margin-bottom: 40px;
    opacity: 0.95;
    position: relative;
}

/* Responsive */
@media (max-width: 768px) {
    .hero {
        /* 좁은 화면에서는 고정 600px 가 너무 큼 → 콘텐츠 기준 자동 높이 */
        min-height: auto;
        padding: 120px 0;
    }
    /* 모바일: 긴 h1 이 2줄이 될 수 있으므로 로테이터 높이 확보
     * (JS 가 실제 세트별 높이를 측정해 동적으로 재설정함) */
    .hero-text-rotator {
        min-height: 160px;
    }
    .hero h1 {
        font-size: 36px;
        /* 한국어 단어 단위 줄바꿈 → 어색한 글자 단위 끊김 방지
         * (Samsung Internet 에서 "최적의 / 세무회 / 계" 처럼
         *  글자 단위로 끊기던 현상 해결) */
        word-break: keep-all;
        overflow-wrap: break-word;
    }

    .hero p {
        font-size: 16px;
        word-break: keep-all;
        overflow-wrap: break-word;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .feature-grid,
    .service-list {
        grid-template-columns: 1fr;
    }
}

/* 추가 안전망: 매우 좁은 화면(360px 안팎 - LG V50 등 19.5:9) */
@media (max-width: 420px) {
    .hero {
        padding: 120px 0;
    }
    .hero-text-rotator {
        min-height: 170px;
    }
    .hero h1 {
        font-size: 30px;
        line-height: 1.35;
        margin-bottom: 16px;
    }
    .hero p {
        font-size: 15px;
        margin-bottom: 28px;
    }
    .hero-content {
        padding: 0 20px;
    }
    .btn {
        padding: 14px 24px;
        font-size: 15px;
    }
}
