/* Dark Theme (Default) */
:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --bg-main: #0b1120;
    --bg-card: rgba(15, 23, 42, 0.7);
    --bg-nav: rgba(11, 15, 26, 0.8);
    --text-white: #ffffff;
    --text-gray: #d1d5db;
    --text-muted: #9ca3af;
    --accent: #10b981;
    --glass-border: rgba(255, 255, 255, 0.08);
    --nav-height: 80px;
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-nav: rgba(248, 250, 252, 0.8);
    --text-white: #0f172a;
    --text-gray: #334155;
    --text-muted: #64748b;
    --glass-border: rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
    transition: background-color 0.3s ease;
}

body {
    font-family: 'Outfit', 'Noto Sans Thai', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-gray);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* Theme Toggle Button Style */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-white);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 0.5rem;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--primary-light);
    transform: scale(1.1);
}

/* Light mode — warm sun style */
[data-theme="light"] .theme-toggle {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #f59e0b;
    color: #d97706;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

[data-theme="light"] .theme-toggle:hover {
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

/* Dark mode — cool moon style */
[data-theme="dark"] .theme-toggle {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(129, 140, 248, 0.3);
    color: #c4b5fd;
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(99, 102, 241, 0.25);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.theme-toggle .fa-cloud-sun,
.theme-toggle .fa-moon {
    transition: transform 0.4s ease, opacity 0.3s ease;
}

[data-theme="light"] .fa-cloud-sun { display: none; }
[data-theme="dark"] .fa-moon { display: none; }
[data-theme="light"] .fa-moon { display: block; }

/* Existing sections modified for theme support */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 3rem 2.5rem;
    border-radius: 32px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glass-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary-light);
}

[data-theme="light"] .glass-card {
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.lang-btn {
    text-decoration: none;
    color: var(--text-white);
    font-weight: 800;
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: 0.3s;
    min-width: 44px;
    text-align: center;
    display: inline-block;
}

.lang-btn:hover {
    color: var(--primary-light);
    border-color: var(--primary-light);
}
[data-theme="light"] .sub-tag {
    background: #f1f5f9;
}

/* Background Accents */
.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 10% 10%, rgba(79, 70, 229, 0.1) 0%, transparent 40%),
                radial-gradient(circle at 90% 90%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Typography Enhancements */
h1, h2, h3 {
    color: var(--text-white);
    line-height: 1.2;
}

/* Nav */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    background: var(--bg-nav);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    transition: background-color 0.3s;
}

.nav-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-white);
    text-decoration: none;
    transition: color 0.3s;
}

.nav-links {
    display: flex;
    gap: 2.5rem;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-gray);
    font-weight: 600;
    font-size: 1rem;
    transition: 0.3s;
}

.nav-links a:hover {
    color: var(--primary-light);
}

.scrolled .nav-links a,
[data-theme="dark"] .nav-links a {
    color: var(--text-gray);
}

[data-theme="dark"] .nav-links a:hover {
    color: #ffffff;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: var(--nav-height);
}

.hero-content {
    flex: 1;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: clamp(3rem, 8vw, 4.5rem);
    margin-bottom: 1.5rem;
    font-weight: 800;
}

.hero p {
    font-size: 1.2rem;
    max-width: 600px;
    margin-bottom: 2.5rem;
    color: var(--text-gray);
}

/* Cards & Grid */
section {
    padding: 100px 0;
    clear: both;
}

.section-title {
    font-size: 2.5rem;
    margin: 6rem 0 4rem 0;
    text-align: center;
    position: relative;
    z-index: 10;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.grid-3 > *:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.skills-grid-detailed > *:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 24px;
    transition: transform 0.3s, border-color 0.3s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: rgba(79, 70, 229, 0.3);
}

/* Project Specifics */
.project-card h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.project-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.tech-tags {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--glass-border);
}

/* Skill Grid Modernized */
.skills-grid-detailed {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 5rem;
}

/* Experience Timeline UI */
.experience-timeline {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding-left: 3rem;
}

.experience-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), transparent);
}

.timeline-item {
    position: relative;
    margin-bottom: 3rem;
}

.timeline-dot {
    position: absolute;
    left: -3rem;
    top: 0.5rem;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 4px solid var(--bg-main);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
}


.category-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.category-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.category-header h3 {
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
}

.sub-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.sub-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

[data-theme="light"] .sub-tag {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.sub-tag:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    border-color: var(--primary);
}




