/* =========================
   Base Tokens (Light/Dark)
   ========================= */
:root{
  --menu-text: #161616;
  --menu-muted: rgba(22,22,22,.75);
  --menu-bg: transparent;
  --menu-hover-bg: rgba(0,0,0,.03);
  --menu-active: #1B8354;          /* green */
  --menu-border: rgba(17,24,39,.12);
  --menu-shadow: 0 14px 30px rgba(0,0,0,.10);
  --dropdown-bg: #ffffff;
  --dropdown-ring: rgba(17,24,39,.10);
  --dropdown-item-hover: rgba(27,131,84,.08);
  --dropdown-item-text: #1B8354;
  --focus: rgba(27,131,84,.35);
}

/* Dark mode via attribute */
[data-theme="dark"]{
  --menu-text: #f2f2f2;
  --menu-muted: rgba(242,242,242,.75);
  --menu-bg: transparent;
  --menu-hover-bg: rgba(255,255,255,.06);
  --menu-active: #88D8AD;
  --menu-border: rgba(255,255,255,.14);
  --menu-shadow: 0 16px 38px rgba(0,0,0,.55);
  --dropdown-bg: #0f172a;          /* slate-like */
  --dropdown-ring: rgba(255,255,255,.10);
  --dropdown-item-hover: rgba(136,216,173,.12);
  --dropdown-item-text: #88D8AD;
  --focus: rgba(136,216,173,.35);
}

/* Auto dark if user prefers and you didn't set data-theme */
@media (prefers-color-scheme: dark){
  :root:not([data-theme]){
    --menu-text: #f2f2f2;
    --menu-muted: rgba(242,242,242,.75);
    --menu-hover-bg: rgba(255,255,255,.06);
    --menu-active: #88D8AD;
    --menu-border: rgba(255,255,255,.14);
    --menu-shadow: 0 16px 38px rgba(0,0,0,.55);
    --dropdown-bg: #0f172a;
    --dropdown-ring: rgba(255,255,255,.10);
    --dropdown-item-hover: rgba(136,216,173,.12);
    --dropdown-item-text: #88D8AD;
    --focus: rgba(136,216,173,.35);
  }
}

/* =========================
   RTL/LTR helpers
   ========================= */
.base-menu{
  direction: inherit;
}
[dir="rtl"] .base-menu{
  direction: rtl;
}
[dir="ltr"] .base-menu{
  direction: ltr;
}

/* Use logical properties so RTL/LTR auto works */
.base-menu{
  display: flex;
  align-items: center;
  gap: 0; /* you already use paddings per item */
  margin-inline-start: 1rem; /* like ms-4 */
}

@media (max-width: 1279px){
  .base-menu{
    display: none; /* mimic hidden until xl */
  }
}

/* =========================
   Top level item
   ========================= */
.base-menu > .hoverNav,
.base-menu > .activeNav{
  position: relative;
  display: flex;
  align-items: center;
  height: 72px;
}

.base-menu .activeNav .activeItem{
  color: var(--menu-active);
  border-bottom: 2px solid currentColor;
}

/* clickable area */
.base-menu .hoverNav > .dropdown-menu-controller,
.base-menu .hoverNav > .w-full,
.base-menu .activeNav > .w-full{
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: .5rem;
  padding-inline: 1rem;
  border-radius: .5rem;
  background: var(--menu-bg);
}

/* for your <button class="dropdown-menu-controller ..."> */
.dropdown-menu-controller{
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--menu-text);
  cursor: pointer;
  gap: .25rem;
  font: inherit;
  line-height: 1;
}

/* for your <a> inside normal item blocks */
.base-menu a{
  color: var(--menu-text);
  text-decoration: none;
  outline: none;
}
.base-menu a:hover{
  color: var(--menu-active);
}
.base-menu .hoverNav:hover > .dropdown-menu-controller,
.base-menu .hoverNav:hover > .w-full{
  background: var(--menu-hover-bg);
}

