/* Header */

.topbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;

  box-sizing: border-box;

  z-index: 1205;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(0,0,0,0.22);
}

.brand{
  text-decoration:none;
  color: var(--text);
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 240px;
}

.brandLogo{
  width: 60px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.35));
}

.brandMeta{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.brandName{
  letter-spacing:0.12em;
  font-weight:800;
  font-size:13px;
}

.brandRole{
  color: var(--muted);
  font-size:12px;
}

.nav{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.nav a{
  color: rgba(240,244,255,0.78);
  text-decoration:none;
  font-size:13px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid transparent;
  transition: 180ms ease;
  box-sizing: border-box;
}

.nav a:hover{
  color: rgba(240,244,255,0.95);
  border-color: rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
}

.nav a.active{
  color: rgba(240,244,255,0.96);
  border-color: rgba(120,210,255,0.40);
  background: rgba(0,0,0,0.18);
}

/* Desktop dropdown */

.navItem{
  position: relative;
}

.dropdown{
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);

  min-width: 220px;
  max-width: min(90vw, 280px);

  background: rgba(10, 14, 28, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;

  padding: 8px;
  display: grid;
  gap: 4px;

  opacity: 0;
  pointer-events: none;
  z-index: 50;

  transition:
    opacity 140ms ease-out,
    transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown a{
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(240,244,255,0.88);
  position: relative;
  box-sizing: border-box;

  opacity: 0;
  transform: translateY(10px);

  transition:
    opacity 220ms ease-out,
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.dropdown a:hover{
  background: rgba(255,255,255,0.08);
  color: rgba(240,244,255,0.96);
}

.dropdown a:not(:last-child)::after{
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -2px;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.hasDropdown:hover .dropdown,
.hasDropdown:focus-within .dropdown{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.hasDropdown:hover .dropdown a,
.hasDropdown:focus-within .dropdown a{
  opacity: 1;
  transform: translateY(0);
}

.dropdown a:nth-child(1){ transition-delay: 80ms; }
.dropdown a:nth-child(2){ transition-delay: 120ms; }
.dropdown a:nth-child(3){ transition-delay: 160ms; }
.dropdown a:nth-child(4){ transition-delay: 200ms; }
.dropdown a:nth-child(5){ transition-delay: 240ms; }
.dropdown a:nth-child(6){ transition-delay: 280ms; }

@media (prefers-reduced-motion: reduce){
  .dropdown{
    transition:none;
  }
  .dropdown a{
    transition:none;
    opacity: 1;
    transform:none;
  }
}

/* Mobile hamburger */

.navToggle{
  display:none;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.22);
  color: rgba(240,244,255,0.92);
  width: 46px;
  height: 40px;
  border-radius: 14px;
  cursor: pointer;
  align-items:center;
  justify-content:center;
  transition: 180ms ease;
  box-sizing: border-box;
}

.navToggle:hover{
  border-color: rgba(120,210,255,0.45);
  box-shadow: 0 10px 30px rgba(0,0,0,0.30);
  transform: translateY(-1px);
}

.navToggleBars{
  width: 20px;
  height: 2px;
  background: rgba(240,244,255,0.92);
  border-radius: 999px;
  position: relative;
  display:block;
  box-shadow: 0 0 14px rgba(120,210,255,0.18);
}

.navToggleBars::before,
.navToggleBars::after{
  content:"";
  position:absolute;
  left:0;
  width: 20px;
  height: 2px;
  background: rgba(240,244,255,0.92);
  border-radius: 999px;
}

.navToggleBars::before{ top:-7px; }
.navToggleBars::after{ top:7px; }

.navBackdrop{
  display:none;
}

/* Mobile drawer and accordion */

@media (max-width: 860px){
  .navToggle{
    display:flex;
    margin-left: auto;
    z-index: 1202;
  }

  .navBackdrop{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px);
    z-index: 1200;
    display:none;
  }

  .nav{
    position: fixed;
    top: 12px;
    right: 12px;
    height: calc(100vh - 24px);

    /* antes: width: min(360px, calc(100vw - 24px)); */
    width: min(240px, calc(100vw - 90px));

    /* extra seguridad para que nunca "empuje" el viewport */
    max-width: min(240px, calc(100vw - 90px));
    box-sizing: border-box;

    display:flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;

    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 22px;
    background: rgba(10, 14, 28, 0.92);
    backdrop-filter: blur(16px);
    box-shadow: 0 18px 70px rgba(0,0,0,0.55);

    transform: translateX(0);
    opacity: 0;
    pointer-events: none;

    transition: transform 180ms ease, opacity 180ms ease;
    z-index: 1201;

    justify-content: flex-start;
    align-content: flex-start;
    padding: 62px 14px 14px;

    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-gutter: stable;
  }

  .topbar.isOpen .nav{
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .topbar.isOpen .navBackdrop{
    display:block;
  }

  .topbar.isOpen .navToggle{
    position: fixed;
    top: 18px;
    right: 18px;
  }

  .nav > a,
  .navItem > a{
    display:block;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    background: rgba(0,0,0,0.18);
    padding: 12px 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .dropdown a{
    opacity: 1;
    transform: none !important;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(0,0,0,0.10);
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
    box-sizing: border-box;
  }

  .dropdown a:hover{
    background: rgba(255,255,255,0.10);
    border-color: rgba(120,210,255,0.28);
    transform: none !important;
  }

  .dropdown a:not(:last-child)::after{
    display:none;
  }

  .nav a:hover{
    transform: none !important;
  }

  .brandLogo{
    width: 52px;
    height: 32px;
  }

  .brandName{
    font-size: 12px;
  }
}

/* Burger to X when open */

@media (max-width: 860px){
  .topbar.isOpen .navToggleBars{
    background: transparent;
    box-shadow: none;
  }

  .topbar.isOpen .navToggleBars::before{
    top:0;
    transform: rotate(45deg);
  }

  .topbar.isOpen .navToggleBars::after{
    top:0;
    transform: rotate(-45deg);
  }
}

/* Mobile dropdowns as accordion */

@media (max-width: 860px){
  .navItem.hasDropdown{
    display: block;
  }

  .navItem.hasDropdown > a{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .navItem.hasDropdown > a::after{
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(240,244,255,0.72);
    border-bottom: 2px solid rgba(240,244,255,0.72);
    transform: rotate(45deg);
    transition: transform 180ms ease, opacity 180ms ease;
    opacity: 0.75;
    flex: 0 0 auto;
    margin-left: 10px;
  }

  .navItem.hasDropdown .dropdown{
    position: static;
    left: auto;
    top: auto;
    transform: none;

    width: 100%;
    max-width: 100%;
    min-width: 0;

    margin-top: 8px;
    padding: 0;

    background: transparent;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;

    display: grid;
    gap: 8px;

    opacity: 1;
    pointer-events: auto;

    overflow: hidden;
    max-height: 0;
    transition: max-height 220ms ease;
  }

  .navItem.hasDropdown .dropdown a{
    margin-left: 14px;
    width: calc(100% - 14px);
  }

  .navItem.hasDropdown.isExpanded .dropdown{
    max-height: 420px;
  }

  .navItem.hasDropdown.isExpanded > a::after{
    transform: rotate(-135deg);
    opacity: 0.95;
  }
}

html,
body{
  max-width: 100%;
  overflow-x: hidden;
}
