/* =========================================
   Universal Navigation Bar (Glassmorphism)
   ========================================= */

.glass-nav {
    width: 100%;
    max-width: var(--nav-max-width);
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;

    /* Absolute Positioning to overlap without pushing content */
    position: absolute;
    top: 6rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 3rem);

    /* Glassmorphism Effect */
    background-image: linear-gradient(144.46deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    backdrop-filter: blur(21px);
    -webkit-backdrop-filter: blur(21px);

    /* Borders / Shape */
    border-radius: 16px;
    border: 1px solid #151515;

    /* Transitions */
    transition: all 0.75s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
    z-index: 9999;
}

/* Cursor-following glow spotlight */
.glass-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: radial-gradient(
        circle 90px at var(--glow-x, -200px) var(--glow-y, -200px),
        rgba(255, 255, 255, 0.24),
        transparent 90%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}

@media (hover: hover) {
    .glass-nav:hover::before {
        opacity: 1;
    }
}

/* Keep nav content above the glow layer */
.nav-top-row,
.nav-dropdown {
    position: relative;
    z-index: 1;
}

body.dark .glass-nav {
    background-image: linear-gradient(144.46deg, rgba(30, 41, 59, 0.6) 0%, rgba(30, 41, 59, 0.2) 100%);
    border: 1px solid var(--border);
}

.nav-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-dropdown {
    width: 100%;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.75s cubic-bezier(0.25, 1, 0.5, 1),
        opacity 0.75s cubic-bezier(0.25, 1, 0.5, 1),
        margin 0.75s cubic-bezier(0.25, 1, 0.5, 1),
        padding 0.75s cubic-bezier(0.25, 1, 0.5, 1);
}

.glass-nav.expanded .nav-dropdown {
    max-height: 400px;
    opacity: 1;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    padding-bottom: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark .glass-nav.expanded .nav-dropdown {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Navigation - Brand */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-logo {
    width: 2.5rem;
    height: 2.5rem;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease, width 0.35s cubic-bezier(0.25, 1, 0.5, 1), margin 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
    line-height: 1;
    letter-spacing: -0.025em;
    transition: color 0.3s ease, letter-spacing 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

@media (hover: hover) {
    .nav-brand:hover .brand-text {
        letter-spacing: 0.4em;
    }
}

/* Navigation - Links */
.nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.nav-links li {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.75s cubic-bezier(0.25, 1, 0.5, 1);
    transition-delay: calc(var(--stagger) * 0.15s);
}

.glass-nav.expanded .nav-links li {
    opacity: 1;
    transform: translateX(0);
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1.5rem;
    /* Universal larger size */
    transition: all 0.3s ease;
    /* Smooth transition for color and weight */
}

.nav-links a.active {
    color: #ec5b13;
    font-weight: 500;
}

@media (hover: hover) {
    .nav-links a:hover {
        color: #ec5b13;
        font-weight: 500;
    }
}

.nav-links a {
    -webkit-tap-highlight-color: transparent;
}

@media (hover: none) {
    .nav-links a:active {
        color: #ec5b13;
    }
}

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

/* Icon Buttons */
.icon-btn {
    padding: 0.5rem;
    border-radius: 9999px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: var(--text-secondary);
}

@media (hover: hover) {
    .icon-btn:hover {
        color: #ec5b13;
        background-color: rgba(200, 200, 200, 0.2);
    }

    body.dark .icon-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #ec5b13;
    }
}

/* Remove sticky tap highlight on touch devices */
.icon-btn {
    -webkit-tap-highlight-color: transparent;
}

/* Brief press flash on touch (JS-driven for reliability) */
.icon-btn.tapped {
    color: #ec5b13 !important;
    background-color: rgba(200, 200, 200, 0.2) !important;
    transition: none !important;
}

body.dark .icon-btn.tapped {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.material-icons-round {
    font-size: 20px;
    vertical-align: middle;
}

@keyframes fade-in-slide-down {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }

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


/* =========================================
   Page-Specific Overrides (Examples)
   ========================================= */

/* Use these sections to change width or position on specific pages */


/* Home Page Specific */
.home-page .glass-nav {
    max-width: var(--nav-max-width);
    top: 6rem;
    /* Position from top */
    padding: 1rem 1.5rem;
    /* Height control (vertical padding) */
}

.home-page .nav-links a {
    font-size: 1.5rem;
    /* <--- EDIT THIS: Font size for Home Page links */
}

/* Toolkit Page Specific - pixel values match index.html's 14px rem base exactly */
.toolkit-page .glass-nav {
    max-width: 1008px;  /* 72rem × 14px = index match */
    top: 3rem;
    padding: 14px 21px; /* 1rem × 14px, 1.5rem × 14px = index match */
}

.toolkit-page .nav-brand {
    gap: 7px; /* 0.5rem × 14px */
}

.toolkit-page .brand-logo {
    width: 35px;
    height: 35px; /* 2.5rem × 14px */
}

.toolkit-page .brand-text {
    font-size: 16px; /* 1.125rem × 14px ≈ 15.75px */
}

.toolkit-page .nav-actions {
    gap: 14px; /* 1rem × 14px */
}

.toolkit-page .icon-btn {
    padding: 7px; /* 0.5rem × 14px */
}

.toolkit-page .nav-links a {
    font-size: 21px; /* 1.5rem × 14px = index match */
}

/* =========================================
   Responsive Adjustments
   ========================================= */
@media (max-width: 640px) {
    .glass-nav {
        margin-top: 4.5rem;
        padding: 0.75rem 1rem;
        width: calc(100% - 3rem);
        max-width: none;
        top: 1rem;
    }

    .brand-text {
        display: block;
        opacity: 1;
    }
}

@keyframes nameReveal {
    0%   { opacity: 0; letter-spacing: -0.025em; }
    15%  { opacity: 1; letter-spacing: -0.025em; }
    55%  { letter-spacing: 0.4em; }
    100% { opacity: 1; letter-spacing: -0.025em; }
}

@media (max-width: 768px) {
    .nav-links {
        /* This hides links in regular view but ellos will show in dropdown if expanded logic allows */
        /* Currently index.css had display:none for nav-links at 768, but we want them in dropdown */
    }
}

/* =========================================
   Mobile Touch Target & UX Improvements
   ========================================= */
@media (max-width: 640px) {
    /* Ensure minimum 44px touch targets for iOS */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.6rem;
    }

    /* Bigger tap areas for nav links in dropdown */
    .nav-links a {
        display: block;
        padding: 0.5rem 0;
        font-size: 1.75rem;
    }

    /* Increase spacing between nav links for easier tapping */
    .nav-links {
        gap: 0.5rem;
    }

    /* Slightly more generous dropdown padding */
    .glass-nav.expanded .nav-dropdown {
        padding-bottom: 1.5rem;
    }

    /* Nav positioned a bit higher on mobile */
    .glass-nav {
        top: 1rem;
    }

    /* Home page: match the override */
    .home-page .glass-nav {
        top: 1rem;
    }

    /* Name wraps cleanly at space (English) and ideographic space (Japanese) */
    .brand-text {
        white-space: normal;
        word-break: keep-all;
        max-width: 7rem;
        line-height: 1.15;
    }

    /* Tighten icon buttons so name has more breathing room */
    .nav-actions {
        gap: 0.25rem;
    }
}

@media (max-width: 400px) {
    /* Very small phones: reduce nav padding */
    .glass-nav {
        padding: 0.6rem 0.75rem;
        width: calc(100% - 3rem);
    }
}