/* ===================== BASE / RESET ===================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --fg: #1a2230;
  --muted: #54607a;
  --accent: #2b6cb0;
  --accent-deep: #1a3f7a;
  --header-h: 84px;
  --maxw: 1280px;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  /* Hidden until components load */
  opacity: 0;
  transition: opacity 0.35s ease;
}

body.page-ready {
  opacity: 1;
}

body.nav-open {
  overflow: hidden;
}

main#home-root {
  flex: 1 0 auto;
}

/* ===================== NAVBAR ===================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  background: transparent;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Frosted-glass state once scrolled */
.site-header.scrolled {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 30px rgba(20, 40, 80, 0.10);
}

.navbar {
  position: relative;
  max-width: var(--maxw);
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Brand / Logo */
.nav-brand {
  position: fixed;
  left: 22px;
  top: 20px;
  display: flex;
  align-items: center;
  height: 44px;
  line-height: 0;
  z-index: 1200;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-brand img {
  height: 40px;
  width: auto;
  display: block;
}
.nav-brand:hover { transform: scale(1.05); }
.nav-brand:active { transform: scale(0.97); }

/* Links list */
.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-item {
  position: relative;
}

/* drawer header (logo + close) — mobile only */
.nav-drawer-head { display: none; }

.nav-link {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--fg);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 8px;
  transition: color 0.25s ease;
}

.nav-link:hover,
.nav-item.open > .nav-link {
  color: var(--accent);
}

/* CTA pill */
.nav-cta {
  display: inline-block;
  margin-left: 8px;
  padding: 12px 26px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.98rem;
  box-shadow: 0 6px 18px rgba(43, 108, 176, 0.32);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.nav-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(43, 108, 176, 0.42);
}

/* ===================== DROPDOWN ===================== */
/* invisible hover bridge so the menu doesn't flicker on the gap */
.nav-item.has-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 16px;
}

.dropdown {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px) scale(0.97);
  transform-origin: top center;
  min-width: 250px;
  padding: 14px;
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(46, 96, 180, 0.86), rgba(19, 47, 104, 0.92));
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 34px 80px rgba(10, 26, 64, 0.45),
    0 8px 24px rgba(10, 26, 64, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.38s;
}

.nav-item.has-dropdown:hover .dropdown,
.nav-item.open .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.dropdown ul {
  list-style: none;
}

.dropdown a {
  display: block;
  padding: 12px 18px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 300;
  letter-spacing: 0.015em;
  position: relative;
  transition:
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    padding-left 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.3s ease;
}

