:root {
    /* Color Palette — Dark Mode (default) */
    --bg: #09090b;
    --surface: #18181b;
    --surface-hover: #27272a;
    --fg: #fafafa;
    --fg-muted: #a1a1aa;
    --fg-dim: #71717a;
    --border: #ffffff14;
    --border-hover: #ffffff2e;
    --accent: #ffffff;
    --nav-bg: rgba(9, 9, 11, 0.85);
    
    /* Sizing & Spacing */
    --max-width: 1200px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
}

/* ==========================================================================
    LIGHT MODE
    To add more light-mode overrides, just add them here under [data-theme="light"]
 ========================================================================== */
[data-theme="light"] {
    --bg: #fafafa;
    --surface: #f4f4f5;
    --surface-hover: #e4e4e7;
    --fg: #09090b;
    --fg-muted: #52525b;
    --fg-dim: #71717a;
    --border: #00000012;
    --border-hover: #00000022;
    --accent: #09090b;
    --nav-bg: rgba(250, 250, 250, 0.85);
}

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

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: 'DM Sans', 'Sarabun', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    /* Smooth transition when toggling themes */
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Grain Effect Overlay for that premium texture */
body::after {
    content: "";
    pointer-events: none;
    opacity: 0.035;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    position: fixed;
    inset: 0;
}

/* Reduce grain opacity in light mode so it doesn't feel gritty */
[data-theme="light"] body::after {
    opacity: 0.015;
}

/* Utility Classes */
.container {
    width: min(90vw, var(--max-width));
    margin: 0 auto;
}

.section-padding {
    padding: 6rem 0;
}

.text-center { text-align: center; }

.section-title {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 3rem;
}

/* Typography */
h1, h2, h3, h4 { line-height: 1.2; }
p { color: var(--fg-muted); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* ==========================================================================
    NAVIGATION
    FIX: .nav-wrapper is now the sticky, full-width element with the background.
    .nav (inside .container) handles the inner layout only.
 ========================================================================== */
.nav-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-base), background-color var(--transition-base);
}

.nav-wrapper.scrolled {
    border-bottom-color: var(--border);
}

.nav {
    padding: 1.25rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.nav-brand img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

.nav-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Theme & language toggle buttons sit together on the right */
.nav-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* Shared style for all nav pill buttons (links, lang, theme) */
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.825rem;
    font-family: inherit;
    border: 1px solid var(--border);
    color: var(--fg-muted);
    background: rgba(128, 128, 128, 0.05);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
    line-height: 1;
}

.btn-link:hover {
    color: var(--fg);
    background: rgba(128, 128, 128, 0.1);
    border-color: var(--fg-muted);
}

/* Theme toggle: show sun in dark mode, moon in light mode */
.theme-btn .icon-moon { display: none; }
.theme-btn .icon-sun  { display: block; }

[data-theme="light"] .theme-btn .icon-sun  { display: none; }
[data-theme="light"] .theme-btn .icon-moon { display: block; }

@media (max-width: 768px) {
    .nav {
        padding: 1rem 0;
        gap: 0.75rem;
    }

    /* On mobile: brand left, controls right, links take full row below */
    .nav-brand {
        flex: 1;
    }

    .nav-brand span {
        font-size: 0.9rem;
    }

    .nav-links {
        width: 100%;
        order: 3;
    }

    .nav-controls {
        order: 2;
    }
}

/* ==========================================================================
    HERO SECTION
========================================================================== */
.hero {
    padding-top: 10vh;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 500;
    letter-spacing: -0.035em;
    max-width: 900px;
    animation: fadeUp 1s ease-out forwards;
}

.hero-image-wrap {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 40px 100px -20px rgba(0,0,0,0.5);
    /* Smooth fade out at the bottom like the prototype */
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    animation: fadeUp 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    animation-delay: 0.2s;
}

.hero-image-wrap img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/* ==========================================================================
    COLLABORATED WITH (INFINITE TICKER)
    FIX: Items are now grouped in .ticker-set. JS clones the set for the loop.
    Padding-right on .ticker-set acts as the trailing gap so -50% lands perfectly.
 ========================================================================== */
.collab-section {
    padding: 4rem 0;
    border-bottom: 1px solid var(--border);
}

.collab-title {
    text-align: center;
    font-size: 1rem;
    color: var(--fg-dim);
    margin-bottom: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ticker-wrapper {
    overflow: hidden;
    display: flex;
    mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
}

.ticker-track {
    display: flex;
    align-items: center;
    animation: scrollTicker 40s linear infinite;
    will-change: transform;
}

.ticker-track:hover {
    animation-play-state: paused;
}

/* Each set is a self-contained flex row with a trailing gap for seamless looping */
.ticker-set {
    display: flex;
    gap: 4rem;
    align-items: center;
    padding-right: 4rem; /* This trailing space makes both sets equal width, so translateX(-50%) is pixel-perfect */
    flex-shrink: 0;
}

.ticker-item {
    flex-shrink: 0;
}

/* EASY SWAP: Adjust height to fit your logo aspect ratios */
.ticker-item img {
    height: 40px;
    width: auto;
    opacity: 0.6;
    filter: grayscale(1);
    transition: opacity var(--transition-base), filter var(--transition-base);
}

.ticker-item img:hover {
    opacity: 1;
    filter: grayscale(0);
}

@keyframes scrollTicker {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); } /* Scrolls exactly one set width */
}

