/* Submenu visibility belongs to mod_menu; never open it with CSS :hover. */
.mod-menu .lark-product-parent,
.mod-menu .lark-product-item {
  min-inline-size: 0;
}

.mod-menu .lark-product-parent.deeper,
.mod-menu .lark-product-item.deeper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: start;
}

.mod-menu .lark-product-parent > .mod-menu__toggle-sub,
.mod-menu .lark-product-item > .mod-menu__toggle-sub {
  grid-column: 2;
  grid-row: 1;
  justify-content: center;
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.mod-menu .lark-product-parent > .mod-menu__toggle-sub:first-child,
.mod-menu .lark-product-item > .mod-menu__toggle-sub:first-child {
  grid-column: 1 / -1;
}

.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub:hover,
.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub:focus-visible {
  background: #eef4ff;
  color: #1456f0;
}

.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub > * {
  pointer-events: none;
}

.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub .icon-chevron-down {
  margin: 0;
  inline-size: 8px;
  block-size: 8px;
  border-inline-end: 2px solid currentColor;
  border-block-end: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.mod-menu .lark-product-parent > .mod-menu__toggle-sub .icon-chevron-down {
  scale: 0.75;
}

/* The toggle centres its children, so without inline spacing the chevron lands on the label's last glyph. */
.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub .icon-chevron-down {
  margin-inline-start: 6px;
}

.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub .icon-chevron-down::before {
  content: none;
}

.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub[aria-expanded="true"] .icon-chevron-down {
  transform: translateY(2px) rotate(225deg);
}

.mod-menu .lark-product-parent > .lark-product-panel {
  --lark-product-icon-size: 28px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 90vw;
  max-block-size: 70vh;
  max-block-size: var(--lark-panel-space, 70dvh);
  margin: 0;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px;
  list-style: none;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: #26354a;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 12px 32px #172f551f;
}

.mod-menu .lark-product-parent > .lark-product-panel:not([aria-hidden="false"]) {
  display: none;
}

.mod-menu .lark-product-parent > .lark-product-panel[aria-hidden="false"] {
  display: grid;
}

.mod-menu .lark-product-panel .lark-product-item {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mod-menu .lark-product-panel .lark-product-card {
  display: grid;
  grid-template-columns: var(--lark-product-icon-size) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-inline-size: 0;
  min-block-size: 64px;
  padding: 10px;
  border-radius: 8px;
  color: #26354a;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.container-header .mod-menu .lark-product-panel .lark-product-card:hover,
.container-header .mod-menu .lark-product-panel .lark-product-card:focus-visible,
.container-header .mod-menu .lark-product-panel .lark-product-card[aria-current] {
  background: #eef4ff;
  color: #1456f0;
  text-decoration: none;
}

.mod-menu .lark-product-card:focus-visible,
.mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub:focus-visible {
  outline: 2px solid #1456f0;
  outline-offset: 2px;
}

.mod-menu .lark-product-icon {
  display: block;
  inline-size: var(--lark-product-icon-size);
  block-size: var(--lark-product-icon-size);
}

.mod-menu .lark-product-icon .lark-product-image {
  display: block;
  inline-size: var(--lark-product-icon-size);
  block-size: var(--lark-product-icon-size);
  max-inline-size: 100%;
  object-fit: contain;
}

.mod-menu .lark-product-copy {
  display: block;
  min-inline-size: 0;
}

.mod-menu .lark-product-title,
.mod-menu .lark-product-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.mod-menu .lark-product-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.mod-menu .lark-product-description {
  margin-block-start: 4px;
  color: #526176;
  font-size: 12px;
  line-height: 1.6;
}

/* Nested branches remain in flow, inside the scrollable panel. */
.mod-menu .lark-product-panel .mod-menu__sub {
  position: static;
  grid-column: 1 / -1;
  inline-size: auto;
  min-inline-size: 0;
  max-inline-size: 100%;
  max-block-size: none;
  margin: 4px 0 4px 12px;
  padding: 0 0 0 8px;
  border: 0;
  border-inline-start: 1px solid #e2e8f0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  font-size: inherit;
}

@media (min-width: 992px) {
  /* Homepage uses the lightweight navigation sheet, not Bootstrap's full CSS. */
  .container-header .navbar-expand-lg {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .container-header .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
  }

  .container-header .navbar-expand-lg .navbar-toggler {
    display: none;
  }

  .container-header:has(.lark-product-parent) .container-nav > nav,
  .container-header:has(.lark-product-parent) .navbar-collapse {
    min-inline-size: 0;
  }

  .container-header:has(.lark-product-parent) .mod-menu {
    flex-wrap: wrap;
  }

  .container-header:has(.lark-product-parent) .mod-menu > li {
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  .mod-menu .lark-product-parent {
    position: relative;
  }

  .mod-menu .lark-product-parent > .lark-product-panel {
    position: absolute;
    z-index: 1001;
    inset-block-start: calc(var(--lark-panel-top, 100%) + 12px);
    inset-inline-start: 0;
    inline-size: min(60rem, 90vw);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    transform: translateX(var(--lark-panel-shift, 0px));
  }

  .mod-menu .lark-product-panel .lark-product-parent > .lark-product-panel {
    position: static;
    inline-size: auto;
    grid-template-columns: minmax(0, 1fr);
    transform: none;
  }
}

@media (min-width: 992px) and (max-width: 1100px) {
  .container-header:has(.lark-product-parent) .container-nav {
    gap: 8px;
  }

  .container-header:has(.lark-product-parent) .container-nav > nav {
    margin-inline-start: 8px;
  }

  .container-header:has(.lark-product-parent) .mod-menu > li > a {
    padding-inline: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 991.98px) {
  /* The collapsed header starts at 992px, so keep the language switcher aligned at every tablet width. */
  .container-header:has(.lark-product-parent) .container-nav {
    position: relative;
    padding-top: 10px;
    min-block-size: 72px;
  }

  .container-header:has(.lark-product-parent) .container-nav > .container-search {
    position: absolute;
    inset-block-start: 10px;
    inset-inline-end: 20px;
  }

  .container-header .navbar-collapse:has(.lark-product-parent).show {
    max-block-size: calc(100vh - 8rem);
    max-block-size: calc(100dvh - 8rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .mod-menu .lark-product-parent > .lark-product-panel {
    position: static;
    max-block-size: none;
    margin-block: 4px 8px;
    overflow: visible;
    transform: none;
    box-shadow: none;
  }
}

/* Follow native menu state; the existing outside-click handler closes the menu. */
body:has(.container-header .lark-product-parent > .mod-menu__toggle-sub[aria-expanded="true"])::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgb(15 23 42 / 32%);
}

.container-header:has(.lark-product-parent > .mod-menu__toggle-sub[aria-expanded="true"]) {
  z-index: 1002;
}

@media (prefers-reduced-motion: reduce) {
  .mod-menu :is(.lark-product-parent, .lark-product-item) > .mod-menu__toggle-sub .icon-chevron-down {
    transition: none;
  }
}

.mod-menu .lark-resources-panel > li > a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-block-end: 10px;
  font-weight: 650;
}
.mod-menu .lark-resources-panel > li > a:is(.lark-resource-news, .lark-resource-events):is(:hover, :focus-visible) {
  --lark-resource-heading-color: #1456f0;
  color: var(--lark-resource-heading-color);
  text-decoration: none;
}

.mod-menu .lark-resources-panel > li > a:is(.lark-resource-news, .lark-resource-events)::before {
  content: "";
  flex: 0 0 34px;
  block-size: 34px;
  border-radius: 8px;
  background: #eef4ff var(--resource-icon) center / 18px no-repeat;
}

.mod-menu .lark-resources-panel .lark-resource-news {
  --resource-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231456f0' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='16' height='16' rx='3'/%3E%3Cpath d='M8 9h8M8 13h8M8 16h5'/%3E%3C/svg%3E");
}

.mod-menu .lark-resources-panel .lark-resource-events {
  --resource-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231456f0' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='6' width='16' height='14' rx='3'/%3E%3Cpath d='M8 4v4m8-4v4M4 11h16m-11 4h2'/%3E%3C/svg%3E");
}

.mod-menu .lark-resources-panel .lark-resource-articles {
  display: grid;
  gap: 6px;
}

.mod-menu .lark-resources-panel .lark-resource-articles a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding-inline: 12px;
  border-block: 8px solid transparent;
  border-radius: 8px;
  background: #f4f7fc;
  font-size: .875rem;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.mod-menu .lark-resources-panel .lark-resource-articles a:is(:hover, :focus-visible) {
  -webkit-line-clamp: unset;
  background: #eef4ff;
  color: #1456f0;
}

@media (min-width: 992px) {
  .mod-menu .lark-product-parent > .lark-resources-panel {
    inline-size: min(640px, 90vw);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .container-header .mod-menu .lark-product-panel :is(a, .lark-product-title, .lark-product-description) {
    color: var(--lark-resource-heading-color, #171717) !important;
  }
}

/* Resources currently shows News only. Keep Events available for later. */
.mod-menu .lark-resources-panel > li:has(> .lark-resource-events) { display: none; }
@media (min-width: 992px) {
  .mod-menu .lark-product-parent > .lark-resources-panel {
    inline-size: min(420px, 90vw);
    grid-template-columns: minmax(0, 1fr);
  }
}