/* Arrow icon animation */
.dropdown-menu-controller svg{
  transition: transform .35s ease, opacity .35s ease;
  opacity: .9;
}
.hoverNav:hover .dropdown-menu-controller svg{
  transform: rotate(180deg);
}

/* Focus style */
.dropdown-menu-controller:focus-visible,
.base-menu a:focus-visible,
.sf-mobile-toggle:focus-visible{
  box-shadow: 0 0 0 4px var(--focus);
  border-radius: .5rem;
}

/* =========================
   Dropdown panel
   ========================= */
.dropdown-menu{
  position: absolute;
  inset-inline-start: -3rem; /* like -left-12 */
  top: 100%;
  margin-top: .75rem;
  width: 15rem; /* w-60 */
  max-width: 20rem;
  background: var(--dropdown-bg);
  border-radius: .75rem;
  padding-block: .5rem;
  box-shadow: var(--menu-shadow);
  outline: 1px solid var(--dropdown-ring);
  z-index: 50;

  /* closed state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(.25rem);
  transition: opacity .35s ease, transform .35s ease, visibility .35s ease;
}

/* open on hover (desktop) */
@media (min-width: 1280px){
  .hoverNav:hover > .dropdown-menu{
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

/* open state (mobile / JS controlled) */
.hoverNav.is-open > .dropdown-menu{
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* =========================
   Dropdown items
   ========================= */
.dropdown-menu-item{
  padding-inline: .5rem;
}
.dropdown-menu-item-content a{
  display: block;
  padding: .5rem 1rem;
  border-radius: .5rem;
  position: relative;
}
.dropdown-menu-item-content a:hover{
  background: var(--dropdown-item-hover);
}
.dropdown-text-item{
  color: var(--dropdown-item-text);
  font-weight: 600;
}

/* Optional: external link icon alignment */
.dropdown-menu-item-content img{
  inline-size: 18px;
  block-size: 18px;
}

/* =========================
   Mobile behavior
   ========================= */
/* On smaller screens, show menu vertically (if you want same HTML for mobile) */
@media (max-width: 1279px){
  .base-menu{
    display: flex;          /* if you will show it */
    flex-direction: column;
    align-items: stretch;
    margin-inline-start: 0;
    gap: .25rem;
    padding: .5rem;
  }

  .base-menu > .hoverNav,
  .base-menu > .activeNav{
    height: auto;
  }

  .base-menu .hoverNav > .dropdown-menu-controller,
  .base-menu .hoverNav > .w-full,
  .base-menu .activeNav > .w-full{
    justify-content: space-between;
    width: 100%;
    padding-inline: 1rem;
    padding-block: .75rem;
    border-radius: .75rem;
  }

  .dropdown-menu{
    position: static;
    width: 100%;
    max-width: 100%;
    margin-top: .5rem;
    transform: none;
    outline: 1px solid var(--dropdown-ring);

    /* closed (mobile) */
    display: none;
    opacity: 1;
    visibility: visible;
  }

  .hoverNav.is-open > .dropdown-menu{
    display: block;
  }
}

/* =========================
   Superfish mobile row toggle (if you use it)
   ========================= */
.sf-mobile-row{
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
}
.sf-mobile-toggle{
  margin-inline-start: auto;
  inline-size: 40px;
  block-size: 40px;
  border-radius: .75rem;
  border: 1px solid var(--menu-border);
  background: transparent;
  cursor: pointer;
  position: relative;
}
.sf-mobile-arrow{
  display: inline-block;
  inline-size: 10px;
  block-size: 10px;
  border-inline-end: 2px solid var(--menu-text);
  border-block-end: 2px solid var(--menu-text);
  transform: rotate(45deg);
  transition: transform .25s ease;
}
.hoverNav.is-open .sf-mobile-arrow{
  transform: rotate(-135deg);
}
