/* Global Styles */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   반응형 줄바꿈 기준 (한글 최적화)
   ======================================== */
* {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* 예외: 코드, 입력 필드 등 */
code, pre, input, textarea, select {
    word-break: normal;
}

/* 줄바꿈 방지가 필요한 경우 */
.nowrap {
    white-space: nowrap;
}

/* ========================================
   토스 스타일 마이크로 인터랙션 & 애니메이션
   ======================================== */

/* 스크롤 트리거 애니메이션 기본 상태 */
.reveal {
    opacity: 0;
    transform: translateY(60px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* 스태거 딜레이 */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* 부드러운 페이드 인 업 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 숫자 카운트업 애니메이션 */
@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.count-up {
    animation: countUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* 글로우 펄스 효과 - 검정색 계열로 통일 */
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5); }
}

.glow-pulse {
    animation: glowPulse 2s ease-in-out infinite;
}

/* 호버 시 떠오르는 효과 */
@media (min-width: 768px) {
    .hover-lift {
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                    box-shadow 0.4s ease;
    }
    
    .hover-lift:hover {
        transform: translateY(-8px);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    }
}

/* 스무스 스케일 효과 */
@media (min-width: 768px) {
    .hover-scale {
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    
    .hover-scale:hover {
        transform: scale(1.05);
    }
}

/* 텍스트 그라디언트 애니메이션 */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.text-gradient-animate {
    background: linear-gradient(90deg, #007AFF, #00D4FF, #007AFF);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite;
}

/* 버튼 리플 이펙트 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* 스크롤 인디케이터 */
@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

.scroll-indicator {
    animation: scrollBounce 2s ease-in-out infinite;
}

/* 카드 틸트 효과 (마우스 따라다니기) */
.card-tilt {
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* 프로그레스 바 애니메이션 */
@keyframes progressFill {
    from { width: 0; }
    to { width: var(--progress-width, 100%); }
}

.progress-animate {
    animation: progressFill 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 타이핑 커서 효과 */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    color: #007AFF;
}

/* 부드러운 언더라인 효과 */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #007AFF;
    transition: width 0.3s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* 스크롤 시 네비게이션 축소 */
.nav-scrolled {
    background: rgba(5, 5, 5, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-scrolled .h-24 {
    height: 4rem !important;
}

/* 인풋 포커스 효과 */
.input-focused {
    position: relative;
}

.input-focused::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #007AFF, #00D4FF);
    border-radius: 2px;
}

/* 이미지 레이지 로드 페이드 인 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.lazy-image.loaded {
    opacity: 1;
}

/* 섹션 디바이더 */
.section-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* 플로팅 라벨 효과 */
.floating-label-group {
    position: relative;
}

.floating-label-group input:focus + label,
.floating-label-group input:not(:placeholder-shown) + label {
    transform: translateY(-24px) scale(0.85);
    color: #007AFF;
}

.floating-label-group label {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    pointer-events: none;
    color: rgba(0, 0, 0, 0.4);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #050505;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Utility for text balance if supported */
h1, h2, h3, p {
    text-wrap: balance;
}

/* 한글 단어 중간 줄바꿈 방지 */
.break-keep {
    word-break: keep-all;
}

/* Ensure smooth transitions for hover effects - PC only */
@media (min-width: 768px) {
    a, button, .group {
        transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* 통일된 카드/박스 스타일 - 흰색 배경 기반 */
.card-base {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #111111;
    position: relative;
}

@media (min-width: 768px) {
    .card-base {
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .card-base:hover {
        background: #fafafa;
        border-color: rgba(0, 0, 0, 0.12);
        transform: translateY(-4px);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    }
}

/* 주요(Primary) 버튼 스타일 - 검정 배경 */
.btn-primary {
    background: linear-gradient(to right, #111111, #222222);
    color: #ffffff;
    padding: 1.25rem 2.5rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 1.125rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .btn-primary {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn-primary:hover {
        transform: scale(1.02);
        background: linear-gradient(to right, #000000, #111111);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    }
    
    .btn-primary i {
        transition: transform 0.3s ease;
    }
    
    .btn-primary:hover i {
        transform: translateX(0.25rem);
    }
}

/* 보조(Secondary) 버튼 스타일 - 투명 테두리 */
.btn-secondary {
    background: transparent;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.5);
    padding: 1.25rem 2.5rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 1.125rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .btn-secondary {
        backdrop-filter: blur(12px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.8);
        transform: scale(1.05);
    }
}

/* 히어로 섹션용 흰색 버튼 스타일 */
.btn-hero-primary {
    background: #ffffff;
    color: #111111;
    padding: 1rem 2.5rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 10px 40px rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .btn-hero-primary {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn-hero-primary:hover {
        transform: scale(1.05);
        background: #f0f0f0;
        box-shadow: 0 10px 50px rgba(255, 255, 255, 0.3);
    }
    
    .btn-hero-primary i {
        transition: transform 0.3s ease;
    }
    
    .btn-hero-primary:hover i {
        transform: translateX(0.25rem);
    }
}

.btn-hero-secondary {
    background: transparent;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.8);
    padding: 1rem 2.5rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .btn-hero-secondary {
        backdrop-filter: blur(12px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn-hero-secondary:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: #ffffff;
        transform: scale(1.05);
    }
}

/* 통일된 폼 요소 스타일 - 흰색 카드 내부용 */
.form-input {
    background: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #111111;
}

.form-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.form-input:focus {
    background: #ffffff;
    border-color: #007AFF;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

@media (min-width: 768px) {
    .form-input {
        transition: all 0.3s ease;
    }
    
    .form-input:focus {
        transform: scale(1.01);
    }
    
    .form-input:hover:not(:focus) {
        border-color: rgba(0, 0, 0, 0.25);
    }
}

/* ========================================
   배경 시스템 - PC/모바일 분리
   ======================================== */

/* 전체 페이지 고정 배경 컨테이너 */
.fixed-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: #000000;
    overflow: hidden;
}

/* 블랙 오버레이 */
.fixed-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
    pointer-events: none;
}

/* Canvas for gradient animation - PC only */
#gradient-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.6;
}

/* ========================================
   모바일 최적화 - 모든 애니메이션 제거
   ======================================== */
@media (max-width: 767px) {
    /* 정적 배경 */
    .fixed-bg {
        background: linear-gradient(135deg, 
            #000000 0%, 
            #1a0a1f 30%, 
            #0f0515 60%, 
            #000000 100%);
    }
    
    .fixed-bg::before {
        content: '';
        position: absolute;
        top: 5%;
        left: -10%;
        width: 50%;
        height: 40%;
        background: radial-gradient(circle, rgba(200, 0, 255, 0.12) 0%, transparent 60%);
        pointer-events: none;
    }
    
    /* Canvas 완전 제거 */
    #gradient-canvas {
        display: none !important;
    }
    
    /* 모든 애니메이션 컨테이너 숨김 */
    .animated-bg-container,
    .gradient-container,
    .wave-overlay,
    .noise-overlay,
    .gradient-blob {
        display: none !important;
    }
    
    /* 모든 애니메이션 비활성화 */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* 필수 애니메이션만 허용 (롤링) */
    .partner-rolling-track,
    .rolling-keywords-track,
    .animate-scroll,
    .animate-scroll-reviews-horizontal {
        animation-duration: 30s !important;
        animation-iteration-count: infinite !important;
    }
    
    /* 스피너 애니메이션 허용 */
    .animate-spin,
    .fa-spin,
    .spinner {
        animation-duration: 1s !important;
        animation-iteration-count: infinite !important;
    }
    
    /* backdrop-filter 제거 (성능 저하 주범) */
    .glass-nav,
    .btn-secondary,
    .btn-hero-secondary,
    [class*="backdrop"] {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* box-shadow 단순화 */
    .btn-primary,
    .btn-hero-primary,
    .card-base {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* filter 제거 */
    .gradient-container,
    .gradient-blob {
        filter: none !important;
    }
    
    /* 호버 효과 완전 제거 */
    .card-base:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-hero-primary:hover,
    .btn-hero-secondary:hover {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* 파트너 로고 필터 단순화 */
    .partner-logo {
        filter: grayscale(100%) brightness(1.5) !important;
        transition: none !important;
    }
    
    .partner-logo:hover {
        filter: grayscale(100%) brightness(1.5) !important;
    }
}

/* ========================================
   PC 전용 애니메이션
   ======================================== */
@media (min-width: 768px) {
    /* CSS-based animated gradients layer */
    .gradient-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        filter: blur(100px);
        opacity: 0.65;
    }

    .gradient-blob {
        position: absolute;
        border-radius: 50%;
        mix-blend-mode: screen;
        filter: blur(40px);
        animation: blob-animation 20s infinite ease-in-out;
        will-change: transform;
    }

    .blob1 {
        width: 600px;
        height: 600px;
        background: radial-gradient(circle at center, 
            rgba(255, 0, 128, 0.8) 0%, 
            rgba(255, 0, 200, 0.4) 40%, 
            transparent 70%);
        top: -200px;
        left: -200px;
        animation-duration: 25s;
    }

    .blob2 {
        width: 500px;
        height: 500px;
        background: radial-gradient(circle at center, 
            rgba(200, 0, 255, 0.8) 0%, 
            rgba(150, 0, 255, 0.4) 40%, 
            transparent 70%);
        bottom: -150px;
        right: -150px;
        animation-duration: 30s;
        animation-delay: 5s;
    }

    .blob3 {
        width: 450px;
        height: 450px;
        background: radial-gradient(circle at center, 
            rgba(255, 0, 150, 0.7) 0%, 
            rgba(200, 0, 100, 0.3) 40%, 
            transparent 70%);
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        animation-duration: 35s;
        animation-delay: 10s;
        animation-name: blob-animation-center;
    }

    .blob4 {
        width: 400px;
        height: 400px;
        background: radial-gradient(circle at center, 
            rgba(180, 0, 255, 0.7) 0%, 
            rgba(100, 0, 200, 0.3) 40%, 
            transparent 70%);
        top: 10%;
        right: 10%;
        animation-duration: 28s;
        animation-delay: 15s;
    }

    .blob5 {
        width: 350px;
        height: 350px;
        background: radial-gradient(circle at center, 
            rgba(255, 0, 200, 0.6) 0%, 
            rgba(200, 0, 150, 0.3) 40%, 
            transparent 70%);
        bottom: 20%;
        left: 20%;
        animation-duration: 32s;
        animation-delay: 7s;
    }

    @keyframes blob-animation {
        0%, 100% {
            transform: translate(0, 0) scale(1) rotate(0deg);
        }
        25% {
            transform: translate(100px, -100px) scale(1.2) rotate(90deg);
        }
        50% {
            transform: translate(-100px, 100px) scale(0.8) rotate(180deg);
        }
        75% {
            transform: translate(50px, 50px) scale(1.1) rotate(270deg);
        }
    }

    @keyframes blob-animation-center {
        0%, 100% {
            transform: translate(-50%, -50%) scale(1) rotate(0deg);
        }
        25% {
            transform: translate(calc(-50% + 100px), calc(-50% - 100px)) scale(1.2) rotate(90deg);
        }
        50% {
            transform: translate(calc(-50% - 100px), calc(-50% + 100px)) scale(0.8) rotate(180deg);
        }
        75% {
            transform: translate(calc(-50% + 50px), calc(-50% + 50px)) scale(1.1) rotate(270deg);
        }
    }

    /* Wave distortion overlay */
    .wave-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: 
            radial-gradient(ellipse at top left, transparent 0%, rgba(255, 0, 128, 0.08) 50%, transparent 100%),
            radial-gradient(ellipse at bottom right, transparent 0%, rgba(200, 0, 255, 0.08) 50%, transparent 100%);
        animation: wave-shift 15s infinite alternate ease-in-out;
    }

    @keyframes wave-shift {
        0% {
            opacity: 0.2;
            transform: scale(1) rotate(0deg);
        }
        100% {
            opacity: 0.4;
            transform: scale(1.1) rotate(5deg);
        }
    }

    /* Noise texture overlay */
    .noise-overlay {
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        opacity: 0.02;
        animation: noise-animation 8s steps(10) infinite;
    }

    @keyframes noise-animation {
        0%, 100% { transform: translate(0, 0); }
        10% { transform: translate(-5%, -5%); }
        20% { transform: translate(-10%, 5%); }
        30% { transform: translate(5%, -10%); }
        40% { transform: translate(-5%, 15%); }
        50% { transform: translate(-10%, 5%); }
        60% { transform: translate(15%, 0); }
        70% { transform: translate(0, 10%); }
        80% { transform: translate(10%, 5%); }
        90% { transform: translate(5%, 0); }
    }
}

/* Custom Animation Classes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0;
}

/* Hide scrollbar for horizontal scroll */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Smooth scrolling for portfolio */
#portfolio-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Auto-scrolling animation for portfolio */
@keyframes scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(calc(-344px * 6));
    }
}

.animate-scroll {
    animation: scroll 30s linear infinite;
    will-change: transform;
}

@media (min-width: 768px) {
    .animate-scroll:hover {
        animation-play-state: paused;
    }
}

/* Auto-scrolling animation for reviews */
@keyframes scroll-reviews-horizontal {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

.animate-scroll-reviews-horizontal {
    animation: scroll-reviews-horizontal 35s linear infinite;
    will-change: transform;
}

@media (min-width: 768px) {
    .animate-scroll-reviews-horizontal:hover {
        animation-play-state: paused;
    }
}

/* Rolling Keywords Section */
.rolling-keywords-container {
    width: 100%;
    overflow: hidden;
    background: transparent;
}

.rolling-keywords-track {
    display: flex;
    align-items: center;
    gap: 2rem;
    white-space: nowrap;
    animation: rolling-keywords 30s linear infinite;
    will-change: transform;
}

.rolling-keyword {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

.keyword-dot {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
}

@keyframes rolling-keywords {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Partner Rolling Section */
.partner-rolling-container {
    width: 100%;
    overflow: hidden;
    background: transparent;
}

.partner-rolling-track {
    display: flex;
    align-items: center;
    gap: 4rem;
    white-space: nowrap;
    animation: rolling-partners 60s linear infinite;
    width: fit-content;
    will-change: transform;
}

@media (max-width: 767px) {
    .partner-rolling-track {
        gap: 2rem;
    }
}

.partner-logo {
    opacity: 0.6;
    filter: grayscale(100%) brightness(2);
    flex-shrink: 0;
    height: 20px;
    width: auto;
    object-fit: contain;
}

@media (min-width: 768px) {
    .partner-logo {
        height: 24px;
        transition: all 0.4s ease;
    }
    
    .partner-logo:hover {
        opacity: 1;
        filter: grayscale(0%) brightness(1);
    }
}

/* 로고 크기 조정 */
.partner-logo.logo-large {
    height: 36px;
}

@media (min-width: 768px) {
    .partner-logo.logo-large {
        height: 44px;
    }
}

.partner-logo.logo-xlarge {
    height: 52px;
}

@media (min-width: 768px) {
    .partner-logo.logo-xlarge {
        height: 64px;
    }
}

.partner-logo.logo-xxlarge {
    height: 64px;
}

@media (min-width: 768px) {
    .partner-logo.logo-xxlarge {
        height: 80px;
    }
}

.partner-logo.logo-안전보건공단 {
    height: 36px;
    align-self: flex-start;
    margin-top: 4px;
}

@media (min-width: 768px) {
    .partner-logo.logo-안전보건공단 {
        height: 44px;
    }
}

@keyframes rolling-partners {
    0% {
        transform: translateX(-66.666%);
    }
    100% {
        transform: translateX(0%);
    }
}
