/* =====================================================
   SSRobotics fix.css — loaded LAST → highest priority
   ===================================================== */

/* ── 1. Canvas elements: restore fixed + behind-everything ── */
#mujoco-stream {
    position: fixed !important;
    top: 0; left: 0;
    width: 100vw !important;
    height: 100vh !important;
    object-fit: cover !important;
    z-index: -2 !important;
    pointer-events: none !important;
}
#bg-fallback-canvas {
    position: fixed !important;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: -2 !important;
    pointer-events: none !important;
}
#particle-canvas {
    position: fixed !important;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: -3 !important;
    pointer-events: none !important;
}

/* ── 2. #home: no overflow:hidden, proper flex layout ──
   (scoped to .spa-active so the hidden hero can't block other SPA pages) */
#home.hero-section.spa-section.spa-active {
    position: relative !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 100vh !important;
    padding: 90px 6% 60px !important;
    box-sizing: border-box;
}

/* ── 3. Hero content: always in front, fully visible ── */
.hero-content {
    position: relative !important;
    z-index: 10 !important;
    max-width: 650px !important;
    padding: 0 !important;
}

/* ── 4. Hero text colours — dark mode visible ── */
[data-theme="dark"] .hero-title,
.hero-title {
    background: linear-gradient(120deg, #ffd700 0%, #ff6d00 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    font-size: clamp(2.8rem, 5vw, 4.5rem) !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    margin-bottom: 0.5rem !important;
}
[data-theme="dark"] .hero-subtitle,
.hero-subtitle,
#home h2 {
    color: #00e676 !important;
    -webkit-text-fill-color: #00e676 !important;
    font-size: clamp(1rem, 2vw, 1.4rem) !important;
    font-weight: 500 !important;
    margin-bottom: 1.2rem !important;
}
[data-theme="dark"] .hero-text,
.hero-text,
#home > .hero-content > p {
    color: #c8d6e5 !important;
    -webkit-text-fill-color: #c8d6e5 !important;
    font-size: 1rem !important;
    line-height: 1.75 !important;
    margin-bottom: 2rem !important;
    max-width: 520px !important;
    text-shadow: none !important;
}
.hero-badge {
    display: inline-block !important;
    color: #ffd700 !important;
    -webkit-text-fill-color: #ffd700 !important;
    background: rgba(255, 215, 0, 0.1) !important;
    border: 1px solid rgba(255, 215, 0, 0.3) !important;
    border-radius: 20px !important;
    padding: 5px 14px !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
    margin-bottom: 1.2rem !important;
}

/* ── 5. Hero buttons ── */
.hero-buttons {
    display: flex !important;
    gap: 1rem !important;
    flex-wrap: wrap !important;
    margin-bottom: 2.5rem !important;
}

/* ── 6. Hero stats ── */
.hero-stats {
    display: flex !important;
    gap: 0.75rem !important;
    flex-wrap: wrap !important;
}
.hero-stat-item {
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(245,166,35,0.25) !important;
    border-radius: 14px !important;
    padding: 12px 18px !important;
    min-width: 95px !important;
    text-align: center !important;
    backdrop-filter: blur(6px) !important;
    transition: transform 0.2s, border-color 0.2s !important;
}
.hero-stat-item:hover {
    transform: translateY(-3px) !important;
    border-color: #f5a623 !important;
}
.hero-stat-number {
    display: block !important;
    font-size: 1.7rem !important;
    font-weight: 800 !important;
    color: #f5a623 !important;
    -webkit-text-fill-color: #f5a623 !important;
    line-height: 1 !important;
}
.hero-stat-label {
    display: block !important;
    font-size: 0.75rem !important;
    color: #8899aa !important;
    -webkit-text-fill-color: #8899aa !important;
    margin-top: 4px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* ── 7. HUD overlay stays in front ── */
.hologram-overlay,
.hud-dashboard-panel,
#hud-dashboard {
    z-index: 5 !important;
    pointer-events: none;
}

/* ── 8. All other sections: proper spacing behind navbar ──
   Top/bottom padding is driven by --ss-sec-pad-top/--ss-sec-pad-bottom,
   set from SSRobotics Studio's layout pane (site-settings.js applyLayout).
   Fallbacks below (90px/80px) match the original hardcoded values, so
   nothing changes until Studio settings load. */
.spa-section.spa-active:not(#home) {
    padding: var(--ss-sec-pad-top,90px) 6% var(--ss-sec-pad-bottom,80px) !important;
    min-height: 100vh !important;
    box-sizing: border-box !important;
}

