/***********************
 * 전역 스타일
 ***********************/
:root {
    --primary-color: #808080;
    /* JavaScript에서 덮어씀 */
    --hover-color: #666666;
    --bg-gradient-start: #f0f9f5;
    --bg-gradient-end: #e8f5ef;
    --header-text-color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #333;
    overflow-x: hidden;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    position: relative;
    padding: 20px 20px 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
}

/***********************
 * 배경 캔버스
 ***********************/
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/***********************
 * 명함 컨테이너
 ***********************/
.card-container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out;
    margin: 20px 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/***********************
 * 헤더
 ***********************/
.card-header {
    background: var(--primary-color);
    color: var(--header-text-color);
    text-align: center;
    padding: 40px 20px;
    position: relative;
}

.company-name {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--header-text-color);
}

/***********************
 * 명함 본문
 ***********************/
.card-body {
    padding: 0 40px;
    padding-top: 100px;
    padding-bottom: 60px;
}

/***********************
 * 프로필 섹션
 ***********************/
.profile-section {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    margin-top: -80px;
}

.profile-img {
    width: 225px;
    height: 225px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    background: #f0f0f0;
    display: block;
    margin: 0 auto;
}

/* ✅ 이미지가 없을 때 숨김 */
.profile-img[src=""],
.profile-img:not([src]) {
    display: none;
}


.name {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 20px;
    color: #222;
}

.job-title {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
    font-weight: 400;
}

/***********************
 * 연락처 섹션 (✅ 타이틀 제거 - HTML에서 처리)
 ***********************/
.contact-section {
    margin-bottom: 30px;
}

.contact-section h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.contact-section ul {
    list-style: none;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    transition: all 0.3s;
}

.contact-item:hover {
    background: #f9f9f9;
    padding-left: 10px;
}

.contact-item:last-child {
    border-bottom: none;
}

.icon-box {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.contact-link {
    color: #333;
    text-decoration: none;
    flex-grow: 1;
    word-break: break-all;
    transition: color 0.3s;
}

.contact-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

a.contact-link {
    cursor: pointer;
}

/***********************
 * 소개 섹션
 ***********************/
.intro-section {
    margin-bottom: 30px;
}

.intro-section h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.intro-section p {
    line-height: 1.8;
    color: #555;
    white-space: pre-wrap;
}

/***********************
 * 갤러리 섹션
 ***********************/
.gallery-section {
    margin-bottom: 30px;
}

.gallery-section h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.gallery-item {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/***********************
 * QR 섹션 (✅ 여백 증가)
 ***********************/
.qr-section {
    text-align: center;
    margin-bottom: 50px;
    /* ✅ 푸터와의 여백 (여기 수정!) */
}

.qr-section h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
    text-align: left;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 50px;
    /* ✅ 30px → 50px (여백 증가) */
}

#qrcode {
    display: inline-block;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#qrcode img {
    display: block;
    margin: 0 auto;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    width: fit-content;
    margin: 0 auto;
    margin-bottom: 50px;
    /* ✅ 버튼 ↔ 푸터 여백 (50px로 통일) */
}

.download-btn:hover {
    background: var(--hover-color);
    /* ✅ CSS 변수 사용 (자동 계산됨) */
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.download-btn i {
    font-size: 1.2rem;
}


/***********************
 * 푸터
 ***********************/
.card-footer {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.card-footer:hover {
    background: #e9ecef;
    color: #666;
}

/***********************
 * 모달
 ***********************/
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    margin: 20px auto;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.modal h3 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2rem;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    font-family: inherit;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

.input-group input[type="color"] {
    height: 50px;
    cursor: pointer;
}

.modal button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.modal button:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/***********************
 * 이미지 모달
 ***********************/
#imageModal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#imageModal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
}

.close:hover {
    color: #ccc;
}

/***********************
 * 비활성 명함 화면
 ***********************/
.inactive-card {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.inactive-card.show {
    display: flex;
}

.inactive-message {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    margin: 20px;
}

.inactive-message .icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.inactive-message h1 {
    font-size: 1.8rem;
    color: #dc3545;
    margin-bottom: 15px;
}

.inactive-message p {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.6;
}

/* ✅ 비활성 화면 푸터 */
.inactive-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.inactive-footer:hover {
    background: rgba(255, 255, 255, 1);
    color: #666;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/***********************
 * 숨김 처리
 ***********************/
.hidden-item {
    display: none !important;
}

/***********************
 * 로그인 모달
 ***********************/
.login-modal {
    max-width: 400px !important;
    text-align: center;
    padding: 40px 30px !important;
}

.login-modal h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: #333;
}

.login-subtitle {
    font-size: 0.95rem;
    color: #666;
    margin-bottom: 30px;
}

.login-modal input[type="password"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.login-modal input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-buttons {
    display: flex;
    gap: 10px;
}

.btn-primary {
    flex: 1;
    padding: 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    flex: 1;
    padding: 15px;
    background: #f0f0f0;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

/***********************
 * 반응형 (모바일) (✅ 프로필 크기 50% 증가)
 ***********************/
@media (max-width: 768px) {
    body {
        padding: 10px 10px 30px;
        align-items: flex-start;
    }

    .card-container {
        border-radius: 15px;
        margin: 10px 0;
    }

    .card-header {
        padding: 30px 15px;
    }

    .company-name {
        font-size: 1.5rem;
    }

    .card-body {
        padding: 0 20px;
        padding-top: 80px;
        padding-bottom: 40px;
    }

    .profile-section {
        margin-top: -60px;
    }

    .profile-img {
        width: 180px;
        /* ✅ 120px → 180px (50% 증가) */
        height: 180px;
        /* ✅ 120px → 180px (50% 증가) */
        border: 4px solid white;
    }

    .name {
        font-size: 1.6rem;
    }

    .job-title {
        font-size: 1rem;
    }

    .intro-section h2,
    .contact-section h2,
    .gallery-section h2,
    .qr-section h2 {
        font-size: 1.1rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .gallery-item {
        height: 120px;
    }

    .modal-content {
        padding: 20px;
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 2.5rem;
    }

    .inactive-message {
        padding: 40px 30px;
    }

    .inactive-message .icon {
        font-size: 4rem;
    }

    .inactive-message h1 {
        font-size: 1.5rem;
    }

    .inactive-message p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 0 15px;
        padding-top: 70px;
        padding-bottom: 30px;
    }

    .profile-img {
        width: 150px;
        /* ✅ 100px → 150px (50% 증가) */
        height: 150px;
        /* ✅ 100px → 150px (50% 증가) */
    }

    .name {
        font-size: 1.4rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/***********************
 * 로딩 상태
 ***********************/
body:not(.loaded) .card-container {
    opacity: 0;
    visibility: hidden;
}

body.loaded .card-container {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease;
}