/* ==================================
   Next.js Theme Inspired 
   ================================== */
:root {
    /* Colors - Midnight Blue / Slate Dark Theme */
    --background: #020617; /* น้ำเงินเข้มเกือบดำ (Slate 950) */
    --foreground: #f8fafc; /* ขาวสว่างอมฟ้านิดๆ ให้ดูละมุน */
    
    /* ชุดสีเทาอมน้ำเงิน (Slate Scale) */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --gray-950: #020617;

    --border: #1e293b; /* เส้นขอบการ์ดสีน้ำเงินหม่น */
    --accents-1: #0a0f1d; /* พื้นหลังรูปภาพในการ์ด (น้ำเงินสว่างขึ้นมานิดนึง) */
    --accents-2: #1e293b; /* พื้นหลังป้าย Badge */
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--gray-300);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* Background Grid Pattern */
.bg-grid {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    pointer-events: none;
    /* Mask ให้จางลงด้านล่าง */
    -webkit-mask-image: radial-gradient(ellipse at top, black 40%, transparent 70%);
    mask-image: radial-gradient(ellipse at top, black 40%, transparent 70%);
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.text-sm { font-size: 0.875rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-5 { margin-top: 2.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 2.5rem; }
.mt-section { margin-top: 6rem; }
.mb-section { margin-bottom: 6rem; }
.uppercase-tracking { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem; font-weight: 600; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Divider */
.section-divider {
    height: 1px;
    width: 100%;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 4rem 0;
}

/* ==================================
   Navbar
   ================================== */
.navbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: saturate(180%) blur(5px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-text { font-weight: 600; font-size: 1.1rem; color: var(--foreground); letter-spacing: -0.02em; }

.nav-links { list-style: none; display: flex; gap: 2rem; }
.nav-links a { text-decoration: none; color: var(--gray-400); font-size: 0.9rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--foreground); }

.nav-actions { display: flex; align-items: center; gap: 1rem; }
.btn-github { color: var(--gray-400); display: flex; align-items: center; transition: color 0.2s; }
.btn-github:hover { color: var(--foreground); }

.mobile-menu-btn { display: none; background: none; border: none; color: var(--foreground); cursor: pointer; }

/* Buttons */
.btn-primary {
    background: var(--foreground); color: var(--background);
    padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.9rem; font-weight: 500;
    text-decoration: none; transition: background 0.2s; border: 1px solid var(--foreground);
}
.btn-primary:hover { background: var(--gray-200); }

.btn-secondary {
    background: transparent; color: var(--foreground);
    padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.9rem; font-weight: 500;
    text-decoration: none; transition: background 0.2s; border: 1px solid var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-900); border-color: var(--gray-500); }

.btn-large { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ==================================
   Hero Section
   ================================== */
.hero-section { padding-top: 6rem; padding-bottom: 2rem; }
.hero-container { max-width: 800px; }

.profile-badge {
    display: inline-flex; align-items: center; gap: 12px;
    background: var(--accents-1); border: 1px solid var(--border);
    padding: 6px 16px 6px 6px; border-radius: 50px; margin-bottom: 2rem;
}
.profile-avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.status-dot { width: 8px; height: 8px; background-color: #0070f3; border-radius: 50%; box-shadow: 0 0 10px #0070f3; }
.AvailableDot { display: flex; align-items: center; gap: 6px; }
.AvailableUpdate { display: flex; flex-direction: column; gap: 2px; }
.status-text { font-size: 0.85rem; color: var(--gray-300); }

.hero-title {
    font-size: 4rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.04em;
    color: var(--foreground); margin-bottom: 1.5rem;
}
.text-gradient {
    background: linear-gradient(180deg, #fff, #a1a1aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle { font-size: 1.25rem; color: var(--gray-400); line-height: 1.6; max-width: 650px; margin: 0 auto; }
.hero-cta { display: flex; justify-content: center; gap: 1rem; }

.tech-logos { color: var(--gray-500); font-weight: 500; font-size: 0.9rem; word-spacing: 0.5rem; }
.tech-logos span { color: var(--gray-300); }

/* ==================================
   Section Headers
   ================================== */
.section-title { font-size: 2.5rem; font-weight: 700; color: var(--foreground); letter-spacing: -0.03em; margin-bottom: 0.5rem; }
.section-desc { font-size: 1.1rem; color: var(--gray-400); }

/* ==================================
   Experience Timeline
   ================================== */
.timeline-container { max-width: 700px; margin: 0 auto; padding-left: 20px; border-left: 1px solid var(--border); position: relative; }
.timeline-item { position: relative; padding-bottom: 3rem; padding-left: 2rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
    position: absolute; left: -5px; top: 6px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--background); border: 2px solid var(--gray-500);
}
.timeline-item:hover .timeline-dot { border-color: var(--foreground); box-shadow: 0 0 10px rgba(255,255,255,0.3); }

.timeline-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.25rem; }
.job-title { font-size: 1.25rem; font-weight: 600; color: var(--foreground); }
.timeline-date { font-size: 0.85rem; color: var(--gray-500); font-family: monospace; }
.company-name { font-size: 1rem; color: var(--gray-300); font-weight: 500; }
.timeline-content .desc { color: var(--gray-400); font-size: 0.95rem; }

/* ==================================
   Projects Grid (Next.js Card Style)
   ================================== */
.next-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.next-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    transition: border-color 0.3s ease;
}

/* Hover glow effect */
.next-card::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(255,255,255,0.06), transparent 40%);
    opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 1;
}
.next-card:hover { border-color: var(--gray-600); }
.next-card:hover::before { opacity: 1; }

.card-inner { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100%; }

.card-image-wrapper {
    width: 100%; height: 200px;
    border-bottom: 1px solid var(--border);
    background: var(--accents-1); overflow: hidden;
}
.card-image-wrapper img { width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: 0.8; transition: opacity 0.3s, transform 0.5s; }
.next-card:hover .card-image-wrapper img { opacity: 1; transform: scale(1.02); }

.card-content { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.card-header h3 { font-size: 1.25rem; font-weight: 600; color: var(--foreground); letter-spacing: -0.02em; }
.badge {
    background: var(--accents-2); border: 1px solid var(--gray-700);
    padding: 2px 8px; border-radius: 99px; font-size: 0.7rem; color: var(--gray-300); text-transform: uppercase; letter-spacing: 0.05em;
}

.card-content p { color: var(--gray-400); font-size: 0.95rem; line-height: 1.5; margin-bottom: 1.5rem; flex-grow: 1; }

.card-footer { display: flex; flex-wrap: wrap; gap: 8px; font-family: monospace; font-size: 0.8rem; color: var(--gray-500); }
.card-footer span::before { content: "• "; }
.card-footer span:first-child::before { content: ""; }

/* Layout adjustments for specific cards */
.large-card { grid-column: span 2; }
.large-card .card-image-wrapper { height: 300px; }
.wide-card { grid-column: span 2; }

/* ==================================
   Footer
   ================================== */
.footer { border-top: 1px solid var(--border); padding: 3rem 0; margin-top: 4rem; background: var(--background); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { color: var(--gray-500); text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.footer-links a:hover { color: var(--foreground); }

/* ==================================
   Animations
   ================================== */
.fade-in { opacity: 0; transform: translateY(10px); transition: opacity 0.6s ease-out, transform 0.6s ease-out; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ==================================
   Responsive
   ================================== */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .mobile-menu-btn { display: block; }
    
    .hero-title { font-size: 2.5rem; }
    .hero-cta { flex-direction: column; }
    .btn-large { width: 100%; text-align: center; }
    
    .section-title { font-size: 2rem; }
    
    .next-grid { grid-template-columns: 1fr; }
    .large-card, .wide-card { grid-column: span 1; }
    .large-card .card-image-wrapper { height: 200px; }
    
    .timeline-header { flex-direction: column; }
    .timeline-date { margin-top: 4px; }
    
    .footer-content { flex-direction: column; gap: 2rem; align-items: flex-start; }
}


/* ==================================
   Clickable Cards Styles
   ================================== */

.clickable-card {
    cursor: pointer;
}

.card-link {
    color: var(--foreground);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

/* ทำให้ลิงก์ครอบคลุมพื้นที่ทั้งหมดของการ์ด โดยไม่ให้ไปทับปุ่มอื่นถ้ามี */
.card-link::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* ซ่อนไอคอนเริ่มต้น แล้วแสดงเมื่อ hover การ์ด */
.link-icon {
    opacity: 0;
    transform: translate(-4px, 4px);
    transition: all 0.3s ease;
    color: var(--gray-400);
}

.next-card:hover .link-icon {
    opacity: 1;
    transform: translate(0, 0);
    color: var(--foreground);
}

/* ให้ Card ที่เป็น Internal Tool ดูแตกต่างนิดหน่อย เพราะคลิกไม่ได้ */
.next-card:not(.clickable-card) h3 {
    color: var(--foreground);
}