/* Slim page-top navigation; only the logo follows the viewport on scroll. */
#navbar {
    position: absolute;
    height: 56px;
    padding: 0 clamp(24px, 2.5vw, 40px) 0 calc(clamp(24px, 2.5vw, 40px) + 64px);
    gap: 28px;
    background: transparent;
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#navbar::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: calc(100% + 54px);
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.48) 46%, rgba(0, 0, 0, 0));
}

.nav-brand { position: fixed; top: 6px; left: clamp(24px, 2.5vw, 40px); display: flex; align-items: center; text-decoration: none; color: var(--heading); }
/* The original image has wide transparent margins. Crop those margins in CSS
   so the monogram is legible without changing the asset or masthead height. */
.nav-brand-mark { position: relative; display: block; width: 44px; height: 44px; overflow: hidden; }
#navbar #site-logo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); height: 96px !important; width: 96px; max-width: none; object-fit: contain; }

.nav-menu { display: flex; align-items: center; justify-content: space-between; flex: 1; gap: 24px; min-width: 0; }
.nav-sections { display: flex; align-items: center; gap: clamp(10px, 1.4vw, 22px); margin: 0 auto; }
.nav-section-link { display: flex; position: relative; align-items: baseline; gap: 5px; padding: 12px 0; font: 500 12px/1.3 'Inter', system-ui, sans-serif; color: var(--reading-muted); text-decoration: none; white-space: nowrap; }
.nav-index { font-size: 9px; font-weight: 400; color: #89929e; }
.nav-section-link::after { content: ''; position: absolute; left: 0; right: 0; bottom: 8px; height: 1px; background: var(--reading-accent); transform: scaleX(0); transform-origin: left; transition: transform 180ms ease; }
.nav-section-link:hover, .nav-section-link[aria-current="location"] { color: var(--heading); }
.nav-section-link:hover::after, .nav-section-link[aria-current="location"]::after { transform: scaleX(1); }
.nav-section-link[aria-current="location"] .nav-index { color: var(--reading-accent); }

.nav-utilities, .nav-socials { display: flex; align-items: center; gap: 8px; }
.nav-socials { gap: 2px; padding-right: 12px; margin-right: 4px; border-right: 1px solid var(--reading-border); }
#navbar .nav-link { color: var(--reading-muted); min-width: 30px; min-height: 40px; }
#navbar .nav-link:hover { color: var(--reading-accent); }
#navbar .nav-link svg { width: 15px; height: 15px; }
.nav-resume, .nav-contact { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; padding: 10px 13px; font: 500 12px/1.3 'Inter', system-ui, sans-serif; text-decoration: none; white-space: nowrap; border: 1px solid var(--reading-border); border-radius: 2px; color: var(--heading); background: var(--surface); }
.nav-resume:hover { border-color: var(--reading-accent); }
.nav-contact { border-color: rgba(199, 161, 92, 0.5); color: var(--reading-accent); }
.nav-contact:hover { border-color: var(--reading-accent); }

.nav-toggle { display: none; align-items: center; justify-content: center; gap: 12px; min-width: 86px; min-height: 44px; background: transparent; border: 1px solid var(--reading-border); border-radius: 2px; color: var(--heading); font: 500 13px/1 'Inter', system-ui, sans-serif; cursor: pointer; }
.nav-toggle-mark { position: relative; width: 15px; height: 12px; }
.nav-toggle-mark span { position: absolute; left: 0; right: 0; top: 3px; height: 1px; background: currentColor; transition: transform 180ms ease; }
.nav-toggle-mark span + span { top: 9px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-mark span { transform: translateY(3px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-mark span + span { transform: translateY(-3px) rotate(-45deg); }

@media (max-width: 1200px) and (min-width: 1101px) {
    #navbar { gap: 16px; padding: 0 20px 0 84px; }
    .nav-brand { left: 20px; }
    .nav-menu { gap: 16px; }
    .nav-sections { gap: 10px; }
    .nav-section-link { font-size: 11px; }
    .nav-index { display: none; }
    .nav-socials { padding-right: 6px; }
}

@media (max-width: 1100px) {
    /* Without JS the links stay visible and wrap, so navigation still works. */
    #navbar { height: auto; min-height: 56px; flex-wrap: wrap; gap: 12px; padding: 8px 20px 8px 84px; }
    .nav-brand { left: 20px; }
    .nav-menu { flex-basis: 100%; flex-wrap: wrap; gap: 16px; }
    .nav-sections { flex-wrap: wrap; margin: 0; gap: 18px; }
    .nav-utilities { flex-wrap: wrap; }
    .nav-enhanced #navbar { height: 56px; padding: 0 20px; flex-wrap: nowrap; justify-content: flex-end; }
    .nav-enhanced .nav-toggle:not([hidden]) { display: inline-flex; }
    .nav-enhanced #nav-menu { display: none; position: absolute; top: calc(100% + 8px); left: 16px; right: 16px; padding: 24px; background: var(--surface); border: 1px solid var(--reading-border); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3); max-height: calc(100dvh - 88px); overflow-y: auto; }
    .nav-enhanced #navbar[data-menu-open="true"] #nav-menu { display: flex; flex-direction: column; align-items: stretch; }
    .nav-enhanced .nav-sections { flex-direction: column; align-items: stretch; gap: 0; }
    .nav-enhanced .nav-section-link { font-size: 17px; padding: 14px 0; gap: 12px; border-bottom: 1px solid var(--reading-border); }
    .nav-enhanced .nav-index { font-size: 10px; }
    .nav-enhanced .nav-section-link::after { display: none; }
    .nav-enhanced .nav-section-link[aria-current="location"] { color: var(--reading-accent); }
    .nav-enhanced .nav-utilities { gap: 10px; padding-top: 22px; }
    #navbar .nav-link { min-width: 40px; min-height: 44px; }
    .nav-socials { border: 0; flex-basis: 100%; padding: 0; margin: 0 0 8px; }
    .nav-resume, .nav-contact { min-height: 44px; padding: 12px 16px; font-size: 13px; }
}

@media (max-width: 480px) {
    .nav-brand { left: 16px; }
    .nav-enhanced #navbar { padding: 0 16px; }
    .nav-enhanced #nav-menu { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .nav-section-link::after, .nav-toggle-mark span { transition: none; }
}
