/* Navigation Styles (Ticket-910) */

:root {
    --vf-header-ink: rgba(17, 17, 17, 0.92);
    --vf-header-ink-muted: rgba(17, 17, 17, 0.74);
    --vf-header-accent: var(--covenant-accent, #7a1e2c);
    --vf-header-surface: rgba(255, 255, 255, 0.88);
    --vf-header-surface-hover: rgba(255, 255, 255, 0.96);
    --vf-header-surface-strong: rgba(255, 255, 255, 0.98);
    --vf-header-border: rgba(42, 42, 42, 0.16);
    --vf-header-shadow: 0 10px 24px rgba(17, 17, 17, 0.08);
    --vf-header-focus-shadow: 0 0 0 3px rgba(122, 30, 44, 0.14);
    --vf-header-panel-bg: var(--vf-header-surface-strong);
    --vf-header-panel-text: rgba(17, 17, 17, 0.96);
    --vf-header-panel-selected-bg: rgba(246, 239, 226, 0.96);
    --vf-header-panel-selected-text: rgba(17, 17, 17, 0.96);
    --vf-header-panel-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
    --vf-header-menu-bg: var(--vf-header-panel-bg);
    --vf-header-menu-text: var(--vf-header-panel-text);
    --vf-header-menu-border: var(--vf-header-border);
    --vf-header-select-bg: var(--vf-header-surface);
    --vf-header-select-bg-hover: var(--vf-header-surface-hover);
    --vf-header-select-border: var(--vf-header-border);
    --vf-header-select-text: var(--vf-header-ink);
    --vf-header-select-panel-bg: var(--vf-header-panel-bg);
    --vf-header-select-panel-text: var(--vf-header-panel-text);
    --vf-header-select-panel-selected-bg: var(--vf-header-panel-selected-bg);
    --vf-header-select-panel-selected-text: var(--vf-header-panel-selected-text);
    --vf-header-select-shadow: var(--vf-header-shadow);
    --vf-header-select-focus-shadow: var(--vf-header-focus-shadow);
}

.vf-header {
    background: rgba(255, 255, 255, 0.3) !important;
    /* Semi-transparent glass */
    backdrop-filter: blur(12px);
    /* Blurs the mesh behind the nav */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(42, 42, 42, 0.05);
    box-shadow: none !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: clamp(0.5rem, 1.4vw, 1.25rem);
    padding: 1rem 1.5rem;
    position: relative;
}

.vf-logo {
    margin: 0;
    flex: 0 0 auto;
}

.vf-logo a {
    text-decoration: none;
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    font-weight: 700;
}

.vf-nav {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
}

.vf-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    /* Spacing between image and text */
    text-decoration: none !important;
}

.vf-brand-text {
    font-family: var(--font-serif, serif);
    /* Matches brand typography */
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.03em;
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92)) !important;
    mix-blend-mode: normal;
    /* Reset blend mode for legibility */
    transition: color 5s ease, opacity 5s ease;
}

/* Nav Toggle (Hamburger) */
.vf-nav .vf-nav-toggle {
    display: none;
    /* Desktop default */
    background: transparent;
    /* Fix "black overlay" inherited from generic button styles */
    border: none;
    cursor: pointer;
    padding: 10px;
    position: relative;
    z-index: 200;
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
}

/* Ensure no generic button styles override this */
body.verseflow-sanctuary .vf-nav .vf-nav-toggle {
    background: transparent;
    border: none;
    display: none;
}



.vf-nav-icon {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    position: relative;
    transition: background 0s 0.3s;
}

.vf-nav-icon::before,
.vf-nav-icon::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    position: absolute;
    left: 0;
    transition-duration: 0.3s, 0.3s;
    transition-delay: 0.3s, 0s;
}

.vf-nav-icon::before {
    top: -8px;
    transition-property: top, transform;
}

.vf-nav-icon::after {
    bottom: -8px;
    transition-property: bottom, transform;
}

/* Open State Icon */
.vf-nav.is-open .vf-nav-icon {
    background: none;
}

.vf-nav.is-open .vf-nav-icon::before {
    top: 0;
    transform: rotate(45deg);
    transition-delay: 0s, 0.3s;
}

.vf-nav.is-open .vf-nav-icon::after {
    bottom: 0;
    transform: rotate(-45deg);
    transition-delay: 0s, 0.3s;
}

/* Desktop Nav */
.vf-nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
    align-items: center;
    min-width: 0;
}

.vf-nav li {
    white-space: nowrap;
}

.vf-nav a {
    text-decoration: none;
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92)) !important;
    mix-blend-mode: normal;
    /* Reset blend mode for legibility */
    font-weight: 500;
    font-size: 0.95rem;
}

.vf-nav-pref-item {
    display: flex;
    align-items: center;
}

