/* =======================
   NAV WRAPPER
======================= */

.nav-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    width: 100%;
    background-color: var(--var-blue-dark-tech);
    /*border-bottom: 1px solid rgba(59, 124, 203, 0.14);*/
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

nav {
    width: 100%;
    max-width: 1340px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 90px;
    position: relative;
}

nav .logo {
    display: flex;
    align-items: center;
    height: 100%;
    width: auto;
    flex-shrink: 0;
    margin-right: 32px;
}

nav .logo a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

nav .logo img {
    height: 38px;
    width: auto;
    display: none;
}

navbar .logo img.logo-dark,
html:not([data-theme="light"]) nav .logo img.logo-dark {
    display: block;
}

html[data-theme="light"] nav .logo img.logo-dark {
    display: none;
}

html[data-theme="light"] nav .logo img.logo-light {
    display: block;
}

html:not([data-theme="light"]) nav .logo img.logo-light {
    display: none;
}

nav .links {
    display: flex;
    align-items: center;
    gap: 24px;
}

nav .links ul {
    list-style-type: none;
    display: flex;
    margin: 0;
    padding: 0;
    gap: 24px;
    align-items: center;
}

nav .links ul li {
    margin: 0;
}

nav .links ul li a {
    text-decoration: none;
    color: var(--var-text-white);
    font-size: 17px;
    font-weight: 500;
    padding: 8px 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: background-color .18s ease, color .12s ease;
}

nav .links ul li a:hover,
nav .links ul li a:focus {
    background-color: var(--var-hover-bg);
    color: var(--var-black-bg);
    outline: none;
}

/* Light mode: plain nav links need dark text */
html[data-theme="light"] nav .links ul li a {
    color: var(--var-text-headers);
}

.contact-btn {
    position: relative;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 0;
    padding: 9px 18px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: background-color .18s ease, transform .20s ease;
    text-decoration: none;

    border: 1.8px solid var(--var-blue-primary);
    color: #F2F6FF;
    background-color: var(--var-blue-primary);
}

.contact-btn:hover {
    background-color: #193e80;
    border-color: #193e80;
}

/* Outline CTA button */
.offert-btn {
    position: relative;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 0;
    padding: 9px 18px;
    font-size: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .18s ease, color .18s ease;

    border: 1.8px solid var(--var-blue-primary);
    color: #F2F6FF;
    background-color: var(--var-blue-primary);
}

.offert-btn:hover {
    background-color: var(--var-blue-secondary) !important;
    color: #F2F6FF !important;
}


html[data-theme="light"] .offert-btn:hover {
    background-color: var(--var-blue-primary) !important;
    border-color: var(--var-blue-primary);
    color: #F2F6FF !important;
}

/* NAV BAS */
.nav-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
}

/* Desktop links sit flush after the logo */
.nav-inner > .links.desktop-links {
    flex-shrink: 0;
}

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-left: auto;
    flex-shrink: 0;
}

.nav-ctas {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* DESKTOP LINKS */
nav .links ul {
    display: flex;
    gap: 24px;
    align-items: center;
}

/* =======================
   HAMBURGER
======================= */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;

    width: 28px;
    height: 28px;

    background: none;
    border: none;
    cursor: pointer;

    z-index: 1200;
    position: relative;
    z-index: 1300;

    transition: transform 0.15s ease;
}

.hamburger span {
    height: 2px;
    width: 100%;
    background: var(--var-text-white);
    border-radius: 2px;

    transition: all 0.25s ease;
}

html[data-theme="light"] .hamburger span {
    background: var(--var-text-headers);
}

.hamburger.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.hamburger:hover {
    transform: scale(1.08);
}

.hamburger:hover span {
    background: var(--var-blue-primary);
}

.hamburger:active {
    transform: scale(0.95);
}

/* =======================
   MOBILE MENU
======================= */

.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: min(85vw, 340px);
    height: 100%;
    background: #0f1b2e;
    border-left: 1px solid rgba(59, 124, 203, 0.2);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    z-index: 1300;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.mobile-menu.open {
    transform: translateX(0);
    box-shadow: -12px 0 48px rgba(0, 0, 0, 0.5);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    height: 72px;
    border-bottom: 1px solid rgba(59, 124, 203, 0.15);
    flex-shrink: 0;
}

