/* Professional B&W Global Styles */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --border-color: #e0e0e0;
    --accent-gray: #f5f5f5;
    --accent-dark: #333333;
    --border-radius: 8px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    overscroll-behavior: auto;
    /* Allow default browser behavior for safety */
    overflow-y: auto;
}

/* Mobile: Allow natural scroll behavior */
@media (max-width: 768px) {

    html,
    body {
        overscroll-behavior: auto !important;
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: flex !important;
        flex-direction: column !important;
        /* Restore flex for sticky footer, but keep scroll safely enabled */
    }
}

/* 🌊 Lenis Required CSS */
html.lenis {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}



h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Utilities */
.btn-primary {
    background-color: var(--text-color);
    color: var(--bg-color);
    border: 1px solid var(--text-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.btn-outline:hover {
    border-color: var(--text-color);
}

/* Inputs */
input.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.8rem;
}

input.form-control:focus {
    border-color: var(--text-color);
    box-shadow: none;
    outline: none;
}

/* Floating Navbar */
.floating-nav {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    box-sizing: border-box;
    /* Ensure padding doesn't add to width */
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 0.8rem 1.5rem;
    /* Reduced horizontal padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
    width: 100%;
    /* Ensure it fills container but respects box-sizing */
    box-sizing: border-box;
}

[data-theme="dark"] .nav-content {
    background: rgba(12, 12, 12, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
}

.nav-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
    text-decoration: none;
    color: var(--text-color);
}

.brand-name {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.04em;
    text-transform: uppercase;
}

.brand-tagline {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

@media (max-width: 768px) {
    .floating-nav {
        width: 95%;
        top: 10px;
    }

    .nav-content {
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    .nav-brand {
        flex-shrink: 0;
    }

    .brand-name {
        font-size: 1.2rem;
    }

    .brand-tagline {
        display: none;
    }

    /* .nav-links becomes a full-screen slide-out menu below (toggled by the
       hamburger); don't force display:none here or the menu can never open. */

    .nav-actions {
        gap: 0.3rem;
        flex-shrink: 0;
    }

    .search-trigger {
        display: none !important;
    }

    .icon-btn {
        font-size: 0.95rem;
        padding: 0.25rem;
        width: 32px;
        height: 32px;
    }

    .profile-trigger {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }

    .auth-buttons {
        gap: 0.4rem;
    }

    .auth-buttons .nav-link-custom {
        font-size: 0.85rem;
    }

    .btn-pill {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 640px) {
    .nav-content {
        padding: 0.6rem 0.8rem;
    }

    .floating-nav {
        width: 98%;
    }
}

@media (max-width: 400px) {
    .nav-content {
        padding: 0.5rem 0.6rem;
    }

    .brand-name {
        font-size: 1.1rem;
    }

    .nav-actions {
        gap: 0.2rem;
    }

    .icon-btn {
        font-size: 0.9rem;
        padding: 0.2rem;
        width: 28px;
        height: 28px;
    }

    .profile-trigger {
        width: 28px;
        height: 28px;
    }

    .btn-pill {
        padding: 0.35rem 0.8rem;
        font-size: 0.8rem;
    }

    .auth-buttons .nav-link-custom {
        font-size: 0.8rem;
    }
}

.nav-links {
    display: flex;
    gap: 3rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

/* Mobile-menu search is hidden on desktop; shown in the slide-out overlay. */
.nav-search-mobile {
    display: none;
}

.nav-link-custom {
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    opacity: 0.5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    position: relative;
    padding: 0.5rem 0;
}

.nav-link-custom:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.nav-link-custom.active {
    opacity: 1;
    color: var(--text-color);
}

.nav-link-custom::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--text-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
    border-radius: 2px;
}

.nav-link-custom.active::after {
    width: 20px;
    /* Subtle indicator */
}

.nav-link-custom:hover::after {
    width: 15px;
}

/* Nav Actions */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.4rem;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.btn-pill {
    background: var(--text-color);
    color: var(--bg-color);
    border-radius: 999px;
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.btn-pill:hover {
    opacity: 0.8;
}

/* Search */
.search-trigger {
    position: relative;
    display: flex;
    align-items: center;
}

@media (max-width: 768px) {
    .search-trigger {
        display: none;
    }
}

.floating-search {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    background: var(--bg-color);
    border-radius: 999px;
    margin-right: 0.5rem;
}

.floating-search.active {
    width: 200px;
    border: 1px solid var(--border-color);
}

.floating-search input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-color);
    outline: none;
}

/* Dropdown */
.profile-dropdown {
    position: relative;
}

.profile-trigger {
    background: var(--accent-gray);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
}

.dropdown-menu-custom {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 180px;
    padding: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.dropdown-menu-custom.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #888;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: var(--accent-gray);
}

.dropdown-item.danger {
    color: #ff4757;
}

.dropdown-item.danger:hover {
    background: rgba(255, 71, 87, 0.1);
}

.notification-dot {
    min-width: 18px;
    height: 18px;
    background: #ff4757;
    color: #fff;
    border-radius: 99px;
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid var(--bg-color);
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 5px rgba(255, 71, 87, 0.3);
}

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dropdown-item:hover {
    background-color: var(--accent-gray);
}

/* Global Minimal Footer */
.site-footer-minimal {
    width: 100%;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    /* Compact padding */
    margin-top: auto;
}

.footer-content-minimal {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    /* Global footer font size reduction */
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.footer-logo-text {
    font-size: 1.1rem;
    /* Smaller logo */
    font-weight: 800;
    color: var(--text-color);
    letter-spacing: -0.03em;
    text-transform: uppercase;
}

.footer-copyright {
    color: #888;
    font-size: 0.8rem;
    font-weight: 500;
}

.footer-center {
    display: flex;
    align-items: center;
    /* Horizontal align if space allows, or tight vertical */
    gap: 1.5rem;
}

.footer-tagline {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
    font-weight: 400;
    display: none;
    /* Hide tagline for true compactness, per "concise" request */
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: #555;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.footer-links a:hover {
    color: var(--text-color);
}

.footer-right {
    display: flex;
    gap: 1rem;
}

.footer-right a {
    color: var(--text-color);
    font-size: 1rem;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.footer-right a:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .site-footer-minimal {
        padding: 1.5rem 1rem;
        /* Even more compact on mobile */
    }

    .footer-content-minimal {
        flex-direction: column;
        gap: 1rem;
        /* Tighter gap */
        text-align: center;
    }

    .footer-left {
        flex-direction: column;
        gap: 0.3rem;
    }

    .footer-links {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .footer-center {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Scroll to Top Button */
#scrollToTop {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.2s ease;
}

#scrollToTop:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* Toast Flash Messages */
#flash-toast-container {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    max-width: 600px;
    width: 90%;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

#flash-toast-container .alert {
    pointer-events: auto;
    /* Re-enable clicks for buttons */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: none;
    backdrop-filter: blur(10px);
}

/* Fog Animation */
/* Fog Animation */
@keyframes fogVanish {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }

    100% {
        opacity: 0;
        transform: scale(1.2) translateY(-10px);
        filter: blur(20px);
    }
}

.fog-vanish {
    animation: fogVanish 1.5s ease-out forwards;
}

/* Responsive Navbar */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1002;
}

@media (max-width: 768px) {

    .floating-nav {
        width: 95%;
        top: 10px;
    }

    .nav-content {
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    /* Show the hamburger so the slide-out menu can be opened on mobile. */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        order: -1;
        /* keep it before the brand */
    }

    /* Links Container - Hidden by default on mobile */
    .nav-links {
        display: flex;
        position: fixed;
        /* Fixed full screen overlay */
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: var(--bg-color);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2rem;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: all 0.3s ease;
        z-index: 999;
        /* Below header content but above page */
        margin: 0;
    }

    /* Active State for Mobile Menu */
    .floating-nav.nav-open .nav-links {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .nav-link-custom {
        font-size: 1.5rem;
        /* Larger text for mobile menu */
    }

    /* Search field inside the mobile slide-out menu */
    .nav-search-mobile {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 80%;
        max-width: 340px;
        padding: 0.7rem 1rem;
        border: 1px solid rgba(128, 128, 128, 0.3);
        border-radius: 999px;
        background: rgba(128, 128, 128, 0.08);
    }

    .nav-search-mobile form {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    .nav-search-mobile i {
        font-size: 1.1rem;
        opacity: 0.6;
    }

    .nav-search-mobile input {
        flex: 1;
        border: none;
        background: transparent;
        outline: none;
        font-size: 1.05rem;
        color: var(--text-color);
    }

    .nav-brand {
        z-index: 1002;
        /* Keep brand above menu */
    }

    .nav-actions {
        z-index: 1002;
        /* Keep actions above menu */
        margin-left: auto;
    }

    .search-trigger input {
        width: 120px;
    }
}
/* ===================================================================
   UI primitives for app.js behaviors
   (toasts, reading progress, copy buttons, share)
   =================================================================== */

/* 🔔 Toasts */
.app-toast-wrap {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}
.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
    border-left: 4px solid #6366f1;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: default;
    opacity: 0;
    transform: translateX(120%);
    transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.32s;
}
.app-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.app-toast__icon {
    font-size: 1.05rem;
    flex-shrink: 0;
}
.app-toast__msg {
    flex: 1;
    min-width: 0;
}
.app-toast__action {
    flex-shrink: 0;
    border: none;
    background: #6366f1;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
}
.app-toast__action:hover { background: #4f46e5; }
.app-toast--success { border-left-color: #22c55e; }
.app-toast--success .app-toast__icon { color: #22c55e; }
.app-toast--error { border-left-color: #ef4444; }
.app-toast--error .app-toast__icon { color: #ef4444; }
.app-toast--warn { border-left-color: #f59e0b; }
.app-toast--warn .app-toast__icon { color: #f59e0b; }
.app-toast--info .app-toast__icon { color: #6366f1; }

/* 📊 Reading progress bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 100001;
    background: linear-gradient(90deg, #6366f1, #ec4899);
    border-radius: 0 2px 2px 0;
    transition: width 0.08s linear;
    pointer-events: none;
}

/* 📋 Code-block copy button */
.blog-content pre, article pre, .ql-editor pre { position: relative; }
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #e5e7eb;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}
.blog-content pre:hover .code-copy-btn,
article pre:hover .code-copy-btn,
.ql-editor pre:hover .code-copy-btn,
.code-copy-btn:focus { opacity: 1; }
.code-copy-btn:hover { background: rgba(255, 255, 255, 0.25); }
.code-copy-btn.copied { background: #22c55e; color: #fff; opacity: 1; }

/* Generic copy/share button feedback */
.copy-btn.copied { color: #22c55e; }

@media (prefers-reduced-motion: reduce) {
    .app-toast { transition: opacity 0.2s; transform: none; }
    .reading-progress { transition: none; }
}