.vf-nav-pref {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.vf-nav-pref__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--vf-header-ink-muted, rgba(17, 17, 17, 0.74));
    opacity: 0.85;
}

.vf-nav-pref__select {
    min-width: 9rem;
    padding: 0.42rem 2.1rem 0.42rem 0.7rem;
    border: 1px solid var(--vf-header-select-border);
    border-radius: 999px;
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--vf-header-select-bg);
    background-image:
        linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        calc(100% - 1rem) calc(50% - 0.12rem),
        calc(100% - 0.72rem) calc(50% - 0.12rem);
    background-repeat: no-repeat;
    background-size: 0.4rem 0.4rem, 0.4rem 0.4rem;
    box-shadow: var(--vf-header-select-shadow);
    color: var(--vf-header-select-text);
    font: inherit;
    line-height: 1.2;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

.vf-nav-pref__select:hover:not([disabled]) {
    background-color: var(--vf-header-select-bg-hover);
    border-color: var(--vf-header-accent);
}

.vf-nav-pref__select:focus-visible {
    outline: 2px solid var(--vf-header-accent);
    outline-offset: 2px;
    box-shadow: var(--vf-header-select-focus-shadow);
}

.vf-nav-pref__select[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

.vf-nav-pref__select option,
.vf-nav-pref__select optgroup {
    background-color: var(--vf-header-select-panel-bg);
    color: var(--vf-header-select-panel-text);
}

.vf-nav-pref__select option:checked,
.vf-nav-pref__select option[selected] {
    background-color: var(--vf-header-select-panel-selected-bg);
    color: var(--vf-header-select-panel-selected-text);
}

.vf-header-tools-wrap {
    position: relative;
    margin-left: clamp(0.35rem, 1vw, 0.9rem);
    flex: 0 0 auto;
}

.vf-header-tools-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--vf-header-border);
    border-radius: 999px;
    background: var(--vf-header-surface);
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    box-shadow: var(--vf-header-shadow);
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.2;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

.vf-header-tools-toggle:hover,
.vf-header-tools-toggle:focus-visible {
    background: var(--vf-header-surface-hover);
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    border-color: var(--vf-header-accent);
    box-shadow: var(--vf-header-focus-shadow);
}

.vf-header-tools-toggle:focus-visible {
    outline: 2px solid var(--vf-header-accent);
    outline-offset: 2px;
}

/*
 * Guidance routes load verseflow-sanctuary.css, which applies broad button
 * styles to every <button>. Reassert the header tools toggle contract with a
 * more specific selector so the Preferences control only appears when the
 * shared collapse state is active.
 */
body.verseflow-sanctuary .vf-header-tools-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--vf-header-border);
    border-radius: 999px;
    background: var(--vf-header-surface);
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    box-shadow: var(--vf-header-shadow);
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.2;
    text-decoration: none;
}

body.verseflow-sanctuary .vf-header-tools-toggle:hover,
body.verseflow-sanctuary .vf-header-tools-toggle:focus-visible {
    background: var(--vf-header-surface-hover);
    color: var(--vf-header-ink, rgba(17, 17, 17, 0.92));
    border-color: var(--vf-header-accent);
    box-shadow: var(--vf-header-focus-shadow);
}

.vf-header-tools-panel {
    display: block;
    color: var(--vf-header-panel-text, rgba(17, 17, 17, 0.96));
}

html:not(.vf-header-tools-collapsible) .vf-header-tools-panel[hidden] {
    display: block;
}

.vf-header-tools {
    display: flex;
    align-items: flex-end;
    gap: clamp(0.5rem, 0.9vw, 0.85rem);
    color: var(--vf-header-panel-text, rgba(17, 17, 17, 0.96));
}

@media (max-width: 1500px) {
    .vf-nav ul {
        gap: clamp(0.7rem, 1.2vw, 1rem);
    }

    .vf-nav a {
        font-size: 0.92rem;
    }

    .vf-header-tools .vf-nav-pref__select {
        min-width: 8rem;
    }
}

html.vf-header-tools-collapsible .vf-header-tools-toggle {
    display: inline-flex;
}

html.vf-header-tools-collapsible body.verseflow-sanctuary .vf-header-tools-toggle {
    display: inline-flex;
}

html.vf-header-tools-collapsible .vf-header-tools-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: min(24rem, calc(100vw - 2rem));
    max-height: min(70vh, 32rem);
    overflow-y: auto;
    padding: 0.85rem;
    border: 1px solid var(--vf-header-border);
    border-radius: 12px;
    background: var(--vf-header-panel-bg);
    box-shadow: var(--vf-header-panel-shadow);
    z-index: 260;
}

html.vf-header-tools-collapsible .vf-header-tools-panel[hidden] {
    display: none !important;
}

