/* ===================================================================
   UNIFIED DUAL-THEME NEUMORPHIC PORTFOLIO — Custom Styles
   Light: porcelain/teal/clay. Dark: aubergine black/moss.
   =================================================================== */

:root, html.light {
    --bg-color: #E8E3DA;
    --surface-color: #F1EDE6;
    --surface-variant-color: #DDD7CC;
    --text-main: #1F2A2A;
    --text-variant: #65716E;
    --primary: #0F6B63;
    --secondary: #B76545;
    --primary-gradient: #0F6B63;
    --shadow-extruded: 8px 8px 16px rgba(160, 151, 137, 0.52);
    --shadow-inset: inset 6px 6px 12px rgba(160, 151, 137, 0.48);
    --shadow-active: inset 4px 4px 8px rgba(160, 151, 137, 0.55);
    --shadow-hover: 11px 11px 20px rgba(146, 138, 126, 0.6);
    --accent-glow: none;
    --border-outline: #C9C0B3;
    --sidebar-shadow: 4px 0px 12px rgba(160, 151, 137, 0.34);
    --img-brightness: 1;
    --img-contrast: 1;
}

/* Green neumorphic elements */
.neumorph-green {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.2), -6px -6px 12px rgba(255, 255, 255, 0.1);
}
.neumorph-inset-green {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: inset 4px 4px 8px rgba(0, 0, 0, 0.25), inset -4px -4px 8px rgba(255, 255, 255, 0.1);
}

html.dark {
    --bg-color: #121014;
    --surface-color: #1B171F;
    --surface-variant-color: #241f29;
    --text-main: #ECE6DD;
    --text-variant: #A49AA5;
    --primary: #9BAE63;
    --secondary: #9BAE63;
    --primary-gradient: linear-gradient(145deg, #9BAE63, #748447);
    --shadow-extruded: 8px 8px 16px #09070b;
    --shadow-inset: inset 6px 6px 12px #09070b;
    --shadow-active: inset 4px 4px 8px #09070b;
    --shadow-hover: 10px 10px 20px #08070a;
    --accent-glow: none;
    --border-outline: #342d39;
    --sidebar-shadow: 10px 0 20px #09070b;
    --img-brightness: 1;
    --img-contrast: 1;
}

html {
    scroll-behavior: smooth;
    max-width: 100%;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    max-width: 100%;
    transition: background-color 0.35s ease, color 0.35s ease;
}

body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ===== Unified Neumorphic Shadow System ===== */
.neumorph-extruded {
    background-color: var(--surface-color);
    box-shadow: var(--shadow-extruded);
    transition: background-color 0.35s ease, box-shadow 0.35s ease, transform 0.3s ease, color 0.35s ease;
}

.neumorph-inset {
    background-color: var(--surface-color);
    box-shadow: var(--shadow-inset);
    transition: background-color 0.35s ease, box-shadow 0.35s ease, color 0.35s ease;
}

.neumorph-active {
    box-shadow: var(--shadow-active) !important;
    transform: scale(0.98);
}

.primary-gradient {
    background: var(--primary-gradient);
    color: #ffffff !important;
    box-shadow: var(--accent-glow);
    transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.2s ease;
}

.accent-glow {
    box-shadow: var(--accent-glow);
}

.proof-chip {
    background-color: var(--surface-color);
    border: 1px solid var(--border-outline);
    box-shadow: var(--shadow-inset);
}

.section-rule {
    height: 1px;
    background: linear-gradient(90deg, var(--primary), transparent);
    opacity: 0.45;
}

/* ===== Sidebar Navigation Active States ===== */
.nav-item-active {
    box-shadow: var(--shadow-active);
    color: var(--primary) !important;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

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

.floating-menu-btn {
    position: fixed;
    left: 16px;
    top: 50%;
    z-index: 44;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border-outline);
    border-radius: 9999px;
    color: var(--primary);
}

.floating-menu-btn:active {
    transform: translateY(-50%) scale(0.96);
}

.floating-menu-label {
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
}

.sidebar-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    border: 1px solid var(--border-outline);
}

/* Force consistent square nav items (48x48) */
#sidebar .nav-links a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    min-height: 48px;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--text-variant);
}

#sidebar .nav-links a:hover {
    color: var(--primary);
}

#sidebar .nav-links a .material-symbols-outlined {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

