/* ================================================================
   SPACE-NAVIGATION.CSS -> NOSTALGIC NEUMORPHIC HOME HUB & GRID
   Warm Memory Canvas (#ded0bf) | Sunset Amber Accents | Vintage Touch
   ================================================================ */

body.is-navigating,
body.is-navigating * {
    pointer-events: none !important;
}

body.space-nav-home-visible,
body:not([data-space-view]),
body[data-space-view="home"] {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    background-color: var(--canvas-bg);
}

body.space-nav-home-visible .spa-shell,
body:not([data-space-view]) .spa-shell,
body[data-space-view="home"] .spa-shell {
    width: 100%;
    max-width: 930px;
    margin: auto;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Home View Container ---------- */
.space-home {
    position: relative;
    width: 100%;
    background: var(--canvas-bg) !important;
    border-radius: var(--radius-xl);
    box-shadow: var(--neu-extruded) !important;
    padding: 28px 24px 30px;
    overflow: hidden;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
}

/* ---------- Header & Branding ---------- */
.neu-hub-header,
.space-home__header {
    position: relative;
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.avatar-ring,
.neu-brand-badge {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--canvas-bg);
    padding: 5px;
    box-shadow: var(--neu-extruded);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.avatar-ring:hover,
.neu-brand-badge:hover {
    transform: scale(1.03) translateY(-2px);
    box-shadow: var(--neu-extruded-hover);
}

.avatar-ring img,
.avatar-img {
    position: absolute;
    inset: 5px;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    border-radius: 50%;
    object-fit: cover;
    display: block;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.15);
    will-change: opacity, transform;
}

.avatar-img--1 {
    animation: avatarCycle1 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.avatar-img--2 {
    animation: avatarCycle2 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.avatar-img--3 {
    animation: avatarCycle3 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.avatar-img--4 {
    animation: avatarCycle4 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes avatarCycle1 {
    0%, 21% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }
    25%, 96% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }
}

@keyframes avatarCycle2 {
    0%, 21% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
    25%, 46% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }
    50%, 100% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
}

@keyframes avatarCycle3 {
    0%, 46% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
    50%, 71% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }
    75%, 100% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
}

@keyframes avatarCycle4 {
    0%, 71% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
    75%, 96% {
        opacity: 1;
        visibility: visible;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        visibility: hidden;
        transform: scale(1.02);
    }
}

.neu-hub-title,
.space-home__eyebrow {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    text-transform: none;
    border: none;
    background: none;
    box-shadow: none;
    padding: 0;
}

.neu-hub-title-btn {
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    letter-spacing: inherit;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-block;
    transition: opacity 0.18s ease, transform 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.neu-hub-title-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.neu-hub-title-btn:active {
    transform: translateY(0);
    opacity: 0.7;
}

.neu-hub-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: none;
    white-space: nowrap;
    line-height: 1.45;
}

.neu-hub-subtitle-link,
a.neu-hub-subtitle {
    display: inline-block;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.neu-hub-subtitle-link:hover,
a.neu-hub-subtitle:hover {
    color: var(--text-primary);
    opacity: 0.9;
    transform: translateY(-1px);
}

.neu-hub-subtitle-link:active,
a.neu-hub-subtitle:active {
    transform: translateY(0);
}

/* ---------- Neumorphic Category Card Grid ---------- */
.space-navigation,
.space-navigation__stage {
    position: relative;
    width: 100%;
    height: auto;
    min-height: unset;
}

.space-navigation {
    background: transparent;
    border-radius: 0;
}

.space-navigation::after {
    display: none;
}

.space-navigation__nodes {
    display: none;
}

/* Main Hub Grid - 15-Column Precision Layout (3 Cards Top / 5 Cards Bottom) */
.neu-grid,
.space-navigation__fallback-grid {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.space-navigation__fallback {
    display: block;
    width: 100%;
}

.space-navigation__fallback-title {
    display: none;
}

/* Top 3 Primary Category Cards (Span 5 columns each: 3 * 5 = 15 cols) */
.neu-card-item:nth-child(1),
.neu-card-item:nth-child(2),
.neu-card-item:nth-child(3),
.space-navigation__fallback-btn:nth-child(1),
.space-navigation__fallback-btn:nth-child(2),
.space-navigation__fallback-btn:nth-child(3) {
    grid-column: span 5;
    min-height: 126px;
    padding: 18px 14px;
}

/* Bottom 5 Specialized Memory Cards (Span 3 columns each: 5 * 3 = 15 cols) */
.neu-card-item:nth-child(4),
.neu-card-item:nth-child(5),
.neu-card-item:nth-child(6),
.neu-card-item:nth-child(7),
.neu-card-item:nth-child(8),
.space-navigation__fallback-btn:nth-child(4),
.space-navigation__fallback-btn:nth-child(5),
.space-navigation__fallback-btn:nth-child(6),
.space-navigation__fallback-btn:nth-child(7),
.space-navigation__fallback-btn:nth-child(8) {
    grid-column: span 3;
    min-height: 114px;
    padding: 14px 10px;
}

/* Individual Neumorphic Card Base Item - Centered Layout */
.neu-card-item,
.space-navigation__fallback-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--canvas-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--neu-extruded-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
    user-select: none;
    overflow: hidden;
}

.neu-card-item:hover,
.space-navigation__fallback-btn:hover {
    box-shadow: var(--neu-extruded-hover);
    transform: translateY(-3px);
}

.neu-card-item:active,
.space-navigation__fallback-btn:active {
    box-shadow: var(--neu-inset);
    transform: translateY(0);
}

/* Card Icon Box - Symmetrically Centered */
.neu-card-icon {
    border-radius: 50%;
    background: var(--canvas-bg);
    box-shadow: 3px 3px 7px rgba(135, 110, 88, 0.42),
               -3px -3px 7px rgba(255, 252, 245, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-amber);
    margin-left: auto;
    margin-right: auto;
    transition: var(--transition-smooth);
}

.neu-card-item:nth-child(-n+3) .neu-card-icon,
.space-navigation__fallback-btn:nth-child(-n+3) .neu-card-icon {
    width: 42px;
    height: 42px;
    font-size: 17px;
    margin-bottom: 10px;
}

.neu-card-item:nth-child(n+4) .neu-card-icon,
.space-navigation__fallback-btn:nth-child(n+4) .neu-card-icon {
    width: 36px;
    height: 36px;
    font-size: 14.5px;
    margin-bottom: 7px;
}

.neu-card-item:hover .neu-card-icon,
.space-navigation__fallback-btn:hover .neu-card-icon {
    transform: scale(1.08);
}

/* Curated Warm Nostalgic Memory Palette Card Icons */
.neu-card-item[data-space-action="family"] .neu-card-icon { color: var(--accent-family); }
.neu-card-item[data-space-action="thoughts"] .neu-card-icon { color: var(--accent-thoughts); }
.neu-card-item[data-space-action="keepsakes"] .neu-card-icon { color: var(--accent-keepsakes); }
.neu-card-item[data-space-action="friends"] .neu-card-icon { color: var(--accent-friends); }
.neu-card-item[data-space-action="campus"] .neu-card-icon { color: var(--accent-campus); }
.neu-card-item[data-space-action="cooking"] .neu-card-icon { color: var(--accent-cooking); }
.neu-card-item[data-space-action="upload"] .neu-card-icon { color: var(--accent-upload); }
.neu-card-item[data-space-action="feedback"] .neu-card-icon { color: var(--accent-feedback); }



/* Card Content Typography - Centered */
.neu-card-content {
    width: 100%;
    text-align: center;
}

.neu-card-title {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    text-align: center;
}

.neu-card-item:nth-child(-n+3) .neu-card-title,
.space-navigation__fallback-btn:nth-child(-n+3) .neu-card-title {
    font-size: 15px;
    margin-bottom: 3px;
}

.neu-card-item:nth-child(n+4) .neu-card-title,
.space-navigation__fallback-btn:nth-child(n+4) .neu-card-title {
    font-size: 13.5px;
    margin-bottom: 2px;
}

.neu-card-desc {
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
}

.neu-card-item:nth-child(-n+3) .neu-card-desc,
.space-navigation__fallback-btn:nth-child(-n+3) .neu-card-desc {
    font-size: 12px;
    line-height: 1.35;
}

.neu-card-item:nth-child(n+4) .neu-card-desc,
.space-navigation__fallback-btn:nth-child(n+4) .neu-card-desc {
    font-size: 11px;
    line-height: 1.3;
}

/* ---------- Neumorphic Bottom Quick Dock ---------- */
.space-quick-dock {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    margin: 22px auto 0;
    width: fit-content;
    max-width: 100%;
    border-radius: var(--radius-full);
    background: var(--canvas-bg);
    box-shadow: var(--neu-inset);
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.space-quick-dock::-webkit-scrollbar {
    display: none;
}

.space-dock-track {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.space-dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--canvas-bg);
    color: var(--text-secondary);
    font-size: 14px;
    box-shadow: var(--neu-extruded-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    opacity: 1 !important;
}

.space-dock-btn:hover {
    color: var(--accent-amber);
    box-shadow: var(--neu-extruded-hover);
    transform: translateY(-2px);
}

.space-dock-btn:active {
    box-shadow: var(--neu-inset);
    transform: translateY(0);
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 900px) and (min-width: 601px) {
    body.space-nav-home-visible .spa-shell,
    body:not([data-space-view]) .spa-shell,
    body[data-space-view="home"] .spa-shell {
        max-width: 620px;
    }

    .space-home {
        padding: 24px 18px 26px;
    }

    .neu-grid,
    .space-navigation__fallback-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
    }

    /* Row 1: 3 cards (Gia đình, Lăng kính, Tạm lưu tạm giữ) */
    .neu-card-item:nth-child(1),
    .neu-card-item:nth-child(2),
    .neu-card-item:nth-child(3),
    .space-navigation__fallback-btn:nth-child(1),
    .space-navigation__fallback-btn:nth-child(2),
    .space-navigation__fallback-btn:nth-child(3) {
        grid-column: span 2;
        min-height: 114px;
        padding: 16px 12px;
    }

    /* Row 2: 3 cards (Cốt, Sinh viên, Cơm sinh viên) */
    .neu-card-item:nth-child(4),
    .neu-card-item:nth-child(5),
    .neu-card-item:nth-child(6),
    .space-navigation__fallback-btn:nth-child(4),
    .space-navigation__fallback-btn:nth-child(5),
    .space-navigation__fallback-btn:nth-child(6) {
        grid-column: span 2;
        min-height: 106px;
        padding: 14px 10px;
    }

    /* Row 3: 2 cards (Đóng góp ký ức, Feedback) */
    .neu-card-item:nth-child(7),
    .neu-card-item:nth-child(8),
    .space-navigation__fallback-btn:nth-child(7),
    .space-navigation__fallback-btn:nth-child(8) {
        grid-column: span 3;
        min-height: 106px;
        padding: 14px 12px;
    }
}

@media (max-width: 600px) {
    body.space-nav-home-visible,
    body:not([data-space-view]),
    body[data-space-view="home"] {
        padding: 12px 8px;
        min-height: 100dvh;
    }

    body.space-nav-home-visible .spa-shell,
    body:not([data-space-view]) .spa-shell,
    body[data-space-view="home"] .spa-shell {
        width: 100%;
        max-width: 100%;
        margin: auto 0;
    }

    .space-home {
        padding: 18px 12px 16px;
        border-radius: var(--radius-lg);
        box-shadow: 8px 8px 18px rgba(135, 110, 88, 0.45),
                   -8px -8px 18px rgba(255, 252, 245, 0.95) !important;
    }

    .neu-hub-header {
        margin-bottom: 12px;
    }

    .avatar-ring,
    .neu-brand-badge {
        width: 106px;
        height: 106px;
        margin: 0 auto 8px;
        padding: 6px;
    }

    .avatar-ring img,
    .avatar-img {
        inset: 6px;
        width: calc(100% - 12px);
        height: calc(100% - 12px);
    }

    .neu-hub-title {
        font-size: 19px;
        margin-bottom: 2px;
    }

    .neu-hub-subtitle {
        font-size: 11.5px;
        line-height: 1.35;
        max-width: 280px;
    }

    .neu-grid,
    .space-navigation__fallback-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-top: 6px;
    }

    .neu-card-item,
    .space-navigation__fallback-btn,
    .neu-card-item:nth-child(n),
    .space-navigation__fallback-btn:nth-child(n) {
        grid-column: span 1 !important;
        padding: 12px 6px;
        min-height: 94px;
        border-radius: 14px;
        align-items: center;
        text-align: center;
        justify-content: center;
        box-shadow: 4px 4px 9px rgba(135, 110, 88, 0.40),
                   -4px -4px 9px rgba(255, 252, 245, 0.92);
    }

    .neu-card-icon,
    .neu-card-item:nth-child(n) .neu-card-icon,
    .space-navigation__fallback-btn:nth-child(n) .neu-card-icon {
        width: 32px;
        height: 32px;
        font-size: 13px;
        margin: 0 auto 5px;
        box-shadow: 2px 2px 5px rgba(135, 110, 88, 0.38),
                   -2px -2px 5px rgba(255, 252, 245, 0.90);
    }

    .neu-card-title,
    .neu-card-item:nth-child(n) .neu-card-title,
    .space-navigation__fallback-btn:nth-child(n) .neu-card-title {
        font-size: 12.5px;
        font-weight: 700;
        margin-bottom: 1px;
        line-height: 1.25;
        text-align: center;
    }

    .neu-card-desc,
    .neu-card-item:nth-child(n) .neu-card-desc,
    .space-navigation__fallback-btn:nth-child(n) .neu-card-desc {
        font-size: 10px;
        line-height: 1.25;
        text-align: center;
    }

    .space-quick-dock {
        padding: 5px 8px;
        margin: 14px auto 0;
        box-shadow: inset 3px 3px 6px rgba(120, 95, 75, 0.45),
                    inset -3px -3px 6px rgba(255, 252, 245, 0.9);
        max-width: calc(100vw - 24px);
    }

    .space-dock-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        flex-shrink: 0;
        aspect-ratio: 1 / 1;
        font-size: 13px;
        box-shadow: 3px 3px 6px rgba(135, 110, 88, 0.4),
                   -3px -3px 6px rgba(255, 252, 245, 0.9);
        opacity: 1 !important;
    }

    .space-dock-track {
        gap: 6px;
    }
}

@media (max-width: 360px) {
    .space-home {
        padding: 14px 8px 12px;
    }

    .neu-grid,
    .space-navigation__fallback-grid {
        gap: 6px;
    }

    .neu-card-item,
    .space-navigation__fallback-btn {
        padding: 10px 4px;
        min-height: 86px;
    }

    .neu-card-title {
        font-size: 11.5px;
    }

    .neu-card-desc {
        font-size: 9px;
    }

    .avatar-ring,
    .neu-brand-badge {
        width: 96px;
        height: 96px;
    }

    .space-dock-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        flex-shrink: 0;
        aspect-ratio: 1 / 1;
        font-size: 11.5px;
    }

    .space-dock-track {
        gap: 4px;
    }
}