/* ── 9. SPA animation: keep simple, no opacity conflict ── */
.spa-section.spa-active {
    animation: fixFadeIn 0.4s ease forwards !important;
}
@keyframes fixFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── 10. Mobile ── */
@media (max-width: 900px) {
    #home.hero-section.spa-section {
        flex-direction: column !important;
        padding: 100px 5% 60px !important;
        justify-content: flex-start !important;
    }
    #hud-dashboard, .hud-dashboard-panel { display: none !important; }
}

/* ════════════════════════════════════════════════
   UX/UI FULL-SITE FIX PACK
   ════════════════════════════════════════════════ */

/* ── 11. Knowledge Hub: Fix tab filter (.hidden overridden by display:flex !important) ── */
.project-card.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── 11b. Books: same treatment so the Books category tabs can actually hide cards ── */
.book-card.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── 11c. Category tab rows: keep them scrollable instead of wrapping into a wall
      of pills now that Projects / Knowledge / Books each have 7 of them ── */
.category-tabs {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .category-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        justify-content: flex-start;
        gap: 10px;
        padding: 2px 4px 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .category-tabs .tab-btn {
        white-space: nowrap;
        font-size: .85rem;
        padding: 7px 16px;
    }
}

/* ── 12. Hero: Remove glitch animation (accessibility + readability) ── */
.hero-title,
[data-theme="dark"] .hero-title {
    animation: none !important;
}

/* ── 13. Hero: Light mode correct text colours ── */
[data-theme="light"] .hero-title {
    background: linear-gradient(120deg, #ff6d00, #c0440a) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}
[data-theme="light"] .hero-subtitle,
[data-theme="light"] #home h2 {
    color: #c0440a !important;
    -webkit-text-fill-color: #c0440a !important;
}
[data-theme="light"] .hero-text,
[data-theme="light"] .hero-content p {
    color: #374151 !important;
    -webkit-text-fill-color: #374151 !important;
    text-shadow: none !important;
}
[data-theme="light"] .hero-badge {
    color: #c0440a !important;
    -webkit-text-fill-color: #c0440a !important;
    background: rgba(255, 109, 0, 0.12) !important;
}
[data-theme="light"] .hero-stat-number {
    color: #c0440a !important;
    -webkit-text-fill-color: #c0440a !important;
}
[data-theme="light"] .hero-stat-label {
    color: #4b5563 !important;
    -webkit-text-fill-color: #4b5563 !important;
}

/* ── 14. Tags: Stop infinite blink on .tag-red / NEW / HOT tags ── */
.tag-red {
    animation: none !important;
    background: rgba(255, 51, 102, 0.18) !important;
    color: #ff3366 !important;
    border: 1px solid rgba(255, 51, 102, 0.35) !important;
    border-radius: 12px !important;
    padding: 3px 10px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
}

/* ── 15. Project cards: flexible image height + fallback background ── */
.project-image {
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    min-height: 150px !important;
    max-height: 210px !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-color: rgba(10, 15, 30, 0.9) !important;
    border-radius: 10px 10px 0 0 !important;
    overflow: hidden !important;
}

/* ── 16. Chatbot: No overflow on small screens ── */
.chat-container {
    max-width: min(380px, calc(100vw - 1.5rem)) !important;
    width: min(380px, calc(100vw - 1.5rem)) !important;
    right: 0.75rem !important;
}

/* ── 17. About: Skill bars — trigger animation when section is visible ── */
.spa-section.spa-visible .skill-fill,
.spa-section.spa-active .skill-fill {
    animation-play-state: running !important;
    animation-name: fillSkill !important;
    animation-duration: 1.5s !important;
    animation-timing-function: ease-out !important;
    animation-fill-mode: forwards !important;
    animation-delay: 0.3s !important;
}

/* ── 18. Mobile nav: hamburger always visible at ≤900px, navbar row layout ── */
@media (max-width: 900px) {
    .hamburger {
        display: flex !important;
    }
    .nav-links {
        display: none !important;
    }
    .navbar {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 1rem !important;
        height: 65px !important;
    }
    .nav-actions {
        margin-left: auto !important;
        margin-top: 0 !important;
    }
}

/* ── 19. Courses: CTA button styled like primary button ── */
#courses .project-btn {
    background: linear-gradient(135deg, #ff6d00, #f5a623) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    transition: transform 0.2s, box-shadow 0.2s !important;
    box-shadow: 0 2px 10px rgba(255,109,0,0.2) !important;
}
#courses .project-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 18px rgba(255,109,0,0.35) !important;
}
#courses .project-btn i { color: #fff !important; -webkit-text-fill-color: #fff !important; }