/* ===== Images Fix for Light Theme ===== */
.project-img,
.profile-img {
    filter: brightness(var(--img-brightness)) contrast(var(--img-contrast));
    transition: filter 0.35s ease;
}

/* Light theme image container overlays */
html.light .project-card-bg {
    opacity: 0.5;
}

html.dark .project-card-bg {
    opacity: 0.35;
}

/* ===== Scrollbar ===== */
body::-webkit-scrollbar {
    width: 8px;
}
body::-webkit-scrollbar-track {
    background: var(--bg-color);
}
body::-webkit-scrollbar-thumb {
    background: var(--surface-variant-color);
    border-radius: 10px;
}

/* ===== Floating Buttons ===== */
.floating-btns {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 60;
}

.fab-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.3s ease;
}

.fab-btn:hover {
    transform: scale(1.12);
}

.fab-btn:active {
    transform: scale(0.95);
}

#scrollTopBtn {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#scrollTopBtn.visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* ===== AI Chat Widget ===== */
.chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.chat-widget {
    position: fixed;
    bottom: 110px;
    right: 32px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 520px;
    border-radius: 24px;
    background-color: var(--surface-color);
    box-shadow: var(--shadow-extruded), 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 110;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(30px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.35s ease, background-color 0.35s ease, box-shadow 0.35s ease;
}

.chat-widget.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--primary-gradient);
    color: #fff;
}

.chat-header h3 {
    margin: 0;
    font-family: 'Hanken Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.chat-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 22px;
    padding: 2px;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header button:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    font-family: 'Manrope', sans-serif;
    word-wrap: break-word;
}

.chat-msg.bot {
    align-self: flex-start;
    background-color: var(--surface-variant-color);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot.typing .dot-typing {
    display: inline-flex;
    gap: 4px;
}

.chat-msg.bot.typing .dot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-variant);
    animation: dotPulse 1.2s infinite ease-in-out;
}

.chat-msg.bot.typing .dot-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-msg.bot.typing .dot-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-outline);
}

.chat-input-area input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 16px;
    font-family: 'Manrope', sans-serif;
    color: var(--text-main);
    box-shadow: var(--shadow-inset);
    background-color: var(--surface-color);
}

.chat-input-area input::placeholder {
    color: var(--text-variant);
}

.chat-input-area button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.chat-input-area button:active {
    transform: scale(0.9);
}

/* ===== Project card hover improvements ===== */
.project-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.project-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

@media (max-width: 767px) {
    main {
        width: 100%;
        max-width: 100vw;
    }

    #themeToggle {
        top: 20px;
        right: 20px;
    }

    #sidebar {
        width: min(82vw, 280px);
        align-items: stretch;
        overflow-y: auto;
        max-width: 100vw;
    }

    .sidebar-close-btn {
        display: flex;
    }

    #sidebar .hidden {
        display: block !important;
    }

    #sidebar .nav-links {
        padding-left: 16px;
        padding-right: 16px;
    }

    #sidebar .nav-links a {
        justify-content: flex-start;
        min-height: 52px;
        padding: 13px 16px;
    }

    #sidebar .nav-links a span:not(.material-symbols-outlined) {
        display: block !important;
        white-space: nowrap;
    }

    #home h1 {
        font-size: clamp(42px, 13vw, 56px) !important;
        line-height: 1.05 !important;
    }

    #home .flex-row {
        flex-wrap: wrap;
    }

    #home a,
    #home button {
        max-width: 100%;
    }

    .project-card {
        border-radius: 24px !important;
        padding: 24px !important;
    }

    #projectFilters {
        justify-content: flex-start;
    }

    #projectFilters .filter-btn {
        padding-left: 16px;
        padding-right: 16px;
    }

    .floating-btns {
        right: 20px;
        bottom: 24px;
        gap: 12px;
    }

    .fab-btn {
        width: 48px;
        height: 48px;
    }

    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        max-width: 100vw;
        height: 85dvh;
        max-height: 85dvh;
        border-radius: 28px 28px 0 0;
        margin: 0;
        transform: translateY(100%);
    }

    .chat-widget.active {
        transform: translateY(0);
    }

    .chat-messages {
        max-height: none;
        flex: 1;
    }
}

/* Hide scrollbar for nav links */
.nav-links::-webkit-scrollbar {
    display: none;
}
.nav-links {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
