/* ===== 기본 리셋 및 변수 ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== 컨테이너 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== 헤더 ===== */
.header {
    text-align: center;
    padding: 60px 20px 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    margin: 0 -20px 40px;
    color: white;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ===== 검색 바 ===== */
.search-container {
    max-width: 500px;
    margin: 24px auto 0;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-family: inherit;
    border: none;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    background: #ffffff;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
    transform: scale(1.02);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f1f5f9;
}

.search-result-item .result-icon {
    font-size: 1.5rem;
}

.search-result-item .result-content h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.search-result-item .result-content p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.search-result-item .result-section {
    font-size: 0.7rem;
    color: var(--primary);
    background: #ede9fe;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* ===== 메인 콘텐츠 ===== */
.main-content {
    padding-bottom: 60px;
}

/* ===== 섹션 ===== */
.section {
    margin-bottom: 48px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.section-title .icon {
    font-size: 1.5rem;
}

/* ===== 카드 그리드 ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ===== 카드 ===== */
.card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 카드 배지 */
.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--secondary);
    color: white;
}

.card-badge.patent {
    background: var(--accent);
}

.card-badge.core {
    background: #ef4444;
}

/* 자체 호스팅 카드 (내부 링크) */
.card-internal {
}

.card-internal:hover {
}

/* 외부 링크 카드 */
.card-external::after {
    content: '↗';
    position: absolute;
    bottom: 12px;
    right: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
}

.card-external:hover::after {
    opacity: 1;
}

/* 주요 카드 (Featured) */
.card-featured {
    border: 2px solid #fecaca;
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
}

.card-featured:hover {
    border-color: #ef4444;
}

/* ===== 푸터 ===== */
.footer {
    text-align: center;
    padding: 30px 20px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 반응형 ===== */
@media (max-width: 768px) {
    .header {
        padding: 40px 20px 30px;
    }

    .logo {
        font-size: 2rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 16px 20px;
    }

    .card-icon {
        font-size: 1.8rem;
    }
}

/* ===== 애니메이션 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeInUp 0.5s ease forwards;
}

.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.2s; }
.section:nth-child(4) { animation-delay: 0.3s; }

/* ===== 폴더 카드 스타일 ===== */
.card-folder {
    cursor: pointer;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #6ee7b7;
    position: relative;
}

.card-folder:hover {
    border-color: var(--secondary);
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.card-folder.active {
    border-color: var(--secondary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
}

.folder-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.card-folder.active .folder-toggle {
    transform: translateY(-50%) rotate(180deg);
}

/* ===== 폴더 하위 콘텐츠 ===== */
.folder-contents {
    grid-column: 1 / -1;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
    background: #f0fdf4;
    border: 1px solid #6ee7b7;
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: -20px;
    margin-bottom: 20px;
}

.folder-contents.open {
    display: grid;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 하위 카드 스타일 ===== */
.card-sub {
    padding: 14px 18px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
}

.card-sub .card-icon {
    font-size: 1.6rem;
}

.card-sub .card-content h3 {
    font-size: 1rem;
}

.card-sub .card-content p {
    font-size: 0.85rem;
}

.card-sub:hover {
    border-color: var(--secondary);
    background: #f0fdf4;
}

.card-sub::after {
    content: '↗';
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
}

.card-sub:hover::after {
    opacity: 1;
}

/* 모바일 폴더 대응 */
@media (max-width: 768px) {
    .folder-contents {
        grid-template-columns: 1fr;
        margin-top: -16px;
    }

    .card-sub {
        padding: 12px 14px;
    }

    .card-sub .card-icon {
        font-size: 1.4rem;
    }
}