.mobile-menu-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.mobile-menu-logo img {
    height: 32px;
    width: auto;
}

.mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    cursor: pointer;
    color: #F2F6FF;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mobile-close:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.24);
}

.mobile-menu-body {
    padding: 20px 10px;
    flex: 1;
}

.mobile-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu li {
    width: 100%;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    width: 100%;
    color: #F2F6FF;
    font-size: 16px;
    font-weight: 500;
    padding: 13px 16px;
    border-radius: 6px;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: background 0.15s ease;
}

.mobile-menu a:hover {
    background: rgba(59, 124, 203, 0.15);
}

/* CTA buttons — match the desktop nav buttons (solid "Be om offert",
   outline "Kontakta mig") incl. the asymmetric corner radius. */
.mobile-menu .offert-btn {
    margin-top: 8px;
    justify-content: center;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 0;
    border: 1.8px solid var(--var-blue-primary);
    background: var(--var-blue-primary);
    color: #F2F6FF !important;
    font-weight: 600;
    padding: 14px 16px;
}

.mobile-menu .offert-btn:hover {
    background: var(--var-blue-secondary);
    border-color: var(--var-blue-secondary);
    color: #F2F6FF !important;
}

.mobile-menu .contact-btn {
    margin-top: 8px;
    justify-content: center;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 0;
    border: 1.8px solid var(--var-blue-secondary);
    background: transparent;
    color: #F2F6FF;
    font-weight: 600;
    padding: 14px 16px;
}

.mobile-menu .contact-btn:hover {
    background: rgba(59, 124, 203, 0.1);
    border-color: var(--var-blue-secondary);
}

/* =======================
   MOBILE MENU — LIGHT MODE
======================= */
html[data-theme="light"] .mobile-menu {
    background: #e8eef8;
    border-left-color: rgba(31, 75, 153, 0.15);
}

html[data-theme="light"] .mobile-menu.open {
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .mobile-menu-header {
    border-bottom-color: rgba(31, 75, 153, 0.12);
}

html[data-theme="light"] .mobile-close {
    background: rgba(31, 75, 153, 0.07);
    border-color: rgba(31, 75, 153, 0.2);
    color: #1a2540;
}

html[data-theme="light"] .mobile-close:hover {
    background: rgba(31, 75, 153, 0.13);
    border-color: rgba(31, 75, 153, 0.35);
}

html[data-theme="light"] .mobile-menu a {
    color: #1a2540;
}

html[data-theme="light"] .mobile-menu a:hover {
    background: rgba(31, 75, 153, 0.08);
}

/* "Kontakta mig" is now an outline button — needs dark text on light bg */
html[data-theme="light"] .mobile-menu .contact-btn {
    border-color: var(--var-blue-primary);
    color: var(--var-blue-primary) !important;
}

html[data-theme="light"] .mobile-menu .contact-btn:hover {
    background: rgba(31, 75, 153, 0.08);
}

/* "Be om offert" stays solid primary; match desktop's light-mode hover */
html[data-theme="light"] .mobile-menu .offert-btn:hover {
    background: var(--var-blue-primary);
    border-color: var(--var-blue-primary);
    color: #fff !important;
}

/* =======================
   OVERLAY
======================= */

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.38s ease;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 868px) {

    .desktop-links {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
    }

    .hamburger {
        display: flex;
    }

    .nav-right {
        gap: 12px;
    }
}

/* =======================
   NAV DROPDOWN
======================= */

.has-dropdown {
    position: relative;
}

/* Invisible bridge — fills the gap between the link and the dropdown panel
   so the :hover chain doesn't break when the mouse travels across the gap  */
.has-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -16px;
    right: -16px;
    height: 12px; /* matches the top offset of .nav-dropdown */
    display: block;
}

/* Parent link — same visual as other nav links, adds chevron */
.nav-parent-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.nav-chevron {
    flex-shrink: 0;
    margin-top: 1px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.75;
}

