/* ux-enhancements.css — site-wide interaction layer: page transitions,
   command palette, lightbox, toasts, back-to-top, mobile nav. Loaded
   after main.css/dark-mode.css so it reads the shared design tokens
   (--primary-color, --ease, --radius-*, --shadow-*, etc.) rather than
   redefining its own palette. */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------
   Page-enter transition — pure CSS, no JS dependency.
--------------------------------------------------------------- */
main {
    animation: pageFadeIn 0.45s var(--ease, ease) both;
}

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

@media (prefers-reduced-motion: reduce) {
    main { animation: none; }
}

/* ---------------------------------------------------------------
   Scroll progress bar (site-wide; blog_post.html has its own
   content-scoped reading bar and the JS skips this one there).
--------------------------------------------------------------- */
.ux-scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--primary-color, #2954d6);
    z-index: 1100;
    transition: width 0.1s linear;
}

/* ---------------------------------------------------------------
   Back to top button — quiet, solid, small.
--------------------------------------------------------------- */
.ux-back-to-top {
    position: fixed;
    left: 1.5rem;
    bottom: 1.5rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-elevated, #fff);
    color: var(--primary-color, #2954d6);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    box-shadow: var(--shadow-md, 0 10px 24px rgba(0, 0, 0, 0.1));
    cursor: pointer;
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s var(--ease, ease), transform 0.25s var(--ease, ease), visibility 0.25s, border-color 0.2s ease;
}

.ux-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ux-back-to-top:hover {
    border-color: var(--primary-color, #2954d6);
    transform: translateY(-2px);
}

/* ---------------------------------------------------------------
   Command palette (Ctrl/Cmd+K quick navigation)
--------------------------------------------------------------- */
.ux-cmdk-trigger {
    display: none;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    color: var(--text-secondary, #5b5f6a);
    background: transparent;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    border-radius: var(--radius-sm, 6px);
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.ux-cmdk-trigger:hover {
    border-color: var(--primary-color, #2954d6);
    color: var(--primary-color, #2954d6);
}

.ux-cmdk-trigger kbd {
    font-family: inherit;
    background: var(--bg-subtle, rgba(0, 0, 0, 0.05));
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.72rem;
}

@media (min-width: 992px) {
    .ux-cmdk-trigger { display: inline-flex; }
}

.ux-cmdk-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 14, 17, 0.55);
    z-index: 1200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 1rem 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.ux-cmdk-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.ux-cmdk-panel {
    width: 100%;
    max-width: 540px;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-lg, 0 24px 56px rgba(0, 0, 0, 0.15));
    overflow: hidden;
    transform: translateY(-10px);
    transition: transform 0.2s var(--ease, ease);
    color: var(--text-primary, #17181c);
}

.ux-cmdk-backdrop.is-open .ux-cmdk-panel {
    transform: translateY(0);
}

.ux-cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

.ux-cmdk-input-wrap i {
    color: var(--text-tertiary, #8a8f99);
}

.ux-cmdk-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    color: inherit;
}

.ux-cmdk-input::placeholder {
    color: var(--text-tertiary, #8a8f99);
}

.ux-cmdk-results {
    max-height: 55vh;
    overflow-y: auto;
    padding: 0.4rem;
}

.ux-cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    font-size: 0.925rem;
}

.ux-cmdk-item i {
    width: 18px;
    text-align: center;
    color: var(--text-tertiary, #8a8f99);
    font-size: 0.85rem;
}

.ux-cmdk-item.is-active,
.ux-cmdk-item:hover {
    background: var(--bg-subtle, rgba(0, 0, 0, 0.04));
}

.ux-cmdk-item.is-active i,
.ux-cmdk-item:hover i {
    color: var(--primary-color, #2954d6);
}

.ux-cmdk-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-tertiary, #8a8f99);
    font-size: 0.875rem;
}

.ux-cmdk-hint {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 1.15rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    color: var(--text-tertiary, #8a8f99);
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

/* ---------------------------------------------------------------
   Global toast notifications — neutral surface with a colored left
   border + icon accent, not a saturated fill block.
--------------------------------------------------------------- */
.ux-toast-container {
    z-index: 1180;
}

.ux-toast {
    min-width: 280px;
    max-width: 360px;
    border-radius: var(--radius-md, 10px);
    background: var(--bg-elevated, #fff);
    color: var(--text-primary, #17181c);
    box-shadow: var(--shadow-lg, 0 24px 56px rgba(0, 0, 0, 0.15));
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    border-left: 3px solid var(--primary-color, #2954d6);
}

.ux-toast .btn-close {
    filter: none;
}

body.dark-mode .ux-toast .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.ux-toast-success { border-left-color: var(--success-color, #158a4a); }
.ux-toast-danger { border-left-color: var(--danger-color, #c0332b); }
.ux-toast-warning { border-left-color: var(--warning-color, #b3670c); }
.ux-toast-info { border-left-color: var(--primary-color, #2954d6); }

/* ---------------------------------------------------------------
   Lightbox
--------------------------------------------------------------- */
.ux-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 7, 0.94);
    z-index: 1250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.ux-lightbox-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.ux-lightbox-backdrop img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.97);
    transition: transform 0.2s var(--ease, ease);
}

.ux-lightbox-backdrop.is-open img {
    transform: scale(1);
}

.ux-lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ux-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.rich-content img,
.blog-content img,
.ux-lightbox-trigger {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.rich-content img:hover,
.blog-content img:hover,
.ux-lightbox-trigger:hover {
    opacity: 0.9;
}

/* ---------------------------------------------------------------
   Mobile nav — solid elevated surface (no blur), hairline border,
   a quiet staggered entrance for each link.
--------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .navbar-collapse {
        margin-top: 0.75rem;
        padding: 0.5rem;
        border-radius: var(--radius-md, 10px);
        background: var(--bg-elevated, #fff);
        box-shadow: var(--shadow-lg, 0 24px 56px rgba(0, 0, 0, 0.15));
        border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    }

    .navbar-collapse .nav-item {
        opacity: 0;
        transform: translateY(-6px);
    }

    .navbar-collapse.show .nav-item {
        animation: navItemIn 0.3s var(--ease, ease) forwards;
    }

    .navbar-collapse.show .nav-item:nth-child(1) { animation-delay: 0.02s; }
    .navbar-collapse.show .nav-item:nth-child(2) { animation-delay: 0.05s; }
    .navbar-collapse.show .nav-item:nth-child(3) { animation-delay: 0.08s; }
    .navbar-collapse.show .nav-item:nth-child(4) { animation-delay: 0.11s; }
    .navbar-collapse.show .nav-item:nth-child(5) { animation-delay: 0.14s; }
    .navbar-collapse.show .nav-item:nth-child(6) { animation-delay: 0.17s; }
    .navbar-collapse.show .nav-item:nth-child(7) { animation-delay: 0.2s; }
    .navbar-collapse.show .nav-item:nth-child(8) { animation-delay: 0.23s; }

    @keyframes navItemIn {
        to { opacity: 1; transform: translateY(0); }
    }

    .navbar-nav .nav-link {
        border-radius: var(--radius-sm, 6px);
        padding: 0.7rem 0.85rem !important;
        display: flex;
        align-items: center;
        gap: 0.65rem;
    }

    .navbar-nav .nav-link i.ux-nav-icon {
        display: inline-flex;
        width: 18px;
        font-size: 0.85rem;
        color: var(--text-tertiary, #8a8f99);
    }

    .navbar-nav .nav-link.active i.ux-nav-icon,
    .navbar-nav .nav-link:hover i.ux-nav-icon {
        color: var(--primary-color, #2954d6);
    }

    .navbar-nav .nav-link.active,
    .navbar-nav .nav-link:hover {
        background: var(--bg-subtle, rgba(0, 0, 0, 0.04));
    }

    .navbar .nav-link::after {
        display: none;
    }
}

@media (min-width: 992px) {
    .ux-nav-icon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .navbar-collapse.show .nav-item { animation: none; opacity: 1; transform: none; }
}
