/* ============================================
   CHAPTER 3 — THE CRAFT (Skills)
   ============================================ */
#skills {
    padding: 60px 0;
    position: relative;
}

/* --- Section Header --- */
.ch3-header {
    margin-bottom: 48px;
}

.ch3-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-family: var(--heading);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.ch3-label svg {
    width: 14px;
    height: 14px;
}

.ch3-title {
    font-family: var(--heading);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Stagger-title: each word animates in */
.ch3-title .stagger-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.ch3-title.visible .stagger-word {
    opacity: 1;
    transform: translateY(0);
}

.ch3-title .stagger-word:nth-child(1) { transition-delay: 0ms; }
.ch3-title .stagger-word:nth-child(2) { transition-delay: 80ms; }
.ch3-title .stagger-word:nth-child(3) { transition-delay: 160ms; }
.ch3-title .stagger-word:nth-child(4) { transition-delay: 240ms; }
.ch3-title .stagger-word:nth-child(5) { transition-delay: 320ms; }

.ch3-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 560px;
    line-height: 1.7;
}

/* --- Skill Tabs --- */
.ch3-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.ch3-tab {
    padding: 10px 20px;
    font-family: var(--heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.ch3-tab:hover {
    color: var(--text-primary);
    border-color: var(--glass-border-hover);
}

.ch3-tab.active {
    color: #fff;
    background: var(--accent-gradient);
    border-color: transparent;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* --- Skill Panels --- */
.ch3-panel {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    animation: ch3FadeIn 0.4s var(--ease-out);
}

.ch3-panel.active {
    display: grid;
}

@keyframes ch3FadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Skill Cards --- */
.ch3-skill-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color var(--transition-normal),
                box-shadow var(--transition-normal),
                transform var(--transition-normal);
    cursor: pointer;
}

.ch3-skill-card:hover {
    border-color: var(--glass-border-hover);
    box-shadow: 0 8px 40px rgba(99, 102, 241, 0.08),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: translateY(-4px);
}

.ch3-skill-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--accent-secondary);
    background: rgba(34, 211, 238, 0.08);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.ch3-skill-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.ch3-skill-card:hover .ch3-skill-icon {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.ch3-skill-info h4 {
    font-family: var(--heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.ch3-skill-info span {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* ============================================
   MARQUEE TICKER
   ============================================ */
.marquee-section {
    padding: 20px 0;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    overflow: hidden;
    position: relative;
}

/* Gradient fade overlays on edges */
.marquee-section::before,
.marquee-section::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 120px;
    z-index: 2;
    pointer-events: none;
}

.marquee-section::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-primary), transparent);
}

.marquee-section::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-primary), transparent);
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee 35s linear infinite;
}

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

.marquee-content {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    padding-right: 0;
}

.marquee-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--heading);
    font-size: 0.9rem;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
    white-space: nowrap;
    padding: 0 12px;
    transition: color var(--transition-fast);
}

.marquee-item:hover {
    color: var(--text-secondary);
}

.marquee-item i {
    font-size: 1.1rem;
    color: var(--accent-secondary);
    opacity: 0.6;
}

.marquee-item svg {
    width: 16px;
    height: 16px;
    fill: var(--accent-secondary);
    opacity: 0.6;
}

.marquee-dot {
    color: var(--accent-primary);
    opacity: 0.4;
    padding: 0 6px;
    font-size: 0.6rem;
    user-select: none;
}

@keyframes marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* ============================================
   CHAPTER 4 — THE WORK (Projects)
   ============================================ */
#projects {
    position: relative;
}