/* staggered reveal of items when the menu opens */
.nav-item.has-dropdown:hover .dropdown a,
.nav-item.open .dropdown a {
  animation: ddItemIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.dropdown a:nth-child(1) { animation-delay: 0.04s; }
.dropdown a:nth-child(2) { animation-delay: 0.09s; }
.dropdown a:nth-child(3) { animation-delay: 0.14s; }
.dropdown a:nth-child(4) { animation-delay: 0.19s; }
.dropdown a:nth-child(5) { animation-delay: 0.24s; }

.dropdown li:nth-child(1) a { animation-delay: 0.04s; }
.dropdown li:nth-child(2) a { animation-delay: 0.09s; }
.dropdown li:nth-child(3) a { animation-delay: 0.14s; }
.dropdown li:nth-child(4) a { animation-delay: 0.19s; }
.dropdown li:nth-child(5) a { animation-delay: 0.24s; }

@keyframes ddItemIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown a::before {
  content: "•";
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.3s ease;
}

.dropdown a:hover {
  background: rgba(255, 255, 255, 0.16);
  padding-left: 24px;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.dropdown a:hover::before {
  color: #9fd2ff;
}

/* wider menu so app names fit on one line */
.dropdown--apps {
  min-width: 300px;
}

/* app links with favicon icons */
.dropdown a.dd-app {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.dropdown a.dd-app::before {
  content: none;
}

.dropdown a.dd-app img {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.dropdown a.dd-app:hover {
  padding-left: 24px;
}

/* extend staggered reveal for the longer Products list */
.dropdown li:nth-child(6) a { animation-delay: 0.29s; }
.dropdown li:nth-child(7) a { animation-delay: 0.34s; }
.dropdown li:nth-child(8) a { animation-delay: 0.39s; }
.dropdown li:nth-child(9) a { animation-delay: 0.44s; }
.dropdown li:nth-child(10) a { animation-delay: 0.49s; }

/* ===================== THEME TOGGLE (corner) ===================== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 22px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(90, 120, 180, 0.28);
  background: rgba(255, 255, 255, 0.6);
  color: var(--accent);
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  backdrop-filter: blur(10px) saturate(150%);
  box-shadow: 0 6px 18px rgba(20, 40, 80, 0.10);
  z-index: 1200;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease,
              transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.theme-toggle:hover {
  transform: scale(1.1);
  border-color: rgba(90, 120, 180, 0.55);
  box-shadow: 0 10px 26px rgba(20, 40, 80, 0.18);
}
.theme-toggle:active { transform: scale(0.94); }

/* stacked icons that rotate + scale-crossfade on toggle */
.theme-toggle .tt-icons { position: relative; width: 22px; height: 22px; }
.theme-toggle .tt-icons svg {
  position: absolute;
  inset: 0;
  width: 22px;
  height: 22px;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}
/* light mode → moon shown, sun tucked away */
.theme-toggle .ic-moon { transform: rotate(0deg) scale(1); opacity: 1; }
.theme-toggle .ic-sun  { transform: rotate(-90deg) scale(0); opacity: 0; }

/* ===================== MOBILE TOGGLE ===================== */
.nav-toggle {
  display: none;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  z-index: 1100;
}

.nav-toggle span {
  width: 26px;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .navbar {
    padding: 0 20px;
  }

  .nav-brand {
    left: 16px;
    top: 22px;
  }
  .nav-brand img {
    height: 34px;
  }

  .nav-toggle {
    display: flex;
  }

  /* sit the theme button just left of the hamburger */
  .theme-toggle {
    top: 22px;
    right: 64px;
    width: 40px;
    height: 40px;
  }

  /* ---- Side drawer (slides in from the LEFT) ---- */
  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(86%, 380px);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 14px 16px 28px;
    /* solid panel (no bleed-through from the page behind) */
    background: linear-gradient(180deg, #ffffff 0%, #eef3fb 100%);
    border-right: 1px solid rgba(120, 140, 190, 0.18);
    box-shadow: 22px 0 60px rgba(20, 40, 80, 0.26);
    transform: translateX(-100%);
    transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 1300;
  }

  .nav-links.open {
    transform: translateX(0);
  }

  /* hide the floating hamburger + theme button while the drawer is open */
  body.nav-open .nav-toggle,
  body.nav-open .theme-toggle {
    opacity: 0;
    pointer-events: none;
  }

  /* drawer header: logo + close */
  .nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(120, 140, 190, 0.20);
  }
  .nav-drawer-logo {
    height: 34px;
    width: auto;
    display: block;
  }
  .nav-close {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(90, 120, 180, 0.24);
    background: rgba(255, 255, 255, 0.7);
    color: var(--fg);
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
            backdrop-filter: blur(8px);
    transition: background 0.25s ease, transform 0.35s ease, border-color 0.25s ease;
  }
  .nav-close svg { width: 20px; height: 20px; }
  .nav-close:hover {
    background: #fff;
    border-color: rgba(90, 120, 180, 0.45);
    transform: rotate(90deg);
  }

  .nav-item.has-dropdown::after {
    display: none;
  }

  .nav-link {
    width: 100%;
    text-align: left;
    min-height: 58px;
    font-size: 1.18rem;
    line-height: 1.15;
    padding: 16px 18px;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
  }
  .nav-link:active { background: rgba(43, 108, 176, 0.08); }
  /* highlight the open section for clarity */
  .nav-item.open > .nav-link {
    background: rgba(43, 108, 176, 0.10);
    box-shadow: inset 0 0 0 1px rgba(43, 108, 176, 0.08);
  }

  /* chevron indicator on dropdown toggles */
  .nav-item.has-dropdown > .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .nav-item.has-dropdown > .nav-link::after {
    content: "";
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.58;
    flex: 0 0 auto;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.26s ease;
  }
  .nav-item.open.has-dropdown > .nav-link::after {
    transform: rotate(-135deg);
    opacity: 0.9;
  }

  /* Dropdowns become inline accordions on mobile.
     Reliability-first design:
     - The panel is ALWAYS opacity:1 / visibility:visible. It is hidden
       ONLY by collapsing its height (max-height + overflow:hidden).
     - JS writes the real scrollHeight on mobile, so the list does not clip
       and the close animation has no tall max-height delay. */
  .dropdown,
  .nav-item.has-dropdown:hover .dropdown,
  .nav-item.open .dropdown {
    position: static;
    transform: none !important;
    visibility: visible;
    opacity: 1;
    min-width: 0;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    display: block;
    padding: 0 6px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
            backdrop-filter: none;
    /* snappy, smooth open/close. The cap sits just above the real content
       (~6 wrapped items) so there's no "dead travel" that makes the close
       feel laggy, while still never clipping the list. */
    transition: max-height 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                padding 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: max-height;
  }

  .nav-item.open .dropdown {
    padding: 6px 6px 12px;
  }

  .dropdown ul {
    display: grid;
    gap: 4px;
    padding: 4px 0 2px;
  }

  /* THE root-cause fix: the desktop "ddItemIn" entrance animation uses
     fill-mode:both, which parks every link at opacity:0 until an override
     wins. On mobile we neutralise it UNCONDITIONALLY and with !important so
     no animation, delay, transform or specificity quirk can ever leave a
     link invisible again. The accordion height is the only reveal. */
  .dropdown a {
    display: block;
    min-height: 46px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.25;
    font-weight: 500;
    white-space: normal;       /* let long product names wrap, don't clip */
    animation: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    -webkit-tap-highlight-color: transparent;
  }

  .dropdown a::before {
    color: var(--accent);
  }

  .dropdown a:hover {
    background: rgba(43, 108, 176, 0.08);
    color: var(--accent);
    padding-left: 16px;
    box-shadow: none;
  }

  .dropdown a:active {
    background: rgba(43, 108, 176, 0.12);
  }

  /* Products: render exactly like the (working) plain text links — no flex,
     no fragile external favicons — so the items are always visible */
  .dropdown--apps a.dd-app {
    display: block;
    min-height: 46px;
    padding: 12px 16px;
    color: var(--muted);
    opacity: 1;
    visibility: visible;
  }
  /* hide BOTH the favicon (img) and the "Our Products" inline icon (svg) so
     every product item is plain text and lines up with the others */
  .dropdown--apps a.dd-app img,
  .dropdown--apps a.dd-app svg { display: none; }
  /* give the product items the same bullet point as the other menu links */
  .dropdown--apps a.dd-app::before {
    content: "•";
    margin-right: 10px;
    color: var(--accent);
  }

  .nav-cta-item {
    margin-top: 18px;
  }

  .nav-cta {
    display: block;
    margin: 0;
    text-align: center;
    padding: 15px 24px;
    font-size: 1.02rem;
    box-shadow: 0 12px 28px rgba(43, 108, 176, 0.26);
  }
}
