/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    overflow-x: hidden;
}

html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* THEME */
:root[data-theme="light"] {
    --bg: #ffffff;
    --text: #111111;
    --sub: #666666;
    --line: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --bg: #0f0f12;
    --text: #f5f5f7;
    --sub: #9a9aa1;
    --line: rgba(255, 255, 255, 0.1);
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: clamp(14px, 2vw, 16px);
    position: relative;
    /* Raspberry Pi performance optimization */
    will-change: auto;
    contain: layout style;
}

/* HEADER */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    width: 100%;
    padding-top: env(safe-area-inset-top);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(14px, 4vw, 18px) clamp(12px, 4vw, 24px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(8px, 2vw, 16px);
}

.logo {
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    letter-spacing: 0.04em;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.logo:hover {
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.nav-links {
    display: flex;
    gap: clamp(8px, 2vw, 16px);
    flex: 1;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 44px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    opacity: 0.85;
    font-size: clamp(0.75rem, 1.5vw, 0.9rem);
    white-space: nowrap;
    transition: opacity 0.2s ease;
    padding: 8px 0;
}

.nav-links a:hover {
    opacity: 1;
}

#themeSelector {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    padding: clamp(6px, 1.5vw, 10px) clamp(8px, 1.5vw, 10px);
    border-radius: 8px;
    font-size: clamp(0.75rem, 1.5vw, 0.9rem);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
}

#themeSelector:hover,
#themeSelector:focus {
    opacity: 0.9;
}