/* ── 20. Tech Stack: Category headers full-width + styled ── */
.tech-stack-category {
    grid-column: 1 / -1 !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    color: #f5a623 !important;
    -webkit-text-fill-color: #f5a623 !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    padding: 6px 0 4px !important;
    border-bottom: 1px solid rgba(245,166,35,0.25) !important;
    margin-top: 10px !important;
}

/* ── 21. Downloads section: needs same bg as others ── */
#downloads.spa-section.spa-active {
    background: #07071a !important;
}

/* ── 22. About section: telemetry/skills cards readable in both themes ── */
[data-theme="light"] .matrix-telemetry-card,
[data-theme="light"] .matrix-skills-card,
[data-theme="light"] .matrix-bio-card {
    background: rgba(255,255,255,0.8) !important;
    border-color: rgba(0,0,0,0.1) !important;
}
[data-theme="light"] .tel-item h4 { color: #111827 !important; -webkit-text-fill-color: #111827 !important; }
[data-theme="light"] .skill-label { color: #374151 !important; }
[data-theme="light"] .hud-val, [data-theme="light"] .bio-name { color: #111827 !important; -webkit-text-fill-color: #111827 !important; }

/* ── 23. Footer padding consistency ── */
footer {
    padding: 60px 6% 40px !important;
}

/* ── 24. Section title not centered in hero ── */
#home .section-title,
#home h1.section-title {
    text-align: left !important;
}

/* ── 25. Project tags: allow wrapping ── */
.project-tags {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin-bottom: 10px !important;
}

/* ── 26. Responsive: tablet breakpoint 768px ── */
@media (max-width: 768px) {
    .matrix-grid {
        grid-template-columns: 1fr !important;
    }
    .matrix-bio-card {
        grid-column: 1 / 2 !important;
        flex-direction: column !important;
        text-align: center !important;
        padding: 24px !important;
    }
    .bio-socials { justify-content: center !important; }
    .hero-buttons { justify-content: center !important; }
    .hero-stats { justify-content: center !important; }
    .hero-content { text-align: center !important; }
    .spa-section.spa-active:not(#home) {
        padding: var(--ss-sec-pad-top,80px) 4% var(--ss-sec-pad-bottom,60px) !important;
    }
}

/* ── 27. Skip link: visible when focused ── */
.skip-link:focus {
    top: 8px !important;
    z-index: 99999 !important;
}

/* ── 11d. "ดูเพิ่มเติม" — the grids now hold 40-70+ cards, so each section
      paints the first 12 matches and reveals the rest 12 at a time ── */
.ss-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 34px;
}

.ss-more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 26px;
    border-radius: 30px;
    cursor: pointer;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: .3px;
    color: var(--neon, #ff6d00);
    background: rgba(255, 109, 0, .07);
    border: 1px solid rgba(255, 109, 0, .38);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background .25s ease, border-color .25s ease,
                box-shadow .25s ease, transform .2s ease, color .25s ease;
}

.ss-more:hover {
    color: #05070d;
    background: linear-gradient(135deg, #ff6d00, #ffd700);
    border-color: transparent;
    box-shadow: 0 8px 26px rgba(255, 109, 0, .32);
    transform: translateY(-2px);
}

.ss-more:active { transform: translateY(0); }

.ss-more i {
    font-size: .8rem;
    transition: transform .25s ease;
}

.ss-more:hover i { transform: translateY(2px); }

/* the button hides itself when the active filter has nothing left to reveal */
.ss-more.is-off { display: none !important; }

/* collapse the wrapper too, so a fully-revealed grid keeps no dead space.
   Split from the rule above on purpose: a browser without :has() would throw
   away the whole selector list if these shared one block. */
.ss-more-wrap:has(.ss-more.is-off) { display: none !important; }

[data-theme="light"] .ss-more {
    color: #b34a00;
    background: rgba(255, 109, 0, .10);
    border-color: rgba(255, 109, 0, .45);
}

[data-theme="light"] .ss-more:hover {
    color: #fff;
    background: linear-gradient(135deg, #ff6d00, #ffab00);
}

@media (max-width: 768px) {
    .ss-more-wrap { margin-top: 26px; }
    .ss-more { padding: 10px 22px; font-size: .9rem; }
}

/* ── 11e. News list — dated headlines with a source, rendered by
      render-content.js from SITE_CONTENT.news.

      NAMING IS LOAD-BEARING: style.css carries two catch-all selectors,
      [class*="grid"] (~line 2642 / 2757) and [class*="card"] (~line 2648),
      which hijack the layout and padding of anything whose class merely
      CONTAINS those substrings. That is why every class here is
      .ss-news-* — no "grid", no "card". Do not rename them to
      .news-grid / .news-card. ── */
.ss-news-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 980px;
    margin: 0 auto;
}

.ss-news-item {
    display: flex;
    gap: 20px;
    align-items: stretch;
    padding: 16px;
    border-radius: 18px;
    text-decoration: none;
    color: inherit;
    background: rgba(13, 18, 30, .55);
    border: 1px solid rgba(255, 109, 0, .16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform .25s ease, border-color .25s ease,
                box-shadow .25s ease, background .25s ease;
}

.ss-news-item:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 109, 0, .48);
    background: rgba(20, 26, 40, .72);
    box-shadow: 0 14px 34px rgba(255, 109, 0, .16);
}

.ss-news-item.no-link { cursor: default; }
.ss-news-item.no-link:hover { transform: none; }

/* the filter tabs add .hidden — there is no generic .hidden rule anywhere
   in the stylesheets, only per-component ones, so this line is what makes
   News filtering actually do something. */
.ss-news-item.hidden { display: none !important; }

.ss-news-thumb {
    /* the covers are 800×450, so hold 16:9 and align to the top instead of
       stretching to the item height — a stretched box crops the cover's
       wordmark straight down the middle */
    flex: 0 0 208px;
    align-self: flex-start;
    aspect-ratio: 16 / 9;
    min-height: 0;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: #0a0f1a;
    border: 1px solid rgba(255, 109, 0, .14);
}

.ss-news-thumb.no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, #1a1207, #0a0f1a);
}

