/* ===== Design Tokens ===== */
:root {
    --bg-primary: #0a0a0a;
    --bg-card: #141414;
    --bg-elevated: #1a1a1a;
    --border: #1e1e1e;
    --border-hover: #333;
    --text-primary: #f0f0f0;
    --text-secondary: #d0d0d0;
    --text-muted: #888;
    --text-faint: #555;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --accent-lang-bg: #0d1f3c;
    --accent-lang-border: #1e3a5f;
    --star-color: #f0c040;
    --star-bg: #1f1c0f;
    --star-border: #3d3520;
    --tag-bg: #1a1a1a;
    --tag-border: #2a2a2a;
    --tag-text: #aaa;
    --header-bg: rgba(10, 10, 10, 0.8);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    color-scheme: dark;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-elevated: #f0f1f3;
    --border: #e0e0e0;
    --border-hover: #bbb;
    --text-primary: #111;
    --text-secondary: #333;
    --text-muted: #666;
    --text-faint: #999;
    --accent: #1a73e8;
    --accent-hover: #1557b0;
    --accent-lang-bg: #e8f0fe;
    --accent-lang-border: #c5d9f2;
    --star-color: #e8a800;
    --star-bg: #fef7e0;
    --star-border: #f0e0a0;
    --tag-bg: #f0f1f3;
    --tag-border: #ddd;
    --tag-text: #555;
    --header-bg: rgba(248, 249, 250, 0.85);
    color-scheme: light;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Base ===== */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); }

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== Skip Link ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 1000;
    font-size: 0.875rem;
}
.skip-link:focus {
    top: 16px;
    color: #fff;
}

/* ===== Progress Bar ===== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    width: 0%;
    z-index: 200;
    transition: width 0.1s linear;
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: box-shadow var(--transition-normal);
}

.site-header.scrolled {
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .site-header.scrolled {
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.08);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.site-title:hover { color: var(--text-primary); text-decoration: none; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.site-nav a {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--transition-fast);
}
.site-nav a:hover { color: var(--text-primary); text-decoration: none; }

.nav-social {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-social a {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-social a:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    text-decoration: none;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-elevated);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* ===== Main Container ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* ===== Hero ===== */
.hero {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 50%, #a78bfa 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 6s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero p {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    line-height: 1.7;
}

.hero-links {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hero-links a {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.hero-links a:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-elevated);
    text-decoration: none;
}

.hero-links a svg {
    flex-shrink: 0;
}

/* ===== Category ===== */
.category {
    margin-bottom: 3.5rem;
}

.category h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--accent), transparent) 1;
}

/* ===== Project Cards ===== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    perspective: 1000px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
    display: flex;
    flex-direction: column;
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
    overflow: hidden;
    cursor: pointer;
}

.project-card::before {
    content: '';
    position: absolute;
    top: var(--mouse-y, 50%);
    left: var(--mouse-x, 50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(138, 180, 248, 0.12) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

[data-theme="light"] .project-card::before {
    background: radial-gradient(circle, rgba(26, 115, 232, 0.08) 0%, transparent 70%);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(138, 180, 248, 0.1), 0 0 0 1px rgba(138, 180, 248, 0.05);
}

[data-theme="light"] .project-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(26, 115, 232, 0.1);
}

.project-card h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.project-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
.project-card h3 a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}
.project-card h3 a:hover { color: var(--accent); }

.project-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    flex: 1;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.project-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    font-size: 0.75rem;
    padding: 0.1875rem 0.625rem;
    border-radius: var(--radius-full);
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid var(--tag-border);
    font-weight: 500;
}

.tag.lang {
    color: var(--accent);
    border-color: var(--accent-lang-border);
    background: var(--accent-lang-bg);
}
.tag.star {
    color: var(--star-color);
    border-color: var(--star-border);
    background: var(--star-bg);
}

/* ===== Project Detail Page ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
    transition: color var(--transition-fast);
}
.back-link:hover { color: var(--text-primary); text-decoration: none; }

.project-hero {
    margin-bottom: 2.5rem;
}

.project-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.project-hero .desc {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.7;
}

.project-hero .links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.btn:hover {
    text-decoration: none;
    opacity: 0.9;
    transform: translateY(-1px);
}
.btn-primary { background: var(--text-primary); color: var(--bg-primary); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
}
.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* Sections */
.section {
    margin-bottom: 2.25rem;
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.section p, .section li {
    font-size: 0.9375rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.section ul {
    list-style: none;
    padding: 0;
}

.section ul li {
    padding: 0.375rem 0;
    padding-left: 1.25rem;
    position: relative;
}

.section ul li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.875rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.5;
}

/* Tech Stack Table */
.tech-table {
    width: 100%;
    border-collapse: collapse;
}

.tech-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.tech-table td:first-child {
    color: var(--text-faint);
    width: 140px;
    font-weight: 500;
}

.tech-table td:last-child { color: var(--text-secondary); }

/* ===== Role Badge ===== */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    background: var(--accent-lang-bg);
    border: 1px solid var(--accent-lang-border);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    color: var(--accent);
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.role-badges {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

/* ===== Video Embed ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
}

.video-wrapper.shorts {
    padding-bottom: 177.78%;
    max-width: 240px;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-caption {
    font-size: 0.8125rem;
    color: var(--text-faint);
    margin-top: 0.5rem;
    text-align: center;
}

/* ===== Project Info Banner ===== */
.project-info-banner {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.project-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.project-info-item .label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-faint);
    font-weight: 600;
}

.project-info-item .value {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Highlight Box ===== */
.highlight-box {
    padding: 1rem 1.25rem;
    background: var(--accent-lang-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 1rem 0;
}

.highlight-box p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity var(--transition-normal), visibility var(--transition-normal), transform var(--transition-normal), color var(--transition-fast), border-color var(--transition-fast);
    z-index: 50;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}
.back-to-top svg { width: 18px; height: 18px; }

/* ===== Footer ===== */
.site-footer {
    border-top: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--accent), transparent) 1;
    padding: 1.5rem 0;
    text-align: center;
}

