﻿/* ==================================================================
   HEADER — nav, logo, links, burger, drawer, overlay
   ================================================================== */

/* ---------- NAV (base) ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(60px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--pad);
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  transition: transform .35s cubic-bezier(.16, 1, .3, 1),
              background-color .3s cubic-bezier(.65, 0, .35, 1);
  will-change: transform;
}
@media (min-width: 768px) {
  .nav {
    height: 68px;
    padding-top: 0;
  }
}

/* Hide on scroll down, show on scroll up — everywhere */
.nav.nav-hidden {
  transform: translateY(-100%);
}

@supports (backdrop-filter: blur(20px)) {
  .nav {
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  [data-theme="dark"] .nav {
    background: rgba(10,10,15,.82);
  }
}

/* ---------- LOGO ---------- */
.logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-img {
  height: 26px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  aspect-ratio: 160 / 30;
  filter: var(--logo-filter);
  transition: filter .3s;
}
@media (min-width: 768px) {
  .logo-img { height: 30px; }
}

/* ---------- NAV RIGHT ---------- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- NAV LINKS (desktop only) ---------- */
.nav-links {
  display: none;
  gap: 2px;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 6px;
  transition: color .2s, background .2s;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--bg-subtle);
}
.nav-links a.active {
  color: var(--text);
  font-weight: 600;
}

/* ---------- CTA button (desktop only) ---------- */
.btn.nav-cta-top {
  display: none;
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-weight: 500;
  font-size: 13.5px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  transition: background .2s, color .2s, box-shadow .2s, transform .15s;
}
.btn.nav-cta-top:hover {
  background: var(--hover);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
  transform: translateY(-1px);
  opacity: 1;
}
.btn.nav-cta-top:active {
  transform: translateY(0) scale(.97);
}
[data-theme="dark"] .btn.nav-cta-top:hover {
  background: rgba(255,255,255,.08);
}

/* ---------- BURGER (mobile only) ---------- */
.burger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  background: none;
  border: none;
  transition: background .2s, transform .3s;
}
.burger:hover {
  background: var(--hover);
  transform: scale(1.05);
}
.burger svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}

/* ==================================================================
   ONE SWAP POINT — 900px
   ================================================================== */

@media (max-width: 899px) {
  .nav-links,
  .btn.nav-cta-top { display: none; }
  .burger { display: flex; }
}

@media (min-width: 900px) {
  .nav-links { display: flex; }
  .btn.nav-cta-top { display: inline-flex; }
  .burger { display: none; }
}

/* ==================================================================
   OVERLAY
   ================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 12, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .4s, visibility 0s linear .4s;
}
.overlay.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity .4s, visibility 0s;
}

/* ==================================================================
   DRAWER — modern mobile menu
   ================================================================== */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(340px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--text);
  border-left: 1px solid var(--line);
  border-radius: 28px 0 0 28px;
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .5s cubic-bezier(.16, 1, .3, 1),
              visibility 0s linear .5s;
}

@supports (backdrop-filter: blur(20px)) {
  .drawer {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
  }
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  box-shadow: -32px 0 80px rgba(0, 0, 0, .28);
  transition: transform .5s cubic-bezier(.16, 1, .3, 1),
              visibility 0s;
}

/* ---------- Close button ---------- */
.xbtn {
  align-self: flex-end;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: background .2s, color .2s, transform .3s;
}
.xbtn:hover {
  background: var(--hover);
  color: var(--text);
  transform: rotate(90deg);
}
.xbtn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}

/* ---------- Drawer links ---------- */
.drawer > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 14px;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
  border-radius: 14px;
  transition: background .2s, color .2s;
}

.drawer > a::after {
  content: "→";
  font-size: 18px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .2s, transform .3s cubic-bezier(.16, 1, .3, 1);
}

.drawer > a:hover,
.drawer > a:focus-visible {
  background: var(--hover);
}
.drawer > a:hover::after,
.drawer > a:focus-visible::after {
  opacity: 1;
  transform: translateX(0);
}

.drawer > a:active {
  background: var(--bg-subtle);
}

.drawer > a.active,
.drawer > a[aria-current="page"] {
  background: var(--bg-subtle);
  font-weight: 600;
}
.drawer > a.active::after,
.drawer > a[aria-current="page"]::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 1;
  transform: none;
}

/* ---------- Staggered entrance ---------- */
@keyframes drawerItemIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.drawer.is-open > a,
.drawer.is-open > .drawer-cta {
  animation: drawerItemIn .55s cubic-bezier(.16, 1, .3, 1) both;
}
.drawer.is-open > a:nth-child(2) { animation-delay: .06s; }
.drawer.is-open > a:nth-child(3) { animation-delay: .11s; }
.drawer.is-open > a:nth-child(4) { animation-delay: .16s; }
.drawer.is-open > a:nth-child(5) { animation-delay: .21s; }
.drawer.is-open > a:nth-child(6) { animation-delay: .26s; }
.drawer.is-open > a:nth-child(7) { animation-delay: .31s; }
.drawer.is-open > a:nth-child(8) { animation-delay: .36s; }
.drawer.is-open > .drawer-cta    { animation-delay: .40s; }

/* ---------- Drawer CTA area ---------- */
.drawer-cta {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-cta .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  border-radius: 14px;
  text-decoration: none;
  box-shadow: none;
  transition: background .2s, color .2s, border-color .2s,
              opacity .2s, transform .15s;
}

.drawer-cta .btn:first-child,
.drawer-cta .btn-primary,
.drawer-cta .btn:only-child {
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
}
.drawer-cta .btn:first-child:hover,
.drawer-cta .btn-primary:hover,
.drawer-cta .btn:only-child:hover {
  opacity: .92;
  transform: translateY(-1px);
}

.drawer-cta .btn:not(:first-child):not(:only-child) {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.drawer-cta .btn:not(:first-child):not(:only-child):hover {
  background: var(--hover);
  border-color: var(--text);
  transform: translateY(-1px);
}

.drawer-cta .btn:active {
  transform: translateY(0) scale(.98);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .drawer,
  .overlay { transition-duration: .01s; }
  .drawer.is-open > a,
  .drawer.is-open > .drawer-cta { animation: none; }
}