html.vf-header-tools-collapsible .vf-header-tools {
    display: grid;
    gap: 0.8rem;
}

html.vf-header-tools-collapsible .vf-header-tools .vf-nav-pref-item {
    width: 100%;
}

html.vf-header-tools-collapsible .vf-header-tools .vf-nav-pref {
    width: 100%;
}

html.vf-header-tools-collapsible .vf-header-tools .vf-nav-pref__select {
    width: 100%;
    min-width: 0;
}

html.vf-header-tools-collapsible .vf-header-tools .vf-nav-saved-item {
    display: block;
}

html.vf-header-tools-collapsible .vf-header-tools .vf-saved-toggle {
    width: 100%;
    justify-content: center;
}

body[class*="atmosphere-"] {
    --vf-header-accent: var(--vf-ui-accent, var(--covenant-accent, #7a1e2c));
}

body.atmosphere-night {
    --vf-header-ink: rgba(255, 255, 255, 0.96);
    --vf-header-ink-muted: rgba(255, 255, 255, 0.76);
    --vf-header-surface: rgba(15, 19, 28, 0.92);
    --vf-header-surface-hover: rgba(25, 31, 44, 0.98);
    --vf-header-surface-strong: rgba(10, 13, 19, 0.96);
    --vf-header-border: rgba(255, 255, 255, 0.2);
    --vf-header-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
    --vf-header-focus-shadow: 0 0 0 3px rgba(243, 179, 195, 0.2);
    --vf-header-panel-bg: rgba(10, 13, 19, 0.96);
    --vf-header-panel-text: rgba(255, 255, 255, 0.96);
    --vf-header-panel-selected-bg: rgba(243, 179, 195, 0.22);
    --vf-header-panel-selected-text: rgba(255, 255, 255, 0.98);
    --vf-header-panel-shadow: 0 18px 36px rgba(0, 0, 0, 0.42);
    --vf-header-menu-bg: var(--vf-header-panel-bg);
    --vf-header-menu-text: var(--vf-header-panel-text);
    --vf-header-menu-border: rgba(255, 255, 255, 0.14);
}

body.atmosphere-night .vf-nav-pref__select {
    color-scheme: dark;
}

body.atmosphere-night .vf-nav-pref__select option:hover,
body.atmosphere-night .vf-nav-pref__select option:focus,
body.atmosphere-night .vf-nav-pref__select option:checked {
    background-color: rgba(243, 179, 195, 0.22);
    color: rgba(255, 255, 255, 0.98);
}

/* Mobile Nav */
@media (max-width: 768px) {
    .vf-nav .vf-nav-toggle {
        display: block;
    }

    /* Ticket-902: Restore visibility on Guidance mobile */
    body.verseflow-sanctuary .vf-nav .vf-nav-toggle {
        display: block;
    }



    .vf-nav ul {
        display: none;
        /* Hidden by default */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--vf-header-menu-bg);
        color: var(--vf-header-menu-text, rgba(17, 17, 17, 0.96));
        flex-direction: column;
        padding: 1.5rem;
        gap: 1.5rem;
        box-shadow: var(--vf-header-panel-shadow);
        border: 1px solid var(--vf-header-menu-border);
        z-index: 100;
    }

    .vf-nav.is-open ul {
        display: flex;
        animation: vf-slide-down 0.3s ease forwards;
    }

    .vf-nav ul a {
        color: var(--vf-header-menu-text, rgba(17, 17, 17, 0.96)) !important;
    }
}

@keyframes vf-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Active Nav Link (Ticket-913) */
.vf-nav .is-active a {
    color: var(--vf-header-accent);
    font-weight: 700;
    position: relative;
}

/* Desktop underline */
@media (min-width: 769px) {
    .vf-nav .is-active a::after {
        content: '';
        display: block;
        width: 100%;
        height: 2px;
        background: var(--vf-header-accent);
        margin-top: 4px;
        border-radius: 1px;
    }
}

/* Breadcrumbs (Ticket-913) */
.vf-breadcrumbs {
    padding: 1rem 1.5rem;
    max-width: var(--max-width, 1400px);
    margin: 0 auto;
    font-size: 0.9rem;
    color: var(--grounded-text);
}

.vf-breadcrumbs ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.vf-breadcrumbs li {
    display: inline-flex;
    align-items: center;
}

.vf-breadcrumbs a {
    text-decoration: none;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.vf-breadcrumbs a:hover {
    opacity: 1;
    color: var(--covenant-accent);
    text-decoration: underline;
}

.vf-breadcrumbs .separator {
    margin: 0 0.5rem;
    opacity: 0.4;
    font-size: 0.8em;
}

.vf-breadcrumbs [aria-current="page"] {
    font-weight: 600;
    color: var(--covenant-accent);
}