.site-footer p {
    font-size: 0.8125rem;
    color: var(--text-faint);
}

.site-footer a {
    color: var(--text-faint);
    transition: color var(--transition-fast);
}
.site-footer a:hover { color: var(--text-muted); }

/* ===== Cursor Glow ===== */
.cursor-glow {
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(138, 180, 248, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease;
}

[data-theme="light"] .cursor-glow {
    background: radial-gradient(circle, rgba(26, 115, 232, 0.03) 0%, transparent 70%);
}

/* ===== 3D Section Titles ===== */
.category h2 {
    transition: transform var(--transition-normal), letter-spacing var(--transition-normal);
}

.category:hover h2 {
    letter-spacing: 3px;
}

/* ===== Card Inner 3D Depth ===== */
.project-card h3,
.project-card p,
.project-card .project-meta {
    position: relative;
    z-index: 1;
}

.project-card h3 {
    transform: translateZ(20px);
}

.project-card .project-meta {
    transform: translateZ(10px);
}

/* ===== Floating Animation for Buttons ===== */
.btn-primary {
    transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(138, 180, 248, 0.2);
}

[data-theme="light"] .btn-primary:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ===== Tag Hover 3D ===== */
.tag {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.project-card:hover .tag {
    transform: translateZ(5px) scale(1.02);
}

/* ===== Video Wrapper 3D Hover ===== */
.video-wrapper {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.video-wrapper:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 32px rgba(138, 180, 248, 0.12);
}

[data-theme="light"] .video-wrapper:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ===== Project Info Banner Shimmer ===== */
.project-info-banner {
    position: relative;
    overflow: hidden;
}

.project-info-banner::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(138, 180, 248, 0.04), transparent);
    animation: shimmer 8s ease-in-out infinite;
}

[data-theme="light"] .project-info-banner::after {
    background: linear-gradient(90deg, transparent, rgba(26, 115, 232, 0.04), transparent);
}

@keyframes shimmer {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

/* ===== Role Badge Hover ===== */
.role-badge {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.role-badge:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(138, 180, 248, 0.15);
}

/* ===== Scroll Reveal Animation ===== */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered card animation */
.project-card.reveal:nth-child(2) { transition-delay: 0.1s; }
.project-card.reveal:nth-child(3) { transition-delay: 0.2s; }
.project-card.reveal:nth-child(4) { transition-delay: 0.15s; }
.project-card.reveal:nth-child(5) { transition-delay: 0.25s; }
.project-card.reveal:nth-child(6) { transition-delay: 0.2s; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .container { padding: 2rem 1.25rem; }
    .category { margin-bottom: 2.5rem; }
}

@media (max-width: 640px) {
    .hero h1 { font-size: 1.75rem; }
    .hero p { font-size: 1rem; }
    .project-grid { grid-template-columns: 1fr; }
    .header-inner {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .project-hero h1 { font-size: 1.5rem; }
    .back-to-top { bottom: 1.25rem; right: 1.25rem; }
}
