/* Unified navigation and button styles - overrides placed here so it's easy to manage separately */

/* Navigation */
.navbar {
    display: flex;
    align-items: center;
    background: var(--background-dark);
    border-bottom: 1px solid rgba(220, 0, 50, 0.08);
    padding: var(--spacing-sm) 0;
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.nav-brand { flex: 0 0 auto; }
.nav-links { flex: 1 1 auto; justify-content: flex-end; }
.nav-links {
    display: flex;
    gap: 0.35rem; /* reduced gap for tighter menu */
    align-items: center;
    flex-wrap: nowrap; /* keep buttons on one line when possible */
    overflow: hidden;
}
.nav-links a {
    color: var(--text-on-dark);
    padding: 0.35rem 0.6rem; /* further reduced padding */
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: calc(0.95rem * 0.6); /* further reduced for compactness */
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.nav-links a:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-on-dark);
    transform: translateY(-1px);
}
.nav-links a.active,
.nav-links a.nav-highlight {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--glow-sm);
}

/* Ensure the highlighted/active link doesn't change layout height compared to other links
   (override larger styles from style.css) */
.nav-links a.nav-highlight {
    padding: 0.35rem 0.6rem; /* match .nav-links a */
    font-size: 0.85rem;     /* compact size used in large screens */
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.nav-links .lang-switch {
    background: transparent;
    padding: 0.15rem 0.4rem; /* smaller language switch */
    border-radius: 6px;
    font-weight: 500;
    opacity: 0.95;
}
.hamburger {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-on-dark);
    font-size: 1.25rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
}
@media (max-width: 768px) {
    .nav-links { display: none; }
    .hamburger { display: block; }
    .navbar.expanded .nav-links { display: flex; flex-direction: column; width: 100%; margin-top: var(--spacing-sm); }
    .nav-links a { width: 100%; }
    /* Hide the second nav row on mobile to simplify the header */
    .nav-bottom { display: none !important; }
}

/* Mobile menu overlay (full screen panel) */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    z-index: 1500;
}
.mobile-menu-overlay.open { display: flex; }
.mobile-menu-panel {
    /* configurable via CSS vars */
    background: var(--mobile-menu-panel-bg, var(--background));
    color: var(--mobile-menu-link-color, var(--text-primary));
    width: 100%;
    max-width: var(--mobile-menu-width, 420px);
    height: 100%;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    animation: slideDown var(--mobile-menu-animation-duration, 220ms) var(--mobile-menu-animation-easing, ease);
}
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.mobile-brand { display:flex; align-items:center; gap:0.5rem; }
.mobile-menu-close { background: transparent; border: none; font-size: 1.25rem; padding: 0.5rem; }
.mobile-menu-links { display: flex; flex-direction: column; padding: 0.5rem 1rem; gap: 0.25rem; overflow:auto; }
.mobile-menu-links a { padding: 0.9rem 0.5rem; font-size: 1.1rem; border-radius: 6px; text-decoration: none; color: var(--mobile-menu-link-color, var(--text-primary)); }
.mobile-onpage { padding: 0.5rem 1rem; border-top: 1px dashed var(--border-color); }
.mobile-onpage h3 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: var(--mobile-menu-onpage-heading-color, var(--text-secondary)); }
.mobile-onpage-links { display:flex; flex-direction:column; gap:0.25rem; }
.mobile-onpage-links a { padding: 0.5rem 0.25rem; font-size: 0.95rem; color: var(--mobile-menu-onpage-link-color, var(--text-secondary)); text-decoration: none; }
.mobile-menu-footer { margin-top: auto; padding: 1rem; border-top: 1px solid var(--border-color); display:flex; justify-content: space-between; align-items:center; }

/* Prevent body scroll when menu open */
body.menu-open { overflow: hidden; }

@keyframes slideDown { from { transform: translateY(-6%); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* Hint for JS: default max label length (can be overridden in CSS or JS) */
:root {
    --mobile-menu-max-label-length: 36;
}

/* If nav content overflows on medium screens, allow collapsing via hamburger appearance */
@media (max-width: 980px) {
    .nav-links { gap: 0.4rem; }
    .nav-links a { padding: 0.4rem 0.7rem; font-size: calc(0.95rem * 0.7); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--glow-sm);
}
.btn-primary:hover {
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-color));
    box-shadow: var(--glow-md);
}
.btn-secondary {
    background: var(--background-gray);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--background); box-shadow: var(--shadow-sm); }
.btn[disabled], .btn.disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

a.btn { display: inline-flex; }

/* Icon spacing */
.btn i, .nav-links a i { margin-right: 0.35rem; font-size: 0.9em; }

/* Two-line navigation: top = page title / language, bottom = page-specific anchors */
/* Default (mobile-first): stack brand above nav */
.navbar .container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
}
.nav-top, .nav-bottom {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}
.nav-top { justify-content: space-between; }
.nav-bottom { justify-content: flex-start; }
.nav-top { padding: 0.15rem 0; }
.nav-bottom { padding: 0.05rem 0 0.25rem 0; }
.nav-bottom:empty {
    /* Preserve layout space even when empty to avoid header jumps during navigation */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Keep a consistent height for the bottom row to avoid jumps between pages
   even when its content changes. Adjust if your links wrap. */
.nav-bottom {
    min-height: 38px;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}
.nav-bottom a { display: inline-flex; align-items: center; }
/* Truncate long section titles in the bottom nav to keep header compact */
.nav-bottom a {
    display: inline-block; /* allow width constraint */
    max-width: 220px;      /* adjust as needed */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.page-title {
    font-weight: 700;
    color: var(--text-on-dark);
    font-size: 1rem;
    padding: 0.25rem 0.6rem;
}
.nav-top .lang-switch { margin-left: auto; }

/* Larger screens: place logo/name left of the top menu using CSS Grid
   Acts like a designer choice: smaller logo and compact name, left-aligned; menu to the right */
@media (min-width: 980px) {
    .navbar .container {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-auto-rows: auto auto;
        grid-column-gap: 1rem;
        align-items: center;
        width: 100%;
    }
    /* Brand on the left spanning both nav rows */
    .nav-brand {
        grid-column: 1 / 2;
        grid-row: 1 / 3;
        align-self: center;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    /* Make the logo and name visually smaller to reduce visual weight */
    .nav-brand img { height: 36px; width: auto; display: block; }
    .nav-brand h1 { font-size: 1rem; margin: 0; color: var(--text-on-dark); font-weight: 700; }
    /* Always stack name under the logo for clear visual hierarchy */
    .nav-brand a { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; text-decoration: none; }
    /* Ensure brand text is visually compact and sits under the image */
    .nav-brand h1 { font-size: 0.95rem; line-height: 1; }

    /* Navigation to the right occupying both rows; keep internal top/bottom stacking */
    .nav-links {
        grid-column: 2 / 3;
        grid-row: 1 / 3;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        width: 100%;
        justify-self: end;
    }
    .nav-top { justify-content: flex-end; }
    .nav-bottom { justify-content: flex-start; }

    /* Slightly reduce link sizes on large screens for compact header */
    .nav-links a { font-size: 0.85rem; padding: 0.3rem 0.55rem; }
}

/* Page-specific utility: hide second nav row on pages that don't need it
   Keep the row in the layout to avoid page jumps when navigating between pages */
.navbar.no-bottom .nav-bottom {
    visibility: hidden; /* keeps layout space */
    opacity: 0;         /* visually hide */
    pointer-events: none; /* prevent interaction */
}
.navbar.no-bottom .nav-links { align-items: flex-end; }
.navbar.no-bottom .nav-top { justify-content: flex-end; }
