/***********************
 * CSS 변수 정의 (최상단)
 ***********************/
:root {
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.25);
    --glass-blur: blur(8px);

    /* 테마 연동용 (JS에서 primary-color로 계산됨) */
    --glass-tint: rgba(0, 0, 0, 0.05);

    /* Glass (theme-linked) */
    --glass-body-bg: color-mix(in srgb, var(--primary-color) 5%, rgba(255, 255, 255, 0.05));

    --glass-body-border: color-mix(in srgb,
            var(--primary-color) 25%,
            rgba(255, 255, 255, 0.25));

    --glass-body-blur: blur(8px);

    /* 색상 */
    --primary-color: #808080;
    --hover-color: #666666;
    --bg-gradient-start: #f0f9f5;
    --bg-gradient-end: #e8f5ef;
    --header-text-color: #ffffff;

    /* ✅ 폰트 크기 변수 */
    --font-company: 1.8rem;
    /* 회사명 */
    --font-name: 1.8rem;
    /* 이름 */
    --font-title: 1.25rem;
    /* 직책 */
    --font-h2: 1.125rem;
    /* 섹션 제목 (소개, 갤러리, QR) */
    --font-body: 1.125rem;
    /* 본문 텍스트 */
    --font-contact: 1.125rem;
    /* 연락처 텍스트 */
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
    :root {
        --font-company: 1.7rem;
        --font-name: 1.7rem;
        --font-title: 1.3rem;
        --font-h2: 1.1rem;
        --font-body: 1rem;
        --font-contact: 1rem;
    }
}

/* 작은 모바일 (480px 이하) */
@media (max-width: 480px) {
    :root {
        --font-company: 1.5rem;
        --font-name: 1.5rem;
        --font-title: 1.2rem;
        --font-h2: 1rem;
        --font-body: 1rem;
        --font-contact: 1rem;
    }
}

/***********************
 * 전역 스타일
 ***********************/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    background: transparent;
    height: 100%;
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #333;
    overflow-x: hidden;
    font-size: var(--font-body);
}

body {
    position: relative;
    padding: 20px 20px 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;

    background: linear-gradient(135deg,
            var(--bg-gradient-start),
            var(--bg-gradient-end));
}

/***********************
 * 배경 캔버스
 ***********************/
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    inset: 0;
    z-index: -1;
    /* 🔥 핵심 변경 */
    pointer-events: none;
}

/***********************
 * 명함 컨테이너
 ***********************/
.card-container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    width: 100%;
    margin: 20px 0;

    background: rgba(255, 255, 255, 0.12);

    /* 유리 효과 투명도 */
    backdrop-filter: blur(4px) saturate(130%);
    -webkit-backdrop-filter: blur(4px) saturate(130%);

    border-radius: 20px;
    border: none;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(255, 255, 255, 0.12);

    overflow: hidden;
    /* animation: fadeInUp 0.6s ease-out; */
}

.card-container::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;

    /* 유리 엣지 하이라이트 */
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.6),
            rgba(255, 255, 255, 0.08));

    /* 실제 선처럼 보이게 마스킹 */
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;

    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    /* 엣지 두께 */
    padding: 2.5px;
    opacity: 0.8;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/***********************
 * 헤더
 ***********************/
.card-header {
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--primary-color) 60%, transparent),
            color-mix(in srgb, var(--primary-color) 30%, transparent));
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);

    border-bottom: 1px solid var(--glass-border);
    color: var(--header-text-color);
    text-align: center;
    padding: 40px 20px;

    position: relative;
}

.card-header::after {
    background: linear-gradient(to bottom,
            color-mix(in srgb, var(--primary-color) 12%, rgba(255, 255, 255, 0.35)),
            transparent);
}

.company-name {
    font-size: var(--font-company);
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--header-text-color);
}

/***********************
 * 명함 본문
 ***********************/
.card-body {
    padding: 100px 40px 60px;

    background: var(--glass-body-bg);

    backdrop-filter: var(--glass-body-blur);
    -webkit-backdrop-filter: var(--glass-body-blur);

    border-top: 1px solid var(--glass-body-border);
}


/***********************
 * 프로필 섹션
 ***********************/
.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: var(--font-name);
    font-weight: 700;
    margin-top: 20px;
    color: #222;
}

.job-title {
    font-size: var(--font-title);
    color: #666;
    margin-bottom: 20px;
    font-weight: 400;
}

/***********************
 * 연락처 섹션
 ***********************/
.contact-section {
    margin-bottom: 30px;
}

.contact-section h2 {
    font-size: var(--font-h2);
    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 8px;
    position: relative;

    border-bottom: 1px solid rgba(255, 255, 255, 0.15);

    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);

    border-radius: 10px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.contact-item:hover {
    background: color-mix(in srgb,
            var(--primary-color) 8%,
            rgba(255, 255, 255, 0.08));

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 8px 20px rgba(0, 0, 0, 0.18);
}

.contact-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;

    opacity: 0;
    transition: opacity 0.25s ease;

    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.25),
            rgba(255, 255, 255, 0.05));
}

.contact-item:hover::after {
    opacity: 1;
}

.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;
    font-size: var(--font-contact);
}

.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: var(--font-h2);
    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;
    font-size: var(--font-body);
}

/***********************
 * 갤러리 섹션
 ***********************/
.gallery-section {
    margin-bottom: 30px;
}

.gallery-section h2 {
    font-size: var(--font-h2);
    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-wrapper {
    position: relative;
    width: 100%;
    height: 150px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: #f0f0f0;
}

.gallery-item-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* 이미지 */
.gallery-item {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item-wrapper:hover .gallery-item {
    transform: scale(1.1);
}

/***********************
 * QR 섹션
 ***********************/
.qr-section {
    text-align: center;
    margin-bottom: 50px;
}

.qr-section h2 {
    font-size: var(--font-h2);
    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;
}

#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;
}

.download-btn:hover {
    background: var(--hover-color);
    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;
    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;
    z-index: 9999;
}

.modal-content {
    background: white;
    padding: 10px;
    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;
    cursor: pointer;
    /* ✅ 전체 영역 클릭 가능 */
}

#modalImage {
    max-width: 90%;
    /* ✅ 전체 화면의 90% */
    max-height: 90%;
    /* ✅ 전체 화면의 90% */
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    cursor: default;
    /* 이미지는 기본 커서 */
}

#imageModal img {
    max-width: 90vw;
    /* 뷰포트 너비의 90% */
    max-height: 90vh;
    /* 뷰포트 높이의 90% */
    width: auto;
    /* ✅ 원본 너비 유지 */
    height: auto;
    /* ✅ 원본 높이 유지 */
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    cursor: default;
    object-fit: contain;
    /* ✅ 비율 유지 */
}

.close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    transition: color 0.3s;
}

.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: 9998;
    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);
}

/***********************
 * 반응형 (모바일)
 ***********************/
@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;
    }

    .card-body {
        padding: 0 20px;
        padding-top: 80px;
        padding-bottom: 40px;
    }

    .profile-section {
        margin-top: -60px;
    }

    .profile-img {
        width: 180px;
        height: 180px;
        border: 4px solid white;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .gallery-item-wrapper {
        height: 120px;
    }

    .gallery-item {
        height: 120px;
    }

    .modal-content {
        padding: 5px;
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 2.5rem;
    }

    #imageModal img {
        max-width: 95vw;
        max-height: 95vh;
    }

    #modalImage {
        max-width: 95%;
        max-height: 95%;
    }

    .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;
        height: 150px;
    }

    .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;
}