/* ==========================================================================
    WHO ARE WE
========================================================================== */
.who-we-are-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    align-items: center;
}

@media (min-width: 768px) {
    .who-we-are-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.who-image {
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    object-fit: cover;
}

/* ==========================================================================
    OUR DATA SHOWS (STATS)
========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 2.5rem 1.5rem;
    text-align: center;
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-5px);
}

.stat-title {
    font-size: 1.1rem;
    color: var(--fg);
    margin-bottom: 1rem;
}

.stat-number-box {
    background: rgba(128, 128, 128, 0.05);
    padding: 2rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1;
}

.stat-subtitle {
    font-size: 0.85rem;
    color: var(--fg-dim);
}

/* ==========================================================================
    WHY CHOOSE US
========================================================================== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transition: background-color var(--transition-base);
}

.feature-card:hover {
    background: var(--surface-hover);
}

.feature-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(128, 128, 128, 0.1);
    border-radius: var(--radius-sm);
    color: var(--fg);
}

/* ==========================================================================
    CAROUSELS (PROJECTS & TEAM)
 ========================================================================== */
.carousel-container {
    position: relative;
    width: 100%;
}

.carousel-track {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
    padding-bottom: 1rem;
    overscroll-behavior-x: contain; /* Prevents the page from scrolling when swiping the carousel */
    touch-action: pan-x;
}

.carousel-track::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.carousel-card {
    flex: 0 0 85%; /* Mobile: one card takes up most of the screen */
    scroll-snap-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .carousel-card {
        flex: 0 0 calc(33.333% - 1rem); /* Desktop: show 3 cards */
        scroll-snap-align: start;
    }
}

/* Team member avatar style, applied via class instead of inline styles */
.team-avatar {
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    width: 60%;
    margin: 0 auto;
    object-fit: cover;
}

.card-image-placeholder {
    width: 100%;
    aspect-ratio: 1/1;
    background: rgba(128, 128, 128, 0.05);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
    font-size: 0.9rem;
    border: 1px dashed var(--border);
    object-fit: cover;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 500;
}

.card-desc {
    font-size: 0.95rem;
    flex-grow: 1; /* Pushes links to bottom if desc is short */
}

.card-links {
    display: flex;
    gap: 1rem;
    margin-top: auto;
}

.card-links a {
    color: var(--fg-muted);
    transition: color var(--transition-fast);
}
.card-links a:hover {
    color: var(--fg);
}

/* Diamond Indicators */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.diamond {
    width: 8px;
    height: 8px;
    background: var(--border-hover);
    transform: rotate(45deg);
    transition: background-color var(--transition-base), transform var(--transition-base);
    cursor: pointer;
    flex-shrink: 0;
}

.diamond.active {
    background: var(--fg);
    transform: rotate(45deg) scale(1.4);
}

/* ==========================================================================
    CONNECT WITH US
========================================================================== */
.connect-box {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    align-items: center;
}

@media (min-width: 900px) {
    .connect-box {
        grid-template-columns: 1fr 1fr;
        padding: 5rem 4rem;
    }
}

/* Faint Background Image */
.connect-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
}

.connect-content, .connect-feeds {
    position: relative;
    z-index: 1;
}

.connect-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
    color: var(--fg-muted);
}

.contact-item svg {
    color: var(--fg);
    flex-shrink: 0;
}

.connect-feeds {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 600px) {
    .connect-feeds { grid-template-columns: 1fr 1fr; }
}

.mock-feed {
    background: rgba(128, 128, 128, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    aspect-ratio: 3/4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    color: var(--fg-dim);
}

/* ==========================================================================
    FOOTER
 ========================================================================== */
footer {
    border-top: 1px solid var(--border);
    padding: 4rem 0 2rem;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-logo-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}

.footer-logo-row img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
}

.footer-col h4 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--fg);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-links a {
    color: var(--fg-muted);
    font-size: 0.9rem;
    transition: color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-links a:hover {
    color: var(--fg);
    transform: translateX(4px);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
    font-size: 0.8rem;
    color: var(--fg-dim);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* ==========================================================================
    ANIMATIONS
 ========================================================================== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Respect the user's system preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ticker-track {
        animation-play-state: paused;
    }
    .hero-title {
        animation: none;
        opacity: 1;
    }
    .hero-image-wrap {
        animation: none;
        opacity: 1;
    }
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .stat-card:hover {
        transform: none;
    }
}