/* Contact */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.contact-info {
    display: grid;
    gap: 1.5rem;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.icon-box {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.3s;
    display: inline-block;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.btn-outline {
    border: 1px solid var(--glass-border);
    color: var(--text-white);
    background: transparent;
    padding: 1rem 2.5rem;
}

.btn-outline:hover {
    background: var(--glass-border);
    border-color: var(--primary-light);
    color: var(--primary-light);
}

/* ==================== Tablet ==================== */
@media (max-width: 1024px) {
    .hero {
        flex-direction: column;
        text-align: center;
        gap: 3rem;
        padding-top: calc(var(--nav-height) + 2rem);
    }

    .hero-content { order: 2; }

    .hero-image {
        order: 1;
        justify-content: center !important;
    }

    /* Better visibility for outline buttons on mobile (Supports both themes) */
    .btn-outline {
        border: 1px solid var(--glass-border) !important;
        color: var(--text-white) !important;
        background: var(--bg-card) !important;
        backdrop-filter: blur(4px);
    }

    .hero p {
        margin-left: auto;
        margin-right: auto;
        font-size: 1rem;
        line-height: 1.6;
        padding: 0 0.5rem;
    }

    .status-badge {
        justify-content: center;
    }
}

/* ==================== Mobile ==================== */
@media (max-width: 768px) {
    /* Nav — clean mobile header */
    .nav-links { display: none; }

    .nav-container {
        padding: 0 1rem;
    }

    /* Hide Hire Me CTA on mobile (use contact section instead) */
    .nav-container > div:last-child .nav-cta {
        display: none;
    }

    /* Hero */
    .hero {
        flex-direction: column;
        text-align: center;
        gap: 1.2rem;
        min-height: auto;
        padding-top: 140px !important; /* Forces enough space on any mobile device */
        padding-bottom: 2rem;
    }

    .hero-content {
        order: 2;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .hero-image {
        order: 1;
        justify-content: center !important;
        flex: none !important;
    }

    .hero h1 {
        font-size: clamp(1.8rem, 10vw, 2.5rem);
        overflow-wrap: break-word;
        word-break: break-word;
        hyphens: auto;
        line-height: 1.1;
    }

    .hero p {
        font-size: 1rem;
        margin-left: auto;
        margin-right: auto;
    }

    .hero-actions {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1rem !important;
        margin-bottom: 2rem;
    }

    .status-badge {
        justify-content: center;
        font-size: 0.75rem;
        margin-top: 2rem; /* Increased top margin to prevent catching the floating frame */
        margin-bottom: 1rem;
    }

    .profile-frame {
        width: 220px !important;
        height: 260px !important;
    }

    /* Sections */
    section {
        padding: 60px 0; /* Consistent padding */
    }

    .section-title {
        font-size: 1.8rem;
        margin: 2rem 0 1.5rem 0; /* Tighter margins */
    }

    .container {
        padding: 0 1rem;
    }

    /* About stats — STACK VERTICALLY ON MOBILE */
    #about div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 2rem !important;
        margin-top: 3rem !important;
        margin-bottom: 3rem !important;
        align-items: center !important;
    }

    #about h3 {
        font-size: 2.2rem !important; 
        margin-bottom: 0.2rem !important;
        white-space: nowrap;
    }

    #about p {
        font-size: 0.85rem !important;
        letter-spacing: 1.5px !important;
    }

    /* Grids */
    .grid-3 { grid-template-columns: 1fr; }
    .skills-grid-detailed { grid-template-columns: 1fr; }
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Cards */
    .glass-card {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .glass-card:hover {
        transform: none;
    }

    /* Project cards */
    .project-card h3 {
        font-size: 1.2rem;
    }

    .project-card ul {
        font-size: 0.85rem !important;
    }

    /* Timeline */
    .experience-timeline {
        padding-left: 2rem;
    }

    .timeline-dot {
        left: -2rem;
        width: 12px;
        height: 12px;
    }

    .experience-timeline .glass-card > div:first-child {
        flex-direction: column !important;
        gap: 0.5rem;
    }

    /* Skills */
    .category-header i {
        font-size: 2rem;
    }

    .category-header h3 {
        font-size: 1.1rem;
    }

    .sub-tag {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* Contact */
    .contact-grid > div:last-child {
        text-align: center !important;
    }

    .contact-grid > div:last-child h3 {
        font-size: 1.4rem !important;
    }

    .contact-card {
        padding: 1rem;
        gap: 1rem;
    }

    .icon-box {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    /* Buttons — touch-friendly sizing */
    .btn {
        padding: 0.85rem 1.5rem;
        font-size: 0.9rem;
    }

    .btn-outline {
        padding: 0.85rem 1.5rem !important;
    }

    /* Footer */
    footer .container {
        flex-direction: column !important;
        gap: 1rem;
        text-align: center;
    }

    /* Certifications */
    #certifications .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ==================== Small Mobile ==================== */
@media (max-width: 400px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 0.9rem;
    }

    .profile-frame {
        width: 160px !important;
        height: 200px !important;
    }

    .hero-actions {
        gap: 0.8rem !important;
    }

    .status-badge {
        margin-top: 1.5rem;
    }

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

    .nav-container > div:last-child {
        gap: 0.4rem !important;
    }

    .lang-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    .theme-toggle {
        width: 34px;
        height: 34px;
        margin-left: 0;
    }

    .glass-card {
        padding: 1.2rem;
    }

    .sub-tag {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
}

/* ==================== Profile Carousel ==================== */
.profile-frame {
    width: 340px;
    height: 400px;
    border-radius: 24px;
    overflow: visible;
    position: relative;
    animation: profileFloat 5s ease-in-out infinite;
}

/* Spinning gradient border */
.profile-glow {
    position: absolute;
    inset: -4px;
    border-radius: 26px;
    background: conic-gradient(
        from var(--angle, 0deg),
        #6366f1, #a855f7, #ec4899, #a855f7, #6366f1
    );
    animation: spinBorder 3s linear infinite;
    z-index: 0;
    filter: blur(1px);
}

.profile-glow::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 30px;
    background: conic-gradient(
        from var(--angle, 0deg),
        #6366f1, #a855f7, #ec4899, #a855f7, #6366f1
    );
    animation: spinBorder 3s linear infinite;
    filter: blur(18px);
    opacity: 0.5;
    z-index: -1;
}

.profile-frame::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 20px;
    z-index: 1;
    pointer-events: none;
}

.profile-photo {
    position: absolute;
    inset: 4px;
    border-radius: 20px;
    z-index: 2;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    object-fit: cover;
}

.profile-photo.active {
    opacity: 1;
}

.profile-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 3;
}

.profile-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.profile-dots .dot.active {
    background: white;
    width: 24px;
    border-radius: 4px;
}

@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes spinBorder {
    to { --angle: 360deg; }
}

@keyframes profileFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
}

/* Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
}
.reveal.active {
    opacity: 1;
    transform: translateY(0);
    transition: 0.8s ease-out;
}