#themeSelector option {
    color: #000000;
    background: white;
    padding: 8px;
}
/* HERO */
.hero {
    min-height: calc(100vh - env(safe-area-inset-top) - 140px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(24px, 8vw, 60px) clamp(16px, 4vw, 24px);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.hero h1 {
    font-size: clamp(1.8rem, 7vw, 3.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: #ffffff !important;
}

/* Explore hero title - always white */
.explore-hero h1 {
    color: #ffffff !important;
}
/* keep .highlight's default color so it stays colored in light mode */

.highlight {
    color: #4f7cff;
}

.subtitle {
    margin-top: clamp(16px, 4vw, 24px);
    font-size: clamp(1rem, 2vw, 1.05rem);
    color: var(--sub);
    max-width: 700px;
    line-height: 1.6;
}

/* FOOTER */
.footer {
    border-top: 1px solid var(--line);
    padding: clamp(24px, 6vw, 40px) clamp(12px, 4vw, 24px);
    padding-bottom: calc(env(safe-area-inset-bottom) + clamp(24px, 6vw, 40px));
    text-align: center;
    font-size: clamp(0.8rem, 1.5vw, 0.85rem);
    color: var(--sub);
}

/* EXPLORE HERO */
.explore-hero {
    position: relative;
    height: clamp(40vh, 70vh, 70vh);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.explore-hero h1 {
    position: relative;
    z-index: 2;
    font-size: clamp(1.5rem, 8vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
    padding: clamp(16px, 4vw, 32px);
    line-height: 1.1;
}

.bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: brightness(0.45);
    /* Performance optimization for Raspberry Pi */
    will-change: auto;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* PROFILE */
.profile {
    max-width: 900px;
    margin: clamp(60px, 12vw, 120px) auto;
    padding: 0 clamp(12px, 4vw, 24px);
    text-align: center;
}

.profile img {
    width: clamp(80px, 25vw, 140px);
    height: clamp(80px, 25vw, 140px);
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: clamp(16px, 4vw, 24px);
    /* Performance optimization for Raspberry Pi */
    will-change: auto;
    contain: layout style paint;
}

.profile h2 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: clamp(12px, 2vw, 16px);
}

.profile ul {
    list-style: none;
    margin-top: clamp(12px, 3vw, 24px);
    color: var(--sub);
    font-size: clamp(0.95rem, 1.8vw, 1rem);
}

.profile li {
    margin: clamp(8px, 1.5vw, 12px) 0;
}

/* SOCIAL LINKS */
.social-links {
    display: flex;
    justify-content: center;
    gap: clamp(16px, 3vw, 24px);
    margin-top: clamp(24px, 5vw, 32px);
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(50px, 10vw, 60px);
    height: clamp(50px, 10vw, 60px);
    border-radius: 50%;
    background: var(--line);
    color: var(--text);
    transition: all 0.3s ease;
    text-decoration: none;
}

.social-links svg {
    width: 50%;
    height: 50%;
    object-fit: contain;
}

.social-links a:hover {
    background: var(--text);
    color: var(--bg);
    transform: scale(1.1);
}

.even {
    text-decoration: line-through;
}

/* DETAIL */
.detail {
    padding: clamp(60px, 10vw, 140px) clamp(12px, 4vw, 10%);
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: clamp(150px, 25vh, 250px);
    border-radius: clamp(12px, 3vw, 30px);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin: clamp(20px, 4vw, 40px) auto;
    max-width: 90%;
}

/* Make sure links with .detail class work as block-level flex containers */
a.detail {
    display: flex;
}

/* Make links inside .detail white and remove underline */
.detail a {
    color: #ffffff;
    text-decoration: none;
}

.detail a * {
    color: #ffffff;
}

.detail h3,
.detail p {
    color: #ffffff;
}

.detail h3 {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
    margin-bottom: clamp(12px, 2vw, 16px);
    font-weight: 700;
}

.detail p {
    max-width: 600px;
    font-size: clamp(0.9rem, 2vw, 1.05rem);
    color: var(--sub);
    line-height: 1.7;
}

/* BACKGROUNDS */
.bg-drone {
    background-image: url('/BG/drone.jpeg');
    background-color: rgba(0, 0, 0, 0.8);
}

.bg-esports {
    background-image: url('/BG/esports.jpg');
    background-color: rgba(0, 0, 0, 0.7);
}

.bg-code {
    background-image: url('/BG/code.jpg');
    background-color: rgba(0, 0, 0, 0.7);
}

.bg-edit {
    background-image: url('/BG/edit.jpg');
    background-color: rgba(0, 0, 0, 0.7);
}

/* AND PAGE */
.and-hero {
    padding: clamp(60px, 10vw, 180px) clamp(12px, 4vw, 24px) clamp(50px, 8vw, 140px);
    text-align: center;
}

.and-hero h1 {
    font-size: clamp(1.8rem, 7vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
}

.and-subtitle {
    margin-top: clamp(16px, 4vw, 24px);
    font-size: clamp(1rem, 2vw, 1.05rem);
    color: var(--sub);
    line-height: 1.6;
}

/* SECTION */
.and-section {
    padding: clamp(60px, 10vw, 140px) clamp(12px, 4vw, 10%);
}

.and-section h2 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    margin-bottom: clamp(20px, 4vw, 32px);
    font-weight: 700;
    line-height: 1.2;
}

.and-section p {
    font-size: clamp(0.95rem, 2vw, 1rem);
    line-height: 1.7;
    margin-bottom: clamp(12px, 2vw, 16px);
    max-width: 700px;
}

.and-section strong {
    font-weight: 600;
}

/* COLLAB */
.bg-collab {
    background-image: url('/images/collaboration.jpg');
    background-size: cover;
    background-position: center;
}

.collab-list {
    list-style: none;
    padding: 0;
}

.collab-list li {
    margin-bottom: clamp(16px, 4vw, 32px);
    line-height: 1.8;
    max-width: 600px;
    font-size: clamp(0.95rem, 2vw, 1rem);
}

.collab-list strong {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

/* PROJECTS */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(280px, 100%, 350px), 1fr));
    gap: clamp(20px, 4vw, 40px);
    padding: 0 clamp(12px, 4vw, 24px);
}

.project-card {
    padding: clamp(16px, 4vw, 32px);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.project-card h3 {
    margin-bottom: clamp(8px, 2vw, 12px);
    font-size: clamp(1.05rem, 2vw, 1.2rem);
}

.project-card p {
    font-size: clamp(0.9rem, 1.8vw, 1rem);
}

/* NAV ACTIVE STATE */
.nav-links a {
    position: relative;
    padding: 8px 0;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -6px;
    width: 100%;
    height: 2px;
    background: var(--text);
    opacity: 0;
    transform: scaleX(0);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-links a:hover::after {
    opacity: 0.3;
    transform: scaleX(1);
}

.nav-links a.active::after {
    opacity: 1;
    transform: scaleX(1);
}

/* RESPONSIVE DESIGN - TABLET & MOBILE (768px and below) */
@media (max-width: 768px) {
    /* Improved responsive typography and spacing */
    body {
        font-size: clamp(13px, 1.8vw, 15px);
    }
    
    /* Navigation adjustments */
    .nav-inner {
        padding: clamp(16px, 3vw, 20px) clamp(16px, 3vw, 20px);
        gap: 12px;
    }
    
    .nav-links {
        gap: 16px;
    }
    
    .nav-links a {
        padding: 10px 0 !important;
    }
    
    #themeSelector {
        min-height: 44px;
        padding: 8px 12px;
    }
    
    /* Hero section adjustments */
    .hero {
        min-height: calc(100vh - env(safe-area-inset-top) - 100px);
        padding: clamp(20px, 6vw, 40px) clamp(12px, 3vw, 20px);
    }
    
    /* Explore hero adjustments */
    .explore-hero {
        height: clamp(40vh, 60vh, 60vh);
        padding: clamp(16px, 3vw, 24px);
    }
    
    /* Detail sections */
    .detail {
        padding: clamp(50px, 8vw, 80px) clamp(12px, 3vw, 5%);
    }
    
    .detail h3 {
        font-size: clamp(1.1rem, 4vw, 1.4rem);
    }
    
    .detail p {
        font-size: clamp(0.9rem, 1.8vw, 0.95rem);
    }
    
    /* And page adjustments */
    .and-hero {
        padding: clamp(50px, 8vw, 100px) clamp(12px, 3vw, 20px) clamp(50px, 6vw, 80px);
    }
    
    .and-section {
        padding: clamp(50px, 8vw, 80px) clamp(12px, 3vw, 5%);
    }
    
    /* Profile section */
    .profile {
        margin: clamp(50px, 8vw, 60px) auto;
        padding: 0 clamp(12px, 3vw, 16px);
    }
    
    .profile img {
        width: clamp(100px, 20vw, 120px);
        height: clamp(100px, 20vw, 120px);
    }
    
    .social-links {
        gap: clamp(12px, 2vw, 20px);
        margin-top: clamp(20px, 4vw, 28px);
    }
    
    .social-links a {
        width: clamp(45px, 9vw, 55px);
        height: clamp(45px, 9vw, 55px);
    }
    
    /* Project grid - single or dual columns */
    .project-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: clamp(16px, 3vw, 24px);
        padding: 0 clamp(12px, 3vw, 16px);
    }
    
    .project-card {
        padding: clamp(16px, 3vw, 20px);
    }
    
    /* Collab list */
    .collab-list li {
        margin-bottom: clamp(16px, 3vw, 24px);
        font-size: clamp(0.9rem, 1.8vw, 0.95rem);
    }
}

/* SMALL TABLET & MOBILE (480px and below) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    /* Navigation - more spacious */
    .nav-inner {
        padding: 14px 12px;
        gap: 10px;
    }
    
    .nav-links {
        gap: 14px;
    }
    
    .logo {
        font-size: clamp(0.9rem, 4vw, 1rem);
    }
    
    .nav-links a {
        font-size: 0.75rem;
        padding: 8px 0 !important;
    }
    
    #themeSelector {
        padding: 8px 10px;
        font-size: 0.75rem;
        min-height: 44px;
    }
    
    /* Hero section */
    .hero {
        min-height: calc(100vh - env(safe-area-inset-top) - 80px);
        padding: clamp(20px, 5vw, 32px) 12px;
    }
    
    .hero h1 {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }
    
    .subtitle {
        font-size: clamp(0.9rem, 1.5vw, 0.95rem);
        margin-top: 12px;
    }
    
    /* Explore hero */
    .explore-hero {
        height: clamp(35vh, 50vh, 50vh);
        padding: 12px;
    }
    
    .explore-hero h1 {
        font-size: clamp(1.2rem, 5vw, 1.6rem);
    }
    
    /* Detail sections */
    .detail {
        padding: clamp(40px, 6vw, 60px) 12px;
        min-height: auto;
    }
    
    .detail h3 {
        font-size: clamp(1rem, 3.5vw, 1.1rem);
        margin-bottom: 8px;
    }
    
    .detail p {
        font-size: clamp(0.85rem, 1.5vw, 0.9rem);
        margin-top: 8px;
    }
    
    /* And page */
    .and-hero {
        padding: clamp(40px, 6vw, 60px) 12px clamp(40px, 5vw, 50px);
    }
    
    .and-hero h1 {
        font-size: clamp(1.3rem, 6vw, 1.8rem);
    }
    
    .and-subtitle {
        font-size: clamp(0.85rem, 1.5vw, 0.9rem);
        margin-top: 10px;
    }
    
    .and-section {
        padding: clamp(40px, 6vw, 60px) 12px;
    }
    
    .and-section h2 {
        font-size: clamp(1.1rem, 4vw, 1.3rem);
        margin-bottom: clamp(16px, 3vw, 20px);
    }
    
    .and-section p {
        font-size: clamp(0.85rem, 1.6vw, 0.9rem);
        margin-bottom: 12px;
    }
    
    /* Profile section */
    .profile {
        margin: clamp(40px, 6vw, 50px) auto;
        padding: 0 12px;
    }
    
    .profile img {
        width: 80px;
        height: 80px;
        margin-bottom: 12px;
    }
    
    .profile h2 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .profile ul {
        font-size: 0.85rem;
    }
    
    .profile li {
        margin: 6px 0;
    }
    
    /* Project grid */
    .project-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 12px;
    }
    
    .project-card {
        padding: 12px;
    }
    
    .project-card h3 {
        font-size: clamp(1rem, 3vw, 1.1rem);
        margin-bottom: 6px;
    }
    
    .project-card p {
        font-size: 0.85rem;
    }
    
    /* Collab list */
    .collab-list li {
        margin-bottom: 16px;
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    .collab-list strong {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }
    
    /* Footer */
    .footer {
        padding: clamp(16px, 4vw, 24px) 12px;
        padding-bottom: calc(env(safe-area-inset-bottom) + clamp(16px, 4vw, 24px));
        font-size: 0.8rem;
    }
}