.has-dropdown:hover .nav-chevron,
.has-dropdown:focus-within .nav-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown panel */
.nav-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    width: 320px;
    background: var(--var-blue-dark-tech);
    border: 1px solid var(--var-border-color);
    border-radius: 6px;
    padding: 6px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.06),
        0 12px 20px rgba(0, 0, 0, 0.14),
        0 24px 48px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0.2s ease;
    z-index: 2000;
}

/* Small arrow pointing up to nav link */
.nav-dropdown-arrow {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 11px;
    height: 11px;
    background: var(--var-blue-dark-tech);
    border-left: 1px solid var(--var-border-color);
    border-top: 1px solid var(--var-border-color);
    border-radius: 2px 0 0 0;
}

/* Show on hover/focus-within */
.has-dropdown:hover .nav-dropdown,
.has-dropdown:focus-within .nav-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Dropdown items */
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--var-text-soft) !important;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 15px;
    font-weight: 400;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus {
    background: var(--var-hover-bg);
    color: var(--var-text-headers) !important;
    outline: none;
}

/* Icon box inside each dropdown item */
.nav-dropdown-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 4px;
    background: var(--var-blue-box);
    border: 1px solid var(--var-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--var-blue-secondary);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-dropdown-item:hover .nav-dropdown-icon {
    background: rgba(74, 144, 226, 0.14);
    border-color: rgba(74, 144, 226, 0.3);
}

.nav-dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-dropdown-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--var-text-headers);
    white-space: nowrap;
    line-height: 1.3;
}

.nav-dropdown-desc {
    font-size: 12px;
    color: var(--var-muted);
    line-height: 1.4;
    white-space: nowrap;
}