.ss-news-thumb.no-img i {
    font-size: 1.9rem;
    color: rgba(255, 109, 0, .55);
}

.ss-news-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ss-news-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .78rem;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}

.ss-news-meta time { color: var(--neon-2, #ffd700); font-weight: 600; }

.ss-news-src {
    padding: 2px 9px;
    border-radius: 20px;
    text-transform: none;
    letter-spacing: 0;
    font-size: .74rem;
    color: rgba(255, 255, 255, .72);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
}

.ss-news-item h3 {
    margin: 0;
    font-family: 'Space Grotesk', 'Noto Sans Thai', sans-serif;
    font-size: 1.12rem;
    line-height: 1.35;
    font-weight: 700;
    color: #fff;
}

.ss-news-item:hover h3 { color: var(--neon, #ff6d00); }

.ss-news-item p {
    margin: 0;
    font-size: .93rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, .68);
}

.ss-news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 2px;
}

.ss-news-go {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    font-size: .86rem;
    font-weight: 600;
    color: var(--neon, #ff6d00);
}

.ss-news-item:hover .ss-news-go { gap: 11px; }
.ss-news-go i { font-size: .76rem; }

[data-theme="light"] .ss-news-item {
    background: rgba(255, 255, 255, .78);
    border-color: rgba(255, 109, 0, .22);
}

[data-theme="light"] .ss-news-item:hover {
    background: #fff;
    border-color: rgba(255, 109, 0, .5);
    box-shadow: 0 14px 34px rgba(255, 109, 0, .14);
}

[data-theme="light"] .ss-news-item h3 { color: #0d1b2a; }
[data-theme="light"] .ss-news-item p { color: #40506a; }
[data-theme="light"] .ss-news-meta { color: #6b7a90; }
[data-theme="light"] .ss-news-meta time { color: #b34a00; }

[data-theme="light"] .ss-news-src {
    color: #40506a;
    background: rgba(13, 27, 42, .05);
    border-color: rgba(13, 27, 42, .12);
}

[data-theme="light"] .ss-news-thumb {
    background-color: #e9eef5;
    border-color: rgba(13, 27, 42, .1);
}

[data-theme="light"] .ss-news-go { color: #b34a00; }

@media (max-width: 768px) {
    .ss-news-item {
        flex-direction: column;
        gap: 13px;
        padding: 13px;
    }
    .ss-news-thumb {
        flex: 0 0 auto;
        align-self: stretch;
        width: 100%;
        aspect-ratio: 16 / 9;
        min-height: 0;
    }
    .ss-news-item h3 { font-size: 1.02rem; }
    .ss-news-item p { font-size: .89rem; }
}