/* EXTRA SMALL MOBILE (340px and below - iPhone SE, etc.) */
@media (max-width: 340px) {
    .nav-inner {
        padding: 12px 10px;
        gap: 6px;
    }
    
    .nav-links {
        gap: 10px;
    }
    
    .logo {
        font-size: 0.85rem;
    }
    
    .nav-links a {
        font-size: 0.7rem;
        padding: 6px 0 !important;
    }
    
    #themeSelector {
        padding: 6px 8px;
        font-size: 0.7rem;
        min-height: 40px;
    }
    
    .hero {
        padding: 16px 10px;
    }
    
    .hero h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
        margin-top: 8px;
    }
    
    .detail {
        padding: 32px 10px;
    }
    
    .detail h3 {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    .detail p {
        font-size: 0.8rem;
    }
    
    .and-hero {
        padding: 32px 10px 32px;
    }
    
    .and-hero h1 {
        font-size: 1.2rem;
    }
    
    .and-section {
        padding: 32px 10px;
    }
    
    .and-section h2 {
        font-size: 1.05rem;
        margin-bottom: 12px;
    }
    
    .and-section p {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }
    
    .profile {
        margin: 32px auto;
        padding: 0 10px;
    }
    
    .profile img {
        width: 70px;
        height: 70px;
        margin-bottom: 8px;
    }
    
    .profile h2 {
        font-size: 1rem;
        margin-bottom: 6px;
    }
    
    .profile ul {
        font-size: 0.8rem;
    }
    
    .profile li {
        margin: 4px 0;
    }
    
    .footer {
        padding: 12px 10px;
        padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
        font-size: 0.75rem;
    }
}

/* ACCESSIBILITY & TOUCH OPTIMIZATION */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices - disable hover effects that don't work well with touch */
    .nav-links a::after {
        opacity: 0;
        transform: scaleX(0);
    }
    
    .project-card:hover {
        transform: none;
    }
    
    a:active,
    button:active {
        opacity: 0.7 !important;
    }
}

/* Reduce animations on devices that prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode improvements for better readability */
@media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
        --bg: #0f0f12;
        --text: #f5f5f7;
        --sub: #9a9aa1;
        --line: rgba(255, 255, 255, 0.1);
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer {
        display: none;
    }
    
    body {
        line-height: 1.5;
    }
}

/* DESKTOP OPTIMIZATION (1200px and above) */
@media (min-width: 1200px) {
    .hero {
        padding: 60px 24px;
    }
    
    .detail {
        padding: 140px 10%;
    }
    
    .and-section {
        padding: 140px 10%;
    }
    
    .project-grid {
        max-width: 1200px;
        margin: 0 auto;
    }
}