/* Light mode overrides */
html[data-theme="light"] .nav-dropdown {
    background: #ffffff;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 12px 20px rgba(0, 0, 0, 0.08),
        0 24px 48px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .nav-dropdown-arrow {
    background: #ffffff;
}

html[data-theme="light"] .nav-dropdown-icon {
    color: var(--var-blue-primary);
    background: rgba(31, 75, 153, 0.07);
    border-color: rgba(31, 75, 153, 0.15);
}

html[data-theme="light"] .nav-dropdown-item:hover .nav-dropdown-icon {
    background: rgba(31, 75, 153, 0.12);
    border-color: rgba(31, 75, 153, 0.25);
}

html[data-theme="light"] .nav-dropdown-item {
    color: var(--var-text-soft) !important;
}

html[data-theme="light"] .nav-dropdown-item:hover {
    color: var(--var-text-headers) !important;
}

/* =======================
   MOBILE SUBMENU
======================= */

.mobile-has-sub {
    width: 100%;
}

.mobile-item-row {
    display: flex;
    align-items: center;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
}

.mobile-parent-link {
    flex: 1;
    border-radius: 6px 0 0 6px !important;
}

.mobile-sub-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    background: none;
    border: none;
    cursor: pointer;
    color: #F2F6FF;
    border-radius: 0 6px 6px 0;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.mobile-sub-toggle:hover {
    background: rgba(59, 124, 203, 0.15);
}

.mobile-sub-toggle svg {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-sub-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* Animated submenu using max-height */
.mobile-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-submenu.open {
    max-height: 260px;
}

.mobile-submenu li a {
    padding: 10px 16px 10px 28px !important;
    font-size: 14.5px !important;
    color: rgba(242, 246, 255, 0.65) !important;
    border-radius: 4px !important;
    display: flex !important;
    align-items: center !important;
    gap: 9px !important;
}

.mobile-submenu li a:hover {
    color: rgba(242, 246, 255, 0.95) !important;
    background: rgba(59, 124, 203, 0.12) !important;
}

.mobile-submenu li a svg {
    flex-shrink: 0;
    opacity: 0.55;
}

/* =======================
   THEME TOGGLE
======================= */

.theme-toggle-container {
    display: flex;
    align-items: center;
}

/* Matches .offert-btn sizing, border and corner style */
.theme-toggle {
    position: relative;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border: 1.8px solid var(--var-blue-secondary);
    background: transparent;
    cursor: pointer;
    padding: 9px 18px;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.35s ease;
}

.theme-toggle:hover {
    background: rgba(59, 124, 203, 0.1);
}

html[data-theme="light"] .theme-toggle {
    border-color: var(--var-blue-primary);
}

html[data-theme="light"] .theme-toggle:hover {
    background: rgba(31, 75, 153, 0.08);
}

/* Sliding circle — left: calc(100% - Xpx) reads the button's own width,
   so this works regardless of how wide padding makes the button            */
.toggle-indicator {
    position: absolute;
    top: 50%;
    left: 5px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--var-blue-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transform: translateY(-50%);
    transition: left 0.42s cubic-bezier(0.65, 0, 0.35, 1),
                background 0.35s ease;
    z-index: 1;
}

/* 100% = button width; 22px circle + 5px right inset = 27px from right edge */
.theme-toggle.dark-mode .toggle-indicator {
    left: calc(100% - 27px);
}

html[data-theme="light"] .toggle-indicator {
    background: var(--var-blue-primary);
}

/* Icons inside the circle */
.sun-icon,
.moon-icon {
    position: absolute;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.sun-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}
.moon-icon {
    opacity: 0;
    transform: scale(0.5) rotate(-30deg);
}

.theme-toggle.dark-mode .sun-icon {
    opacity: 0;
    transform: scale(0.5) rotate(30deg);
}
.theme-toggle.dark-mode .moon-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Hidden sizer — widest label text, in normal flow so padding sizes the button */
.toggle-sizer {
    visibility: hidden;
    pointer-events: none;
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
    padding-left: 10px;
}

/* Text labels */
.label-light,
.label-dark {
    position: absolute;
    top: 50%;
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.01em;
}

/* Light mode: circle LEFT → text fills right */
.label-light {
    left: 33px;
    right: 6px;
    text-align: center;
    color: var(--var-blue-secondary);
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    transition: opacity 0.22s ease, transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}

html[data-theme="light"] .label-light {
    color: var(--var-blue-primary);
}

/* Dark mode: circle RIGHT → text fills left */
.label-dark {
    left: 6px;
    right: 33px;
    text-align: center;
    color: var(--var-blue-secondary);
    transform: translateY(-50%) translateX(-8px);
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}

html[data-theme="light"] .label-dark {
    color: var(--var-blue-primary);
}

.theme-toggle.dark-mode .label-light {
    opacity: 0;
    transform: translateY(-50%) translateX(8px);
}
.theme-toggle.dark-mode .label-dark {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--var-blue-primary);
    outline-offset: 2px;
}

/* ── Contact button replacing theme toggle ── */
.nav-contact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 6px;
    border: 1.8px solid var(--var-blue-secondary);
    background: transparent;
    color: var(--var-text-white);
    padding: 9px 18px;
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.35s ease;
}

.nav-contact-btn:hover {
    background: rgba(59, 124, 203, 0.1);
}

html[data-theme="light"] .nav-contact-btn {
    border-color: var(--var-blue-primary);
    color: var(--var-blue-primary);
}

html[data-theme="light"] .nav-contact-btn:hover {
    background: rgba(31, 75, 153, 0.08);
}

.nav-contact-btn:focus-visible {
    outline: 2px solid var(--var-blue-primary);
    outline-offset: 2px;
}
/* ─────────────────────────────────────────── */

/* =======================
   NAV MOBILE OVERRIDES
   (must come after base nav rules so they win the cascade)
======================= */
@media (max-width: 868px) {
    nav {
        height: 72px;
        padding: 0 10px;
    }

    nav .logo img {
        height: 32px;
        width: auto;
    }

    .mobile-menu-logo img {
        height: 32px;
        width: auto;
    }

    /* Compact toggle on mobile — same height as hamburger (28px) */
    .theme-toggle {
        padding: 4px 12px;
        min-width: 128px;
        overflow: hidden;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 4px;
    }

    /* Circle 18px, 4px inset; dark mode: calc(100% - 22px) = 18px circle + 4px right inset */
    .toggle-indicator {
        width: 18px;
        height: 18px;
        left: 4px;
    }

    .theme-toggle.dark-mode .toggle-indicator {
        left: calc(100% - 22px);
    }

    .label-light {
        left: 28px;
        right: 5px;
    }

    .label-dark {
        left: 5px;
        right: 28px;
    }
}
