/**
 * Submenu accordion toggle — arhitekt.hr — v2
 * v2: the parent item text (e.g. "Ustroj") opens/closes the submenu too,
 *     so it gets a pointer cursor and dims the +/− on hover.
 * Pairs with submenu-toggle-v2.js (use v2 INSTEAD of v1).
 * Load both after the theme's own menu CSS
 * so these rules can override default link padding if needed.
 * ----------------------------------------------------------------------
 * Collapsed state (max-height: 0) is set only by the JS, never here —
 * so if the script fails to load, the full menu stays visible and usable.
 */

.has-submenu {
  position: relative;
}

/* keep link text clear of the toggle button */
.has-submenu > a {
  padding-right: 2.5em;
}

/* v2: the parent text is a toggle now, not a page link */
.has-submenu > a[role="button"] {
  cursor: pointer;
}

ul.level2 {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* --- toggle button ------------------------------------------------- */

.submenu-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25em;
  height: 2.25em;
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  margin-top: -3px; /* nudge the +/− up to line up with the text */
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.submenu-toggle::before {
  content: "+";
  display: inline-block;
  font-size: 1.55em;
  font-weight: 700;
}

.has-submenu.submenu-open > .submenu-toggle::before {
  content: "\2212"; /* − minus sign */
}

.submenu-toggle:hover,
.has-submenu > a[role="button"]:hover + .submenu-toggle {
  opacity: 0.75;
}

/* v2: keyboard focus lands on the parent text (the +/− is skipped) */
.has-submenu > a[role="button"]:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.submenu-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* --- mobile ---------------------------------------------------------
   Same accordion, just bigger tap targets and a touch of extra breathing
   room between submenu links so fingers don't mis-tap. Adjust the
   breakpoint to match the theme's existing mobile-menu switch. */

@media (max-width: 767px) {
  .submenu-toggle {
    width: 44px;
    height: 44px;
  }

  .has-submenu > a {
    padding-right: 44px;
  }

  ul.level2 > li > a {
    padding-top: 0.65em;
    padding-bottom: 0.65em;
  }
}

@media (prefers-reduced-motion: reduce) {
  ul.level2 {
    transition: none;
  }
}

/* =====================================================================
   arhitekt.hr theme fixes (2026-10-06)
   The theme (web.less) styles the header menu differently on desktop
   (hover dropdowns, > 1200px) and on mobile/tablet (hamburger panel,
   <= 1200px), so the +/− and the level2 list need a few overrides.
   ===================================================================== */

/* --- desktop dropdown (> 1200px) ---------------------------------------
   The theme limits every dropdown list to 85px (.nav li:hover ul) and
   floats its items; with overflow: hidden that cut the level2 text off
   ("Povjere…", "Studen…"). Let the level2 list be as wide as its longest
   item, stack the items, and put the +/− right after the text instead of
   at the far right of the (now wider) item. */
@media (min-width: 1201px) {
  .nav li.category ul.subcategory li.has-submenu ul.level2 {
    width: max-content;
    max-width: none;
  }

  .nav li.category ul.subcategory li.has-submenu ul.level2 li {
    float: none;
    max-width: none;
  }

  .nav li.category ul.subcategory li.has-submenu ul.level2 li a {
    white-space: nowrap;
  }

  /* keep the +/− on the same line as long names
     ("Poslijediplomski studiji" pushed it to the next row) */
  .nav li.category ul.subcategory li.has-submenu {
    white-space: nowrap;
  }

  .nav li.category ul.subcategory li.has-submenu > a {
    display: inline-block;
    padding-right: 2px;
  }

  .nav li.category ul.subcategory li.has-submenu > .submenu-toggle {
    position: static;
    display: inline-flex;
    vertical-align: middle;
    width: 1.5em;
    height: 1.5em;
    min-width: 0;
    min-height: 0;
  }
}

/* --- mobile / tablet panel (<= 1200px) ----------------------------------
   Theme links here are 24px tall (padding 2px 0), so the 32–44px tall
   +/− sat lower than the text. Match its height to the link line. */
@media (max-width: 1200px) {
  .nav li.category ul.subcategory li.has-submenu > .submenu-toggle {
    top: 0;
    height: 24px;
    min-height: 24px;
  }
}
