/* ============================================
   InsightLab v2.0 — Modern Stylesheet
   ============================================ */

/* --- Variables & Design System --- */
:root {
    /* Font */
    --font-primary: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Type Scale — clear hierarchy */
    --text-xl: 3rem;      /* 48px – hero */
    --text-lg: 1.75rem;   /* 28px – section titles */
    --text-md: 1.125rem;  /* 18px – lead / subtitles */
    --text-sm: 1rem;      /* 16px – body */
    --text-xs: 0.875rem;  /* 14px – captions / meta */

    /* Spacing Scale — generous & consistent */
    --space-xl: 5rem;     /* 80px */
    --space-lg: 3rem;     /* 48px */
    --space-md: 1.5rem;   /* 24px */
    --space-sm: 0.75rem;  /* 12px */
    --space-xs: 0.375rem; /* 6px */

    /* Colors */
    --color-primary: #4f46e5;
    --color-primary-light: #6366f1;
    --color-primary-dark: #3730a3;
    --color-accent: #06b6d4;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-light: #64748b;
    --color-border: #e2e8f0;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

    /* Navbar height token */
    --navbar-h: 64px;

    /* Misc */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --max-width: 1100px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 0.95);
    border-bottom-color: var(--color-border);
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--navbar-h);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-text);
}

.nav-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
    border-radius: 8px;
    object-fit: contain;
}

.nav-menu {
    display: flex;
    flex-direction: row;
    list-style: none;
    gap: 0.25rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.nav-link {
    text-decoration: none;
    color: var(--color-text-light);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--color-primary);
    background: rgba(79, 70, 229, 0.06);
}

.nav-cta {
    background: var(--color-primary);
    color: #fff !important;
    margin-left: 0.5rem;
}

.nav-cta:hover {
    background: var(--color-primary-dark) !important;
    color: #fff !important;
}

/* Hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: var(--transition);
}

.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ============================================
   HERO
   ============================================ */
.hero {
    position: relative;
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: var(--space-xl) 0;
    padding-top: calc(var(--navbar-h) + var(--space-xl));
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--color-bg);
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: var(--space-lg) var(--space-md);
    max-width: 700px;
}

.hero-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 100px;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
}

.hero-title {
    font-size: clamp(2.5rem, 7vw, var(--text-xl));
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.03em;
    color: var(--color-text);
    margin-bottom: var(--space-md);
}

.hero-title .accent {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--text-md);
    color: var(--color-text-light);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto var(--space-lg);
    line-height: 1.6;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 100px;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.hero-cta:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(79, 70, 229, 0.4);
}

.hero-cta svg {
    transition: transform var(--transition);
}

.hero-cta:hover svg {
    transform: translate(2px, -2px);
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
    text-align: center;
    max-width: 640px;
    margin: 0 auto var(--space-lg);
}

.section-title {
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    margin-bottom: var(--space-sm);
}

.section-desc {
    color: var(--color-text-light);
    font-size: var(--text-md);
    line-height: 1.7;
}

/* ============================================
   MAIN / APPS GRID
   ============================================ */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.apps-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* ============================================
   APP CARD
   ============================================ */
.app-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    content-visibility: auto;
    contain-intrinsic-size: 420px;
    transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.app-card[data-animate] {
    opacity: 0;
    transform: translateY(30px);
}

.app-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.app-card:hover {
    border-color: rgba(79, 70, 229, 0.2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.app-icon {
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(79, 70, 229, 0.06);
    flex-shrink: 0;
}

.app-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-bottom: 0.2rem;
}

.app-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    background: rgba(79, 70, 229, 0.08);
    padding: 0.15rem 0.6rem;
    border-radius: 100px;
}

.app-desc {
    color: var(--color-text-light);
    font-size: var(--text-sm);
    line-height: 1.75;
    margin-bottom: var(--space-md);
}

/* Read more */
.app-more {
    margin-bottom: 0.75rem;
}

.app-more summary {
    cursor: pointer;
    color: var(--color-primary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.app-more summary::-webkit-details-marker { display: none; }

.app-more summary::before {
    content: '+ ';
    font-weight: 700;
}

.app-more[open] summary::before {
    content: '− ';
}

.app-more[open] .app-desc {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Gallery */
.app-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

.app-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--color-border);
    display: block;
}

.app-gallery img:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary-light);
}

/* Button */
.app-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: var(--text-xs);
    text-decoration: none;
    border-radius: 100px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    margin-top: var(--space-sm);
}

.app-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

/* ============================================
   COMMENTS SECTION
   ============================================ */
.comments-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.comments-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--color-border);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-md) var(--space-md);
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    max-width: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.footer-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.footer-name small {
    font-weight: 400;
    color: var(--color-text-light);
    font-size: 0.8rem;
}

.footer-copy {
    color: var(--color-text-light);
    font-size: var(--text-xs);
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.92);
    transition: transform 0.3s ease;
}

.lightbox.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-close {
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.6rem;
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --navbar-h: 56px;
        --text-lg: 1.5rem;
        --text-md: 1rem;
        --space-xl: 3.5rem;
        --space-lg: 2rem;
    }

    /* --- Navbar --- */
    .nav-container {
        padding: 0 var(--space-md);
        height: var(--navbar-h);
    }

    .nav-logo {
        font-size: 1rem;
        gap: 0.4rem;
        flex-shrink: 0;
    }

    .nav-icon {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        max-width: 28px;
        max-height: 28px;
    }

    .nav-toggle {
        display: flex;
        flex-shrink: 0;
    }

    .nav-menu {
        position: fixed;
        top: var(--navbar-h);
        left: 0;
        right: 0;
        background: var(--color-surface);
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-sm) var(--space-md);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
        transform: translateY(-120%);
        transition: var(--transition);
        gap: var(--space-xs);
        z-index: 999;
    }

    .nav-menu.active {
        transform: translateY(0);
    }

    .nav-link {
        padding: 0.85rem var(--space-md);
        width: 100%;
        text-align: left;
        font-size: var(--text-sm);
        white-space: normal;
        display: block;
        border-radius: var(--radius-sm);
    }

    .nav-cta {
        margin: var(--space-xs) 0 0;
        padding: 0.85rem var(--space-md);
        font-size: var(--text-sm);
        width: 100%;
        text-align: center;
        display: block;
        border-radius: var(--radius-sm);
        margin-left: 0;
    }

    /* --- Hero --- */
    .hero {
        min-height: auto;
        padding: var(--space-lg) 0;
        padding-top: calc(var(--navbar-h) + var(--space-lg));
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: var(--text-sm);
    }

    /* --- Cards --- */
    .app-card {
        padding: var(--space-md);
    }

    .app-gallery {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .app-gallery img {
        height: 200px;
    }

    /* --- Footer --- */
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .lightbox-prev { left: 0.75rem; }
    .lightbox-next { right: 0.75rem; }
}

@media (max-width: 480px) {
    :root {
        --navbar-h: 48px;
        --space-xl: 2.5rem;
        --space-lg: 1.5rem;
        --space-md: 1rem;
    }

    .nav-container {
        padding: 0 var(--space-sm);
    }

    .nav-logo {
        font-size: 0.9rem;
    }

    .nav-icon {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
    }

    .hero-title {
        font-size: 1.85rem;
    }

    .hero-content {
        padding: var(--space-md) var(--space-sm);
    }

    .app-title {
        font-size: 1.15rem;
    }

    .app-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    main {
        padding: var(--space-lg) var(--space-sm);
    }
}