.ch4-header {
    padding: 40px 0 40px;
    max-width: 1280px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

.ch4-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-family: var(--heading);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.ch4-label svg {
    width: 14px;
    height: 14px;
}

.ch4-title {
    font-family: var(--heading);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Stagger-title animation */
.ch4-title .stagger-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.ch4-title.visible .stagger-word {
    opacity: 1;
    transform: translateY(0);
}

.ch4-title .stagger-word:nth-child(1) { transition-delay: 0ms; }
.ch4-title .stagger-word:nth-child(2) { transition-delay: 80ms; }
.ch4-title .stagger-word:nth-child(3) { transition-delay: 160ms; }

.ch4-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 680px;
    line-height: 1.7;
}

/* --- Horizontal Scroll Wrapper --- */
.ch4-wrapper {
    height: 400vh; /* scroll runway — more room for 4 cards */
    position: relative;
}

.ch4-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    overflow: hidden;
    width: 100%;
}

.ch4-track {
    display: flex;
    gap: 32px;
    padding: 0 10vw;
    will-change: transform;
    width: max-content;
}

/* --- Project Cards --- */
.ch4-project-card {
    min-width: 420px;
    max-width: 500px;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.ch4-project-card .ch4-project-image {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.ch4-project-card:hover .ch4-project-image {
    transform: scale(1.05);
}

/* Overlay gradient */
.ch4-project-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(10, 10, 15, 0.95) 0%,
        rgba(10, 10, 15, 0.4) 50%,
        transparent 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 28px;
    transition: background var(--transition-normal);
}

.ch4-project-card:hover .ch4-project-overlay {
    background: linear-gradient(
        to top,
        rgba(10, 10, 15, 0.98) 0%,
        rgba(10, 10, 15, 0.6) 60%,
        rgba(10, 10, 15, 0.3) 100%
    );
}

/* Tags */
.ch4-project-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--transition-normal),
                transform var(--transition-normal);
}

.ch4-project-card:hover .ch4-project-tags {
    opacity: 1;
    transform: translateY(0);
}

.ch4-tag {
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-primary);
    font-family: var(--heading);
}

/* Card title */
.ch4-project-card h3 {
    font-family: var(--heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* Description (reveal on hover) */
.ch4-project-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    opacity: 0;
    max-height: 0;
    transition: opacity var(--transition-normal),
                max-height var(--transition-normal);
}

.ch4-project-card:hover p {
    opacity: 1;
    max-height: 100px;
}

/* Border glow on hover */
.ch4-project-border {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    transition: border-color var(--transition-normal),
                box-shadow var(--transition-normal);
    pointer-events: none;
}

.ch4-project-card:hover .ch4-project-border {
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 30px var(--accent-glow);
}

/* ============================================
   MOBILE RESPONSIVE — Ch3, Marquee, Ch4
   ============================================ */
@media (max-width: 768px) {
    /* Chapter 3 mobile */
    #skills {
        padding: 60px 0;
    }

    .ch3-tabs {
        gap: 6px;
    }

    .ch3-tab {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .ch3-panel {
        grid-template-columns: 1fr 1fr;
    }

    .ch3-skill-card {
        padding: 16px;
        gap: 12px;
    }

    .ch3-skill-icon {
        width: 38px;
        height: 38px;
        font-size: 1.3rem;
    }

    /* Marquee mobile */
    .marquee-section::before,
    .marquee-section::after {
        width: 60px;
    }

    /* Chapter 4 mobile — stack vertically */
    .ch4-wrapper {
        height: auto;
    }

    .ch4-sticky {
        position: static;
        height: auto;
    }

    .ch4-track {
        flex-direction: column;
        transform: none !important;
        padding: 0 24px;
        gap: 24px;
        padding-bottom: 80px;
    }

    .ch4-project-card {
        min-width: 100%;
    }

    .ch4-header {
        padding: 60px 24px 40px;
    }

    /* On mobile show tags and desc by default */
    .ch4-project-tags {
        opacity: 1;
        transform: translateY(0);
    }

    .ch4-project-card p {
        opacity: 1;
        max-height: 100px;
    }
}

@media (max-width: 480px) {
    .ch3-panel {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .ch3-title .stagger-word {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .ch4-title .stagger-word {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .ch3-panel {
        animation: none;
    }

    .marquee-track {
        animation: none;
    }

    .ch4-project-card .ch4-project-image {
        transition: none;
    }

    .ch4-project-card {
        transition: none;
    }
}
